com.gemstone.gemfire.cache.GemFireCache Java Examples

The following examples show how to use com.gemstone.gemfire.cache.GemFireCache. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ParRegUtil.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public static void doRebalance(GemFireCache cache) {
   ResourceManager resMan = cache.getResourceManager();
   boolean heapEviction = (resMan.getEvictionHeapPercentage() > 0);
   RebalanceFactory factory = resMan.createRebalanceFactory();
   try {
      RebalanceResults simulateResults = null;
      if (!heapEviction) {  
         Log.getLogWriter().info("Calling rebalance simulate");
         RebalanceOperation simulateOp = factory.simulate();
         simulateResults = simulateOp.getResults(); 
         Log.getLogWriter().info(RebalanceUtil.RebalanceResultsToString(simulateResults, "Simulate"));
      }

      Log.getLogWriter().info("Starting rebalancing");
      RebalanceOperation rebalanceOp = factory.start();
      RebalanceResults rebalanceResults = rebalanceOp.getResults();
      Log.getLogWriter().info(RebalanceUtil.RebalanceResultsToString(rebalanceResults, "Rebalance"));

      if (!(heapEviction || (ConfigPrms.getHadoopConfig() != null))) {
        RebalanceUtil.isBalanceImproved(rebalanceResults); // this throws an exception if not improved
        RebalanceUtil.checkSimulateAgainstRebalance(simulateResults, rebalanceResults);
      }
   } catch (InterruptedException e) {
      throw new TestException(TestHelper.getStackTrace(e));
   }
}
 
Example #2
Source File: ParRegUtil.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public synchronized static void HydraTask_recreateBucketsFromHDFS(GemFireCache cache) {
   Set<Region<?,?>> regSet = cache.rootRegions();
   Integer thisVmId = RemoteTestModule.getMyVmid();
   Iterator it = regSet.iterator();
   while (it.hasNext()) {
      Region aRegion = (Region)(it.next());
      PartitionAttributes prAttr = aRegion.getAttributes().getPartitionAttributes();
      if (prAttr != null) { // is a partitioned region
         if (prAttr.getLocalMaxMemory() != 0) { // is a data store, not an accessor
           Set keys = aRegion.keySet();
           Log.getLogWriter().info("after aRegion.keySet() recreateBucketsFromHDFS found keySet size = " + keys.size() + " with region.size() = " + aRegion.size() + " for " + aRegion.getFullPath());
           for (Iterator kit = keys.iterator(); kit.hasNext(); ) {
              Object key = kit.next();
              aRegion.get(key);
           }
           Log.getLogWriter().info("iterating aRegion.keySet() recreateBucketsFromHDFS found keySet size = " + keys.size() + " with region.size() = " + aRegion.size() + " for " + aRegion.getFullPath());
         }
      }
   }
}
 
Example #3
Source File: ParRegUtil.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public static void doRebalance(GemFireCache cache) {
   ResourceManager resMan = cache.getResourceManager();
   boolean heapEviction = (resMan.getEvictionHeapPercentage() > 0);
   RebalanceFactory factory = resMan.createRebalanceFactory();
   try {
      RebalanceResults simulateResults = null;
      if (!heapEviction) {  
         Log.getLogWriter().info("Calling rebalance simulate");
         RebalanceOperation simulateOp = factory.simulate();
         simulateResults = simulateOp.getResults(); 
         Log.getLogWriter().info(RebalanceUtil.RebalanceResultsToString(simulateResults, "Simulate"));
      }

      Log.getLogWriter().info("Starting rebalancing");
      RebalanceOperation rebalanceOp = factory.start();
      RebalanceResults rebalanceResults = rebalanceOp.getResults();
      Log.getLogWriter().info(RebalanceUtil.RebalanceResultsToString(rebalanceResults, "Rebalance"));

      if (!(heapEviction || (ConfigPrms.getHadoopConfig() != null))) {
        RebalanceUtil.isBalanceImproved(rebalanceResults); // this throws an exception if not improved
        RebalanceUtil.checkSimulateAgainstRebalance(simulateResults, rebalanceResults);
      }
   } catch (InterruptedException e) {
      throw new TestException(TestHelper.getStackTrace(e));
   }
}
 
