public static PersistentID compactDiskStore(String diskStoreName) { PersistentID persistentID = null; GemFireCacheImpl cache = GemFireCacheImpl.getInstance(); if(cache != null && !cache.isClosed()) { DiskStoreImpl diskStore = (DiskStoreImpl) cache.findDiskStore(diskStoreName); if(diskStore != null && diskStore.forceCompaction()) { persistentID = diskStore.getPersistentID(); } } return persistentID; }
public static void closeCache() { if (cache != null && !cache.isClosed()) { cache.close(); cache.getDistributedSystem().disconnect(); } }
public final DiskStoreImpl getOrCreateDefaultDiskStore() { DiskStoreImpl result = (DiskStoreImpl) findDiskStore(null); if (result == null) { synchronized (this) { result = (DiskStoreImpl) findDiskStore(null); if (result == null) { result = (DiskStoreImpl) createDiskStoreFactory().create(DEFAULT_DS_NAME); } } } return result; }
@Override public void run2() throws CacheException { GemFireCacheImpl.getInstance().close(); } });
public LocalRegion getRegion() { // The region will be null mostly for the other node where the gateway event // is serialized final GemFireCacheImpl cache; return this._region != null ? this._region : (this._region = ((cache = GemFireCacheImpl.getInstance()) != null ? (LocalRegion)cache.getRegion(this._regionName) : null)); }
private LocalRegion findRegion() { GemFireCacheImpl cache = null; try { cache = GemFireCacheImpl.getInstance(); if (cache != null) { return cache.getRegionByPathForProcessing(regionName); } } catch (CancelException e) { // nothing to do } return null; }
public void testTxDistributedRegion() throws Exception { AttributesFactory attr = new AttributesFactory(); attr.setScope(Scope.DISTRIBUTED_ACK); Region region = cache.createRegion("DistributedRegion", attr.create()); checkOpRejection(region, true, true); region.close(); assertEquals(0 + SYSTEM_LISTENERS, cache.getResourceManager(false). getResourceListeners(ResourceType.HEAP_MEMORY).size()); }
/** * This method creates the client health monitoring region. * * @param cache * The current GemFire Cache * @guarded.By ClientHealthMonitoringRegion.class */ private static void initialize(GemFireCacheImpl cache) { try { AttributesFactory factory = new AttributesFactory(); factory.setScope(Scope.LOCAL); factory.setEntryTimeToLive(new ExpirationAttributes( ADMIN_REGION_EXPIRY_INTERVAL, ExpirationAction.DESTROY)); cache.getLogger().fine("ClientHealthMonitoringRegion, setting TTL for entry...."); factory.addCacheListener(prepareCacheListener()); factory.setStatisticsEnabled(true); RegionAttributes regionAttrs = factory.create(); InternalRegionArguments internalArgs = new InternalRegionArguments(); internalArgs.setIsUsedForMetaRegion(true); internalArgs.setIsUsedForPartitionedRegionAdmin(false); currentInstance = cache.createVMRegion(ADMIN_REGION_NAME, regionAttrs, internalArgs); } catch (Exception ex) { cache.getLoggerI18n().error(LocalizedStrings. ClientHealthMonitoringRegion_ERROR_WHILE_CREATING_AN_ADMIN_REGION, ex); } }
@Override protected boolean operateOnTX(TXStateProxy txProxy, DistributionManager dm) { // remove from hosted TXStates upfront so that there is no scope for a stray // message to create anything related to this TX final GemFireCacheImpl cache = GemFireCacheImpl.getInstance(); final TXManagerImpl txMgr; if (cache != null && (txMgr = cache.getCacheTransactionManager()) != null) { txProxy = txMgr.removeHostedTXState(getTXId(), Boolean.FALSE); } if (txProxy != null) { txProxy.rollback(null, this.callbackArg); } return true; }
if (!this.skipListeners() && (asyncQueueIds = rgn.getAsyncEventQueueIds()).size() > 0) { for (final Object q : rgn.getCache().getAsyncEventQueues()) { final AsyncEventQueueImpl asyncQueue = (AsyncEventQueueImpl)q; if (!asyncQueue.isParallel() for (final Object s : rgn.getCache().getAllGatewaySenders()) { final AbstractGatewaySender sender = (AbstractGatewaySender)s; if (!sender.isForInternalUse() && !sender.isParallel()
/** * * @return true if member has Gateway senders */ public boolean hasGatewaySender() { return (cache != null && cache.getAllGatewaySenders().size() > 0); }
logger = cache.getLogger(); DistributedMember member = cache.getDistributedSystem().getDistributedMember(); DiskStoreFactory diskStoreFactory = cache.createDiskStoreFactory(diskStoreAttrs); diskStoreFactory.create(diskStoreName);
public void testCompactionDuringBackup() throws IOException, InterruptedException { DiskStoreFactory dsf = cache.createDiskStoreFactory(); dsf.setDiskDirs(diskDirs); dsf.setMaxOplogSize(1); ds.finishBackup(new BackupManager(cache.getDistributedSystem().getDistributedMember(), cache)); script.generate(backupDir); cache.close(); destroyDiskDirs(); restoreBackup(false);
/** * Given a region path, get the associated hdfs store. */ private static ArrayList<HDFSStoreImpl> getHDFSStore(String regionPath) { ArrayList<HDFSStoreImpl> destinationhdfsStores = new ArrayList<HDFSStoreImpl>(); LocalRegion region = Misc.getGemFireCache().getRegionByPath(regionPath, false); if (region == null) {// no region associated return destinationhdfsStores; } if (region.getHDFSStoreName() == null) return destinationhdfsStores; HDFSStoreImpl hdfsStore = Misc.getGemFireCache().findHDFSStore(region.getHDFSStoreName()); if (hdfsStore != null) destinationhdfsStores.add(hdfsStore); return destinationhdfsStores; }
protected DiskStoreImpl findDiskStore(RegionAttributes ra, InternalRegionArguments internalRegionArgs) { getCache().getPdxRegistry().creatingPersistentRegion(); DiskStoreImpl diskStore = (DiskStoreImpl)getGemFireCache().findDiskStore(getDiskStoreName()); if (diskStore == null) { throw new IllegalStateException(LocalizedStrings.CacheCreation_DISKSTORE_NOTFOUND_0.toLocalizedString(getDiskStoreName())); return getGemFireCache().getOrCreateDefaultDiskStore(); } else /* backwards compat mode */{ DiskStoreFactory dsf = getGemFireCache().createDiskStoreFactory(); dsf.setDiskDirsAndSizes(getDiskDirs(), getDiskDirSizes()); DiskWriteAttributes dwa = getDiskWriteAttributes();
private static List<DiskStoreImpl> listDiskStores(boolean includeDataDictionary) { List<DiskStoreImpl> diskStoresList = new ArrayList<DiskStoreImpl>(); GemFireCacheImpl cache = GemFireCacheImpl.getInstance(); Collection<DiskStoreImpl> diskStores = cache.listDiskStoresIncludingRegionOwned(); for (DiskStoreImpl diskStore : diskStores) { if (!diskStore.getName().equals(GfxdConstants.GFXD_DD_DISKSTORE_NAME) || includeDataDictionary) { diskStoresList.add(diskStore); } } return diskStoresList; }
private void createCache() throws CacheException { Properties p = new Properties(); p.setProperty("mcast-port", "0"); // loner this.cache = (GemFireCacheImpl)new CacheFactory(p).create(); AttributesFactory af = new AttributesFactory(); af.setScope(Scope.DISTRIBUTED_NO_ACK); af.setIndexMaintenanceSynchronous(true); this.region = this.cache.createRegion("TXTest", af.create()); this.txMgr = this.cache.getCacheTransactionManager(); this.listenerAfterCommit = 0; this.listenerAfterFailedCommit = 0; this.listenerAfterRollback = 0; this.listenerClose = 0; }
@Override public void run2() { GemFireCacheImpl gfc = (GemFireCacheImpl) getCache(); InternalRegionArguments ira = new InternalRegionArguments().setTestCallable(new TXTroubleMaker()); try { AttributesFactory af = new AttributesFactory(); af.setDataPolicy(DataPolicy.REPLICATE); af.setScope(Scope.DISTRIBUTED_ACK); gfc.createVMRegion(rgnName1, af.create(), ira); gfc.createVMRegion(rgnName2, af.create(), ira); } catch (IOException ioe) { fail(ioe.toString()); } catch (TimeoutException e) { fail(e.toString()); } catch (ClassNotFoundException e) { fail(e.toString()); } } };
public static void HydraTask_turnOnGatewayDraining() throws TestException { // Drain if configured for old WAN GemFireCacheImpl cache = GemFireCacheImpl.getInstance(); List<GatewayHub> hubs = cache.getGatewayHubs(); for(GatewayHub hub : hubs) { List<Gateway> gws = hub.getGateways(); for(Gateway gw : gws) { List<GatewayEventListener> lists = gw.getListeners(); for(GatewayEventListener gel : lists) { ((BlockingGListener)gel).setDraining(true); } } } // Drain if configured for new WAN Set<AsyncEventQueue> queues = cache.getAsyncEventQueues(); for (AsyncEventQueue queue : queues) { ((BlockingGListener) queue.getAsyncEventListener()).setDraining(true); } }
/** * Close a cache. * @param gfc the cache to close. */ protected void closeCache(GemFireCacheImpl gfc) { gfc.close(); }