Implement more stuff
This commit is contained in:
parent
19b6fc3e4e
commit
687df96022
|
@ -4,8 +4,10 @@ import java.util.List;
|
|||
|
||||
import com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx;
|
||||
|
||||
import de.hsh.inform.orientdb_project.model.HostModel;
|
||||
import de.hsh.inform.orientdb_project.model.TcpConnectionModel;
|
||||
import de.hsh.inform.orientdb_project.orientdb.OrientDbHelperService;
|
||||
import de.hsh.inform.orientdb_project.repository.HostRepository;
|
||||
import de.hsh.inform.orientdb_project.repository.TcpConnectionRepository;
|
||||
import de.hsh.inform.orientdb_project.util.ConfigPropertiesReader;
|
||||
|
||||
|
@ -29,6 +31,11 @@ public class Main {
|
|||
long r = tcr.getTotalDataVolumePerMinuteBetweenHosts("172.16.114.207", "206.251.19.72");
|
||||
System.out.println("Bytes per Second: " + r);
|
||||
|
||||
HostRepository hr = new HostRepository(ogf);
|
||||
for(HostModel hm : hr.findByConnectionsTo("197.218.177.69", 25)) {
|
||||
System.out.println(hm);
|
||||
}
|
||||
|
||||
// Done
|
||||
odhs.close();
|
||||
}
|
||||
|
|
|
@ -38,4 +38,13 @@ public class HostModel {
|
|||
return arguments;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder("[Host ipAddress=");
|
||||
sb.append(this.ipAddress);
|
||||
sb.append(", internal=");
|
||||
sb.append(this.internal);
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -146,13 +146,13 @@ public class NodeBasedImportService extends AbstractNetdataImportService {
|
|||
}
|
||||
|
||||
private void addHostIfNew(Inet4Address ipAddress) {
|
||||
if(this.knownHosts.containsKey(ipAddress)) {
|
||||
String ipAddressStr = ipAddress.toString().split("/")[1];
|
||||
if(this.knownHosts.containsKey(ipAddressStr)) {
|
||||
return; // Host already known, nothing to do!
|
||||
} else {
|
||||
// Check internal/external by IP
|
||||
boolean isInternal = ipAddress.isSiteLocalAddress(); // TODO: VERIFY IF THIS IS CORRECT!
|
||||
// Create Vertex and add to HashMap
|
||||
String ipAddressStr = ipAddress.toString().split("/")[1];
|
||||
HostModel hostModel = new HostModel(ipAddressStr, isInternal);
|
||||
Vertex host = this.og.addVertex("class:Host", hostModel.getArguments());
|
||||
this.knownHosts.put(ipAddressStr, host);
|
||||
|
|
|
@ -3,6 +3,7 @@ package de.hsh.inform.orientdb_project.repository;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.orientechnologies.orient.core.sql.OCommandSQL;
|
||||
import com.tinkerpop.blueprints.GraphQuery;
|
||||
import com.tinkerpop.blueprints.Vertex;
|
||||
import com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx;
|
||||
|
@ -18,10 +19,13 @@ public class HostRepository {
|
|||
}
|
||||
|
||||
public List<HostModel> findByConnectionsTo(String ipAddress, int port) {
|
||||
GraphQuery gq = this.ogf.query();
|
||||
gq = gq.has("@class", "Host");
|
||||
// TODO
|
||||
return this.getListFromVertices(gq.vertices());
|
||||
String sql = "" +
|
||||
"SELECT EXPAND(out('isTargetHostFor')[targetPort=" + port + "].out('hasSourceHost')) " +
|
||||
"FROM Host WHERE ipAddress = '" + ipAddress + "';";
|
||||
|
||||
@SuppressWarnings("unchecked") // We know.
|
||||
Iterable<Vertex> vertices = (Iterable<Vertex>) this.ogf.command(new OCommandSQL(sql)).execute();
|
||||
return this.getListFromVertices(vertices);
|
||||
}
|
||||
|
||||
public List<HostModel> findAllByConnectionsToOutsideHosts() {
|
||||
|
|
Loading…
Reference in New Issue