当前位置: 首页>>代码示例>>Java>>正文


Java OvsdbMap类代码示例

本文整理汇总了Java中org.onosproject.ovsdb.rfc.notation.OvsdbMap的典型用法代码示例。如果您正苦于以下问题:Java OvsdbMap类的具体用法?Java OvsdbMap怎么用?Java OvsdbMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


OvsdbMap类属于org.onosproject.ovsdb.rfc.notation包,在下文中一共展示了OvsdbMap类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getIfaceid

import org.onosproject.ovsdb.rfc.notation.OvsdbMap; //导入依赖的package包/类
private String getIfaceid(Interface intf) {
    OvsdbMap ovsdbMap = (OvsdbMap) intf.getExternalIdsColumn().data();
    @SuppressWarnings("unchecked")
    Map<String, String> externalIds = ovsdbMap.map();
    if (externalIds.isEmpty()) {
        log.warn("The external_ids is null");
        return null;
    }
    String ifaceid = externalIds
            .get(OvsdbConstant.EXTERNAL_ID_INTERFACE_ID);
    if (ifaceid == null) {
        log.warn("The ifaceid is null");
        return null;
    }
    return ifaceid;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:17,代码来源:DefaultOvsdbClient.java

示例2: getMacAndIfaceid

import org.onosproject.ovsdb.rfc.notation.OvsdbMap; //导入依赖的package包/类
/**
 * Gets mac and iface from the table Interface.
 *
 * @param intf Interface instance
 * @return attachedMac, ifaceid
 */
private String[] getMacAndIfaceid(Interface intf) {
    OvsdbMap ovsdbMap = (OvsdbMap) intf.getExternalIdsColumn().data();
    @SuppressWarnings("unchecked")
    Map<String, String> externalIds = ovsdbMap.map();
    if (externalIds == null) {
        log.warn("The external_ids is null");
        return null;
    }

    String attachedMac = externalIds.get(OvsdbConstant.EXTERNAL_ID_VM_MAC);
    if (attachedMac == null) {
        log.debug("The attachedMac is null"); //FIXME why always null?
        return null;
    }
    String ifaceid = externalIds
            .get(OvsdbConstant.EXTERNAL_ID_INTERFACE_ID);
    if (ifaceid == null) {
        log.warn("The ifaceid is null");
        return null;
    }
    return new String[]{attachedMac, ifaceid};
}
 
开发者ID:shlee89,项目名称:athena,代码行数:29,代码来源:OvsdbControllerImpl.java

示例3: getValueFromKvType

import org.onosproject.ovsdb.rfc.notation.OvsdbMap; //导入依赖的package包/类
/**
 * Convert KeyValuedColumnType JsonNode into OvsdbMap value.
 * @param json KeyValuedColumnType JsonNode
 * @param kvType KeyValuedColumnType entity
 * @return Object OvsdbMap
 */
private static Object getValueFromKvType(JsonNode json, KeyValuedColumnType kvType) {
    if (json.isArray()) {
        if (json.size() == 2) {
            if (json.get(0).isTextual() && "map".equals(json.get(0).asText())) {
                Map map = Maps.newHashMap();
                for (JsonNode pairNode : json.get(1)) {
                    if (pairNode.isArray() && json.size() == 2) {
                        Object key = transToValue(pairNode.get(0), kvType.keyType());
                        Object value = transToValue(pairNode.get(1), kvType.valueType());
                        map.put(key, value);
                    }
                }
                return OvsdbMap.ovsdbMap(map);
            }
        }
    }
    return null;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:25,代码来源:TransValueUtil.java

示例4: serialize

import org.onosproject.ovsdb.rfc.notation.OvsdbMap; //导入依赖的package包/类
@Override
public void serialize(OvsdbMap map, JsonGenerator generator,
                      SerializerProvider provider)
        throws IOException, JsonProcessingException {
    generator.writeStartArray();
    generator.writeString("map");
    generator.writeStartArray();
    Map javaMap = map.map();
    for (Object key : javaMap.keySet()) {
        generator.writeStartArray();
        generator.writeObject(key);
        generator.writeObject(javaMap.get(key));
        generator.writeEndArray();
    }
    generator.writeEndArray();
    generator.writeEndArray();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:18,代码来源:OvsdbMapSerializer.java

示例5: getOvsdbQos

import org.onosproject.ovsdb.rfc.notation.OvsdbMap; //导入依赖的package包/类
private OvsdbQos getOvsdbQos(Row row) {
    DatabaseSchema dbSchema = getDatabaseSchema(DATABASENAME);
    Qos qos = (Qos) TableGenerator.getTable(dbSchema, row, OvsdbTable.QOS);
    if (qos == null) {
        return null;
    }

    String type = (String) qos.getTypeColumn().data();
    Map<String, String> otherConfigs;
    Map<String, String> externalIds;
    Map<Long, String> queues;

    otherConfigs = ((OvsdbMap) qos.getOtherConfigColumn().data()).map();
    externalIds  = ((OvsdbMap) qos.getExternalIdsColumn().data()).map();
    queues = ((OvsdbMap) qos.getQueuesColumn().data()).map();
    return OvsdbQos.builder().qosType(type).
            queues(queues).otherConfigs(otherConfigs).
            externalIds(externalIds).build();
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:20,代码来源:DefaultOvsdbClient.java

示例6: getOvsdbQueue

import org.onosproject.ovsdb.rfc.notation.OvsdbMap; //导入依赖的package包/类
private OvsdbQueue getOvsdbQueue(Row row) {
    DatabaseSchema dbSchema = getDatabaseSchema(DATABASENAME);
    Queue queue = (Queue) TableGenerator.getTable(dbSchema, row, OvsdbTable.QUEUE);
    if (queue == null) {
        return null;
    }

    OvsdbSet dscpOvsdbSet = ((OvsdbSet) queue.getDscpColumn().data());
    @SuppressWarnings("unchecked")
    Set<String> dscpSet = dscpOvsdbSet.set();
    Long dscp = null;
    if (dscpSet != null && !dscpSet.isEmpty()) {
        dscp = Long.valueOf((String) dscpSet.toArray()[0]);
    }

    Map<String, String> otherConfigs;
    Map<String, String> externalIds;

    otherConfigs = ((OvsdbMap) queue.getOtherConfigColumn().data()).map();
    externalIds  = ((OvsdbMap) queue.getExternalIdsColumn().data()).map();
    return OvsdbQueue.builder().dscp(dscp).
            otherConfigs(otherConfigs).externalIds(externalIds).build();
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:24,代码来源:DefaultOvsdbClient.java

示例7: getFormatData

import org.onosproject.ovsdb.rfc.notation.OvsdbMap; //导入依赖的package包/类
/**
 * if the type is Set, convert into OvsdbSet, if Map, convert into OvsdbMap.
 * @param value Object
 * @return Object
 */
public static Object getFormatData(Object value) {
    if (value instanceof Map) {
        return OvsdbMap.ovsdbMap((Map) value);
    } else if (value instanceof Set) {
        return OvsdbSet.ovsdbSet((Set) value);
    } else {
        return value;
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:15,代码来源:TransValueUtil.java

示例8: getMirrorings

import org.onosproject.ovsdb.rfc.notation.OvsdbMap; //导入依赖的package包/类
/**
 * Helper method which retrieves mirrorings statistics using bridge uuid.
 *
 * @param bridgeUuid the uuid of the bridge
 * @return the list of the mirrorings statistics.
 */
private List<MirroringStatistics> getMirrorings(Uuid bridgeUuid) {
    DatabaseSchema dbSchema = schema.get(DATABASENAME);
    if (dbSchema == null) {
        log.warn("Unable to retrieve dbSchema {}", DATABASENAME);
        return null;
    }
    OvsdbRowStore rowStore = getRowStore(DATABASENAME, BRIDGE);
    if (rowStore == null) {
        log.warn("Unable to retrieve rowStore {} of {}", BRIDGE, DATABASENAME);
        return null;
    }

    Row bridgeRow = rowStore.getRow(bridgeUuid.value());
    Bridge bridge = (Bridge) TableGenerator.
            getTable(dbSchema, bridgeRow, OvsdbTable.BRIDGE);

    Set<Uuid> mirroringsUuids = (Set<Uuid>) ((OvsdbSet) bridge
            .getMirrorsColumn().data()).set();

    OvsdbRowStore mirrorRowStore = getRowStore(DATABASENAME, MIRROR);
    if (mirrorRowStore == null) {
        log.warn("Unable to retrieve rowStore {} of {}", MIRROR, DATABASENAME);
        return null;
    }

    List<MirroringStatistics> mirroringStatistics = new ArrayList<>();
    ConcurrentMap<String, Row> mirrorTableRows = mirrorRowStore.getRowStore();
    mirrorTableRows.forEach((key, row) -> {
        if (!mirroringsUuids.contains(Uuid.uuid(key))) {
            return;
        }
        Mirror mirror = (Mirror) TableGenerator
                .getTable(dbSchema, row, OvsdbTable.MIRROR);
        mirroringStatistics.add(MirroringStatistics.mirroringStatistics(mirror.getName(),
                                                                  (Map<String, Integer>) ((OvsdbMap) mirror
                                                               .getStatisticsColumn().data()).map()));
    });
    return ImmutableList.copyOf(mirroringStatistics);
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:46,代码来源:DefaultOvsdbClient.java

示例9: applyQos

import org.onosproject.ovsdb.rfc.notation.OvsdbMap; //导入依赖的package包/类
@Override
public void applyQos(PortNumber portNumber, String qosName) {
    DatabaseSchema dbSchema = schema.get(DATABASENAME);
    OvsdbRowStore portRowStore = getRowStore(DATABASENAME, PORT);
    if (portRowStore == null) {
        log.debug("The port uuid is null");
        return;
    }
    OvsdbRowStore qosRowStore = getRowStore(DATABASENAME, QOS);
    if (qosRowStore == null) {
        log.debug("The qos uuid is null");
        return;
    }

    // Due to Qos Table doesn't have a unique identifier except uuid, unlike
    // Bridge or Port Table has a name column,in order to make the api more
    // general, put qos name in external_ids column of Qos Table if this qos
    // created by onos.
    ConcurrentMap<String, Row> qosTableRows = qosRowStore.getRowStore();
    ConcurrentMap<String, Row> portTableRows = portRowStore.getRowStore();
    Row qosRow = qosTableRows.values().stream().filter(r -> {
        OvsdbMap ovsdbMap = (OvsdbMap) (r.getColumn(EXTERNAL_ID).data());
        return qosName.equals(ovsdbMap.map().get(QOS_EXTERNAL_ID_KEY));
    }).findFirst().orElse(null);

    Row portRow = portTableRows.values().stream()
            .filter(r -> r.getColumn("name").data().equals(portNumber.name()))
            .findFirst().orElse(null);
    if (portRow != null && qosRow != null) {
        String qosId = qosRow.uuid().value();
        Uuid portUuid = portRow.uuid();
        Map<String, Column> columns = new HashMap<>();
        Row newPortRow = new Row(PORT, portUuid, columns);
        Port newport = new Port(dbSchema, newPortRow);
        columns.put(Port.PortColumn.QOS.columnName(), newport.getQosColumn());
        newport.setQos(Uuid.uuid(qosId));
        updateConfig(PORT, UUID, portUuid.value(), newport.getRow());
    }
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:40,代码来源:DefaultOvsdbClient.java

示例10: dropQos

import org.onosproject.ovsdb.rfc.notation.OvsdbMap; //导入依赖的package包/类
@Override
public void dropQos(QosId qosId) {
    OvsdbRowStore rowStore = getRowStore(DATABASENAME, QOS);
    if (rowStore != null) {
        ConcurrentMap<String, Row> qosTableRows = rowStore.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) {
            deleteConfig(QOS, UUID, qosRow.uuid().value(), PORT, PORT_QOS, qosRow.uuid());
        }
    }
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:15,代码来源:DefaultOvsdbClient.java

示例11: getIfaceid

import org.onosproject.ovsdb.rfc.notation.OvsdbMap; //导入依赖的package包/类
private String getIfaceid(Interface intf) {
    OvsdbMap ovsdbMap = (OvsdbMap) intf.getExternalIdsColumn().data();
    @SuppressWarnings("unchecked")
    Map<String, String> externalIds = ovsdbMap.map();
    if (externalIds.isEmpty()) {
        log.warn("The external_ids is null");
        return null;
    }
    String ifaceid = externalIds.get(EXTERNAL_ID_INTERFACE_ID);
    if (ifaceid == null) {
        log.warn("The ifaceid is null");
        return null;
    }
    return ifaceid;
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:16,代码来源:DefaultOvsdbClient.java

示例12: createQos

import org.onosproject.ovsdb.rfc.notation.OvsdbMap; //导入依赖的package包/类
@Override
public boolean createQos(OvsdbQos ovsdbQos) {
    DatabaseSchema dbSchema = schema.get(DATABASENAME);
    Qos qos = (Qos) TableGenerator.createTable(dbSchema, OvsdbTable.QOS);
    OvsdbRowStore rowStore = getRowStore(DATABASENAME, QOS);
    if (rowStore == null) {
        log.debug("The qos uuid is null");
        return false;
    }

    ArrayList<Operation> operations = Lists.newArrayList();
    Set<String> types = Sets.newHashSet();
    Map<Long, Uuid> queues = Maps.newHashMap();

    types.add(ovsdbQos.qosType());
    qos.setOtherConfig(ovsdbQos.otherConfigs());
    qos.setExternalIds(ovsdbQos.externalIds());
    qos.setType(types);
    if (ovsdbQos.qosQueues().isPresent()) {
        for (Map.Entry<Long, String> entry : ovsdbQos.qosQueues().get().entrySet()) {
            OvsdbRowStore queueRowStore = getRowStore(DATABASENAME, QUEUE);
            if (queueRowStore != null) {
                ConcurrentMap<String, Row> queueTableRows = queueRowStore.getRowStore();
                Row queueRow = queueTableRows.values().stream().filter(r -> {
                    OvsdbMap ovsdbMap = (OvsdbMap) (r.getColumn(EXTERNAL_ID).data());
                    return entry.getValue().equals(ovsdbMap.map().get(QUEUE_EXTERNAL_ID_KEY));
                }).findFirst().orElse(null);
                if (queueRow != null) {
                    queues.put(entry.getKey(), queueRow.uuid());
                }
            }
        }
        qos.setQueues(queues);
    }

    Insert qosInsert = new Insert(dbSchema.getTableSchema(QOS), QOS, qos.getRow());
    operations.add(qosInsert);
    try {
        transactConfig(DATABASENAME, operations).get();
    } catch (InterruptedException | ExecutionException e) {
        return false;
    }
    return true;
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:45,代码来源:DefaultOvsdbClient.java

示例13: unbindQueues

import org.onosproject.ovsdb.rfc.notation.OvsdbMap; //导入依赖的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);
    }
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:48,代码来源:DefaultOvsdbClient.java


注:本文中的org.onosproject.ovsdb.rfc.notation.OvsdbMap类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。