use of org.apache.tinkerpop.gremlin.orientdb.executor.OGremlinResultSet in project open-kilda by telstra.
the class OrientDbFlowMeterRepository method exists.
@Override
public boolean exists(SwitchId switchId, MeterId meterId) {
String switchIdAsStr = SwitchIdConverter.INSTANCE.toGraphProperty(switchId);
Long meterIdAsLong = MeterIdConverter.INSTANCE.toGraphProperty(meterId);
try (OGremlinResultSet results = graphSupplier.get().querySql(format("SELECT @rid FROM %s WHERE %s = ? AND %s = ? LIMIT 1", FlowMeterFrame.FRAME_LABEL, FlowMeterFrame.SWITCH_PROPERTY, FlowMeterFrame.METER_ID_PROPERTY), switchIdAsStr, meterIdAsLong)) {
return results.iterator().hasNext();
}
}
use of org.apache.tinkerpop.gremlin.orientdb.executor.OGremlinResultSet in project open-kilda by telstra.
the class OrientDbIslRepository method findActiveSwitchesAndPop.
private Map<String, String> findActiveSwitchesAndPop() {
String switchStatusAsStr = SwitchStatusConverter.INSTANCE.toGraphProperty(SwitchStatus.ACTIVE);
Map<String, String> switches = new HashMap<>();
try (OGremlinResultSet results = graphSupplier.get().querySql(QUERY_FETCH_SWITCHES_BY_STATUS, switchStatusAsStr)) {
results.forEach(gs -> switches.put(gs.getProperty(SwitchFrame.SWITCH_ID_PROPERTY), gs.getProperty(SwitchFrame.POP_PROPERTY)));
}
return switches;
}
use of org.apache.tinkerpop.gremlin.orientdb.executor.OGremlinResultSet in project open-kilda by telstra.
the class OrientDbIslRepository method findAllActive.
@Override
public Collection<IslImmutableView> findAllActive() {
Map<String, String> switches = findActiveSwitchesAndPop();
List<IslImmutableView> isls = new ArrayList<>();
try (OGremlinResultSet results = graphSupplier.get().querySql(QUERY_FETCH_ISLS_BY_STATUS, IslStatusConverter.INSTANCE.toGraphProperty(IslStatus.ACTIVE))) {
results.forEach(gs -> {
String srcSwitch = gs.getProperty(IslFrame.SRC_SWITCH_ID_PROPERTY);
String dstSwitch = gs.getProperty(IslFrame.DST_SWITCH_ID_PROPERTY);
if (switches.containsKey(srcSwitch) && switches.containsKey(dstSwitch)) {
isls.add(mapToIslImmutableView(gs, switches.get(srcSwitch), switches.get(dstSwitch)));
}
});
}
return isls;
}
Aggregations