private Set<String> getAllRegionFullPaths() { if (this.cache.isClosed() || this.clientPRAdvisors == null) { return null; } Set<String> keys = null; try { keys = this.clientPRAdvisors.keySet(); } catch (Exception npe) { return null; } return keys; }
public ClientPartitionAdvisor getClientPartitionAdvisor(String regionFullPath) { if (this.cache.isClosed() || this.clientPRAdvisors == null) { return null; } ClientPartitionAdvisor prAdvisor = null; try { prAdvisor = this.clientPRAdvisors.get(regionFullPath); } catch (Exception npe) { return null; } return prAdvisor; }
public Set<ClientPartitionAdvisor> getColocatedClientPartitionAdvisor(String regionFullPath) { if (this.cache.isClosed() || this.clientPRAdvisors == null || this.colocatedPRAdvisors == null) { return null; } return this.colocatedPRAdvisors.get(regionFullPath); }
public static void closeCache() { try { if (!cache.isClosed()) { cache.close(); } } catch (Exception e) { e.printStackTrace(); } }
public static void startCache() { try { if (cache.isClosed()) { cache = CacheFactory.create(ds); } } catch (Exception e) { e.printStackTrace(); } }
public void closeCache() { if (!cache.isClosed()) { cache.close(); } }
public static void restartCache() { try { if (!cache.isClosed()) { cache.close(); } cache = CacheFactory.create(ds); } catch (Exception e) { e.printStackTrace(); } }
private LogWrapper(Cache cache) { logger = Logger.getLogger(this.getClass().getCanonicalName()); if (cache != null && !cache.isClosed()) { logger.addHandler(cache.getLogger().getHandler()); CommandResponseWriterHandler handler = new CommandResponseWriterHandler(); handler.setFilter(record -> record.getLevel().intValue() >= Level.FINE.intValue()); handler.setLevel(Level.FINE); logger.addHandler(handler); } logger.setUseParentHandlers(false); }
public static QueryService getQueryService() { if (cache.isClosed()) startCache(); return cache.getQueryService(); }
private void addClientPartitionAdvisor(String regionFullPath, ClientPartitionAdvisor advisor) { if (this.cache.isClosed() || this.clientPRAdvisors == null) { return; } try { this.clientPRAdvisors.put(regionFullPath, advisor); if (advisor.getColocatedWith() != null) { String parentRegionPath = advisor.getColocatedWith(); Set<ClientPartitionAdvisor> colocatedAdvisors = this.colocatedPRAdvisors.get(parentRegionPath); if (colocatedAdvisors == null) { colocatedAdvisors = new CopyOnWriteArraySet<ClientPartitionAdvisor>(); this.colocatedPRAdvisors.put(parentRegionPath, colocatedAdvisors); } colocatedAdvisors.add(advisor); } } catch (Exception npe) { // ignore, shutdown case } }
protected static final void destroyRegions(final Cache cache) { if (cache != null && !cache.isClosed()) { // try to destroy the root regions first so that we clean up any persistent files. for (Region<?, ?> root : cache.rootRegions()) { String regionFullPath = root == null ? null : root.getFullPath(); // for colocated regions you can't locally destroy a partitioned region. if (root.isDestroyed() || root instanceof HARegion || root instanceof PartitionedRegion) { continue; } try { root.localDestroyRegion("teardown"); } catch (Throwable t) { logger.error("Failure during tearDown destroyRegions for " + regionFullPath, t); } } } }
public static void closeCache(boolean keepalive) { if (expected != null) { expected.remove(); expected = null; } if (cache != null && !cache.isClosed()) { cache.close(keepalive); cache.getDistributedSystem().disconnect(); } }
/** * Stops a VM as a Managing node */ protected void stopManagingNode(final VM vm) { vm.invoke("Stop Being Managing Node", () -> { Cache existingCache = GemFireCacheImpl.getInstance(); if (existingCache != null && !existingCache.isClosed()) { if (managementService.isManager()) { managementService.stopManager(); } } }); }
public static void closeCache() { if (expected != null) { expected.remove(); expected = null; } if (cache != null && !cache.isClosed()) { cache.close(); cache.getDistributedSystem().disconnect(); } }
private static void destroyRegions(final Cache cache) { if (cache != null && !cache.isClosed()) { // try to destroy the root regions first so that we clean up any persistent files. for (Region<?, ?> root : cache.rootRegions()) { String regionFullPath = root == null ? null : root.getFullPath(); // for colocated regions you can't locally destroy a partitioned region. if (root.isDestroyed() || root instanceof HARegion || root instanceof PartitionedRegion) { continue; } try { root.localDestroyRegion("CacheRule_tearDown"); } catch (Exception ignore) { } } } }
protected static void closeCache() { removeExpectedExceptions(ignoredExceptions); if (cache != null && !cache.isClosed()) { DistributedSystem sys = cache.getDistributedSystem(); cache.close(); sys.disconnect(); cache = null; } disconnectFromDS(); }
protected static void closeCache(final Boolean keepAlive) { removeExpectedExceptions(ignoredExceptions); if (cache != null && !cache.isClosed()) { DistributedSystem sys = cache.getDistributedSystem(); cache.close(keepAlive); sys.disconnect(); cache = null; } disconnectFromDS(); }
@Test public void processResponseWhenCacheClosedShuouldReturnNull() throws Exception { Cache cache = mock(Cache.class); ClientMetadataService cms = new ClientMetadataService(cache); cms = spy(cms); doReturn(true).when(cache).isClosed(); Message msg = mock(Message.class); GetClientPRMetaDataOp.GetClientPRMetaDataOpImpl op = new GetClientPRMetaDataOp.GetClientPRMetaDataOpImpl("testRegion", cms); op = spy(op); when(msg.getMessageType()).thenReturn(MessageType.RESPONSE_CLIENT_PR_METADATA); assertNull(op.processResponse(msg)); verify(cms, times(1)).setMetadataStable(eq(true)); } }
/** Close the cache */ private synchronized void closeCache() { if (cache != null) { try { if (!cache.isClosed()) { CacheTransactionManager txMgr = cache.getCacheTransactionManager(); if (txMgr != null) { if (txMgr.exists()) { // make sure we cleanup this threads txid stored in a thread local txMgr.rollback(); } } cache.close(); } } finally { cache = null; } } }
public static void closeCache() throws IOException { if (cache != null && !cache.isClosed()) { cache.close(); cache.getDistributedSystem().disconnect(); cache = null; } else { AsyncEventQueueTestBase test = new AsyncEventQueueTestBase(); if (test.isConnectedToDS()) { test.getSystem().disconnect(); } } }