Search in sources :

Example 1 with Endpoint

use of org.onosproject.store.cluster.messaging.Endpoint in project onos by opennetworkinglab.

the class ClusterCommunicationManager method doUnicast.

private CompletableFuture<Void> doUnicast(MessageSubject subject, byte[] payload, NodeId toNodeId) {
    ControllerNode node = clusterService.getNode(toNodeId);
    checkArgument(node != null, "Unknown nodeId: %s", toNodeId);
    Endpoint nodeEp = new Endpoint(node.ip(), node.tcpPort());
    MeteringAgent.Context context = subjectMeteringAgent.startTimer(subject.toString() + ONE_WAY_SUFFIX);
    return messagingService.sendAsync(nodeEp, subject.toString(), payload).whenComplete((r, e) -> context.stop(e));
}
Also used : Endpoint(org.onosproject.store.cluster.messaging.Endpoint) ControllerNode(org.onosproject.cluster.ControllerNode) MeteringAgent(org.onosproject.utils.MeteringAgent)

Example 2 with Endpoint

use of org.onosproject.store.cluster.messaging.Endpoint in project onos by opennetworkinglab.

the class ClusterCommunicationManager method sendAndReceive.

private CompletableFuture<byte[]> sendAndReceive(MessageSubject subject, byte[] payload, NodeId toNodeId, Duration timeout) {
    ControllerNode node = clusterService.getNode(toNodeId);
    checkArgument(node != null, "Unknown nodeId: %s", toNodeId);
    Endpoint nodeEp = new Endpoint(node.ip(), node.tcpPort());
    MeteringAgent.Context epContext = endpointMeteringAgent.startTimer(NODE_PREFIX + toNodeId.toString() + ROUND_TRIP_SUFFIX);
    MeteringAgent.Context subjectContext = subjectMeteringAgent.startTimer(subject.toString() + ROUND_TRIP_SUFFIX);
    return messagingService.sendAndReceive(nodeEp, subject.toString(), payload, timeout).whenComplete((bytes, throwable) -> {
        subjectContext.stop(throwable);
        epContext.stop(throwable);
    });
}
Also used : Endpoint(org.onosproject.store.cluster.messaging.Endpoint) ControllerNode(org.onosproject.cluster.ControllerNode) MeteringAgent(org.onosproject.utils.MeteringAgent)

Aggregations

ControllerNode (org.onosproject.cluster.ControllerNode)2 Endpoint (org.onosproject.store.cluster.messaging.Endpoint)2 MeteringAgent (org.onosproject.utils.MeteringAgent)2