@Override public void flush() { if (currentReadBuffer != null) { currentReadBuffer.flip(); fba.accept(currentReadBuffer); currentReadBuffer = null; } }
synchronized void reportRemoteEOS() { ri.flush(); ri.getFullBufferAcceptor().close(); remoteClose.set(true); }
public void abort(int ecode) { ccb.getWriteInterface().getFullBufferAcceptor().error(ecode); synchronized (NetworkOutputChannel.this) { aborted = true; NetworkOutputChannel.this.notifyAll(); } }
@Override public void open(IHyracksCommonContext ctx) throws HyracksDataException { try { ccb = netManager.connect(remoteAddress); } catch (Exception e) { throw HyracksDataException.create(e); } ccb.getReadInterface().setFullBufferAcceptor(new ReadFullBufferAcceptor()); ccb.getWriteInterface().setEmptyBufferAcceptor(new WriteEmptyBufferAcceptor()); ccb.getReadInterface().setBufferFactory(new ReadBufferFactory(nBuffers, ctx), nBuffers, ctx.getInitialFrameSize()); ByteBuffer writeBuffer = ByteBuffer.allocate(INITIAL_MESSAGE_SIZE); writeBuffer.putLong(partitionId.getJobId().getId()); writeBuffer.putInt(partitionId.getConnectorDescriptorId().getId()); writeBuffer.putInt(partitionId.getSenderIndex()); writeBuffer.putInt(partitionId.getReceiverIndex()); writeBuffer.flip(); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Sending partition request: " + partitionId + " on channel: " + ccb); } ccb.getWriteInterface().getFullBufferAcceptor().accept(writeBuffer); ccb.getWriteInterface().getFullBufferAcceptor().close(); }
@Override public void open(IHyracksCommonContext ctx) throws HyracksDataException { try { ccb = netManager.connect(remoteAddress); } catch (Exception e) { throw HyracksDataException.create(e); } ccb.getReadInterface().setFullBufferAcceptor(new ReadFullBufferAcceptor()); ccb.getWriteInterface().setEmptyBufferAcceptor(new WriteEmptyBufferAcceptor()); for (int i = 0; i < nBuffers; ++i) { ccb.getReadInterface().getEmptyBufferAcceptor().accept(ctx.allocateFrame()); } ByteBuffer writeBuffer = ByteBuffer.allocate(INITIAL_MESSAGE_SIZE); writeBuffer.putLong(jobId.getId()); writeBuffer.putLong(resultSetId.getId()); writeBuffer.putInt(partition); writeBuffer.flip(); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Sending partition request for JobId: " + jobId + " partition: " + partition + " on channel: " + ccb); } ccb.getWriteInterface().getFullBufferAcceptor().accept(writeBuffer); ccb.getWriteInterface().getFullBufferAcceptor().close(); }
ccb.getWriteInterface().getFullBufferAcceptor().accept(destBuffer);
@Override public void close() throws HyracksDataException { ccb.getWriteInterface().getFullBufferAcceptor().close(); }
void reportRemoteError(int ecode) { ri.flush(); ri.getFullBufferAcceptor().error(ecode); remoteClose.set(true); }
private void sendMessageToChannel(IChannelControlBlock ccb, INcAddressedMessage msg) throws IOException { byte[] serializedMsg = JavaSerializationUtils.serialize(msg); if (serializedMsg.length > maxMsgSize) { throw new HyracksDataException("Message exceeded maximum size"); } // Prepare the message buffer ByteBuffer msgBuffer = messagingFramePool.get(); if (msgBuffer == null) { throw new HyracksDataException("Could not get an empty buffer"); } msgBuffer.clear(); msgBuffer.put(serializedMsg); msgBuffer.flip(); // Give the buffer to the channel write interface for writing ccb.getWriteInterface().getFullBufferAcceptor().accept(msgBuffer); }
private void closeChannel(IChannelControlBlock ccb) { ccb.getWriteInterface().getFullBufferAcceptor().close(); }
@Override public void fail() throws HyracksDataException { ccb.getWriteInterface().getFullBufferAcceptor().error(AbstractChannelWriteInterface.REMOTE_ERROR_CODE); }
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; } }