use of org.onosproject.cluster.NodeId in project onos by opennetworkinglab.
the class DeviceRoleCommand method doExecute.
@Override
protected void doExecute() {
MastershipAdminService service = get(MastershipAdminService.class);
MastershipRole mastershipRole = MastershipRole.valueOf(role.toUpperCase());
Futures.getUnchecked(service.setRole(new NodeId(node), deviceId(uri), mastershipRole));
}
use of org.onosproject.cluster.NodeId in project onos by opennetworkinglab.
the class SimpleClusterStore method activate.
@Activate
public void activate() {
instance = new DefaultControllerNode(new NodeId("local"), LOCALHOST);
listenerRegistry = new ListenerRegistry<>();
eventDispatcher.addSink(WorkPartitionEvent.class, listenerRegistry);
log.info("Started");
}
use of org.onosproject.cluster.NodeId in project onos by opennetworkinglab.
the class RoleInfoCodecTest method testRoleInfoEncode.
/**
* 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));
}
use of org.onosproject.cluster.NodeId in project onos by opennetworkinglab.
the class RegionJsonMatcher method matchesSafely.
@Override
protected boolean matchesSafely(JsonNode jsonRegion, Description description) {
// check id
String jsonRegionId = jsonRegion.get("id").asText();
String regionId = region.id().toString();
if (!jsonRegionId.equals(regionId)) {
description.appendText("region id was " + jsonRegionId);
return false;
}
// check type
String jsonType = jsonRegion.get("type").asText();
String type = region.type().toString();
if (!jsonType.equals(type)) {
description.appendText("type was " + jsonType);
return false;
}
// check name
String jsonName = jsonRegion.get("name").asText();
String name = region.name();
if (!jsonName.equals(name)) {
description.appendText("name was " + jsonName);
return false;
}
// check size of master array
JsonNode jsonMasters = jsonRegion.get("masters");
if (jsonMasters.size() != region.masters().size()) {
description.appendText("masters size was " + jsonMasters.size());
return false;
}
// check master
for (Set<NodeId> set : region.masters()) {
boolean masterFound = false;
for (int masterIndex = 0; masterIndex < jsonMasters.size(); masterIndex++) {
masterFound = checkEquality(jsonMasters.get(masterIndex), set);
}
if (!masterFound) {
description.appendText("master not found " + set.toString());
return false;
}
}
return true;
}
use of org.onosproject.cluster.NodeId in project onos by opennetworkinglab.
the class RegionCodecTest method testRegionDecode.
/**
* 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));
}
Aggregations