Examples of PutFromLoadValidator


Examples of org.hibernate.cache.infinispan.access.PutFromLoadValidator

      final TransactionManager remoteTm = remoteCollectionRegion.getTransactionManager();
      withCacheManager(new CacheManagerCallable(
            TestCacheManagerFactory.createLocalCacheManager(false)) {
         @Override
         public void call() {
            PutFromLoadValidator validator = new PutFromLoadValidator(
                  cm, remoteTm, 20000) {
               @Override
               public boolean acquirePutFromLoadLock(Object key) {
                  boolean acquired = super.acquirePutFromLoadLock(key);
                  try {
View Full Code Here

Examples of org.hibernate.cache.jbc.access.PutFromLoadValidator

    protected Fqn<String> createRegionFqn(String regionName, String regionPrefix) {
        return getTypeLastRegionFqn(regionName, regionPrefix, TYPE);
    }
   
    public PutFromLoadValidator getPutFromLoadValidator() {
       return new PutFromLoadValidator(transactionManager);
    }
View Full Code Here

Examples of org.hibernate.cache.jbc.access.PutFromLoadValidator

    protected Fqn<String> createRegionFqn(String regionName, String regionPrefix) {
        return getTypeLastRegionFqn(regionName, regionPrefix, TYPE);
    }
   
    public PutFromLoadValidator getPutFromLoadValidator() {
       return new PutFromLoadValidator(transactionManager);
    }
View Full Code Here

Examples of org.hibernate.cache.jbc.access.PutFromLoadValidator

  public void testNakedPutTransactional() throws Exception {
    nakedPutTest(true);
  }

  private void nakedPutTest(boolean transactional) throws Exception {
    PutFromLoadValidator testee = new PutFromLoadValidator(
        transactional ? tm : null);
    if (transactional) {
      tm.begin();
    }
   
    boolean lockable = testee.acquirePutFromLoadLock(KEY1);
    try {
      assertTrue(lockable);
    }
    finally {
      if (lockable) {
        testee.releasePutFromLoadLock(KEY1);
      }
    }
  }
View Full Code Here

Examples of org.hibernate.cache.jbc.access.PutFromLoadValidator

  public void testRegisteredPutTransactional() throws Exception {
    registeredPutTest(true);
  }

  private void registeredPutTest(boolean transactional) throws Exception {
    PutFromLoadValidator testee = new PutFromLoadValidator(
        transactional ? tm : null);
    if (transactional) {
      tm.begin();
    }
    testee.registerPendingPut(KEY1);
   
    boolean lockable = testee.acquirePutFromLoadLock(KEY1);
    try {
      assertTrue(lockable);
    }
    finally {
      if (lockable) {
        testee.releasePutFromLoadLock(KEY1);
      }
    }
  }
View Full Code Here

Examples of org.hibernate.cache.jbc.access.PutFromLoadValidator

    nakedPutAfterRemovalTest(true, true);
  }

  private void nakedPutAfterRemovalTest(boolean transactional,
      boolean removeRegion) throws Exception {
    PutFromLoadValidator testee = new PutFromLoadValidator(
        transactional ? tm : null);
    if (removeRegion) {
      testee.invalidateRegion();
    } else {
      testee.invalidateKey(KEY1);
    }
    if (transactional) {
      tm.begin();
    }
   
    boolean lockable = testee.acquirePutFromLoadLock(KEY1);
    try {
      assertFalse(lockable);
    }
    finally {
      if (lockable) {
        testee.releasePutFromLoadLock(KEY1);
      }
    }

  }
View Full Code Here

Examples of org.hibernate.cache.jbc.access.PutFromLoadValidator

    registeredPutAfterRemovalTest(true, true);
  }

  private void registeredPutAfterRemovalTest(boolean transactional,
      boolean removeRegion) throws Exception {
    PutFromLoadValidator testee = new PutFromLoadValidator(
        transactional ? tm : null);
    if (removeRegion) {
      testee.invalidateRegion();
    } else {
      testee.invalidateKey(KEY1);
    }
    if (transactional) {
      tm.begin();
    }
    testee.registerPendingPut(KEY1);
   
    boolean lockable = testee.acquirePutFromLoadLock(KEY1);
    try {
      assertTrue(lockable);
    }
    finally {
      if (lockable) {
        testee.releasePutFromLoadLock(KEY1);
      }
    }
  }
View Full Code Here

Examples of org.hibernate.cache.jbc.access.PutFromLoadValidator

    registeredPutWithInterveningRemovalTest(true, true);
  }

  private void registeredPutWithInterveningRemovalTest(boolean transactional,
      boolean removeRegion) throws Exception {
    PutFromLoadValidator testee = new PutFromLoadValidator(
        transactional ? tm : null);
    if (transactional) {
      tm.begin();
    }
    testee.registerPendingPut(KEY1);
    if (removeRegion) {
      testee.invalidateRegion();
    } else {
      testee.invalidateKey(KEY1);
    }
   
    boolean lockable = testee.acquirePutFromLoadLock(KEY1);
    try {
      assertFalse(lockable);
    }
    finally {
      if (lockable) {
        testee.releasePutFromLoadLock(KEY1);
      }
    }
  }
View Full Code Here

Examples of org.hibernate.cache.jbc.access.PutFromLoadValidator

    delayedNakedPutAfterRemovalTest(true, true);
  }

  private void delayedNakedPutAfterRemovalTest(boolean transactional,
      boolean removeRegion) throws Exception {
    PutFromLoadValidator testee = new TestValidator(transactional ? tm
        : null, 100, 1000, 500, 10000);
    if (removeRegion) {
      testee.invalidateRegion();
    } else {
      testee.invalidateKey(KEY1);
    }
    if (transactional) {
      tm.begin();
    }
    Thread.sleep(110);
   
    boolean lockable = testee.acquirePutFromLoadLock(KEY1);
    try {
      assertTrue(lockable);
    }
    finally {
      if (lockable) {
        testee.releasePutFromLoadLock(KEY1);
      }
    }

  }
View Full Code Here

Examples of org.hibernate.cache.jbc.access.PutFromLoadValidator

  public void testMultipleRegistrationsTransactional() throws Exception {
    multipleRegistrationtest(true);
  }

  private void multipleRegistrationtest(final boolean transactional) throws Exception {
    final PutFromLoadValidator testee = new PutFromLoadValidator(transactional ? tm : null);
   
    final CountDownLatch registeredLatch = new CountDownLatch(3);
    final CountDownLatch finishedLatch = new CountDownLatch(3);
    final AtomicInteger success = new AtomicInteger();
   
    Runnable r = new Runnable() {
      public void run() {
        try {
          if (transactional) {
            tm.begin();
          }
          testee.registerPendingPut(KEY1);
          registeredLatch.countDown();
          registeredLatch.await(5, TimeUnit.SECONDS);
          if (testee.acquirePutFromLoadLock(KEY1)) {
            try {
              success.incrementAndGet();
            }
            finally {
              testee.releasePutFromLoadLock(KEY1);
            }
          }
          finishedLatch.countDown();
        }
        catch (Exception e)  {
          e.printStackTrace();
        }
      }
    };
   
    ExecutorService executor = Executors.newFixedThreadPool(3);
   
    // Start with a removal so the "isPutValid" calls will fail if
    // any of the concurrent activity isn't handled properly
   
    testee.invalidateRegion();
   
    // Do the registration + isPutValid calls
    executor.execute(r);
    executor.execute(r);
    executor.execute(r);
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.