Example #4
Source File: ParRegUtil.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public synchronized static void HydraTask_recreateBucketsFromHDFS(GemFireCache cache) {
   Set<Region<?,?>> regSet = cache.rootRegions();
   Integer thisVmId = RemoteTestModule.getMyVmid();
   Iterator it = regSet.iterator();
   while (it.hasNext()) {
      Region aRegion = (Region)(it.next());
      PartitionAttributes prAttr = aRegion.getAttributes().getPartitionAttributes();
      if (prAttr != null) { // is a partitioned region
         if (prAttr.getLocalMaxMemory() != 0) { // is a data store, not an accessor
           Set keys = aRegion.keySet();
           Log.getLogWriter().info("after aRegion.keySet() recreateBucketsFromHDFS found keySet size = " + keys.size() + " with region.size() = " + aRegion.size() + " for " + aRegion.getFullPath());
           for (Iterator kit = keys.iterator(); kit.hasNext(); ) {
              Object key = kit.next();
              aRegion.get(key);
           }
           Log.getLogWriter().info("iterating aRegion.keySet() recreateBucketsFromHDFS found keySet size = " + keys.size() + " with region.size() = " + aRegion.size() + " for " + aRegion.getFullPath());
         }
      }
   }
}
 
Example #5
Source File: ParRegUtil.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public synchronized static void HydraTask_waitForRecovery(GemFireCache cache) {
   Set<Region<?,?>> regSet = cache.rootRegions();
   Integer thisVmId = RemoteTestModule.getMyVmid();
   List prNames = new ArrayList();
   Iterator it = regSet.iterator();
   int numColocatedRegions = 0;
   while (it.hasNext()) {
      Region aRegion = (Region)(it.next());
      PartitionAttributes prAttr = aRegion.getAttributes().getPartitionAttributes();
      if (prAttr != null) { // is a partitioned region
         if (prAttr.getLocalMaxMemory() != 0) { // is a data store, not an acessor
            if (prAttr.getRedundantCopies() != 0) { // this PR has redundant copies to recover
               prNames.add(aRegion.getFullPath());
            }
            if (prAttr.getColocatedWith() != null) {
               numColocatedRegions++;
            }
         }
      }
   }
   if (prNames.size() != 0) {
      if (ConfigPrms.getHadoopConfig() != null) {
         int numPRs = (prNames.size() * 2) - numColocatedRegions;
         PRObserver.waitForRebalRecov(thisVmId, 1, numPRs, null, null, false);
      } else {
         PRObserver.waitForRebalRecov(thisVmId, 1, prNames.size(), prNames, null, false);
      }
   } else {
      Log.getLogWriter().info("No recovery to wait for; there are no data store PRs in this vm");
   }
}
 
Example #6
Source File: ServerLocator.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public void restarting(DistributedSystem ds, GemFireCache cache) {
  if (ds != null) {
    this.loadSnapshot = new LocatorLoadSnapshot();
    this.ds = (InternalDistributedSystem)ds;
    this.advisor = ControllerAdvisor.createControllerAdvisor(this); // escapes constructor but allows field to be final
  }
}
 
Example #7
Source File: InternalLocator.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public void restarting(DistributedSystem ds, GemFireCache cache) {
  if (ds != null) {
    this.logger = ds.getLogWriter().convertToLogWriterI18n();
    for (TcpHandler handler: this.allHandlers) {
      handler.restarting(ds, cache);
    }
  }
}
 
Example #8
Source File: SecurityTestUtils.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public static void checkForDistUser(final Properties props,
    final String sharedSchemaName, final int privileges,
    final boolean readOnlyConnection) {
  try {
    checkDistUser(props, sharedSchemaName, privileges, readOnlyConnection);
  } catch (SQLException e) {
    e.printStackTrace();
    GemFireCache cache = Misc.getGemFireCacheNoThrow();
    throw GemFireXDRuntimeException.newRuntimeException("Check Exception in "
        + (cache != null ? cache.getDistributedSystem()
            .getDistributedMember() : "cache is null"), e);
  }
}
 
