There seems to be a problem with extending DefaultConsistentHash. I tested with a simple class:
public class ExtendedHash extends DefaultConsistentHash implements Serializable {
@Override
public List<Address> locate(Object key, int replCount) {
try {
return super.locate(key, replCount);
} catch (RuntimeException e) {
e.printStackTrace();
throw e;
}
}
}
Started a cluster of 3 or 4 nodes (on different ports) and after stopping one of the nodes I get this:
2010-10-01 15:34:15,714 ERROR [org.infinispan.remoting.rpc.RpcManagerImpl] (Rehasher-nts-50584) unexpected error while replicating
java.lang.NullPointerException
at org.infinispan.distribution.DefaultConsistentHash.locate(DefaultConsistentHash.java:66)
at com.mb.kerrigan.hash.DHash.locate(DHash.java:21)
at org.infinispan.commands.control.RehashControlCommand.shouldTransferOwnershipFromLeftNodes(RehashControlCommand.java:191)
at org.infinispan.commands.control.RehashControlCommand.pullStateForLeave(RehashControlCommand.java:169)
at org.infinispan.commands.control.RehashControlCommand.perform(RehashControlCommand.java:129)
at org.infinispan.remoting.InboundInvocationHandlerImpl.handle(InboundInvocationHandlerImpl.java:76)
at org.infinispan.remoting.transport.jgroups.CommandAwareRpcDispatcher.executeCommand(CommandAwareRpcDispatcher.java:176)
at org.infinispan.remoting.transport.jgroups.CommandAwareRpcDispatcher.handle(CommandAwareRpcDispatcher.java:148)
at org.jgroups.blocks.RequestCorrelator.handleRequest(RequestCorrelator.java:575)
at org.jgroups.blocks.RequestCorrelator.receiveMessage(RequestCorrelator.java:486)
at org.jgroups.blocks.RequestCorrelator.receive(RequestCorrelator.java:362)
at org.jgroups.blocks.MessageDispatcher$ProtocolAdapter.up(MessageDispatcher.java:771)
at org.jgroups.JChannel.up(JChannel.java:1453)
at org.jgroups.stack.ProtocolStack.up(ProtocolStack.java:887)
at org.jgroups.protocols.pbcast.FLUSH.up(FLUSH.java:435)
at org.jgroups.protocols.pbcast.STREAMING_STATE_TRANSFER.up(STREAMING_STATE_TRANSFER.java:265)
at org.jgroups.protocols.FRAG2.up(FRAG2.java:188)
at org.jgroups.protocols.FC.up(FC.java:494)
at org.jgroups.protocols.pbcast.GMS.up(GMS.java:888)
at org.jgroups.protocols.pbcast.STABLE.up(STABLE.java:234)
at org.jgroups.protocols.UNICAST.handleDataReceived(UNICAST.java:576)
at org.jgroups.protocols.UNICAST.up(UNICAST.java:294)
at org.jgroups.protocols.pbcast.NAKACK.up(NAKACK.java:707)
at org.jgroups.protocols.VERIFY_SUSPECT.up(VERIFY_SUSPECT.java:132)
at org.jgroups.protocols.FD.up(FD.java:266)
at org.jgroups.protocols.FD_SOCK.up(FD_SOCK.java:270)
at org.jgroups.protocols.MERGE2.up(MERGE2.java:210)
at org.jgroups.protocols.Discovery.up(Discovery.java:281)
at org.jgroups.protocols.TP.passMessageUp(TP.java:1009)
at org.jgroups.protocols.TP.access$100(TP.java:56)
at org.jgroups.protocols.TP$IncomingPacket.handleMyMessage(TP.java:1549)
at org.jgroups.protocols.TP$IncomingPacket.run(TP.java:1531)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
2010-10-01 15:34:15,714 ERROR [org.infinispan.remoting.rpc.RpcManagerImpl] (Rehasher-nts-50584) unexpected error while replicating
java.lang.NullPointerException
at org.infinispan.distribution.DefaultConsistentHash.locate(DefaultConsistentHash.java:66)
at test.ExtendedHash.locate(ExtendedHash.java:12)
at org.infinispan.commands.control.RehashControlCommand.shouldTransferOwnershipFromLeftNodes(RehashControlCommand.java:191)
at org.infinispan.commands.control.RehashControlCommand.pullStateForLeave(RehashControlCommand.java:169)
at org.infinispan.commands.control.RehashControlCommand.perform(RehashControlCommand.java:129)
at org.infinispan.remoting.InboundInvocationHandlerImpl.handle(InboundInvocationHandlerImpl.java:76)
at org.infinispan.remoting.transport.jgroups.CommandAwareRpcDispatcher.executeCommand(CommandAwareRpcDispatcher.java:176)
at org.infinispan.remoting.transport.jgroups.CommandAwareRpcDispatcher.handle(CommandAwareRpcDispatcher.java:148)
at org.jgroups.blocks.RequestCorrelator.handleRequest(RequestCorrelator.java:575)
at org.jgroups.blocks.RequestCorrelator.receiveMessage(RequestCorrelator.java:486)
at org.jgroups.blocks.RequestCorrelator.receive(RequestCorrelator.java:362)
at org.jgroups.blocks.MessageDispatcher$ProtocolAdapter.up(MessageDispatcher.java:771)
at org.jgroups.JChannel.up(JChannel.java:1453)
at org.jgroups.stack.ProtocolStack.up(ProtocolStack.java:887)
at org.jgroups.protocols.pbcast.FLUSH.up(FLUSH.java:435)
at org.jgroups.protocols.pbcast.STREAMING_STATE_TRANSFER.up(STREAMING_STATE_TRANSFER.java:265)
at org.jgroups.protocols.FRAG2.up(FRAG2.java:188)
at org.jgroups.protocols.FC.up(FC.java:494)
at org.jgroups.protocols.pbcast.GMS.up(GMS.java:888)
at org.jgroups.protocols.pbcast.STABLE.up(STABLE.java:234)
at org.jgroups.protocols.UNICAST.handleDataReceived(UNICAST.java:576)
at org.jgroups.protocols.UNICAST.up(UNICAST.java:294)
at org.jgroups.protocols.pbcast.NAKACK.up(NAKACK.java:707)
at org.jgroups.protocols.VERIFY_SUSPECT.up(VERIFY_SUSPECT.java:132)
at org.jgroups.protocols.FD.up(FD.java:266)
at org.jgroups.protocols.FD_SOCK.up(FD_SOCK.java:270)
at org.jgroups.protocols.MERGE2.up(MERGE2.java:210)
at org.jgroups.protocols.Discovery.up(Discovery.java:281)
at org.jgroups.protocols.TP.passMessageUp(TP.java:1009)
at org.jgroups.protocols.TP.access$100(TP.java:56)
at org.jgroups.protocols.TP$IncomingPacket.handleMyMessage(TP.java:1549)
at org.jgroups.protocols.TP$IncomingPacket.run(TP.java:1531)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
I saw that DefaultConsistentHash is not Serializable, but using an Externalizer class. User code can't adopt the same approach, as the class name must be registered in ConstantObjectTable.MARSHALLABLES at compile time.
Please provide some comments, is it possible to extend DefaultConsistentHash without running into those serialization problems?