Object writeReplace() { String s = uri.getScheme(); if (s.equals("node")) { return new NodeAffinity(uri.getSchemeSpecificPart()); } else if (s.equals("cluster")) { return new ClusterAffinity(uri.getSchemeSpecificPart()); } else if (s.equals("local")) { return LOCAL; } else { // keep same object return this; } }
public boolean equals(final Object other) { return other instanceof NodeAffinity && equals((NodeAffinity) other); }
marshaller.writeObject(strongAffinityUpdate); } else { marshaller.writeObject(new NodeAffinity(channel.getConnection().getEndpoint().getName())); final String nodeName = weakAffinityUpdate.getNodeName(); final byte[] bytes = nodeName.getBytes(StandardCharsets.UTF_8); PackedInteger.writePackedInteger(os, bytes.length);
final String nodeName = weakAffinityUpdate.getNodeName(); final byte[] bytes = nodeName.getBytes(StandardCharsets.UTF_8); PackedInteger.writePackedInteger(os, bytes.length);
marshaller.writeObject(strongAffinityUpdate); } else { marshaller.writeObject(new NodeAffinity(channel.getConnection().getEndpoint().getName())); final String nodeName = weakAffinityUpdate.getNodeName(); final byte[] bytes = nodeName.getBytes(StandardCharsets.UTF_8); PackedInteger.writePackedInteger(os, bytes.length);
private void removeNode(final AbstractInvocationContext context) { final Affinity targetAffinity = context.getTargetAffinity(); if (targetAffinity instanceof NodeAffinity) { final RemoteEJBReceiver ejbReceiver = context.getClientContext().getAttachment(RemoteTransportProvider.ATTACHMENT_KEY); if (ejbReceiver != null) { final EJBClientChannel ejbClientChannel = context.getAttachment(RemoteEJBReceiver.EJBCC_KEY); if (ejbClientChannel != null) { final NodeInformation nodeInformation = ejbReceiver.getDiscoveredNodeRegistry().getNodeInformation(((NodeAffinity) targetAffinity).getNodeName()); if (nodeInformation != null) { nodeInformation.removeModule(ejbClientChannel, context.getLocator().getIdentifier().getModuleIdentifier()); } } } } } }
@Override public Affinity getStrictAffinity() { return new NodeAffinity(this.environment.getNodeName()); }
marshaller.writeObject(strongAffinityUpdate); } else { marshaller.writeObject(new NodeAffinity(channel.getConnection().getEndpoint().getName())); final String nodeName = weakAffinityUpdate.getNodeName(); final byte[] bytes = nodeName.getBytes(StandardCharsets.UTF_8); PackedInteger.writePackedInteger(os, bytes.length);
filterSpec = FilterSpec.equal(FILTER_ATTR_NODE, ((NodeAffinity) weakAffinity).getNodeName()); return doFirstMatchDiscovery(context, filterSpec, null); } else if (affinity instanceof NodeAffinity) { filterSpec = FilterSpec.equal(FILTER_ATTR_NODE, ((NodeAffinity) affinity).getNodeName()); return doFirstMatchDiscovery(context, filterSpec, null); } else if (affinity instanceof ClusterAffinity) { filterSpec = FilterSpec.all( FilterSpec.equal(FILTER_ATTR_CLUSTER, ((ClusterAffinity) affinity).getClusterName()), FilterSpec.equal(FILTER_ATTR_NODE, ((NodeAffinity) weakAffinity).getNodeName()) ); fallbackFilterSpec = FilterSpec.all(
public boolean equals(final Affinity other) { return other instanceof NodeAffinity && equals((NodeAffinity) other); }
/** * Get the affinity specification corresponding to the given URI. * * @param uri the URI * @return the affinity specification (not {@code null}) */ public static Affinity forUri(URI uri) { if (uri == null || ! uri.isAbsolute()) return NONE; final String scheme = uri.getScheme(); assert scheme != null; // due to isAbsolute() check switch (scheme) { case "node": return new NodeAffinity(uri.getSchemeSpecificPart()); case "cluster": return new ClusterAffinity(uri.getSchemeSpecificPart()); case "local": return LOCAL; default: return new URIAffinity(uri); } }
final String nodeName = weakAffinityUpdate.getNodeName(); final byte[] bytes = nodeName.getBytes(StandardCharsets.UTF_8); PackedInteger.writePackedInteger(os, bytes.length);
public boolean equals(final Affinity other) { return other instanceof NodeAffinity && equals((NodeAffinity) other); }
ProtocolV3ObjectResolver(final Connection connection, final boolean preferUri) { final String remoteEndpointName = connection.getRemoteEndpointName(); peerNodeAffinity = remoteEndpointName == null ? null : new NodeAffinity(remoteEndpointName); final String localEndpointName = connection.getEndpoint().getName(); selfNodeAffinity = localEndpointName == null ? null : new NodeAffinity(localEndpointName); this.preferUri = preferUri; final URI peerURI = connection.getPeerURI(); peerUriAffinity = peerURI == null ? null : (URIAffinity) Affinity.forUri(peerURI); }
final String nodeName = weakAffinityUpdate.getNodeName(); final byte[] bytes = nodeName.getBytes(StandardCharsets.UTF_8); PackedInteger.writePackedInteger(os, bytes.length);
public boolean equals(final Object other) { return other instanceof NodeAffinity && equals((NodeAffinity) other); }
ProtocolV1ObjectResolver(final Connection connection, final boolean preferUri) { final String remoteEndpointName = connection.getRemoteEndpointName(); peerNodeAffinity = remoteEndpointName == null ? null : new NodeAffinity(remoteEndpointName); final String localEndpointName = connection.getEndpoint().getName(); selfNodeAffinity = localEndpointName == null ? null : new NodeAffinity(localEndpointName); this.preferUri = preferUri; final URI peerURI = connection.getPeerURI(); peerUriAffinity = peerURI == null ? null : (URIAffinity) Affinity.forUri(peerURI); }
private void removeNode(final AbstractInvocationContext context) { final Affinity targetAffinity = context.getTargetAffinity(); if (targetAffinity instanceof NodeAffinity) { final RemoteEJBReceiver ejbReceiver = context.getClientContext().getAttachment(RemoteTransportProvider.ATTACHMENT_KEY); if (ejbReceiver != null) { final EJBClientChannel ejbClientChannel = context.getAttachment(RemoteEJBReceiver.EJBCC_KEY); if (ejbClientChannel != null) { final NodeInformation nodeInformation = ejbReceiver.getDiscoveredNodeRegistry().getNodeInformation(((NodeAffinity) targetAffinity).getNodeName()); if (nodeInformation != null) { nodeInformation.removeModule(ejbClientChannel, context.getLocator().getIdentifier().getModuleIdentifier()); } } } } } }
public boolean equals(final Object other) { return other instanceof NodeAffinity && equals((NodeAffinity) other); }
@Override public Affinity getWeakAffinity(I id) { if (this.cache.getCacheConfiguration().clustering().cacheMode().isClustered()) { Node node = this.locatePrimaryOwner(id); Map.Entry<String, ?> entry = this.registry.getEntry(node); if (entry != null) { return new NodeAffinity(entry.getKey()); } } return Affinity.NONE; }