Add unimplemented methods to other import services

This commit is contained in:
Jan Philipp Timme 2016-11-28 18:10:27 +01:00
parent f1838d8ce3
commit 67aa56fec4
Signed by untrusted user: JPT
GPG Key ID: 5F2C85EC6F3754B7
3 changed files with 32 additions and 8 deletions

View File

@ -35,5 +35,8 @@ public class DummyImportService extends AbstractNetdataImportService {
public void handleIcmpPacket(IcmpV4CommonPacket icmp, long ts, int ms) {} public void handleIcmpPacket(IcmpV4CommonPacket icmp, long ts, int ms) {}
@Override
public void afterImport() {}
} }

View File

@ -104,5 +104,10 @@ public class LowPerformanceOrientDbNetdataImportService extends AbstractNetdataI
Edge isContainedInEdge = this.og.addEdge("class:isContainedIn", icmpPacket, ipPacket, "isContainedIn"); Edge isContainedInEdge = this.og.addEdge("class:isContainedIn", icmpPacket, ipPacket, "isContainedIn");
} }
@Override
public void afterImport() {
// TODO Auto-generated method stub
}
} }

View File

@ -7,6 +7,8 @@ import org.pcap4j.packet.IpV4Packet;
import org.pcap4j.packet.TcpPacket; import org.pcap4j.packet.TcpPacket;
import org.pcap4j.packet.UdpPacket; 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.Direction;
import com.tinkerpop.blueprints.Edge; import com.tinkerpop.blueprints.Edge;
import com.tinkerpop.blueprints.Vertex; import com.tinkerpop.blueprints.Vertex;
@ -14,25 +16,34 @@ import com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx;
import de.hsh.inform.orientdb_project.netdata.AbstractNetdataImportService; import de.hsh.inform.orientdb_project.netdata.AbstractNetdataImportService;
/**
* Document based insertion of data using specific clusters
*/
public class OrientDbNetdataImportService extends AbstractNetdataImportService { public class OrientDbNetdataImportService extends AbstractNetdataImportService {
private OrientGraphNoTx og; private OrientGraphNoTx og;
private ODatabaseDocumentTx rg;
private long frameCounter = 0;
public OrientDbNetdataImportService(String filename, OrientGraphNoTx orientGraph) { public OrientDbNetdataImportService(String filename, OrientGraphNoTx orientGraph) {
super(filename); super(filename);
this.og = orientGraph; this.og = orientGraph;
this.rg = this.og.getRawGraph();
} }
public void handleEthernetPacket(EthernetPacket ether, long ts, int ms) { public void handleEthernetPacket(EthernetPacket ether, long ts, int ms) {
Vertex ethernetFrame = this.og.addVertex("class:EthernetFrame"); ODocument ethernetFrame = new ODocument("EthernetFrame");
ethernetFrame.setProperty("sourceMac", ether.getHeader().getSrcAddr().toString()); ethernetFrame.field("sourceMac", ether.getHeader().getSrcAddr().toString());
ethernetFrame.setProperty("targetMac", ether.getHeader().getDstAddr().toString()); ethernetFrame.field("targetMac", ether.getHeader().getDstAddr().toString());
ethernetFrame.setProperty("rawData", ether.getRawData()); ethernetFrame.field("rawData", ether.getRawData());
ethernetFrame.setProperty("size", ether.getRawData().length); ethernetFrame.field("size", ether.getRawData().length);
ethernetFrame.setProperty("payloadSize", ether.getRawData().length - ether.getHeader().length()); ethernetFrame.field("payloadSize", ether.getRawData().length - ether.getHeader().length());
ethernetFrame.setProperty("timestamp", ts); ethernetFrame.field("timestamp", ts);
ethernetFrame.setProperty("microseconds", ms); ethernetFrame.field("microseconds", ms);
this.rg.save(ethernetFrame, "ethernetFrameCluster");
super.handleEthernetPacket(ether, ts, ms); super.handleEthernetPacket(ether, ts, ms);
} }
@ -102,5 +113,10 @@ public class OrientDbNetdataImportService extends AbstractNetdataImportService {
Edge isContainedInEdge = this.og.addEdge("class:isContainedIn", icmpPacket, ipPacket, "isContainedIn"); Edge isContainedInEdge = this.og.addEdge("class:isContainedIn", icmpPacket, ipPacket, "isContainedIn");
} }
@Override
public void afterImport() {
// TODO Auto-generated method stub
}
} }