Package org.infinispan.remoting.responses

Examples of org.infinispan.remoting.responses.Response


         }
      }
   }

   private Object getResponseFromPrimaryOwner(Address primaryOwner, Map<Address, Response> addressResponseMap) {
      Response fromPrimaryOwner = addressResponseMap.get(primaryOwner);
      if (fromPrimaryOwner == null) {
         log.tracef("Primary owner %s returned null", primaryOwner);
         return null;
      }
      if (fromPrimaryOwner.isSuccessful()) {
         return ((SuccessfulResponse) fromPrimaryOwner).getResponseValue();
      }

      if (addressResponseMap.get(primaryOwner) instanceof CacheNotFoundResponse) {
         // This means the cache wasn't running on the primary owner, so the command wasn't executed.
View Full Code Here


      // is then stored in the transactional context to be used during the commit phase.
      // However if the current node is already the coordinator, then we fall back to "normal" ReplicationInterceptor
      // logic for this step.
      if (!rpcManager.getTransport().isCoordinator()) {
         Map<Address, Response> resps = rpcManager.invokeRemotely(null, command, true, true);
         Response r = resps.get(rpcManager.getTransport().getCoordinator())// We only really care about the coordinator's response.
         CacheTransaction ct = context.getCacheTransaction();
         if (r.isSuccessful()) {
            SuccessfulResponse sr = (SuccessfulResponse) r;
            EntryVersionsMap uv = (EntryVersionsMap) sr.getResponseValue();
            ct.setUpdatedEntryVersions(uv);
         }
      } else {
View Full Code Here

      //3. then the remote ones
      if (notOnlyMeInTheCluster() && broadcastForPreparedTx) {
         boolean success = true;
         Map<Address, Response> responses = getAllPreparedTxFromCluster();
         for (Map.Entry<Address, Response> rEntry : responses.entrySet()) {
            Response thisResponse = rEntry.getValue();
            if (isSuccessful(thisResponse)) {
               List<Xid> responseValue = (List<Xid>) ((SuccessfulResponse) thisResponse).getResponseValue();
               if (log.isTraceEnabled()) {
                  log.tracef("Received Xid lists %s from node %s", responseValue, rEntry.getKey());
               }
View Full Code Here

      Map<Xid, InDoubtTxInfoImpl> result = new HashMap<Xid, InDoubtTxInfoImpl>();
      if (rpcManager != null) {
         GetInDoubtTxInfoCommand inDoubtTxInfoCommand = commandFactory.buildGetInDoubtTxInfoCommand();
         Map<Address, Response> addressResponseMap = rpcManager.invokeRemotely(null, inDoubtTxInfoCommand, true, false);
         for (Map.Entry<Address, Response> re : addressResponseMap.entrySet()) {
            Response r = re.getValue();
            if (!isSuccessful(r)) {
               throw new CacheException("Could not fetch in doubt transactions: " + r);
            }
            Set<InDoubtTxInfoImpl> infoInDoubtSet = (Set<InDoubtTxInfoImpl>) ((SuccessfulResponse) r).getResponseValue();
            for (InDoubtTxInfoImpl infoInDoubt : infoInDoubtSet) {
View Full Code Here

         return new ExceptionResponse(e);
      }
   }

   private Response handleWithWaitForBlocks(CacheRpcCommand cmd) throws Throwable {
      Response resp = handleInternal(cmd);

      // A null response is valid and OK ...
      if (resp == null || resp.isValid()) {
         //TODO Check if message replaying is still needed without FLUSH
         //if (replayIgnored) resp = new ExtendedResponse(resp, true);
      } else {
         // invalid response
         log.tracef("Unable to execute command, got invalid response %s", resp);
View Full Code Here

         if (exception != null) {
            log.tracef(exception, "Unexpected exception from %s", sender);
            throw new CacheException("Remote (" + sender + ") failed unexpectedly", exception);
         }
         if (responseObject instanceof Response) {
            Response response = (Response) responseObject;
            if (response instanceof ExceptionResponse) {
               Exception e = ((ExceptionResponse) response).getException();
               if (!(e instanceof RpcException)) {
                  // if we have any application-level exceptions make sure we throw them!!
                  if (shouldThrowException(e)) {
View Full Code Here

         // If this thread blocked during a NBST flush, then inform the sender
         // it needs to replay ignored messages
         boolean replayIgnored = sr == DistributedSync.SyncResponse.STATE_ACHIEVED;
         if (trace) log.trace("Enough waiting; replayIgnored = {0}, sr {1}", replayIgnored, sr);

         Response resp = inboundInvocationHandler.handle(cmd);

         // A null response is valid and OK ...
         if (resp == null || resp.isValid()) {
            if (replayIgnored) resp = new ExtendedResponse(resp, true);
         } else {
            // invalid response
            newCacheStarting.set(true);
            if (trace) log.trace("Unable to execute command, got invalid response");
View Full Code Here

      ClusteredGetCommand clusteredGetCommand = new ClusteredGetCommand(key, cache.getName());
      List<Response> response = doRemoteCall(clusteredGetCommand);
      if (response.isEmpty()) return null;
      if (response.size() > 1)
         throw new CacheLoaderException("Response length is always 0 or 1, received: " + response);
      Response firstResponse = response.get(0);
      if (firstResponse.isSuccessful() && firstResponse instanceof SuccessfulResponse) {
         return (InternalCacheEntry) ((SuccessfulResponse) firstResponse).getResponseValue();
      }

      String message = "Unknown response from remote cache: " + response;
      log.error(message);
View Full Code Here

               } else {
                  throw new TimeoutException("Replication timeout for " + rsp.getSender());
               }
            } else {
               if (rsp.getValue() != null) {
                  Response value = (Response) rsp.getValue();
                  if (value instanceof ExceptionResponse) {
                     Exception e = ((ExceptionResponse) value).getException();
                     if (!(e instanceof ReplicationException)) {
                        // if we have any application-level exceptions make sure we throw them!!
                        if (trace) log.trace("Recieved exception '{0}' from {1}", e, rsp.getSender());
View Full Code Here

         case MAGICNUMBER_EXCEPTION_RESPONSE:
            Exception e = (Exception) unmarshallObject(in, refMap);
            return new ExceptionResponse(e);
         case MAGICNUMBER_EXTENDED_RESPONSE:
            boolean replay = in.readBoolean();
            Response response = (Response) unmarshallObject(in, refMap);
            return new ExtendedResponse(response, replay);
         default:
            return null;
      }
   }
View Full Code Here

TOP

Related Classes of org.infinispan.remoting.responses.Response

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.