Example #9
Source File: SecurityTestUtils.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public static void checkForDistUser(final Properties props,
    final String sharedSchemaName, final int privileges,
    final boolean readOnlyConnection) {
  try {
    checkDistUser(props, sharedSchemaName, privileges, readOnlyConnection);
  } catch (SQLException e) {
    e.printStackTrace();
    GemFireCache cache = Misc.getGemFireCacheNoThrow();
    throw GemFireXDRuntimeException.newRuntimeException("Check Exception in "
        + (cache != null ? cache.getDistributedSystem()
            .getDistributedMember() : "cache is null"), e);
  }
}
 
Example #10
Source File: DurableClientsTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/** 
 * Utility method to create the cache or client cache (depending on 
 * test configuration).
 */
public static GemFireCache createCache () {
  GemFireCache cache = null;
  if (useClientCache) {
    cache = ClientCacheHelper.createCache(ConfigPrms.getClientCacheConfig());
  } else {
    cache = CacheHelper.createCache(ConfigPrms.getCacheConfig());
  }
  return cache;
}
 
Example #11
Source File: DurableClientsTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Utility method to get either the Cache or ClientCache (depending on 
 * test configuration).
 */
public static GemFireCache getCache() {
    GemFireCache cache = null;
    if (useClientCache) {
      cache = ClientCacheHelper.getCache();
    } else {
      cache = CacheHelper.getCache();
    }
    return cache;
 }
 
Example #12
Source File: DurableClientsTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Initializes the test region in the cache client VM and registers a CQ
 */
public static void initCQClient() {
  synchronized (HAClientQueue.class) {
    if (getCache() == null) {
      // create the cache and region
      GemFireCache cache = createCache();

      // init CQ Service
      CQUtil.initialize();
      CQUtil.initializeCQService(useClientCache); 

      int numOfRegion = TestConfig.tab().intAt(
          durableClients.DurableClientsPrms.numberOfRegions, 1);
      for (int i = 0; i < numOfRegion; i++) {
        Region region = createRegion(REGION_NAME + i);
        PoolImpl mybw = ClientHelper.getPool(region);
        myPool = mybw;
        Log.getLogWriter().info(
            "The primary server endpoint is " + mybw.getPrimaryName());
        String VmDurableId = ((InternalDistributedSystem)InternalDistributedSystem
            .getAnyInstance()).getConfig().getDurableClientId();
        Log.getLogWriter().info(" VM Durable Client Id is " + VmDurableId);
        if (!DurableClientsBB.getBB().getSharedMap().containsKey(VmDurableId)) {
          HashMap map = new HashMap();
          DurableClientsBB.getBB().getSharedMap().put(VmDurableId, map);
        }
        Log.getLogWriter().info("Doing durable cq register");
        CQUtil.registerDurableCQ(region);
      }
      readyForEvents();
    }
  }
}
 
Example #13
Source File: DurableClientsTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Initializes the client caches and the regions
 * 
 */

public static void initCacheClient() {
  synchronized (DurableClientsTest.class) {
    if (getCache() == null) {  // first thread
      // create the cache and region
      GemFireCache cache = createCache();

      int numOfRegion = TestConfig.tab().intAt(
          durableClients.DurableClientsPrms.numberOfRegions, 1);
      for (int i = 0; i < numOfRegion; i++) {
        Region region = createRegion(REGION_NAME + i);
        PoolImpl mybw = ClientHelper.getPool(region);
        DurableClientsTest.myPool = mybw;
        Log.getLogWriter().info(
            "The primary server endpoint is " + mybw.getPrimaryName());

        String VmDurableId = ((InternalDistributedSystem)InternalDistributedSystem
            .getAnyInstance()).getConfig().getDurableClientId();
        Log.getLogWriter().info(" VM Durable Client Id is " + VmDurableId);
        if (!DurableClientsBB.getBB().getSharedMap().containsKey(VmDurableId)) {
          HashMap map = new HashMap();
          DurableClientsBB.getBB().getSharedMap().put(VmDurableId, map);
        }
      }
      // client sending the ready message
      readyForEvents();
    }
  }

}
 
