private ProtocolMessage sendProtocolMessage(final ProtocolMessage msg, final String hostname, final int port) { Socket socket = null; try { try { socket = SocketUtils.createSocket(new InetSocketAddress(hostname, port), socketConfiguration); } catch (IOException e) { throw new ProtocolException("Failed to send message to Cluster Coordinator due to: " + e, e); } try { // marshal message to output stream final ProtocolMessageMarshaller<ProtocolMessage> marshaller = protocolContext.createMarshaller(); marshaller.marshal(msg, socket.getOutputStream()); } catch (final IOException ioe) { throw new ProtocolException("Failed marshalling '" + msg.getType() + "' protocol message due to: " + ioe, ioe); } final ProtocolMessage response; try { // unmarshall response and return final ProtocolMessageUnmarshaller<ProtocolMessage> unmarshaller = protocolContext.createUnmarshaller(); response = unmarshaller.unmarshal(socket.getInputStream()); } catch (final IOException ioe) { throw new ProtocolException("Failed unmarshalling '" + MessageType.CONNECTION_RESPONSE + "' protocol message from " + socket.getRemoteSocketAddress() + " due to: " + ioe, ioe); } return response; } finally { SocketUtils.closeQuietly(socket); } }
final ProtocolMessageMarshaller<ProtocolMessage> marshaller = protocolContext.createMarshaller(); marshaller.marshal(msg, baos); msgBytes = baos.toByteArray();
/** * Requests a node to be offloaded. The configured value for * handshake timeout is applied to the socket before making the request. * * @param msg a message * @throws ProtocolException if the message failed to be sent */ @Override public void offload(final OffloadMessage msg) throws ProtocolException { Socket socket = null; try { socket = createSocket(msg.getNodeId(), true); // marshal message to output stream try { final ProtocolMessageMarshaller<ProtocolMessage> marshaller = protocolContext.createMarshaller(); marshaller.marshal(msg, socket.getOutputStream()); } catch (final IOException ioe) { throw new ProtocolException("Failed marshalling '" + msg.getType() + "' protocol message due to: " + ioe, ioe); } } finally { SocketUtils.closeQuietly(socket); } }
final ProtocolMessageMarshaller<ProtocolMessage> marshaller = protocolContext.createMarshaller(); marshaller.marshal(msg, baos); msgBytes = baos.toByteArray(); try { final ProtocolMessageUnmarshaller<ProtocolMessage> unmarshaller = protocolContext.createUnmarshaller(); response = unmarshaller.unmarshal(socket.getInputStream()); } catch (final IOException ioe) {
/** * Requests a node to disconnect from the cluster. The configured value for * handshake timeout is applied to the socket before making the request. * * @param msg a message * @throws ProtocolException if the message failed to be sent */ @Override public void disconnect(final DisconnectMessage msg) throws ProtocolException { Socket socket = null; try { socket = createSocket(msg.getNodeId(), true); // marshal message to output stream try { final ProtocolMessageMarshaller<ProtocolMessage> marshaller = protocolContext.createMarshaller(); marshaller.marshal(msg, socket.getOutputStream()); } catch (final IOException ioe) { throw new ProtocolException("Failed marshalling '" + msg.getType() + "' protocol message due to: " + ioe, ioe); } } finally { SocketUtils.closeQuietly(socket); } }
final ProtocolMessageMarshaller<ProtocolMessage> marshaller = protocolContext.createMarshaller(); marshaller.marshal(msg, socket.getOutputStream()); } catch (final IOException ioe) { try { final ProtocolMessageUnmarshaller<ProtocolMessage> unmarshaller = protocolContext.createUnmarshaller(); response = unmarshaller.unmarshal(socket.getInputStream()); } catch (final IOException ioe) {
final ProtocolMessageMarshaller<ProtocolMessage> marshaller = protocolContext.createMarshaller(); marshaller.marshal(msg, baos); msgBytes = baos.toByteArray();
final ProtocolMessageUnmarshaller<ProtocolMessage> unmarshaller = protocolContext.createUnmarshaller(); final ByteCountingInputStream countingIn = new ByteCountingInputStream(socket.getInputStream()); InputStream wrappedInStream = countingIn; final ProtocolMessageMarshaller<ProtocolMessage> marshaller = protocolContext.createMarshaller(); marshaller.marshal(response, socket.getOutputStream()); } catch (final IOException ioe) {
/** * Requests a node to be offloaded. The configured value for * handshake timeout is applied to the socket before making the request. * * @param msg a message * @throws ProtocolException if the message failed to be sent */ @Override public void offload(final OffloadMessage msg) throws ProtocolException { Socket socket = null; try { socket = createSocket(msg.getNodeId(), true); // marshal message to output stream try { final ProtocolMessageMarshaller<ProtocolMessage> marshaller = protocolContext.createMarshaller(); marshaller.marshal(msg, socket.getOutputStream()); } catch (final IOException ioe) { throw new ProtocolException("Failed marshalling '" + msg.getType() + "' protocol message due to: " + ioe, ioe); } } finally { SocketUtils.closeQuietly(socket); } }
final ProtocolMessageMarshaller<ProtocolMessage> marshaller = protocolContext.createMarshaller(); marshaller.marshal(msg, socket.getOutputStream()); } catch (final IOException ioe) { try { final ProtocolMessageUnmarshaller<ProtocolMessage> unmarshaller = protocolContext.createUnmarshaller(); response = unmarshaller.unmarshal(socket.getInputStream()); } catch (final IOException ioe) {
/** * Requests a node to disconnect from the cluster. The configured value for * handshake timeout is applied to the socket before making the request. * * @param msg a message * @throws ProtocolException if the message failed to be sent */ @Override public void disconnect(final DisconnectMessage msg) throws ProtocolException { Socket socket = null; try { socket = createSocket(msg.getNodeId(), true); // marshal message to output stream try { final ProtocolMessageMarshaller<ProtocolMessage> marshaller = protocolContext.createMarshaller(); marshaller.marshal(msg, socket.getOutputStream()); } catch (final IOException ioe) { throw new ProtocolException("Failed marshalling '" + msg.getType() + "' protocol message due to: " + ioe, ioe); } } finally { SocketUtils.closeQuietly(socket); } }
private ProtocolMessage sendProtocolMessage(final ProtocolMessage msg, final String hostname, final int port) { Socket socket = null; try { try { socket = SocketUtils.createSocket(new InetSocketAddress(hostname, port), socketConfiguration); } catch (IOException e) { throw new ProtocolException("Failed to send message to Cluster Coordinator due to: " + e, e); } try { // marshal message to output stream final ProtocolMessageMarshaller<ProtocolMessage> marshaller = protocolContext.createMarshaller(); marshaller.marshal(msg, socket.getOutputStream()); } catch (final IOException ioe) { throw new ProtocolException("Failed marshalling '" + msg.getType() + "' protocol message due to: " + ioe, ioe); } final ProtocolMessage response; try { // unmarshall response and return final ProtocolMessageUnmarshaller<ProtocolMessage> unmarshaller = protocolContext.createUnmarshaller(); response = unmarshaller.unmarshal(socket.getInputStream()); } catch (final IOException ioe) { throw new ProtocolException("Failed unmarshalling '" + MessageType.CONNECTION_RESPONSE + "' protocol message from " + socket.getRemoteSocketAddress() + " due to: " + ioe, ioe); } return response; } finally { SocketUtils.closeQuietly(socket); } }
final ProtocolMessageMarshaller<ProtocolMessage> marshaller = protocolContext.createMarshaller(); marshaller.marshal(msg, baos); msgBytes = baos.toByteArray(); try { final ProtocolMessageUnmarshaller<ProtocolMessage> unmarshaller = protocolContext.createUnmarshaller(); response = unmarshaller.unmarshal(socket.getInputStream()); } catch (final IOException ioe) {
final ProtocolMessageMarshaller<ProtocolMessage> marshaller = protocolContext.createMarshaller(); marshaller.marshal(msg, socket.getOutputStream()); } catch (final IOException ioe) { try { final ProtocolMessageUnmarshaller<ProtocolMessage> unmarshaller = protocolContext.createUnmarshaller(); response = unmarshaller.unmarshal(socket.getInputStream()); } catch (final IOException ioe) {
final ProtocolMessageUnmarshaller<ProtocolMessage> unmarshaller = protocolContext.createUnmarshaller(); final ByteCountingInputStream countingIn = new ByteCountingInputStream(socket.getInputStream()); InputStream wrappedInStream = countingIn; final ProtocolMessageMarshaller<ProtocolMessage> marshaller = protocolContext.createMarshaller(); marshaller.marshal(response, socket.getOutputStream()); } catch (final IOException ioe) {
private void dispatchRequest(final Socket socket) { try { final ProtocolMessageUnmarshaller<ProtocolMessage> unmarshaller = authorityProviderProtocolContext.createUnmarshaller(); final ProtocolMessage request = unmarshaller.unmarshal(socket.getInputStream()); final ProtocolMessage response = request; final ProtocolMessageMarshaller<ProtocolMessage> marshaller = authorityProviderProtocolContext.createMarshaller(); marshaller.marshal(response, socket.getOutputStream());
final ProtocolMessageMarshaller<ProtocolMessage> marshaller = protocolContext.createMarshaller(); marshaller.marshal(msg, socket.getOutputStream()); } catch (final IOException ioe) { try { final ProtocolMessageUnmarshaller<ProtocolMessage> unmarshaller = protocolContext.createUnmarshaller(); response = unmarshaller.unmarshal(socket.getInputStream()); } catch (final IOException ioe) {
final ProtocolMessageMarshaller marshaller = authorityProviderProtocolContext.createMarshaller(); marshaller.marshal(msg, socket.getOutputStream()); } catch (final IOException ioe) { final ProtocolMessageUnmarshaller<ProtocolMessage> unmarshaller = authorityProviderProtocolContext.createUnmarshaller(); final DoesDnExistMessage response = (DoesDnExistMessage) unmarshaller.unmarshal(socket.getInputStream());
final ProtocolMessageMarshaller marshaller = authorityProviderProtocolContext.createMarshaller(); marshaller.marshal(msg, socket.getOutputStream()); } catch (final IOException ioe) { final ProtocolMessageUnmarshaller<ProtocolMessage> unmarshaller = authorityProviderProtocolContext.createUnmarshaller(); final GetAuthoritiesMessage response = (GetAuthoritiesMessage) unmarshaller.unmarshal(socket.getInputStream());
final ProtocolMessageMarshaller marshaller = authorityProviderProtocolContext.createMarshaller(); marshaller.marshal(msg, socket.getOutputStream()); } catch (final IOException ioe) { final ProtocolMessageUnmarshaller<ProtocolMessage> unmarshaller = authorityProviderProtocolContext.createUnmarshaller(); final GetGroupForUserMessage response = (GetGroupForUserMessage) unmarshaller.unmarshal(socket.getInputStream());