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 ClusterAffinity && equals((ClusterAffinity) other); }
private IoFuture<ConnectionPeerIdentity> getConnection(final AbstractInvocationContext context, final URI target, @NotNull AuthenticationContext authenticationContext) throws Exception { Affinity affinity = context.getLocator().getAffinity(); String cluster = (affinity instanceof ClusterAffinity) ? ((ClusterAffinity) affinity).getClusterName() : context.getInitialCluster(); if (cluster != null) { return doPrivileged((PrivilegedAction<IoFuture<ConnectionPeerIdentity>>) () -> discoveredNodeRegistry.getConnectedIdentityUsingClusterEffective(Endpoint.getCurrent(), target, "ejb", "jboss", authenticationContext, cluster)); } return doPrivileged((PrivilegedAction<IoFuture<ConnectionPeerIdentity>>) () -> Endpoint.getCurrent().getConnectedIdentity(target, "ejb", "jboss", authenticationContext)); } }
/** * 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 selectedNode = selector.selectNode(((ClusterAffinity) locator.getAffinity()).getClusterName(), connectedNodes.toArray(NO_STRINGS), availableNodes.toArray(NO_STRINGS)); if (selectedNode == null) { throw withSuppressed(Logs.MAIN.selectorReturnedNull(selector), problems);
public boolean equals(final Affinity other) { return other instanceof ClusterAffinity && equals((ClusterAffinity) other); }
private Affinity getClusterAffinity() { Registry<String, List<ClientMapping>> registry = this.clientMappingRegistry; Group group = registry != null ? registry.getGroup() : null; return group != null && !group.isSingleton() ? new ClusterAffinity(group.getName()) : null; }
final String clusterName = strongAffinityUpdate.getClusterName(); final byte[] bytes = clusterName.getBytes(StandardCharsets.UTF_8); PackedInteger.writePackedInteger(os, bytes.length);
public boolean equals(final Affinity other) { return other instanceof ClusterAffinity && equals((ClusterAffinity) other); }
EJBRootContext(final NamingProvider namingProvider, final FastHashtable<String, Object> env, final ProviderEnvironment providerEnvironment) { super(env); this.namingProvider = namingProvider; this.providerEnvironment = providerEnvironment; // TODO, Switch to providerEnvironment using WildFLy Naming, when attachments are added Object learned = env.get(LEARNED_AFFINITY_KEY); if (learned == null || ! (learned instanceof LearnedAffinity)) { // check if strong affinity for this context has been set in the environment String clusterName = getClusterAffinityValueFromEnvironment(); if (clusterName != null) { learned = new LearnedAffinity(new ClusterAffinity(clusterName)); } else { learned = new LearnedAffinity(shouldLearnAffinity() ? null : Affinity.NONE); } env.put(LEARNED_AFFINITY_KEY, learned); } this.baseAffinity = (LearnedAffinity) learned; }
if (weakAffinity instanceof NodeAffinity) { filterSpec = FilterSpec.all( FilterSpec.equal(FILTER_ATTR_CLUSTER, ((ClusterAffinity) affinity).getClusterName()), FilterSpec.equal(FILTER_ATTR_NODE, ((NodeAffinity) weakAffinity).getNodeName()) ); fallbackFilterSpec = FilterSpec.all( FilterSpec.equal(FILTER_ATTR_CLUSTER, ((ClusterAffinity) affinity).getClusterName()), FilterSpec.hasAttribute(FILTER_ATTR_NODE) ); FilterSpec.equal(FILTER_ATTR_CLUSTER, ((ClusterAffinity) affinity).getClusterName()) ); return doClusterDiscovery(context, filterSpec);
public boolean equals(final Affinity other) { return other instanceof ClusterAffinity && equals((ClusterAffinity) other); }
@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()); }
final String clusterName = strongAffinityUpdate.getClusterName(); final byte[] bytes = clusterName.getBytes(StandardCharsets.UTF_8); PackedInteger.writePackedInteger(os, bytes.length);
public boolean equals(final Object other) { return other instanceof ClusterAffinity && equals((ClusterAffinity) other); }
byte[] b = new byte[PackedInteger.readPackedInteger(inputStream)]; inputStream.readFully(b); context.setLocator(context.getLocator().withNewAffinity(new ClusterAffinity(new String(b, StandardCharsets.UTF_8))));
private IoFuture<ConnectionPeerIdentity> getConnection(final AbstractInvocationContext context, final URI target, @NotNull AuthenticationContext authenticationContext) throws Exception { Affinity affinity = context.getLocator().getAffinity(); String cluster = (affinity instanceof ClusterAffinity) ? ((ClusterAffinity) affinity).getClusterName() : context.getInitialCluster(); if (cluster != null) { return doPrivileged((PrivilegedAction<IoFuture<ConnectionPeerIdentity>>) () -> discoveredNodeRegistry.getConnectedIdentityUsingClusterEffective(Endpoint.getCurrent(), target, "ejb", "jboss", authenticationContext, cluster)); } return doPrivileged((PrivilegedAction<IoFuture<ConnectionPeerIdentity>>) () -> Endpoint.getCurrent().getConnectedIdentity(target, "ejb", "jboss", authenticationContext)); } }
public boolean equals(final Object other) { return other instanceof ClusterAffinity && equals((ClusterAffinity) other); }
response.readFully(b); String clusterName = new String(b, StandardCharsets.UTF_8); affinity = new ClusterAffinity(clusterName);
private IoFuture<ConnectionPeerIdentity> getConnection(final AbstractInvocationContext context, final URI target, @NotNull AuthenticationContext authenticationContext) throws Exception { Affinity affinity = context.getLocator().getAffinity(); String cluster = (affinity instanceof ClusterAffinity) ? ((ClusterAffinity) affinity).getClusterName() : context.getInitialCluster(); if (cluster != null) { return doPrivileged((PrivilegedAction<IoFuture<ConnectionPeerIdentity>>) () -> discoveredNodeRegistry.getConnectedIdentityUsingClusterEffective(Endpoint.getCurrent(), target, "ejb", "jboss", authenticationContext, cluster)); } return doPrivileged((PrivilegedAction<IoFuture<ConnectionPeerIdentity>>) () -> Endpoint.getCurrent().getConnectedIdentity(target, "ejb", "jboss", authenticationContext)); } }