Example #14
Source File: ParRegUtil.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public synchronized static void HydraTask_waitForRecovery(GemFireCache cache) {
   Set<Region<?,?>> regSet = cache.rootRegions();
   Integer thisVmId = RemoteTestModule.getMyVmid();
   List prNames = new ArrayList();
   Iterator it = regSet.iterator();
   int numColocatedRegions = 0;
   while (it.hasNext()) {
      Region aRegion = (Region)(it.next());
      PartitionAttributes prAttr = aRegion.getAttributes().getPartitionAttributes();
      if (prAttr != null) { // is a partitioned region
         if (prAttr.getLocalMaxMemory() != 0) { // is a data store, not an acessor
            if (prAttr.getRedundantCopies() != 0) { // this PR has redundant copies to recover
               prNames.add(aRegion.getFullPath());
            }
            if (prAttr.getColocatedWith() != null) {
               numColocatedRegions++;
            }
         }
      }
   }
   if (prNames.size() != 0) {
      if (ConfigPrms.getHadoopConfig() != null) {
         int numPRs = (prNames.size() * 2) - numColocatedRegions;
         PRObserver.waitForRebalRecov(thisVmId, 1, numPRs, null, null, false);
      } else {
         PRObserver.waitForRebalRecov(thisVmId, 1, prNames.size(), prNames, null, false);
      }
   } else {
      Log.getLogWriter().info("No recovery to wait for; there are no data store PRs in this vm");
   }
}
 
Example #15
Source File: DurableClientsTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Initializes the client caches and the regions
 * 
 */

public static void initCacheClient() {
  synchronized (DurableClientsTest.class) {
    if (getCache() == null) {  // first thread
      // create the cache and region
      GemFireCache cache = createCache();

      int numOfRegion = TestConfig.tab().intAt(
          durableClients.DurableClientsPrms.numberOfRegions, 1);
      for (int i = 0; i < numOfRegion; i++) {
        Region region = createRegion(REGION_NAME + i);
        PoolImpl mybw = ClientHelper.getPool(region);
        DurableClientsTest.myPool = mybw;
        Log.getLogWriter().info(
            "The primary server endpoint is " + mybw.getPrimaryName());

        String VmDurableId = ((InternalDistributedSystem)InternalDistributedSystem
            .getAnyInstance()).getConfig().getDurableClientId();
        Log.getLogWriter().info(" VM Durable Client Id is " + VmDurableId);
        if (!DurableClientsBB.getBB().getSharedMap().containsKey(VmDurableId)) {
          HashMap map = new HashMap();
          DurableClientsBB.getBB().getSharedMap().put(VmDurableId, map);
        }
      }
      // client sending the ready message
      readyForEvents();
    }
  }

}
 
Example #16
Source File: DurableClientsTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Initializes the test region in the cache client VM and registers a CQ
 */
public static void initCQClient() {
  synchronized (HAClientQueue.class) {
    if (getCache() == null) {
      // create the cache and region
      GemFireCache cache = createCache();

      // init CQ Service
      CQUtil.initialize();
      CQUtil.initializeCQService(useClientCache); 

      int numOfRegion = TestConfig.tab().intAt(
          durableClients.DurableClientsPrms.numberOfRegions, 1);
      for (int i = 0; i < numOfRegion; i++) {
        Region region = createRegion(REGION_NAME + i);
        PoolImpl mybw = ClientHelper.getPool(region);
        myPool = mybw;
        Log.getLogWriter().info(
            "The primary server endpoint is " + mybw.getPrimaryName());
        String VmDurableId = ((InternalDistributedSystem)InternalDistributedSystem
            .getAnyInstance()).getConfig().getDurableClientId();
        Log.getLogWriter().info(" VM Durable Client Id is " + VmDurableId);
        if (!DurableClientsBB.getBB().getSharedMap().containsKey(VmDurableId)) {
          HashMap map = new HashMap();
          DurableClientsBB.getBB().getSharedMap().put(VmDurableId, map);
        }
        Log.getLogWriter().info("Doing durable cq register");
        CQUtil.registerDurableCQ(region);
      }
      readyForEvents();
    }
  }
}
 
