Search in sources :

Example 6 with OGremlinResultSet

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();
    }
}
Also used : OGremlinResultSet(org.apache.tinkerpop.gremlin.orientdb.executor.OGremlinResultSet)

Example 7 with OGremlinResultSet

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;
}
Also used : HashMap(java.util.HashMap) OGremlinResultSet(org.apache.tinkerpop.gremlin.orientdb.executor.OGremlinResultSet)

Example 8 with OGremlinResultSet

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;
}
Also used : ArrayList(java.util.ArrayList) OGremlinResultSet(org.apache.tinkerpop.gremlin.orientdb.executor.OGremlinResultSet)

Aggregations

OGremlinResultSet (org.apache.tinkerpop.gremlin.orientdb.executor.OGremlinResultSet)8 HashMap (java.util.HashMap)4 ArrayList (java.util.ArrayList)3 OrientGraph (org.apache.tinkerpop.gremlin.orientdb.OrientGraph)1 OGremlinResult (org.apache.tinkerpop.gremlin.orientdb.executor.OGremlinResult)1