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; } }
@Override public Affinity getStrictAffinity() { return new NodeAffinity(this.environment.getNodeName()); }
/** * 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); } }
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); }
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); }
@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; }
@Override public Affinity getStrictAffinity() { Group group = this.registry.getGroup(); return this.cache.getCacheConfiguration().clustering().cacheMode().isClustered() ? new ClusterAffinity(group.getName()) : new NodeAffinity(this.registry.getEntry(group.getLocalMember()).getKey()); }
if (nodeName != null) context.setTargetAffinity(new NodeAffinity(nodeName)); return problems;
final String nodeName = entry.getKey(); final URI uri = entry.getValue(); context.setTargetAffinity(new NodeAffinity(nodeName)); context.setDestination(uri); context.setTargetAffinity(new NodeAffinity(selectedNode));
context.setTargetAffinity(new NodeAffinity(nodeValue.toString())); } else {
marshaller.writeObject(strongAffinityUpdate); } else { marshaller.writeObject(new NodeAffinity(channel.getConnection().getEndpoint().getName()));
byte[] b = new byte[PackedInteger.readPackedInteger(inputStream)]; inputStream.readFully(b); context.setWeakAffinity(new NodeAffinity(new String(b, StandardCharsets.UTF_8)));
final byte[] b = new byte[PackedInteger.readPackedInteger(response)]; response.readFully(b); clientInvocationContext.setWeakAffinity(new NodeAffinity(new String(b, StandardCharsets.UTF_8)));
@Override public Affinity getStrictAffinity() { return new NodeAffinity(this.environment.getNodeName()); }
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); }
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); }
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); }
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); }
@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; }
@Override public Affinity getStrictAffinity() { Group group = this.registry.getGroup(); return this.cache.getCacheConfiguration().clustering().cacheMode().isClustered() ? new ClusterAffinity(group.getName()) : new NodeAffinity(this.registry.getEntry(group.getLocalMember()).getKey()); }