use of org.apache.hyracks.api.comm.IChannelControlBlock in project asterixdb by apache.
the class NCMessageBroker method sendMessageToNC.
@Override
public void sendMessageToNC(String nodeId, INcAddressedMessage message) throws Exception {
IChannelControlBlock messagingChannel = ncs.getMessagingNetworkManager().getMessagingChannel(nodeId);
sendMessageToChannel(messagingChannel, message);
}
use of org.apache.hyracks.api.comm.IChannelControlBlock in project asterixdb by apache.
the class MessagingNetworkManager method establishNewConnection.
private IChannelControlBlock establishNewConnection(String nodeId) throws Exception {
Map<String, NodeControllerInfo> nodeControllers = ncs.getNodeControllersInfo();
// Get the node messaging address from its info
NodeControllerInfo nodeControllerInfo = nodeControllers.get(nodeId);
if (nodeControllerInfo == null) {
throw new NetException("Could not find node: " + nodeId);
}
NetworkAddress nodeMessagingNeAddress = nodeControllerInfo.getMessagingNetworkAddress();
SocketAddress nodeAddress = new InetSocketAddress(InetAddress.getByName(nodeMessagingNeAddress.getAddress()), nodeMessagingNeAddress.getPort());
// Open the channel
IChannelControlBlock ccb = connect(nodeAddress);
try {
// Prepare the initial message buffer
ByteBuffer initialBuffer = ccb.getReadInterface().getBufferFactory().createBuffer();
prepareMessagingInitialMessage(ncs.getId(), initialBuffer);
// Send the initial messaging channel handshake message to register the opened channel on both nodes
ccb.getWriteInterface().getFullBufferAcceptor().accept(initialBuffer);
return ccb;
} catch (NetException e) {
closeChannel(ccb);
throw e;
}
}
use of org.apache.hyracks.api.comm.IChannelControlBlock in project asterixdb by apache.
the class MessagingNetworkManager method getMessagingChannel.
public IChannelControlBlock getMessagingChannel(String nodeId) throws Exception {
synchronized (ncChannels) {
IChannelControlBlock ccb = ncChannels.get(nodeId);
if (ccb == null) {
// Establish new connection
ccb = establishNewConnection(nodeId);
addOpenChannel(nodeId, ccb);
}
return ccb;
}
}
Aggregations