本文整理汇总了Java中org.onosproject.ovsdb.rfc.utils.ConditionUtil类的典型用法代码示例。如果您正苦于以下问题:Java ConditionUtil类的具体用法?Java ConditionUtil怎么用?Java ConditionUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ConditionUtil类属于org.onosproject.ovsdb.rfc.utils包,在下文中一共展示了ConditionUtil类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateConfig
import org.onosproject.ovsdb.rfc.utils.ConditionUtil; //导入依赖的package包/类
/**
* Update transact config.
*
* @param tableName table name
* @param columnName column name
* @param uuid uuid
* @param row the config data
*/
private void updateConfig(String tableName, String columnName, String uuid,
Row row) {
DatabaseSchema dbSchema = schema.get(OvsdbConstant.DATABASENAME);
TableSchema tableSchema = dbSchema.getTableSchema(tableName);
List<Condition> conditions = Lists.newArrayList();
Condition condition = ConditionUtil.isEqual(columnName, Uuid.uuid(uuid));
conditions.add(condition);
Update update = new Update(tableSchema, row, conditions);
ArrayList<Operation> operations = Lists.newArrayList();
operations.add(update);
transactConfig(OvsdbConstant.DATABASENAME, operations);
}
示例2: updateConfig
import org.onosproject.ovsdb.rfc.utils.ConditionUtil; //导入依赖的package包/类
/**
* Update transact config.
*
* @param tableName table name
* @param columnName column name
* @param uuid uuid
* @param row the config data
*/
private void updateConfig(String tableName, String columnName, String uuid,
Row row) {
DatabaseSchema dbSchema = schema.get(DATABASENAME);
TableSchema tableSchema = dbSchema.getTableSchema(tableName);
List<Condition> conditions = Lists.newArrayList();
Condition condition = ConditionUtil.isEqual(columnName, Uuid.uuid(uuid));
conditions.add(condition);
Update update = new Update(tableSchema, row, conditions);
ArrayList<Operation> operations = Lists.newArrayList();
operations.add(update);
transactConfig(DATABASENAME, operations);
}
示例3: removeQos
import org.onosproject.ovsdb.rfc.utils.ConditionUtil; //导入依赖的package包/类
@Override
public void removeQos(PortNumber portNumber) {
DatabaseSchema dbSchema = schema.get(DATABASENAME);
OvsdbRowStore rowStore = getRowStore(DATABASENAME, PORT);
if (rowStore == null) {
log.debug("The qos uuid is null");
return;
}
ConcurrentMap<String, Row> ovsTableRows = rowStore.getRowStore();
Row portRow = ovsTableRows.values().stream()
.filter(r -> r.getColumn("name").data().equals(portNumber.name()))
.findFirst().orElse(null);
if (portRow == null) {
log.warn("Couldn't find port {} in ovsdb port table.", portNumber.name());
return;
}
OvsdbSet ovsdbSet = ((OvsdbSet) portRow.getColumn(PORT_QOS).data());
@SuppressWarnings("unchecked")
Set<Uuid> qosIdSet = ovsdbSet.set();
if (qosIdSet == null || qosIdSet.isEmpty()) {
return;
}
Uuid qosUuid = (Uuid) qosIdSet.toArray()[0];
Condition condition = ConditionUtil.isEqual(UUID, portRow.uuid());
List<Condition> conditions = Lists.newArrayList(condition);
Mutation mutation = MutationUtil.delete(PORT_QOS, qosUuid);
List<Mutation> mutations = Lists.newArrayList(mutation);
ArrayList<Operation> operations = Lists.newArrayList();
Mutate mutate = new Mutate(dbSchema.getTableSchema(PORT), conditions, mutations);
operations.add(mutate);
transactConfig(DATABASENAME, operations);
}
示例4: createTunnel
import org.onosproject.ovsdb.rfc.utils.ConditionUtil; //导入依赖的package包/类
@Override
public boolean createTunnel(String bridgeName, String portName, String tunnelType, Map<String, String> options) {
String bridgeUuid = getBridgeUuid(bridgeName);
if (bridgeUuid == null) {
log.warn("Couldn't find bridge {} in {}", bridgeName, nodeId.getIpAddress());
return false;
}
if (getPortUuid(portName, bridgeUuid) != null) {
log.warn("Port {} already exists", portName);
// remove existing one and re-create?
return false;
}
ArrayList<Operation> operations = Lists.newArrayList();
DatabaseSchema dbSchema = schema.get(OvsdbConstant.DATABASENAME);
// insert a new port to the port table
Port port = (Port) TableGenerator.createTable(dbSchema, OvsdbTable.PORT);
port.setName(portName);
Insert portInsert = new Insert(dbSchema.getTableSchema("Port"), "Port", port.getRow());
portInsert.getRow().put("interfaces", Uuid.uuid("Interface"));
operations.add(portInsert);
// update the bridge table
Condition condition = ConditionUtil.isEqual("_uuid", Uuid.uuid(bridgeUuid));
Mutation mutation = MutationUtil.insert("ports", Uuid.uuid("Port"));
List<Condition> conditions = new ArrayList<>(Arrays.asList(condition));
List<Mutation> mutations = new ArrayList<>(Arrays.asList(mutation));
operations.add(new Mutate(dbSchema.getTableSchema("Bridge"), conditions, mutations));
// insert a tunnel interface
Interface intf = (Interface) TableGenerator.createTable(dbSchema, OvsdbTable.INTERFACE);
intf.setName(portName);
intf.setType(tunnelType);
intf.setOptions(options);
Insert intfInsert = new Insert(dbSchema.getTableSchema("Interface"), "Interface", intf.getRow());
operations.add(intfInsert);
transactConfig(OvsdbConstant.DATABASENAME, operations);
return true;
}
示例5: unbindQueues
import org.onosproject.ovsdb.rfc.utils.ConditionUtil; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void unbindQueues(QosId qosId, List<Long> queueKeys) {
DatabaseSchema dbSchema = schema.get(DATABASENAME);
OvsdbRowStore qosRowStore = getRowStore(DATABASENAME, QOS);
if (qosRowStore == null) {
return;
}
ConcurrentMap<String, Row> qosTableRows = qosRowStore.getRowStore();
Row qosRow = qosTableRows.values().stream().filter(r -> {
OvsdbMap ovsdbMap = (OvsdbMap) (r.getColumn(EXTERNAL_ID).data());
return qosId.name().equals(ovsdbMap.map().get(QOS_EXTERNAL_ID_KEY));
}).findFirst().orElse(null);
if (qosRow == null) {
log.warn("Can't find QoS {}", qosId);
return;
}
Map<Long, Uuid> deleteQueuesMap = new HashMap<>();
Map<Integer, Uuid> queuesMap = ((OvsdbMap) qosRow.getColumn(QUEUES).data()).map();
queueKeys.forEach(key -> {
if (queuesMap.containsKey(key.intValue())) {
deleteQueuesMap.put(key, queuesMap.get(key.intValue()));
}
});
if (deleteQueuesMap.size() != 0) {
TableSchema parentTableSchema = dbSchema
.getTableSchema(QOS);
ColumnSchema parentColumnSchema = parentTableSchema
.getColumnSchema(QUEUES);
Mutation mutation = MutationUtil.delete(parentColumnSchema.name(), OvsdbMap.ovsdbMap(deleteQueuesMap));
List<Mutation> mutations = Collections.singletonList(mutation);
Condition condition = ConditionUtil.isEqual(UUID, qosRow.uuid());
List<Condition> conditionList = Collections.singletonList(condition);
List<Operation> operations = Collections.singletonList(
new Mutate(parentTableSchema, conditionList, mutations));
transactConfig(DATABASENAME, operations);
}
}
示例6: createInterface
import org.onosproject.ovsdb.rfc.utils.ConditionUtil; //导入依赖的package包/类
@Override
public boolean createInterface(String bridgeName, OvsdbInterface ovsdbIface) {
String bridgeUuid = getBridgeUuid(bridgeName);
if (bridgeUuid == null) {
log.warn("Couldn't find bridge {} in {}", bridgeName, nodeId.getIpAddress());
return false;
}
if (getPortUuid(ovsdbIface.name(), bridgeUuid) != null) {
log.warn("Interface {} already exists", ovsdbIface.name());
// remove existing one and re-create?
return false;
}
ArrayList<Operation> operations = Lists.newArrayList();
DatabaseSchema dbSchema = schema.get(DATABASENAME);
// insert a new port with the interface name
Port port = (Port) TableGenerator.createTable(dbSchema, OvsdbTable.PORT);
port.setName(ovsdbIface.name());
Insert portInsert = new Insert(dbSchema.getTableSchema(PORT), PORT, port.getRow());
portInsert.getRow().put(INTERFACES, Uuid.uuid(INTERFACE));
operations.add(portInsert);
// update the bridge table with the new port
Condition condition = ConditionUtil.isEqual(UUID, Uuid.uuid(bridgeUuid));
Mutation mutation = MutationUtil.insert(PORTS, Uuid.uuid(PORT));
List<Condition> conditions = Lists.newArrayList(condition);
List<Mutation> mutations = Lists.newArrayList(mutation);
operations.add(new Mutate(dbSchema.getTableSchema(BRIDGE), conditions, mutations));
// insert an interface
Interface intf = (Interface) TableGenerator.createTable(dbSchema, OvsdbTable.INTERFACE);
intf.setName(ovsdbIface.name());
intf.setType(ovsdbIface.typeToString());
if (ovsdbIface.mtu().isPresent()) {
Set<Long> mtuSet = Sets.newConcurrentHashSet();
mtuSet.add(ovsdbIface.mtu().get());
intf.setMtu(mtuSet);
intf.setMtuRequest(mtuSet);
}
intf.setOptions(ovsdbIface.options());
Insert intfInsert = new Insert(dbSchema.getTableSchema(INTERFACE), INTERFACE, intf.getRow());
operations.add(intfInsert);
transactConfig(DATABASENAME, operations);
log.info("Created interface {}", ovsdbIface);
return true;
}