Skip to content

Commit

Permalink
Merge pull request #236 from stuartwdouglas/no-affinity-invocations
Browse files Browse the repository at this point in the history
 Also replace the affinity of deserialized locators if it is NONE for…
  • Loading branch information
dmlloyd authored Mar 16, 2017
2 parents a3053cf + c83e880 commit 2b5d451
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public Class<?> resolveProxyClass(final Unmarshaller unmarshaller, final String[
if (version < 3) {
configuration.setClassTable(ProtocolV1ClassTable.INSTANCE);
configuration.setObjectTable(ProtocolV1ObjectTable.INSTANCE);
configuration.setObjectResolver(new ProtocolV1ObjectResolver(channel.getConnection().getEndpoint().getName()));
configuration.setObjectResolver(new ProtocolV1ObjectResolver(channel.getConnection().getEndpoint().getName(), channel.getConnection().getPeerURI()));
configuration.setVersion(2);
// Do not wait for cluster topology report.
finishedParts.set(0b10);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public ObjectResolver getObjectResolver(final Transport transport, final boolean
if (transport instanceof RemoteTransport) {
final RemoteTransport remoteTransport = (RemoteTransport) transport;
if (remoteTransport.getVersion() == 1) {
return new ProtocolV1ObjectResolver(remoteTransport.getConnection().getEndpoint().getName());
return new ProtocolV1ObjectResolver(remoteTransport.getConnection().getEndpoint().getName(), remoteTransport.getConnection().getPeerURI());
} else if (remoteTransport.getVersion() == 2) {
return new ProtocolV3ObjectResolver(remoteTransport.getConnection().getPeerURI());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
import org.jboss.marshalling.MarshallerFactory;
import org.jboss.marshalling.Marshalling;
import org.jboss.marshalling.MarshallingConfiguration;
import org.jboss.marshalling.UTFUtils;
import org.jboss.marshalling.Unmarshaller;
import org.jboss.marshalling.river.RiverMarshallerFactory;
import org.jboss.remoting3.Channel;
Expand Down Expand Up @@ -117,7 +116,7 @@ final class EJBServerChannel {
if (version < 3) {
configuration.setClassTable(ProtocolV1ClassTable.INSTANCE);
configuration.setObjectTable(ProtocolV1ObjectTable.INSTANCE);
configuration.setObjectResolver(new ProtocolV1ObjectResolver(channel.getConnection().getEndpoint().getName()));
configuration.setObjectResolver(new ProtocolV1ObjectResolver(channel.getConnection().getEndpoint().getName(), channel.getConnection().getPeerURI()));
configuration.setVersion(2);
} else {
configuration.setObjectTable(ProtocolV3ObjectTable.INSTANCE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

package org.jboss.ejb.protocol.remote;

import java.net.URI;

import org.jboss.ejb.client.AbstractEJBMetaData;
import org.jboss.ejb.client.Affinity;
import org.jboss.ejb.client.EJBMetaDataImpl;
Expand All @@ -30,18 +32,25 @@
* @author <a href="mailto:david.lloyd@redhat.com">David M. Lloyd</a>
*/
final class ProtocolV1ObjectResolver implements ObjectResolver {

private static final boolean DISABLE_V1_AFFINITY_REWRITE = Boolean.getBoolean("org.jboss.ejb.client.disable-v1-affinity-rewrite");

private final Affinity peerURIAffinity;
private final NodeAffinity nodeAffinity;

ProtocolV1ObjectResolver(final String nodeName) {
ProtocolV1ObjectResolver(final String nodeName, URI peerURI) {
nodeAffinity = new NodeAffinity(nodeName);
this.peerURIAffinity = Affinity.forUri(peerURI);
}

public Object readResolve(final Object replacement) {
if (replacement instanceof EJBMetaDataImpl) {
return ((EJBMetaDataImpl) replacement).toAbstractEJBMetaData();
} else if ((replacement instanceof NodeAffinity) && replacement.equals(nodeAffinity)) {
// Swap a node affinity with the name of this node with a local affinity
return Affinity.LOCAL;
return peerURIAffinity;
} else if(replacement == Affinity.NONE && !DISABLE_V1_AFFINITY_REWRITE) {
return peerURIAffinity;
}
return replacement;
}
Expand Down

0 comments on commit 2b5d451

Please sign in to comment.