Example #17
Source File: DurableClientsTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Utility method to get either the Cache or ClientCache (depending on 
 * test configuration).
 */
public static GemFireCache getCache() {
    GemFireCache cache = null;
    if (useClientCache) {
      cache = ClientCacheHelper.getCache();
    } else {
      cache = CacheHelper.getCache();
    }
    return cache;
 }
 
Example #18
Source File: ServerLocator.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public void restarting(DistributedSystem ds, GemFireCache cache) {
  if (ds != null) {
    this.loadSnapshot = new LocatorLoadSnapshot();
    this.ds = (InternalDistributedSystem)ds;
    this.advisor = ControllerAdvisor.createControllerAdvisor(this); // escapes constructor but allows field to be final
  }
}
 
Example #19
Source File: InternalLocator.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public void restarting(DistributedSystem ds, GemFireCache cache) {
  if (ds != null) {
    this.logger = ds.getLogWriter().convertToLogWriterI18n();
    for (TcpHandler handler: this.allHandlers) {
      handler.restarting(ds, cache);
    }
  }
}
 
Example #20
Source File: DurableClientsTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/** 
 * Utility method to create the cache or client cache (depending on 
 * test configuration).
 */
public static GemFireCache createCache () {
  GemFireCache cache = null;
  if (useClientCache) {
    cache = ClientCacheHelper.createCache(ConfigPrms.getClientCacheConfig());
  } else {
    cache = CacheHelper.createCache(ConfigPrms.getCacheConfig());
  }
  return cache;
}
 
Example #21
Source File: GemfireConfiguration.java    From tutorials with MIT License 5 votes vote down vote up
@Bean(name="employee")
@Autowired
LocalRegionFactoryBean<String, Employee> getEmployee(final GemFireCache cache) {
    LocalRegionFactoryBean<String, Employee> employeeRegion = new LocalRegionFactoryBean<String, Employee>();
    employeeRegion.setCache(cache);
    employeeRegion.setClose(false);
    employeeRegion.setName("employee");
    employeeRegion.setPersistent(false);
    employeeRegion.setDataPolicy(DataPolicy.PRELOADED);
    return employeeRegion;
}
 
Example #22
Source File: GemfireCacheConfig.java    From spring4-sandbox with Apache License 2.0 5 votes vote down vote up
@Bean
LocalRegionFactoryBean<String, Conference> localRegionFactory(final GemFireCache cache) {
	return new LocalRegionFactoryBean<String, Conference>() {{
		setCache(cache);
		setName("conference");
	}};
}
 
Example #23
Source File: JmxManagerLocator.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
public void restarting(DistributedSystem ds, GemFireCache cache) {
  this.cache = (GemFireCacheImpl)cache;
}
 
Example #24
Source File: CQTest.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
/** Do random operations and verification for concurrent tests.
 *  The task starts up and all threads concurrently do random
 *  operations. The operations run for maxTaskGranularitySec or
 *  numOpsPerTask, depending the on the defined hydra parameters, 
 *  then all threads will pause. During the pause, one thread goes
 *  first and writes the regionSnapshot to the blackboard. Then
 *  all other client threads read the blackboard and verify the
 *  state of the cqs they have registered. After all threads are 
 *  done with verification, the task ends.
 */
