当前位置: 首页>>代码示例>>Java>>正文


Java Cache.isClosed方法代码示例

本文整理汇总了Java中com.gemstone.gemfire.cache.Cache.isClosed方法的典型用法代码示例。如果您正苦于以下问题:Java Cache.isClosed方法的具体用法?Java Cache.isClosed怎么用?Java Cache.isClosed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.gemstone.gemfire.cache.Cache的用法示例。


在下文中一共展示了Cache.isClosed方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: LogWrapper

import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
private LogWrapper() {
  logger = Logger.getLogger(this.getClass().getCanonicalName());

  Cache cache = CliUtil.getCacheIfExists();
  if (cache != null && !cache.isClosed()) {
    //TODO - Abhishek how to set different log levels for different handlers???
    logger.addHandler(cache.getLogger().getHandler());
    CommandResponseWriterHandler handler = new CommandResponseWriterHandler();
    handler.setFilter(new Filter() {
      @Override
      public boolean isLoggable(LogRecord record) {
        return record.getLevel().intValue() >= Level.FINE.intValue();
      }
    });
    handler.setLevel(Level.FINE);
    logger.addHandler(handler);
  }
  logger.setUseParentHandlers(false);
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:20,代码来源:LogWrapper.java

示例2: createLocalCommandService

import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
/**
 * Returns a newly created or existing instance of the
 * <code>CommandService<code> associated with the
 * specified <code>Cache</code>.
 *
 * @param cache
 *          Underlying <code>Cache</code> instance to be used to create a Command Service.
 * @throws CommandServiceException
 *           If command service could not be initialized.
 */
public static final CommandService createLocalCommandService(Cache cache)
    throws CommandServiceException {
  if (cache == null || cache.isClosed()) {
    throw new CacheClosedException("Can not create command service as cache doesn't exist or cache is closed.");
  }

 /* if (!cache.isServer()) {
    throw new IllegalArgumentException("Server cache is required.");
  }*/

  if (localCommandService == null || !localCommandService.isUsable()) {
    String nonExistingDependency = CliUtil.cliDependenciesExist(false);
    if (nonExistingDependency != null) {
      throw new DependenciesNotFoundException(LocalizedStrings.CommandServiceManager_COULD_NOT_FIND__0__LIB_NEEDED_FOR_CLI_GFSH.toLocalizedString(new Object[] {nonExistingDependency}));
    }

    localCommandService = new MemberCommandService(cache);
  }

  return localCommandService;
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:32,代码来源:CommandService.java

示例3: getRegionIteratorSize

import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
/**
 * Retruns the size of region iterator for count(*) on a region without
 * whereclause.
 * @param collExpr 
 * @throws RegionNotFoundException 
 * @since 6.6.2
 */
private int getRegionIteratorSize(ExecutionContext context,
    CompiledValue collExpr) throws RegionNotFoundException {
  Region region;
  String regionPath = ((CompiledRegion) collExpr).getRegionPath();
  if (context.getBucketRegion() == null) {
    region = context.getCache().getRegion(regionPath);
  } else {
    region = context.getBucketRegion();
  }
  if (region != null) {
    return region.size();
  } else {
    // if we couldn't find the region because the cache is closed, throw
    // a CacheClosedException
    Cache cache = context.getCache();
    if (cache.isClosed()) {
      throw new CacheClosedException();
    }
    throw new RegionNotFoundException(
        LocalizedStrings.CompiledRegion_REGION_NOT_FOUND_0
            .toLocalizedString(regionPath));
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:31,代码来源:CompiledSelect.java

示例4: disconnect

import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
@Override
protected void disconnect(Cache cache) {
  Exception severeEx = null;
  try {
    getFabricServiceInstance().stop(this.bootProps);
  } catch (SQLException se) {
    if (((se.getErrorCode() == 50000) && ("XJ015".equals(se.getSQLState())))) {
      // we got the expected exception
    }
    else {
      severeEx = se;
    }
  } catch (Exception ex) {
    // got an unexpected exception
    severeEx = ex;
  } finally {
    if (severeEx != null) {
      // if the error code or SQLState is different, we have
      // an unexpected exception (shutdown failed)
      String msg = LocalizedResource.getMessage("FS_JDBC_SHUTDOWN_ERROR");
      logSevere(msg, severeEx);
    }
    if (!cache.isClosed()) {
      cache.close();
    }
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:28,代码来源:GfxdServerLauncher.java

示例5: getConnection

import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
/**
 * Acquires or adds a new <code>Connection</code> to the corresponding
 * <code>Gateway</code>
 *
 * @return the <code>Connection</code>
 *
 * @throws GatewaySenderException
 * @throws InterruptedException 
 */
public Connection getConnection() throws GatewaySenderException{
  // IF the connection is null 
  // OR the connection's ServerLocation doesn't match with the one stored in sender
  // THEN initialize the connection
  if(!this.sender.isParallel()) {
    if (this.connection == null
        || !this.connection.getServer().equals(this.sender.getServerLocation())) {
      if (this.logger.fineEnabled()) {
        logger
            .fine("Initializing new connection as serverlocation of old connection is : "
                + ((this.connection == null) ? "null" : this.connection
                    .getServer())
                + " and the serverlocation to connect is"
                + this.sender.getServerLocation());
      }
      // Initialize the connection
      initializeConnection();
    }
  } else {
    if (this.connection == null) {
      initializeConnection();
    }
  }
  
  // Here we might wait on a connection to another server if I was secondary
  // so don't start waiting until I am primary
  Cache cache = this.sender.getCache();
  if (cache != null && !cache.isClosed()) {
    if (this.sender.isPrimary() && (this.connection != null)) {
      if (this.ackReaderThread == null || !this.ackReaderThread.isRunning()) {
        this.ackReaderThread = new AckReaderThread(this.sender);
        this.ackReaderThread.start();
        this.ackReaderThread.waitForRunningAckReaderThreadRunningState();
      }
    }
  }
  return this.connection;
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:48,代码来源:GatewaySenderEventRemoteDispatcher.java

示例6: startBeingManagingNode

import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
public void startBeingManagingNode() {
  Cache existingCache = GemFireCacheImpl.getInstance();
  if (existingCache != null && !existingCache.isClosed()) {
    managementService = ManagementService.getManagementService(existingCache);
    SystemManagementService service = (SystemManagementService) managementService;
    service.createManager();
    service.startManager();
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:10,代码来源:ManagementTestBase.java

示例7: closeCache

import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
public static void closeCache() {
  Cache cache = CacheServerTestUtil.getCache();
  if (cache != null && !cache.isClosed()) {
    // might fail in DataSerializerRecoveryListener.RecoveryTask in shutdown
    cache.getLogger().info("<ExpectedException action=add>" +
        RejectedExecutionException.class.getName() + "</ExpectedException>");
    cache.close(true);
    cache.getDistributedSystem().disconnect();
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:11,代码来源:DurableClientStatsDUnitTest.java

示例8: closeCache

import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
public static void closeCache() {
  Cache cache = CacheServerTestUtil.getCache();
  if (cache != null && !cache.isClosed()) {
    cache.close(true);
    cache.getDistributedSystem().disconnect();
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:8,代码来源:DurableRegistrationDUnitTest.java

示例9: closeCache

import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
public static void closeCache()
{
  Cache cache = new BridgeWriterMiscDUnitTest("temp").getCache();
  if (cache != null && !cache.isClosed()) {
    cache.close();
    cache.getDistributedSystem().disconnect();
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:9,代码来源:BridgeWriterMiscDUnitTest.java

示例10: closeCache

import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
/**
 * close the client cache
 *
 */
public static void closeCache()
{
  Cache cacheClient = GemFireCacheImpl.getInstance();
  if (cacheClient != null && !cacheClient.isClosed()) {
    cacheClient.close();
    cacheClient.getDistributedSystem().disconnect();
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:13,代码来源:ClientInterestNotifyDUnitTest.java

示例11: HydraTask_offHeapCeilingTestOOM

import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
/** Test task for members that are expected to get OOM for off-heap memory and close their cache.
 * 
 *  Put until OOM for off-heap is detected.
 *  Wait for the signal to reinitialize.
 */
public static void HydraTask_offHeapCeilingTestOOM() throws Throwable {
  SharedCounters sc = MemScaleBB.getBB().getSharedCounters();
  final boolean isLeader = false; // members that runOOM are never the leader
  Log.getLogWriter().info("isLeader: " + isLeader);

  Cache theCache = CacheHelper.getCache();
  DistributedSystem ds = DistributedSystemHelper.getDistributedSystem();
  putUntilOOMDetected(); // returns when this member closes the cache
  // verify the cache is closed and we are disconnected from the ds
  long begin = System.currentTimeMillis();
  while (!theCache.isClosed() || ds.isConnected()) {
    Thread.sleep(100);
    if (System.currentTimeMillis() > (begin + 60*1000)) {
      break;
    }
  }
  boolean cacheClosed = theCache.isClosed();
  boolean dsConnected = ds.isConnected();
  Log.getLogWriter().info("After getting off-heap OOM, cacheClosed is " + cacheClosed + ", dsConnected is " + dsConnected);
  if (!cacheClosed) {
    throw new TestException("Expected the cache to be closed, but Cache.isClosed() is " + cacheClosed);
  }
  if (dsConnected) {
    throw new TestException("Expected the distributed system to be disconnected, but isConnected() is " + dsConnected);
  }
  TestHelper.waitForCounter(MemScaleBB.getBB(), "doneValidating", MemScaleBB.doneValidating, 1, true, -1, 1000);
  DistributedSystemHelper.cleanupAfterAutoDisconnect();
  HydraTask_initializeRegions(); // for next test iteration
  pause(isLeader, "pause4", null, MemScalePrms.getNumThreads2(), false);
  logDurationHistory();

  // see if it is time to stop
  if (sc.read(MemScaleBB.timeToStop) > 0) {
    throw new StopSchedulingTaskOnClientOrder("Completed " + sc.read(MemScaleBB.currentExecutionCycle)+ " test cycles");
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:42,代码来源:OffHeapStressTest.java

示例12: HydraTask_startupShutdown

import com.gemstone.gemfire.cache.Cache; //导入方法依赖的package包/类
/** Task to do a shutDownAll, then restart
 * 
 */
public static void HydraTask_startupShutdown() {
  logExecutionNumber();
  long sleepSecBeforeShutDownAll = RecoveryPrms.getSleepSecBeforeShutDownAll(); // defaults to 0
  if (sleepSecBeforeShutDownAll > 0) {
    Log.getLogWriter().info("Sleeping for " + sleepSecBeforeShutDownAll + " seconds");
    MasterController.sleepForMs((int)sleepSecBeforeShutDownAll * 1000);
  }
  List<ClientVmInfo> vmList = StopStartVMs.getAllVMs();
  List<ClientVmInfo> locators = StopStartVMs.getMatchVMs(vmList, "locator");
  List<ClientVmInfo> vmListExcludeLocators = new ArrayList<ClientVmInfo>();
  vmListExcludeLocators.addAll(vmList);
  vmListExcludeLocators.removeAll(locators);
  Log.getLogWriter().info("vmList is " + vmListExcludeLocators);
  AdminDistributedSystem adminDS = AdminHelper.getAdminDistributedSystem();
  Cache theCache = CacheHelper.getCache();
  if (adminDS == null) {
    throw new TestException("Test is configured to use shutDownAllMembers, but this vm must be an admin vm to use it");
  }
  List stopModes = new ArrayList();
  stopModes.add(ClientVmMgr.MeanKill);
  Object[] tmp = StopStartVMs.shutDownAllMembers(adminDS, stopModes);
  List<ClientVmInfo> shutDownAllVMs = (List<ClientVmInfo>)tmp[0];
  Set shutdownAllResults = (Set)(tmp[1]);
  if (shutdownAllResults.size() != vmListExcludeLocators.size()) { // shutdownAll did not return the expected number of members
    throw new TestException("Expected shutDownAllMembers to return " + vmListExcludeLocators.size() +
        " members in its result, but it returned " + shutdownAllResults.size() + ": " + shutdownAllResults);
  }
  if (shutdownAllResults.size() > shutDownAllVMs.size()) {
    // shutdownAllResults is bigger because we shutdown this vm also, but it was not stopped
    // just disconnected
    boolean cacheClosed = theCache.isClosed();
    if (cacheClosed) {
      Log.getLogWriter().info("shutDownAllMembers disconnected this vm");
      testInstance = null;
    } else {
      throw new TestException("shutDownAllMembers should have disconnected this vm, but the cache " +
          theCache + " isClosed is " + cacheClosed);
    }
  }

  // restart the stopped vms; this will run a dynamic init task to recover from disk
  Log.getLogWriter().info("Restarting the vms");
  List dataStoreVMs = new ArrayList();
  List proxyVMs = new ArrayList();
  Map sharedMap = RecoveryBB.getBB().getSharedMap().getMap();
  for (Object key: sharedMap.keySet()) {
    if (key instanceof String)  {
      if (((String)key).startsWith("proxy")) {
        proxyVMs.add(sharedMap.get(key));
      } else if (((String)key).startsWith("dataStore")) {
        dataStoreVMs.add(sharedMap.get(key));
      }
    }
  }
  Log.getLogWriter().info("Restarting the vms, dataStoreVMS: " + dataStoreVMs + ", proxyVMs: " + proxyVMs);
  StopStartVMs.startVMs(dataStoreVMs);
  if (proxyVMs.size() > 0) {
    StopStartVMs.startVMs(proxyVMs);
  }

  long serversAreBack = RecoveryBB.getBB().getSharedCounters().incrementAndRead(RecoveryBB.serversAreBack);
  Log.getLogWriter().info("serversAreBack counter is " + serversAreBack);
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:67,代码来源:StartupShutdownTest.java


注:本文中的com.gemstone.gemfire.cache.Cache.isClosed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。