本文整理汇总了Java中org.onosproject.ovsdb.rfc.notation.Mutation类的典型用法代码示例。如果您正苦于以下问题:Java Mutation类的具体用法?Java Mutation怎么用?Java Mutation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Mutation类属于org.onosproject.ovsdb.rfc.notation包,在下文中一共展示了Mutation类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Mutate
import org.onosproject.ovsdb.rfc.notation.Mutation; //导入依赖的package包/类
/**
* Constructs a Mutate object.
* @param schema TableSchema entity
* @param where the List of Condition entity
* @param mutations the List of Mutation entity
*/
public Mutate(TableSchema schema, List<Condition> where,
List<Mutation> mutations) {
checkNotNull(schema, "TableSchema cannot be null");
checkNotNull(mutations, "mutations cannot be null");
checkNotNull(where, "where cannot be null");
this.tableSchema = schema;
this.op = Operations.MUTATE.op();
this.where = where;
this.mutations = mutations;
}
示例2: serialize
import org.onosproject.ovsdb.rfc.notation.Mutation; //导入依赖的package包/类
@Override
public void serialize(Mutation condition, JsonGenerator generator,
SerializerProvider provider)
throws IOException, JsonProcessingException {
generator.writeStartArray();
generator.writeString(condition.getColumn());
generator.writeString(condition.getMutator().mutator());
generator.writeObject(condition.getValue());
generator.writeEndArray();
}
示例3: removeQos
import org.onosproject.ovsdb.rfc.notation.Mutation; //导入依赖的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.notation.Mutation; //导入依赖的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.notation.Mutation; //导入依赖的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.notation.Mutation; //导入依赖的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;
}
示例7: getMutations
import org.onosproject.ovsdb.rfc.notation.Mutation; //导入依赖的package包/类
/**
* Returns the mutations member of mutate operation.
* @return the mutations member of mutate operation
*/
public List<Mutation> getMutations() {
return mutations;
}
示例8: sum
import org.onosproject.ovsdb.rfc.notation.Mutation; //导入依赖的package包/类
/**
* Returns a Mutation that means += .
* @param columnName column name
* @param data column value
* @return Mutation
*/
public static Mutation sum(String columnName, Object data) {
Object value = TransValueUtil.getFormatData(data);
return new Mutation(columnName, Mutator.SUM, value);
}
示例9: difference
import org.onosproject.ovsdb.rfc.notation.Mutation; //导入依赖的package包/类
/**
* Returns a Mutation that means -= .
* @param columnName column name
* @param data column value
* @return Mutation
*/
public static Mutation difference(String columnName, Object data) {
Object value = TransValueUtil.getFormatData(data);
return new Mutation(columnName, Mutator.DIFFERENCE, value);
}
示例10: product
import org.onosproject.ovsdb.rfc.notation.Mutation; //导入依赖的package包/类
/**
* Returns a Mutation that means *= .
* @param columnName column name
* @param data column value
* @return Mutation
*/
public static Mutation product(String columnName, Object data) {
Object value = TransValueUtil.getFormatData(data);
return new Mutation(columnName, Mutator.PRODUCT, value);
}
示例11: quotient
import org.onosproject.ovsdb.rfc.notation.Mutation; //导入依赖的package包/类
/**
* Returns a Mutation that means /= .
* @param columnName column name
* @param data column value
* @return Mutation
*/
public static Mutation quotient(String columnName, Object data) {
Object value = TransValueUtil.getFormatData(data);
return new Mutation(columnName, Mutator.QUOTIENT, value);
}
示例12: remainder
import org.onosproject.ovsdb.rfc.notation.Mutation; //导入依赖的package包/类
/**
* Returns a Mutation that means %= .
* @param columnName column name
* @param data column value
* @return Mutation
*/
public static Mutation remainder(String columnName, Object data) {
Object value = TransValueUtil.getFormatData(data);
return new Mutation(columnName, Mutator.REMAINDER, value);
}
示例13: insert
import org.onosproject.ovsdb.rfc.notation.Mutation; //导入依赖的package包/类
/**
* Returns a Mutation that means insert .
* @param columnName column name
* @param data column value
* @return Mutation
*/
public static Mutation insert(String columnName, Object data) {
Object value = TransValueUtil.getFormatData(data);
return new Mutation(columnName, Mutator.INSERT, value);
}
示例14: delete
import org.onosproject.ovsdb.rfc.notation.Mutation; //导入依赖的package包/类
/**
* Returns a Mutation that means delete .
* @param columnName column name
* @param data column value
* @return Mutation
*/
public static Mutation delete(String columnName, Object data) {
Object value = TransValueUtil.getFormatData(data);
return new Mutation(columnName, Mutator.DELETE, value);
}