protected void doConcOpsAndVerify() {
   PdxTest.initClassLoader();
   // wait for all threads to be ready to do this task, then do random ops
   long counter = CQUtilBB.getBB().getSharedCounters().incrementAndRead(CQUtilBB.ReadyToBegin);
   if (counter == 1) {
      logExecutionNumber();
   }
   concVerifyCoordinator = new MethodCoordinator(CQTest.class.getName(), "concVerify");
   CQUtilBB.getBB().getSharedCounters().zero(CQUtilBB.ConcurrentLeader);
   TestHelper.waitForCounter(CQUtilBB.getBB(), 
                             "CQUtilBB.ReadyToBegin", 
                             CQUtilBB.ReadyToBegin, 
                             numThreadsInClients, 
                             true, 
                             -1,
                             1000);
   checkForLastIteration();

   Log.getLogWriter().info("Zeroing ShapshotWritten");
   CQUtilBB.getBB().getSharedCounters().zero(CQUtilBB.SnapshotWritten);

   // do random operations 
   doEntryOperations(aRegion);
    
   // versioning allows testing with ClientCacheFactory
   GemFireCache cache = versionHelperInstance.getCache();
   RebalanceFactory factory = cache.getResourceManager().createRebalanceFactory();
   RebalanceOperation rop = factory.start();
   RebalanceResults results = null;
   try {
      results = rop.getResults();
   } catch (InterruptedException e) {
      throw new TestException(TestHelper.getStackTrace(e));
   }

   Log.getLogWriter().info(RebalanceUtil.RebalanceResultsToString(results, "rebalance"));

   // wait for all threads to pause, then do the verify
   Log.getLogWriter().info("Zeroing FinishedVerify");
   CQUtilBB.getBB().getSharedCounters().zero(CQUtilBB.FinishedVerify);
   CQUtilBB.getBB().getSharedCounters().increment(CQUtilBB.Pausing);
   TestHelper.waitForCounter(CQUtilBB.getBB(), 
                             "CQUtilBB.Pausing", 
                             CQUtilBB.Pausing, 
                             numThreadsInClients, 
                             true, 
                             -1,
                             5000);
   Log.getLogWriter().info("Zeroing ReadyToBegin");
   CQUtilBB.getBB().getSharedCounters().zero(CQUtilBB.ReadyToBegin);

   // in a bridge configuration, wait for the message queues to finish pushing
   // to the clients
   if (isBridgeConfiguration) {
      // wait for 30 seconds of client silence
      SilenceListener.waitForSilence(30, 5000);
   }

   // do verification
   concVerifyCoordinator.executeOnce(this, new Object[0]);
   if (!concVerifyCoordinator.methodWasExecuted()) {
      throw new TestException("Test problem: concVerify did not execute");
   }
   CQUtilBB.getBB().getSharedCounters().increment(CQUtilBB.FinishedVerify);

   // wait for everybody to finish verify, then exit
   TestHelper.waitForCounter(CQUtilBB.getBB(), 
                             "CQUtilBB.FinishedVerify", 
                             CQUtilBB.FinishedVerify, 
                             numThreadsInClients,
                             true, 
                             -1,
                             5000);
   Log.getLogWriter().info("Zeroing Pausing");
   CQUtilBB.getBB().getSharedCounters().zero(CQUtilBB.Pausing);

   counter = CQUtilBB.getBB().getSharedCounters().read(CQUtilBB.TimeToStop);
   if (counter >= 1)
      throw new StopSchedulingOrder("Num executions is " + 
            CQUtilBB.getBB().getSharedCounters().read(CQUtilBB.ExecutionNumber));
}
 
Example #25
Source File: LocatorImpl.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
public void restarting(DistributedSystem ds, GemFireCache cache) {
}
 
Example #26
Source File: HDFSRegionDirector.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
public GemFireCache getCache() {
  return this.cache;
}
 
Example #27
Source File: HDFSRegionDirector.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
public HDFSRegionDirector setCache(GemFireCache cache) {
  this.cache = cache;
  return this;
}
 
Example #28
Source File: CQTest.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
/** Do random operations and verification for concurrent tests.
 *  The task starts up and all threads concurrently do random
 *  operations. The operations run for maxTaskGranularitySec or
 *  numOpsPerTask, depending the on the defined hydra parameters, 
 *  then all threads will pause. During the pause, one thread goes
 *  first and writes the regionSnapshot to the blackboard. Then
 *  all other client threads read the blackboard and verify the
 *  state of the cqs they have registered. After all threads are 
 *  done with verification, the task ends.
 */
