Package org.jboss.cache

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


      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

   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

      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

   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

      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

    * 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

   }

   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

   }

   public void testExceptionSuppression() throws Exception
   {
      PutForExternalReadTestBaseTL tl = threadLocal.get();
      RPCManager barfingRpcManager = EasyMock.createNiceMock(RPCManager.class);
      RPCManager originalRpcManager = tl.cache1.getConfiguration().getRuntimeConfig().getRPCManager();
      try
      {
         List<Address> memberList = originalRpcManager.getMembers();
         expect(barfingRpcManager.getMembers()).andReturn(memberList).anyTimes();
         expect(barfingRpcManager.getLocalAddress()).andReturn(originalRpcManager.getLocalAddress()).anyTimes();
         expect(barfingRpcManager.callRemoteMethods(anyAddresses(), (ReplicableCommand) anyObject(), anyBoolean(), anyLong(), anyBoolean())).andThrow(new RuntimeException("Barf!")).anyTimes();
         replay(barfingRpcManager);

         TestingUtil.extractComponentRegistry(tl.cache1).registerComponent(barfingRpcManager, RPCManager.class);
         tl.cache1.getConfiguration().getRuntimeConfig().setRPCManager(barfingRpcManager);
View Full Code Here

    * @throws Exception
    */
   private void cacheModeLocalTest(boolean transactional) throws Exception
   {
      PutForExternalReadTestBaseTL tl = threadLocal.get();
      RPCManager rpcManager = EasyMock.createMock(RPCManager.class);
      RPCManager originalRpcManager = tl.cache1.getConfiguration().getRuntimeConfig().getRPCManager();

      // inject a mock RPC manager so that we can test whether calls made are sync or async.
      tl.cache1.getConfiguration().getRuntimeConfig().setRPCManager(rpcManager);

      // specify that we expect nothing will be called on the mock Rpc Manager.
View Full Code Here

TOP

Related Classes of org.jboss.cache.RPCManager

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.