Skip to content

Commit

Permalink
ISPN-972 RemoteTransactionLoggerImpl should handle RPC errors better
Browse files Browse the repository at this point in the history
  • Loading branch information
maniksurtani committed Mar 10, 2011
1 parent 68bca66 commit 36b607f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

/**
Expand All @@ -23,6 +24,8 @@ public class RemoteTransactionLogDetails {
final List<WriteCommand> modifications;
final Collection<PrepareCommand> pendingPreparesMap;

public static final RemoteTransactionLogDetails DEFAULT = new RemoteTransactionLogDetails(true, Collections.<WriteCommand>emptyList(), Collections.<PrepareCommand>emptyList());

public RemoteTransactionLogDetails(boolean drainNextCallWithoutLock, List<WriteCommand> modifications, Collection<PrepareCommand> pendingPreparesMap) {
this.drainNextCallWithoutLock = drainNextCallWithoutLock;
this.modifications = modifications;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import org.infinispan.remoting.responses.SuccessfulResponse;
import org.infinispan.remoting.rpc.RpcManager;
import org.infinispan.remoting.transport.Address;
import org.infinispan.util.logging.Log;
import org.infinispan.util.logging.LogFactory;

import java.util.Collection;
import java.util.Collections;
Expand All @@ -28,6 +30,7 @@ public class RemoteTransactionLoggerImpl implements RemoteTransactionLogger {
private final RpcManager rpcManager;
private boolean drainWithoutLock = true;
private Collection<PrepareCommand> pendingPrepares;
private static final Log log = LogFactory.getLog(RemoteTransactionLoggerImpl.class);

public RemoteTransactionLoggerImpl(CommandsFactory commandsFactory, Address targetNode, RpcManager rpcManager) {
this.commandsFactory = commandsFactory;
Expand All @@ -38,7 +41,11 @@ public RemoteTransactionLoggerImpl(CommandsFactory commandsFactory, Address targ

private RemoteTransactionLogDetails extractRemoteTransactionLogDetails(ReplicableCommand c) {
Map<Address, Response> lr = rpcManager.invokeRemotely(Collections.singleton(targetNode), c, true, true);
if (lr.size() != 1) throw new RpcException("Expected just one response; got " + lr + " instead!");
if (lr.size() != 1) {
log.warn("Expected just one response; got %s", lr);
return RemoteTransactionLogDetails.DEFAULT;
}

Response r = lr.get(targetNode);
if (r != null && r.isSuccessful() && r.isValid()) {
return (RemoteTransactionLogDetails) ((SuccessfulResponse) r).getResponseValue();
Expand Down

0 comments on commit 36b607f

Please sign in to comment.