本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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));
}
示例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);
}
示例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));
}
示例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));
}
}
示例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;
}
}
示例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));
}
示例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));
}
示例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));
}
示例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());
}