@Override public ClientMapping readObject(ObjectInput input) throws IOException { byte[] sourceAddress = new byte[IndexSerializer.UNSIGNED_BYTE.readInt(input)]; input.readFully(sourceAddress); int sourceNetworkMaskBits = IndexSerializer.UNSIGNED_BYTE.readInt(input); String destAddress = input.readUTF(); int destPort = IndexSerializer.UNSIGNED_SHORT.readInt(input); return new ClientMapping(InetAddress.getByAddress(sourceAddress), sourceNetworkMaskBits, destAddress, destPort); }
@Override public void writeObject(ObjectOutput output, ClientMapping mapping) throws IOException { byte[] address = mapping.getSourceNetworkAddress().getAddress(); IndexSerializer.UNSIGNED_BYTE.writeInt(output, address.length); output.write(address); IndexSerializer.UNSIGNED_BYTE.writeInt(output, mapping.getSourceNetworkMaskBits()); output.writeUTF(mapping.getDestinationAddress()); IndexSerializer.UNSIGNED_SHORT.writeInt(output, mapping.getDestinationPort()); }
host = NetworkUtils.canonize(clientMapping.getDestinationAddress()); port = clientMapping.getDestinationPort();
private List<ClientMapping> fixupMappings(List<ClientMapping> clientMappings) { for (ClientMapping mapping : clientMappings) { mapping.updatePortIfUnknown(calculatePort()); } return clientMappings; }
host = NetworkUtils.canonize(clientMapping.getDestinationAddress()); port = clientMapping.getDestinationPort();
private List<ClientMapping> fixupMappings(List<ClientMapping> clientMappings) { for (ClientMapping mapping : clientMappings) { mapping.updatePortIfUnknown(calculatePort()); } return clientMappings; }
private ClusterTopologyListener.ClusterInfo getClusterInfo(final Map<String, List<ClientMapping>> entries) { final List<ClusterTopologyListener.NodeInfo> nodeInfoList = new ArrayList<>(entries.size()); for (Map.Entry<String, List<ClientMapping>> entry : entries.entrySet()) { final String nodeName = entry.getKey(); final List<ClientMapping> clientMappingList = entry.getValue(); final List<ClusterTopologyListener.MappingInfo> mappingInfoList = new ArrayList<>(clientMappingList.size()); for (ClientMapping clientMapping : clientMappingList) { try { if (InetAddress.getByName(clientMapping.getDestinationAddress()).isAnyLocalAddress()) { EjbLogger.REMOTE_LOGGER.clusteredEJBsBoundToINADDRANY(nodeName, clientMapping.getDestinationAddress()); } } catch (UnknownHostException e) { // ignore } mappingInfoList.add(new ClusterTopologyListener.MappingInfo( clientMapping.getDestinationAddress(), clientMapping.getDestinationPort(), clientMapping.getSourceNetworkAddress(), clientMapping.getSourceNetworkMaskBits()) ); } nodeInfoList.add(new ClusterTopologyListener.NodeInfo(nodeName, mappingInfoList)); } return new ClusterTopologyListener.ClusterInfo(this.clientMappingRegistry.getGroup().getName(), nodeInfoList); } }
List<ClientMapping> getClientMappings() { final List<ClientMapping> ret = new ArrayList<>(); RemotingConnectorBindingInfoService.RemotingConnectorInfo info = this.remotingConnectorInfo.get(); if (info.getSocketBinding().getClientMappings() != null && !info.getSocketBinding().getClientMappings().isEmpty()) { ret.addAll(info.getSocketBinding().getClientMappings()); } else { // TODO: We use the textual form of IP address as the destination address for now. // This needs to be configurable (i.e. send either host name or the IP address). But // since this is a corner case (i.e. absence of any client-mappings for a socket binding), // this should be OK for now final String destinationAddress = info.getSocketBinding().getAddress().getHostAddress(); final InetAddress clientNetworkAddress; try { clientNetworkAddress = InetAddress.getByName("::"); } catch (UnknownHostException e) { throw new RuntimeException(e); } final ClientMapping defaultClientMapping = new ClientMapping(clientNetworkAddress, 0, destinationAddress, info.getSocketBinding().getAbsolutePort()); ret.add(defaultClientMapping); } return ret; } }
private List<ClientMapping> fixupMappings(List<ClientMapping> clientMappings) { for (ClientMapping mapping : clientMappings) { mapping.updatePortIfUnknown(calculatePort()); } return clientMappings; }
@Override public void writeObject(ObjectOutput output, ClientMapping mapping) throws IOException { byte[] address = mapping.getSourceNetworkAddress().getAddress(); IndexSerializer.UNSIGNED_BYTE.writeInt(output, address.length); output.write(address); IndexSerializer.UNSIGNED_BYTE.writeInt(output, mapping.getSourceNetworkMaskBits()); output.writeUTF(mapping.getDestinationAddress()); IndexSerializer.UNSIGNED_SHORT.writeInt(output, mapping.getDestinationPort()); }
@Override public ClientMapping readObject(ObjectInput input) throws IOException { byte[] sourceAddress = new byte[IndexSerializer.UNSIGNED_BYTE.readInt(input)]; input.readFully(sourceAddress); int sourceNetworkMaskBits = IndexSerializer.UNSIGNED_BYTE.readInt(input); String destAddress = input.readUTF(); int destPort = IndexSerializer.UNSIGNED_SHORT.readInt(input); return new ClientMapping(InetAddress.getByAddress(sourceAddress), sourceNetworkMaskBits, destAddress, destPort); }
final InetAddress clientNetworkAddress = clientMapping.getSourceNetworkAddress(); final int netMask = clientMapping.getSourceNetworkMaskBits(); final int netMaskAndIPFamilyDifferentiator; if (clientNetworkAddress instanceof Inet4Address) { output.writeUTF(clientMapping.getDestinationAddress()); output.writeShort(clientMapping.getDestinationPort());
List<ClientMapping> getClientMappings() { if (this.remotingServer == null) { return Collections.emptyList(); } final SocketBinding socketBinding = this.remotingServer.getSocketBinding(); final List<ClientMapping> clientMappings = socketBinding.getClientMappings(); if (clientMappings != null && !clientMappings.isEmpty()) { return clientMappings; } // TODO: We use the textual form of IP address as the destination address for now. // This needs to be configurable (i.e. send either host name or the IP address). But // since this is a corner case (i.e. absence of any client-mappings for a socket binding), // this should be OK for now final String destinationAddress = socketBinding.getAddress().getHostAddress(); final InetAddress clientNetworkAddress; try { clientNetworkAddress = InetAddress.getByName("::"); } catch (UnknownHostException e) { throw new RuntimeException(e); } final ClientMapping defaultClientMapping = new ClientMapping(clientNetworkAddress, 0, destinationAddress, socketBinding.getAbsolutePort()); return Collections.singletonList(defaultClientMapping); }
ClientMapping resolvedClientMapping = null; for (final ClientMapping clientMapping : clientMappings) { final InetAddress sourceNetworkAddress = clientMapping.getSourceNetworkAddress(); final int netMask = clientMapping.getSourceNetworkMaskBits(); final boolean match = NetworkUtil.belongsToNetwork(bindAddress, sourceNetworkAddress, (byte) (netMask & 0xff)); if (match) { continue; final ClusterNodeManager remotingClusterNodeManager = new RemotingConnectionClusterNodeManager(clusterContext, endpoint, addedNodeName, resolvedClientMapping.getDestinationAddress(), resolvedClientMapping.getDestinationPort()); clusterContext.addClusterNodes(remotingClusterNodeManager);
clientMappings.add(new ClientMapping(sourceAddress, mask, destination, port));
clientMappings.add(new ClientMapping(sourceAddress, mask, destination, port));
clientMappings.add(new ClientMapping(sourceAddress, mask, destination, port));
clientMappings.add(new ClientMapping(sourceAddress, mask, destination, port));