Package org.infinispan.commands.remote

Examples of org.infinispan.commands.remote.ClusteredGetCommand


      if (entry.getLifespan() < 0 || entry.getLifespan() > configuration.getL1Lifespan())
         entry.setLifespan(configuration.getL1Lifespan());
   }

   public InternalCacheEntry retrieveFromRemoteSource(Object key) throws Exception {
      ClusteredGetCommand get = cf.buildClusteredGetCommand(key);

      ResponseFilter filter = new ClusteredGetResponseValidityFilter(locate(key));
      List<Response> responses = rpcManager.invokeRemotely(locate(key), get, ResponseMode.SYNCHRONOUS,
                                                           configuration.getSyncReplTimeout(), false, filter);
View Full Code Here


      rpcManager = this.cache.getRpcManager();
   }

   public InternalCacheEntry load(Object key) throws CacheLoaderException {
      if (!(isCacheReady() && isLocalCall())) return null;
      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);
View Full Code Here

   public StateTransferControlCommand buildStateTransferControlCommand(boolean block) {
      return new StateTransferControlCommand(block);
   }

   public ClusteredGetCommand buildClusteredGetCommand(Object key) {
      return new ClusteredGetCommand(key, cacheName);
   }
View Full Code Here

         case ClearCommand.COMMAND_ID:
            ClearCommand cc = (ClearCommand) c;
            cc.init(notifier);
            break;
         case ClusteredGetCommand.COMMAND_ID:
            ClusteredGetCommand clusteredGetCommand = (ClusteredGetCommand) c;
            clusteredGetCommand.initialize(dataContainer, cacheLoaderManager, icc);
            break;
         case LockControlCommand.COMMAND_ID:
            LockControlCommand lcc = (LockControlCommand)c;
            lcc.init(interceptorChain, icc,txTable);
            break;   
View Full Code Here

   @Override
   public InternalCacheEntry load(Object key) throws CacheLoaderException {
      if (!(isCacheReady() && isLocalCall())) return null;

      ClusteredGetCommand clusteredGetCommand = new ClusteredGetCommand(
            key, cache.getName(), InfinispanCollections.<Flag>emptySet(), false, null,
            cache.getCacheConfiguration().dataContainer().keyEquivalence());

      Collection<Response> responses = doRemoteCall(clusteredGetCommand);
      if (responses.isEmpty()) return null;
View Full Code Here

               break;
            case SingleRpcCommand.COMMAND_ID:
               command = new SingleRpcCommand(cacheName);
               break;
            case ClusteredGetCommand.COMMAND_ID:
               command = new ClusteredGetCommand(cacheName);
               break;
            case StateRequestCommand.COMMAND_ID:
               command = new StateRequestCommand(cacheName);
               break;
            case StateResponseCommand.COMMAND_ID:
View Full Code Here

         public ClusteredGetCommand answer(InvocationOnMock invocation) {
            Object key = invocation.getArguments()[0];
            Set<Flag> flags = (Set<Flag>) invocation.getArguments()[1];
            boolean acquireRemoteLock = (Boolean) invocation.getArguments()[2];
            GlobalTransaction gtx = (GlobalTransaction) invocation.getArguments()[3];
            return new ClusteredGetCommand(key, "cache1", flags, acquireRemoteLock, gtx);
         }
      });

      EntryFactory entryFactory = mock(EntryFactory.class);
      DataContainer dataContainer = mock(DataContainer.class);
      LockManager lockManager = mock(LockManager.class);
      StateTransferManager stateTransferManager = mock(StateTransferManager.class);

      TestAddress A = new TestAddress(0, "A");
      TestAddress B = new TestAddress(1, "B");
      List<Address> members1 = new ArrayList<Address>();
      List<Address> members2 = new ArrayList<Address>();
      members1.add(A);
      members2.add(A);
      members2.add(B);
      ReplicatedConsistentHash readCh = new ReplicatedConsistentHash(members1);
      ReplicatedConsistentHash writeCh = new ReplicatedConsistentHash(members2);
      final CacheTopology cacheTopology = new CacheTopology(1, readCh, writeCh);
      when(stateTransferManager.getCacheTopology()).thenAnswer(new Answer<CacheTopology>() {
         @Override
         public CacheTopology answer(InvocationOnMock invocation) {
            return cacheTopology;
         }
      });
      replInterceptor.injectDependencies(commandsFactory, entryFactory, lockManager, dataContainer, stateTransferManager);
      RpcManager rpcManager = mock(RpcManager.class);
      Transport transport = mock(Transport.class);
      when(rpcManager.getAddress()).thenReturn(B);
      when(rpcManager.getTransport()).thenReturn(transport);
      when(transport.getMembers()).thenReturn(members2);
      replInterceptor.inject(rpcManager);
      replInterceptor.injectConfiguration(configuration);

      when(rpcManager.invokeRemotely(any(Collection.class), any(ClusteredGetCommand.class), any(ResponseMode.class),
            anyLong(), anyBoolean(), any(ResponseFilter.class))).thenAnswer(new Answer<Map<Address, Response>>() {
         @Override
         public Map<Address, Response> answer(InvocationOnMock invocation) {
            Collection<Address> recipients = (Collection<Address>) invocation.getArguments()[0];
            ClusteredGetCommand clusteredGetCommand = (ClusteredGetCommand) invocation.getArguments()[1];
            if (clusteredGetCommand.getKey().equals("theKey")) {
               Map<Address, Response> results = new HashMap<Address, Response>();
               for (Address recipient : recipients) {
                  results.put(recipient, SuccessfulResponse.create(new ImmortalCacheValue("theValue")));
               }
               return results;
View Full Code Here

      if (entry.getLifespan() < 0 || entry.getLifespan() > configuration.getL1Lifespan())
         entry.setLifespan(configuration.getL1Lifespan());
   }

   public InternalCacheEntry retrieveFromRemoteSource(Object key, InvocationContext ctx) throws Exception {
      ClusteredGetCommand get = cf.buildClusteredGetCommand(key, ctx.getFlags());

      List<Address> targets = locate(key);
      targets.remove(getSelf());
      ResponseFilter filter = new ClusteredGetResponseValidityFilter(targets);
      Map<Address, Response> responses = rpcManager.invokeRemotely(targets, get, ResponseMode.SYNCHRONOUS,
View Full Code Here

      rpcManager = this.cache.getRpcManager();
   }

   public InternalCacheEntry load(Object key) throws CacheLoaderException {
      if (!(isCacheReady() && isLocalCall())) return null;
      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);
View Full Code Here

   public StateTransferControlCommand buildStateTransferControlCommand(boolean block) {
      return new StateTransferControlCommand(block);
   }

   public ClusteredGetCommand buildClusteredGetCommand(Object key, Set<Flag> flags) {
      return new ClusteredGetCommand(key, cacheName, flags);
   }
View Full Code Here

TOP

Related Classes of org.infinispan.commands.remote.ClusteredGetCommand

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.