@Override public void init(NodeEngine nodeEngine, Properties properties) { ClassDefinitionBuilder builder = new ClassDefinitionBuilder(ClientPortableHook.ID, ClientPortableHook.PRINCIPAL); builder.addUTFField("uuid").addUTFField("ownerUuid"); serializationService.getSerializationContext().registerClassDefinition(builder.build()); node.getConnectionManager().addConnectionListener(this); }
void bind(final ClientEndpoint endpoint) { final Connection conn = endpoint.getConnection(); if (conn instanceof TcpIpConnection) { Address address = new Address(conn.getRemoteSocketAddress()); TcpIpConnectionManager connectionManager = (TcpIpConnectionManager) node.getConnectionManager(); connectionManager.bind((TcpIpConnection) conn, address, null, false); } sendClientEvent(endpoint); }
public boolean send(Response response, Address target) { checkNotNull(target, "Target is required!"); if (thisAddress.equals(target)) { throw new IllegalArgumentException( "Target is this node! -> " + target + ", response: " + response); } byte[] bytes = serializationService.toBytes(response); Packet packet = new Packet(bytes, -1).setAllFlags(FLAG_OP | FLAG_RESPONSE); if (response.isUrgent()) { packet.setFlag(FLAG_URGENT); } ConnectionManager connectionManager = node.getConnectionManager(); Connection connection = connectionManager.getOrConnect(target); return connectionManager.transmit(packet, connection); }
@Override public boolean send(Operation op, Address target) { checkNotNull(target, "Target is required!"); if (thisAddress.equals(target)) { throw new IllegalArgumentException("Target is this node! -> " + target + ", op: " + op); } byte[] bytes = serializationService.toBytes(op); int partitionId = op.getPartitionId(); Packet packet = new Packet(bytes, partitionId).setFlag(FLAG_OP); if (op.isUrgent()) { packet.setFlag(FLAG_URGENT); } ConnectionManager connectionManager = node.getConnectionManager(); Connection connection = connectionManager.getOrConnect(target); return connectionManager.transmit(packet, connection); }
@Override public void init(NodeEngine nodeEngine, Properties properties) { node.getConnectionManager().addConnectionListener(connectionListener); }
public static void terminateInstance(HazelcastInstance hz) { final Node node = getNode(hz); node.getConnectionManager().shutdown(); node.shutdown(true); }