diff --git a/src/main/java/de/hsh/inform/orientdb_project/DummyImportService.java b/src/main/java/de/hsh/inform/orientdb_project/DummyImportService.java index 9be8daa..fd33b7d 100644 --- a/src/main/java/de/hsh/inform/orientdb_project/DummyImportService.java +++ b/src/main/java/de/hsh/inform/orientdb_project/DummyImportService.java @@ -35,5 +35,8 @@ public class DummyImportService extends AbstractNetdataImportService { public void handleIcmpPacket(IcmpV4CommonPacket icmp, long ts, int ms) {} + @Override + public void afterImport() {} + } diff --git a/src/main/java/de/hsh/inform/orientdb_project/orientdb/LowPerformanceOrientDbNetdataImportService.java b/src/main/java/de/hsh/inform/orientdb_project/orientdb/LowPerformanceOrientDbNetdataImportService.java index 44e950d..1ed8731 100644 --- a/src/main/java/de/hsh/inform/orientdb_project/orientdb/LowPerformanceOrientDbNetdataImportService.java +++ b/src/main/java/de/hsh/inform/orientdb_project/orientdb/LowPerformanceOrientDbNetdataImportService.java @@ -104,5 +104,10 @@ public class LowPerformanceOrientDbNetdataImportService extends AbstractNetdataI Edge isContainedInEdge = this.og.addEdge("class:isContainedIn", icmpPacket, ipPacket, "isContainedIn"); } + @Override + public void afterImport() { + // TODO Auto-generated method stub + } + } diff --git a/src/main/java/de/hsh/inform/orientdb_project/orientdb/OrientDbNetdataImportService.java b/src/main/java/de/hsh/inform/orientdb_project/orientdb/OrientDbNetdataImportService.java index ff7ac1b..23ca947 100644 --- a/src/main/java/de/hsh/inform/orientdb_project/orientdb/OrientDbNetdataImportService.java +++ b/src/main/java/de/hsh/inform/orientdb_project/orientdb/OrientDbNetdataImportService.java @@ -7,6 +7,8 @@ import org.pcap4j.packet.IpV4Packet; import org.pcap4j.packet.TcpPacket; import org.pcap4j.packet.UdpPacket; +import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx; +import com.orientechnologies.orient.core.record.impl.ODocument; import com.tinkerpop.blueprints.Direction; import com.tinkerpop.blueprints.Edge; import com.tinkerpop.blueprints.Vertex; @@ -14,25 +16,34 @@ import com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx; import de.hsh.inform.orientdb_project.netdata.AbstractNetdataImportService; +/** + * Document based insertion of data using specific clusters + */ public class OrientDbNetdataImportService extends AbstractNetdataImportService { private OrientGraphNoTx og; + private ODatabaseDocumentTx rg; + + private long frameCounter = 0; + public OrientDbNetdataImportService(String filename, OrientGraphNoTx orientGraph) { super(filename); this.og = orientGraph; + this.rg = this.og.getRawGraph(); } public void handleEthernetPacket(EthernetPacket ether, long ts, int ms) { - Vertex ethernetFrame = this.og.addVertex("class:EthernetFrame"); - ethernetFrame.setProperty("sourceMac", ether.getHeader().getSrcAddr().toString()); - ethernetFrame.setProperty("targetMac", ether.getHeader().getDstAddr().toString()); - ethernetFrame.setProperty("rawData", ether.getRawData()); - ethernetFrame.setProperty("size", ether.getRawData().length); - ethernetFrame.setProperty("payloadSize", ether.getRawData().length - ether.getHeader().length()); - ethernetFrame.setProperty("timestamp", ts); - ethernetFrame.setProperty("microseconds", ms); + ODocument ethernetFrame = new ODocument("EthernetFrame"); + ethernetFrame.field("sourceMac", ether.getHeader().getSrcAddr().toString()); + ethernetFrame.field("targetMac", ether.getHeader().getDstAddr().toString()); + ethernetFrame.field("rawData", ether.getRawData()); + ethernetFrame.field("size", ether.getRawData().length); + ethernetFrame.field("payloadSize", ether.getRawData().length - ether.getHeader().length()); + ethernetFrame.field("timestamp", ts); + ethernetFrame.field("microseconds", ms); + this.rg.save(ethernetFrame, "ethernetFrameCluster"); super.handleEthernetPacket(ether, ts, ms); } @@ -102,5 +113,10 @@ public class OrientDbNetdataImportService extends AbstractNetdataImportService { Edge isContainedInEdge = this.og.addEdge("class:isContainedIn", icmpPacket, ipPacket, "isContainedIn"); } + @Override + public void afterImport() { + // TODO Auto-generated method stub + } + }