use of org.onosproject.cluster.ClusterService in project onos by opennetworkinglab.
the class GossipDeviceStoreTest method setUp.
@Before
public void setUp() throws Exception {
clusterCommunicator = createNiceMock(ClusterCommunicationService.class);
replay(clusterCommunicator);
ClusterService clusterService = new TestClusterService();
testGossipDeviceStore = new TestGossipDeviceStore(deviceClockService, clusterService, clusterCommunicator);
testGossipDeviceStore.mastershipService = new TestMastershipService();
ecMapBuilder = createNiceMock(EventuallyConsistentMapBuilder.class);
expect(ecMapBuilder.withName(anyObject(String.class))).andReturn(ecMapBuilder).anyTimes();
expect(ecMapBuilder.withSerializer(anyObject(KryoNamespace.Builder.class))).andReturn(ecMapBuilder).anyTimes();
expect(ecMapBuilder.withAntiEntropyPeriod(5, TimeUnit.SECONDS)).andReturn(ecMapBuilder).anyTimes();
expect(ecMapBuilder.withTimestampProvider(anyObject(BiFunction.class))).andReturn(ecMapBuilder).anyTimes();
expect(ecMapBuilder.withTombstonesDisabled()).andReturn(ecMapBuilder).anyTimes();
ecMap = createNiceMock(EventuallyConsistentMap.class);
expect(ecMapBuilder.build()).andReturn(ecMap).anyTimes();
testStorageService = createNiceMock(StorageService.class);
expect(testStorageService.eventuallyConsistentMapBuilder()).andReturn(ecMapBuilder).anyTimes();
replay(testStorageService, ecMapBuilder, ecMap);
testGossipDeviceStore.storageService = testStorageService;
testGossipDeviceStore.deviceClockService = deviceClockService;
gossipDeviceStore = testGossipDeviceStore;
gossipDeviceStore.activate();
deviceStore = gossipDeviceStore;
verify(clusterCommunicator);
reset(clusterCommunicator);
}
use of org.onosproject.cluster.ClusterService in project onos by opennetworkinglab.
the class DistributedGroupStoreTest method setUp.
@Before
public void setUp() throws Exception {
groupStoreImpl = new DistributedGroupStore();
groupStoreImpl.storageService = new TestStorageService();
groupStoreImpl.clusterCommunicator = new ClusterCommunicationServiceAdapter();
groupStoreImpl.mastershipService = new MasterOfAll();
groupStoreImpl.cfgService = new ComponentConfigAdapter();
groupStoreImpl.deviceService = new InternalDeviceServiceImpl();
ClusterService mockClusterService = createMock(ClusterService.class);
NodeId nodeId = new NodeId(NODE_ID);
MockControllerNode mockControllerNode = new MockControllerNode(nodeId);
expect(mockClusterService.getLocalNode()).andReturn(mockControllerNode).anyTimes();
replay(mockClusterService);
groupStoreImpl.clusterService = mockClusterService;
groupStoreImpl.activate(null);
groupStore = groupStoreImpl;
auditPendingReqQueue = TestUtils.getField(groupStoreImpl, "auditPendingReqQueue");
}
use of org.onosproject.cluster.ClusterService in project onos by opennetworkinglab.
the class ControlMetricsWebResource method controlMessageMetrics.
/**
* Returns control message metrics of a given device.
*
* @param deviceId device identification
* @return control message metrics of a given device
* @onos.rsModel ControlMessageMetric
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("messages/{deviceId}")
public Response controlMessageMetrics(@PathParam("deviceId") String deviceId) {
ObjectNode root = mapper().createObjectNode();
ControlPlaneMonitorService monitorService = get(ControlPlaneMonitorService.class);
ClusterService clusterService = get(ClusterService.class);
NodeId localNodeId = clusterService.getLocalNode().id();
metricsStats(monitorService, localNodeId, CONTROL_MESSAGE_METRICS, DeviceId.deviceId(deviceId), root);
return ok(root).build();
}
use of org.onosproject.cluster.ClusterService in project onos by opennetworkinglab.
the class ControlMetricsWebResource method controlMessageMetrics.
/**
* Returns control message metrics of all devices.
*
* @return array of all control message metrics
* @onos.rsModel ControlMessageMetrics
*/
@GET
@Path("messages")
@Produces(MediaType.APPLICATION_JSON)
public Response controlMessageMetrics() {
ObjectNode root = mapper().createObjectNode();
ControlPlaneMonitorService monitorService = get(ControlPlaneMonitorService.class);
ClusterService clusterService = get(ClusterService.class);
NodeId localNodeId = clusterService.getLocalNode().id();
ArrayNode deviceNodes = root.putArray("devices");
monitorService.availableResourcesSync(localNodeId, CONTROL_MESSAGE).forEach(name -> {
ObjectNode deviceNode = mapper().createObjectNode();
ObjectNode valueNode = mapper().createObjectNode();
metricsStats(monitorService, localNodeId, CONTROL_MESSAGE_METRICS, DeviceId.deviceId(name), valueNode);
deviceNode.put("name", name);
deviceNode.set("value", valueNode);
deviceNodes.add(deviceNode);
});
return ok(root).build();
}
use of org.onosproject.cluster.ClusterService in project onos by opennetworkinglab.
the class OpenstackEastWestProbeCommand method doExecute.
@Override
protected void doExecute() {
OpenstackTroubleshootService tsService = get(OpenstackTroubleshootService.class);
InstancePortService instPortService = get(InstancePortService.class);
MastershipService mastershipService = get(MastershipService.class);
ClusterService clusterService = get(ClusterService.class);
OpenstackNodeService osNodeService = get(OpenstackNodeService.class);
if (tsService == null) {
error("Failed to troubleshoot openstack networking.");
return;
}
if ((!isAll && vmIps == null) || (isAll && vmIps != null)) {
print("Please specify one of VM IP address or -a option.");
return;
}
NodeId localNodeId = clusterService.getLocalNode().id();
for (OpenstackNode node : osNodeService.completeNodes(COMPUTE)) {
if (!localNodeId.equals(mastershipService.getMasterFor(node.intgBridge()))) {
error("Current node is not the master for all compute nodes. " + "Please enforce mastership first using openstack-reset-mastership -c !");
return;
}
}
if (isAll) {
printHeader();
// send ICMP PACKET_OUT to all connect VMs whose instance port state is ACTIVE
Set<InstancePort> activePorts = instPortService.instancePorts().stream().filter(p -> p.state() == ACTIVE).collect(Collectors.toSet());
activePorts.forEach(srcPort -> activePorts.forEach(dstPort -> printReachability(tsService.probeEastWest(srcPort, dstPort))));
} else {
if (vmIps.length > 2) {
print("Too many VM IPs. The number of IP should be limited to 2.");
return;
}
IpAddress srcIp = getIpAddress(vmIps[0]);
if (srcIp == null) {
return;
}
InstancePort srcPort = instPort(instPortService, srcIp);
if (srcPort == null) {
print("Specified source IP is not existing.");
return;
}
final Set<IpAddress> dstIps = Sets.newConcurrentHashSet();
if (vmIps.length == 2) {
IpAddress dstIp = getIpAddress(vmIps[1]);
if (dstIp == null) {
return;
}
dstIps.add(dstIp);
}
if (vmIps.length == 1) {
dstIps.addAll(instPortService.instancePorts().stream().filter(p -> !p.ipAddress().equals(srcIp)).filter(p -> p.state().equals(InstancePort.State.ACTIVE)).map(InstancePort::ipAddress).collect(Collectors.toSet()));
}
printHeader();
dstIps.stream().filter(ip -> instPort(instPortService, ip) != null).map(ip -> instPort(instPortService, ip)).forEach(port -> probeExecutor.execute(() -> printReachability(tsService.probeEastWest(srcPort, port))));
}
}
Aggregations