Examples of RPCManager


Examples of org.infinispan.remoting.rpc.RpcManager

      return mapTaskPart;
   }

   protected Map<KOut, VOut> executeReducePhase(Set<KOut> allMapPhasesResponses,
            boolean useCompositeKeys) throws InterruptedException, ExecutionException {
      RpcManager rpc = cache.getRpcManager();
      String destCache = null;
      if (useCompositeKeys) {
         destCache = DEFAULT_TMP_CACHE_CONFIGURATION_NAME;
      } else {
         destCache = taskId.toString();
      }
      Cache<Object, Object> dstCache = cache.getCacheManager().getCache(destCache);
      Map<Address, List<KOut>> keysToNodes = mapKeysToNodes(dstCache.getAdvancedCache()
               .getDistributionManager(), allMapPhasesResponses, useCompositeKeys);
      Map<KOut, VOut> reduceResult = new HashMap<KOut, VOut>();
      List<ReduceTaskPart<Map<KOut, VOut>>> reduceTasks = new ArrayList<ReduceTaskPart<Map<KOut, VOut>>>();
      ReduceCommand<KOut, VOut> reduceCommand = null;
      for (Entry<Address, List<KOut>> e : keysToNodes.entrySet()) {
         Address address = e.getKey();
         List<KOut> keys = e.getValue();
         if (address.equals(rpc.getAddress())) {
            reduceCommand = buildReduceCommand(taskId.toString(), destCache, clone(reducer), keys,
                     useCompositeKeys);
         } else {
            reduceCommand = buildReduceCommand(taskId.toString(), destCache, reducer, keys,
                     useCompositeKeys);
View Full Code Here

Examples of org.infinispan.remoting.rpc.RpcManager

      }

      @Override
      public boolean cancel(boolean mayInterruptIfRunning) {
         if (!isCancelled()) {
            RpcManager rpc = cache.getRpcManager();
            synchronized (cancellableTasks) {
               for (CancellableTaskPart task : cancellableTasks) {
                  boolean sendingToSelf = task.getExecutionTarget().equals(
                           rpc.getTransport().getAddress());
                  CancelCommand cc = buildCancelCommand(task);
                  if (sendingToSelf) {
                     cc.init(cancellationService);
                     try {
                        cc.perform(null);
                     } catch (Throwable e) {
                        log.couldNotExecuteCancellationLocally(e.getLocalizedMessage());
                     }
                  } else {
                     rpc.invokeRemotely(Collections.singletonList(task.getExecutionTarget()), cc, rpc.getDefaultRpcOptions(true));
                  }
                  cancelled = true;
                  done = true;
               }
            }
View Full Code Here

Examples of org.jboss.cache.RPCManager

   {
      assert replQ != null;
      assert replQ.elements.size() == 0 : "expected 0, recieved " + replQ.elements.size();

      // mock the RPCManager used in the cache
      RPCManager mockRpcManager = EasyMock.createStrictMock(RPCManager.class);
      injectRpcManager(mockRpcManager);

      // expect basic cluster related calls
      expect(mockRpcManager.getMembers()).andReturn(originalRpcManager.getMembers()).anyTimes();
      replay(mockRpcManager);

      // check that nothing on the RPCManager will be called until we hit the replication queue threshold.
      for (int i = 0; i < COUNT - 1; i++) cache.put("/a/b/c/" + i, "k", "v");
      assertEquals(replQ.elements.size(), COUNT - 1);

      // verify that no calls have been made on the mockRpcManager
      verify(mockRpcManager);

      // reset the mock
      reset(mockRpcManager);

      // now try the last PUT which should result in the queue being flushed.
      expect(mockRpcManager.getMembers()).andReturn(originalRpcManager.getMembers()).anyTimes();
      expect(mockRpcManager.callRemoteMethods((Vector<Address>) anyObject(), (ReplicableCommand) anyObject(), anyBoolean(), anyLong(), anyBoolean())).andReturn(Collections.emptyList()).anyTimes();
      replay(mockRpcManager);

      cache.put("/a/b/c/LAST", "k", "v");
      assert replQ.elements.size() == 0;
View Full Code Here

Examples of org.jboss.cache.RPCManager

      assert totalInvocations % COUNT == 0 : "NumThreads and NumLoopsPerThread must multiply to be a multiple of COUNT";

      final CountDownLatch latch = new CountDownLatch(1);

      // mock the RPCManager used in the cache
      RPCManager mockRpcManager = EasyMock.createStrictMock(RPCManager.class);
      injectRpcManager(mockRpcManager);

      // expect basic cluster related calls
      expect(mockRpcManager.getMembers()).andReturn(originalRpcManager.getMembers()).anyTimes();
      expect(mockRpcManager.callRemoteMethods((Vector<Address>) anyObject(), (ReplicableCommand) anyObject(), anyBoolean(), anyLong(), anyBoolean())).andReturn(Collections.emptyList()).anyTimes();
      replay(mockRpcManager);

      Thread[] threads = new Thread[numThreads];

      for (int i = 0; i < numThreads; i++)
View Full Code Here

Examples of org.jboss.cache.RPCManager

   public void testQueueHoldAndFlush() throws Exception
   {
      assert replQ != null;

      // mock the RPCManager used in the cache
      RPCManager mockRpcManager = EasyMock.createStrictMock(RPCManager.class);
      injectRpcManager(mockRpcManager);

      // expect basic cluster related calls
      expect(mockRpcManager.getMembers()).andReturn(originalRpcManager.getMembers()).anyTimes();
      replay(mockRpcManager);

      // check that nothing on the RPCManager will be called until we hit the replication queue threshold.
      for (int i = 0; i < COUNT - 1; i++) cache.put("/a/b/c/" + i, "k", "v");
      assert replQ.elements.size() == COUNT - 1;

      // verify that no calls have been made on the mockRpcManager
      verify(mockRpcManager);

      // reset the mock
      reset(mockRpcManager);

      // now try the last PUT which should result in the queue being flushed.
      expect(mockRpcManager.getMembers()).andReturn(originalRpcManager.getMembers()).anyTimes();
      expect(mockRpcManager.callRemoteMethods((Vector<Address>) anyObject(), (ReplicableCommand) anyObject(), anyBoolean(), anyLong(), anyBoolean())).andReturn(Collections.emptyList()).anyTimes();
      replay(mockRpcManager);

      cache.put("/a/b/c/LAST", "k", "v");
      assert replQ.elements.size() == 0;
View Full Code Here

Examples of org.jboss.cache.RPCManager

      assert totalInvocations % COUNT == 0 : "NumThreads and NumLoopsPerThread must multiply to be a multiple of COUNT";

      final CountDownLatch latch = new CountDownLatch(1);

      // mock the RPCManager used in the cache
      RPCManager mockRpcManager = EasyMock.createStrictMock(RPCManager.class);
      injectRpcManager(mockRpcManager);

      // expect basic cluster related calls
      expect(mockRpcManager.getMembers()).andReturn(originalRpcManager.getMembers()).anyTimes();
      expect(mockRpcManager.callRemoteMethods((Vector<Address>) anyObject(), (ReplicableCommand) anyObject(), anyBoolean(), anyLong(), anyBoolean())).andReturn(Collections.emptyList()).anyTimes();
      replay(mockRpcManager);

      Thread[] threads = new Thread[numThreads];

      for (int i = 0; i < numThreads; i++)
View Full Code Here

Examples of org.jboss.cache.RPCManager

   public void testOOBFlag() throws Exception
   {
      DelegatingRPCManager delegatingRPCManager = new DelegatingRPCManager();
      ComponentRegistry cr = TestingUtil.extractComponentRegistry(c1);
      RPCManager origRpcManager = cr.getComponent(RPCManager.class);
      delegatingRPCManager.delegate = origRpcManager;
      cr.registerComponent(delegatingRPCManager, RPCManager.class);
      cr.rewire();

      c1.getTransactionManager().begin();
View Full Code Here

Examples of org.jboss.cache.RPCManager

      long startTime = System.currentTimeMillis();
      log.warn("Starting cache");
      cache.start();
      // now remove the existing RpcDispatcher and replace with one that is a noop.
      ComponentRegistry cr = TestingUtil.extractComponentRegistry(cache);
      RPCManager rpcManager = cr.getComponent(RPCManager.class);
      RpcDispatcher d = (RpcDispatcher) TestingUtil.extractField(rpcManager, "rpcDispatcher");
      d.stop();
      RpcDispatcher replacement = new NoopDispatcher();
      replacement.setRequestMarshaller(d.getRequestMarshaller());
      replacement.setResponseMarshaller(d.getResponseMarshaller());
View Full Code Here

Examples of org.jboss.cache.RPCManager

    * Builds a listener that will observe the given cache for recieving replication commands.
    */
   public ReplicationListener(Cache cache)
   {
      ComponentRegistry componentRegistry = TestingUtil.extractComponentRegistry(cache);
      RPCManager rpcManager = componentRegistry.getComponent(RPCManager.class);
      CommandAwareRpcDispatcher realDispatcher = (CommandAwareRpcDispatcher) TestingUtil.extractField(rpcManager, "rpcDispatcher");
      RpcDispatcher.Marshaller2 realMarshaller = (RpcDispatcher.Marshaller2) realDispatcher.getMarshaller();
      RpcDispatcher.Marshaller2 delegate = null;
      if (realDispatcher instanceof InactiveRegionAwareRpcDispatcher)
         delegate = new RegionMarshallerDelegate((Marshaller) realMarshaller);
View Full Code Here

Examples of org.jboss.cache.RPCManager

   }

   public void testAsyncForce() throws Exception
   {
      PutForExternalReadTestBaseTL tl = threadLocal.get();
      RPCManager rpcManager = EasyMock.createNiceMock(RPCManager.class);
      RPCManager originalRpcManager = tl.cache1.getConfiguration().getRuntimeConfig().getRPCManager();
      List<Address> memberList = originalRpcManager.getMembers();
      expect(rpcManager.getMembers()).andReturn(memberList).anyTimes();
      // inject a mock RPC manager so that we can test whether calls made are sync or async.
      ComponentRegistry cr = TestingUtil.extractComponentRegistry(tl.cache1);
      cr.registerComponent(rpcManager, RPCManager.class);
      cr.rewire();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.