protected void doConcOpsAndVerify() {
   PdxTest.initClassLoader();
   // wait for all threads to be ready to do this task, then do random ops
   long counter = CQUtilBB.getBB().getSharedCounters().incrementAndRead(CQUtilBB.ReadyToBegin);
   if (counter == 1) {
      logExecutionNumber();
   }
   concVerifyCoordinator = new MethodCoordinator(CQTest.class.getName(), "concVerify");
   CQUtilBB.getBB().getSharedCounters().zero(CQUtilBB.ConcurrentLeader);
   TestHelper.waitForCounter(CQUtilBB.getBB(), 
                             "CQUtilBB.ReadyToBegin", 
                             CQUtilBB.ReadyToBegin, 
                             numThreadsInClients, 
                             true, 
                             -1,
                             1000);
   checkForLastIteration();

   Log.getLogWriter().info("Zeroing ShapshotWritten");
   CQUtilBB.getBB().getSharedCounters().zero(CQUtilBB.SnapshotWritten);

   // do random operations 
   doEntryOperations(aRegion);
    
   // versioning allows testing with ClientCacheFactory
   GemFireCache cache = versionHelperInstance.getCache();
   RebalanceFactory factory = cache.getResourceManager().createRebalanceFactory();
   RebalanceOperation rop = factory.start();
   RebalanceResults results = null;
   try {
      results = rop.getResults();
   } catch (InterruptedException e) {
      throw new TestException(TestHelper.getStackTrace(e));
   }

   Log.getLogWriter().info(RebalanceUtil.RebalanceResultsToString(results, "rebalance"));

   // wait for all threads to pause, then do the verify
   Log.getLogWriter().info("Zeroing FinishedVerify");
   CQUtilBB.getBB().getSharedCounters().zero(CQUtilBB.FinishedVerify);
   CQUtilBB.getBB().getSharedCounters().increment(CQUtilBB.Pausing);
   TestHelper.waitForCounter(CQUtilBB.getBB(), 
                             "CQUtilBB.Pausing", 
                             CQUtilBB.Pausing, 
                             numThreadsInClients, 
                             true, 
                             -1,
                             5000);
   Log.getLogWriter().info("Zeroing ReadyToBegin");
   CQUtilBB.getBB().getSharedCounters().zero(CQUtilBB.ReadyToBegin);

   // in a bridge configuration, wait for the message queues to finish pushing
   // to the clients
   if (isBridgeConfiguration) {
      // wait for 30 seconds of client silence
      SilenceListener.waitForSilence(30, 5000);
   }

   // do verification
   concVerifyCoordinator.executeOnce(this, new Object[0]);
   if (!concVerifyCoordinator.methodWasExecuted()) {
      throw new TestException("Test problem: concVerify did not execute");
   }
   CQUtilBB.getBB().getSharedCounters().increment(CQUtilBB.FinishedVerify);

   // wait for everybody to finish verify, then exit
   TestHelper.waitForCounter(CQUtilBB.getBB(), 
                             "CQUtilBB.FinishedVerify", 
                             CQUtilBB.FinishedVerify, 
                             numThreadsInClients,
                             true, 
                             -1,
                             5000);
   Log.getLogWriter().info("Zeroing Pausing");
   CQUtilBB.getBB().getSharedCounters().zero(CQUtilBB.Pausing);

   counter = CQUtilBB.getBB().getSharedCounters().read(CQUtilBB.TimeToStop);
   if (counter >= 1)
      throw new StopSchedulingOrder("Num executions is " + 
            CQUtilBB.getBB().getSharedCounters().read(CQUtilBB.ExecutionNumber));
}
 
Example #29
Source File: LocatorImpl.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
public void restarting(DistributedSystem ds, GemFireCache cache) {
}
 
Example #30
Source File: HDFSRegionDirector.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
public GemFireCache getCache() {
  return this.cache;
}