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


Java NodeId.nodeId方法代码示例

本文整理汇总了Java中org.onosproject.cluster.NodeId.nodeId方法的典型用法代码示例。如果您正苦于以下问题:Java NodeId.nodeId方法的具体用法?Java NodeId.nodeId怎么用?Java NodeId.nodeId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.onosproject.cluster.NodeId的用法示例。


在下文中一共展示了NodeId.nodeId方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: MockRegion

import org.onosproject.cluster.NodeId; //导入方法依赖的package包/类
public MockRegion(RegionId id, String name, Type type) {
    this.id = id;
    this.name = name;
    this.type = type;

    final NodeId nodeId1 = NodeId.nodeId("1");
    final NodeId nodeId2 = NodeId.nodeId("2");
    final NodeId nodeId3 = NodeId.nodeId("3");
    final NodeId nodeId4 = NodeId.nodeId("4");

    Set<NodeId> nodeIds1 = ImmutableSet.of(nodeId1);
    Set<NodeId> nodeIds2 = ImmutableSet.of(nodeId1, nodeId2);
    Set<NodeId> nodeIds3 = ImmutableSet.of(nodeId1, nodeId2, nodeId3);
    Set<NodeId> nodeIds4 = ImmutableSet.of(nodeId1, nodeId2, nodeId3, nodeId4);

    this.masters = ImmutableList.of(nodeIds1, nodeIds2, nodeIds3, nodeIds4);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:18,代码来源:RegionsResourceTest.java

示例2: decode

import org.onosproject.cluster.NodeId; //导入方法依赖的package包/类
@Override
public RoleInfo decode(ObjectNode json, CodecContext context) {
    if (json == null || !json.isObject()) {
        return null;
    }

    // parse node identifier of master
    NodeId nodeId = json.get(MASTER) == null ?
            null : NodeId.nodeId(json.get(MASTER).asText());

    // parse node identifier of backups
    List<NodeId> backups = new ArrayList<>();

    ArrayNode backupsJson = (ArrayNode) nullIsIllegal(json.get(BACKUPS),
            BACKUPS + MISSING_MEMBER_MESSAGE);

    IntStream.range(0, backupsJson.size()).forEach(i -> {
        JsonNode backupJson = nullIsIllegal(backupsJson.get(i),
                "Backup node id cannot be null");
        backups.add(NodeId.nodeId(backupJson.asText()));
    });

    return new RoleInfo(nodeId, backups);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:25,代码来源:RoleInfoCodec.java

示例3: decode

import org.onosproject.cluster.NodeId; //导入方法依赖的package包/类
@Override
public MastershipTerm decode(ObjectNode json, CodecContext context) {
    if (json == null || !json.isObject()) {
        return null;
    }

    // node identifier of master
    NodeId nodeId = NodeId.nodeId(nullIsIllegal(json.get(MASTER),
            MASTER + MISSING_MEMBER_MESSAGE).asText());

    // term number
    long termNumber = nullIsIllegal(json.get(TERM_NUMBER),
            TERM_NUMBER + MISSING_MEMBER_MESSAGE).asLong();

    return MastershipTerm.of(nodeId, termNumber);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:17,代码来源:MastershipTermCodec.java

示例4: testRegionEncode

import org.onosproject.cluster.NodeId; //导入方法依赖的package包/类
/**
 * Tests encoding of a Region object.
 */
@Test
public void testRegionEncode() {
    NodeId nodeId1 = NodeId.nodeId("1");
    NodeId nodeId2 = NodeId.nodeId("2");
    NodeId nodeId3 = NodeId.nodeId("3");
    NodeId nodeId4 = NodeId.nodeId("4");

    Set<NodeId> set1 = ImmutableSet.of(nodeId1);
    Set<NodeId> set2 = ImmutableSet.of(nodeId1, nodeId2);
    Set<NodeId> set3 = ImmutableSet.of(nodeId1, nodeId2, nodeId3);
    Set<NodeId> set4 = ImmutableSet.of(nodeId1, nodeId2, nodeId3, nodeId4);
    List<Set<NodeId>> masters = ImmutableList.of(set1, set2, set3, set4);

    RegionId regionId = RegionId.regionId("1");
    String name = "foo";
    Region.Type type = Region.Type.ROOM;

    Region region = new DefaultRegion(regionId, name, type, masters);

    ObjectNode regionJson = regionCodec.encode(region, context);
    assertThat(regionJson, matchesRegion(region));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:26,代码来源:RegionCodecTest.java

示例5: createMockRoleInfo

import org.onosproject.cluster.NodeId; //导入方法依赖的package包/类
/**
 * Creates a mock role info which is comprised of one master and three backups.
 *
 * @return a mock role info instance
 */
private RoleInfo createMockRoleInfo() {
    NodeId master = NodeId.nodeId("master");
    List<NodeId> backups = ImmutableList.of(nodeId1, nodeId2, nodeId3);

    return new RoleInfo(master, backups);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:12,代码来源:MastershipResourceTest.java

示例6: bgpTopologyProviderDeviceTestLabel1

import org.onosproject.cluster.NodeId; //导入方法依赖的package包/类
/**
 * Add device check label registration is done.
 *
 * @throws BgpParseException while adding a device
 */
@Test
public void bgpTopologyProviderDeviceTestLabel1() throws BgpParseException {
    LinkedList<BgpValueType> subTlvs = new LinkedList<>();
    BgpValueType tlv = new AutonomousSystemTlv(100);
    short deslength = AutonomousSystemTlv.LENGTH;
    short desType = AutonomousSystemTlv.TYPE;

    subTlvs.add(tlv);
    BgpNodeLSIdentifier localNodeDescriptors = new BgpNodeLSIdentifier(new NodeDescriptors(subTlvs, deslength,
                                                                                           desType));
    BgpNodeLSNlriVer4 nodeNlri = new BgpNodeLSNlriVer4(0, (byte) Constants.DIRECT, localNodeDescriptors, false,
                                                       new RouteDistinguisher());

    PathAttrNlriDetails details = new PathAttrNlriDetails();
    details.setIdentifier(0);
    details.setProtocolID(ProtocolType.DIRECT);
    List<BgpValueType> pathAttributes = new LinkedList<>();
    List<BgpValueType> linkStateAttributes = new LinkedList<>();
    tlv = BgpAttrRouterIdV4.of(Ip4Address.valueOf("1.1.1.1"), LinkStateAttributes.ATTR_NODE_IPV4_LOCAL_ROUTER_ID);
    linkStateAttributes.add(tlv);
    pathAttributes.add(new LinkStateAttributes(linkStateAttributes));
    details.setPathAttribute(pathAttributes);

    for (BgpNodeListener l : controller.nodeListener) {
        l.addNode(nodeNlri, details);
        assertThat(nodeRegistry.connected.size(), is(1));
    }

    MastershipEvent event = new MastershipEvent(Type.MASTER_CHANGED, nodeRegistry.connected.iterator().next(),
            new RoleInfo(NodeId.nodeId("Node1"), new LinkedList<>()));

    listener.event(event);
    assertThat(labelResourceAdminService.resourcePool.keySet().size(), is(1));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:40,代码来源:BgpTopologyProviderTest.java

示例7: bgpTopologyProviderDeviceTestLabel2

import org.onosproject.cluster.NodeId; //导入方法依赖的package包/类
/**
 * Add device check label registration is done and delete node destroy label pool.
 *
 * @throws BgpParseException while adding a device
 */
@Test
public void bgpTopologyProviderDeviceTestLabel2() throws BgpParseException {
    LinkedList<BgpValueType> subTlvs = new LinkedList<>();
    BgpValueType tlv = new AutonomousSystemTlv(100);
    short deslength = AutonomousSystemTlv.LENGTH;
    short desType = AutonomousSystemTlv.TYPE;

    subTlvs.add(tlv);
    BgpNodeLSIdentifier localNodeDescriptors = new BgpNodeLSIdentifier(new NodeDescriptors(subTlvs, deslength,
                                                                                           desType));
    BgpNodeLSNlriVer4 nodeNlri = new BgpNodeLSNlriVer4(0, (byte) Constants.DIRECT, localNodeDescriptors, false,
                                                       new RouteDistinguisher());

    PathAttrNlriDetails details = new PathAttrNlriDetails();
    details.setIdentifier(0);
    details.setProtocolID(ProtocolType.DIRECT);
    List<BgpValueType> pathAttributes = new LinkedList<>();
    List<BgpValueType> linkStateAttributes = new LinkedList<>();
    tlv = BgpAttrRouterIdV4.of(Ip4Address.valueOf("1.1.1.1"), LinkStateAttributes.ATTR_NODE_IPV4_LOCAL_ROUTER_ID);
    linkStateAttributes.add(tlv);
    pathAttributes.add(new LinkStateAttributes(linkStateAttributes));
    details.setPathAttribute(pathAttributes);

    for (BgpNodeListener l : controller.nodeListener) {
        l.addNode(nodeNlri, details);
        assertThat(nodeRegistry.connected.size(), is(1));
        // Check label resource reserved for that device
        MastershipEvent event = new MastershipEvent(Type.MASTER_CHANGED, nodeRegistry.connected.iterator().next(),
                new RoleInfo(NodeId.nodeId("Node1"), new LinkedList<>()));
        listener.event(event);
        assertThat(labelResourceAdminService.resourcePool.keySet().size(), is(1));

        l.deleteNode(nodeNlri);
        assertThat(nodeRegistry.connected.size(), is(0));
        assertThat(labelResourceAdminService.resourcePool.keySet().size(), is(0));
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:43,代码来源:BgpTopologyProviderTest.java

示例8: execute

import org.onosproject.cluster.NodeId; //导入方法依赖的package包/类
@Override
protected void execute() {
    ControlPlaneMonitorService service = get(ControlPlaneMonitorService.class);
    NodeId nodeId = NodeId.nodeId(node);
    switch (type) {
        case "cpu":
            printMetricsStats(service, nodeId, CPU_METRICS);
            break;
        case "memory":
            printMetricsStats(service, nodeId, MEMORY_METRICS);
            break;
        case "disk":
            printMetricsStats(service, nodeId, DISK_METRICS, name);
            break;
        case "network":
            printMetricsStats(service, nodeId, NETWORK_METRICS, name);
            break;
        case "control_message":
            if (name != null) {
                printMetricsStats(service, nodeId, CONTROL_MESSAGE_METRICS,
                        DeviceId.deviceId(name));
            }
            break;
        default:
            print(INVALID_TYPE);
            break;
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:29,代码来源:ControlMetricsStatsListCommand.java

示例9: testMastershipTermEncode

import org.onosproject.cluster.NodeId; //导入方法依赖的package包/类
/**
 * Tests encoding of a mastership term object.
 */
@Test
public void testMastershipTermEncode() {
    NodeId masterNodeId = NodeId.nodeId("1");
    long termNumber = 10;

    MastershipTerm mastershipTerm = MastershipTerm.of(masterNodeId, termNumber);
    ObjectNode mastershipTermJson = mastershipTermCodec.encode(mastershipTerm, context);
    assertThat(mastershipTermJson, MastershipTermJsonMatcher.matchesMastershipTerm(mastershipTerm));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:13,代码来源:MastershipTermCodecTest.java

示例10: testRoleInfoEncode

import org.onosproject.cluster.NodeId; //导入方法依赖的package包/类
/**
 * Tests encoding of a role info object.
 */
@Test
public void testRoleInfoEncode() {
    NodeId masterNodeId = NodeId.nodeId("1");
    NodeId backupNodeId1 = NodeId.nodeId("1");
    NodeId backupNodeId2 = NodeId.nodeId("2");
    NodeId backupNodeId3 = NodeId.nodeId("3");
    List<NodeId> backupNodeIds =
            ImmutableList.of(backupNodeId1, backupNodeId2, backupNodeId3);

    RoleInfo roleInfo = new RoleInfo(masterNodeId, backupNodeIds);
    ObjectNode roleInfoJson = roleInfoCodec.encode(roleInfo, context);
    assertThat(roleInfoJson, RoleInfoJsonMatcher.matchesRoleInfo(roleInfo));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:17,代码来源:RoleInfoCodecTest.java

示例11: testRegionDecode

import org.onosproject.cluster.NodeId; //导入方法依赖的package包/类
/**
 * Tests decoding of a json object.
 */
@Test
public void testRegionDecode() throws IOException {
    Region region = getRegion("Region.json");
    checkCommonData(region);

    assertThat(region.masters().size(), is(2));

    NodeId nodeId1 = NodeId.nodeId("1");
    NodeId nodeId2 = NodeId.nodeId("2");
    Set<NodeId> nodeIds1 = region.masters().get(0);
    Set<NodeId> nodeIds2 = region.masters().get(1);
    assertThat(nodeIds1.containsAll(ImmutableSet.of(nodeId1)), is(true));
    assertThat(nodeIds2.containsAll(ImmutableSet.of(nodeId1, nodeId2)), is(true));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:18,代码来源:RegionCodecTest.java

示例12: decodeNodeId

import org.onosproject.cluster.NodeId; //导入方法依赖的package包/类
/**
 * Decodes node id json to node id object.
 *
 * @param json json object
 * @return decoded node id object
 */
private NodeId decodeNodeId(JsonNode json) {
    return NodeId.nodeId(nullIsIllegal(json, NODE_ID +
            MISSING_MEMBER_MSG).asText());
}
 
开发者ID:shlee89,项目名称:athena,代码行数:11,代码来源:RegionCodec.java


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