public static PartitionedRegion getPartitionedRegion(String prName, Cache cache) { Region region = cache.getRegion(prName); if (region != null) { if (region instanceof PartitionedRegion) return (PartitionedRegion) region; } return null; }
protected static Region<Object, ValueWrapper> getMemcachedRegion(Cache cache) { Region<Object, ValueWrapper> r = cache.getRegion(GemFireMemcachedServer.REGION_NAME); if (r == null) { synchronized (AbstractCommand.class) { r = cache.getRegion(GemFireMemcachedServer.REGION_NAME); if (r == null) { RegionFactory<Object, ValueWrapper> rf = cache.createRegionFactory(RegionShortcut.PARTITION); r = rf.create(GemFireMemcachedServer.REGION_NAME); } } } return r; }
public static void closeCache(boolean keepalive) { if (expected != null) { expected.remove(); expected = null; } if (cache != null && !cache.isClosed()) { cache.close(keepalive); cache.getDistributedSystem().disconnect(); } }
public static QueryService getQueryService() { if (cache.isClosed()) startCache(); return cache.getQueryService(); }
boolean sameConfig = other.getLockLease() == this.getLockLease() && other.getLockTimeout() == this.getLockTimeout() && other.getSearchTimeout() == this.getSearchTimeout() && other.getMessageSyncInterval() == this.getMessageSyncInterval() && other.getCopyOnRead() == this.getCopyOnRead() && other.isServer() == this.isServer(); Collection<CacheServer> otherBridges = other.getCacheServers(); if (myBridges.size() != otherBridges.size()) { throw new RuntimeException( DiskStoreAttributesCreation dsac = (DiskStoreAttributesCreation) diskStore; String name = dsac.getName(); DiskStore ds = other.findDiskStore(name); if (ds == null) { getLogger().fine("Disk store " + name + " not found."); other.listRegionAttributes(); if (myNamedAttributes.size() != otherNamedAttributes.size()) { throw new RuntimeException( "Entry value is a " + myEntry.getValue().getClass().getName()); RegionAttributesCreation myAttrs = (RegionAttributesCreation) myEntry.getValue(); RegionAttributes<Object, Object> otherAttrs = other.getRegionAttributes(myId); if (otherAttrs == null) { getLogger().fine("No attributes for " + myId); Collection<Region<?, ?>> otherRoots = other.rootRegions(); if (myRoots.size() != otherRoots.size()) { throw new RuntimeException("roots size");
protected Region createRegion(String regionName, RegionShortcut shortcut) { return this.cache.createRegionFactory(shortcut).create(regionName); } }
@Override public void afterCreate(EntryEvent event) { if ((Long) event.getKey() == 900) { cache.getLogger().fine(" Gateway sender is killed by a test"); cache.close(); cache.getDistributedSystem().disconnect(); } } };
protected int startBridgeServerWithEmbeddedLocator(final String[] groups, final String locators, final String[] regions, final ServerLoadProbe probe) throws IOException { Cache cache = new CacheFactory().set(MCAST_PORT, "0").set(LOCATORS, locators) .set(START_LOCATOR, locators).create(); for (String regionName : regions) { cache.createRegionFactory(RegionShortcut.REPLICATE).setEnableSubscriptionConflation(true) .create(regionName); } CacheServer server = cache.addCacheServer(); server.setGroups(groups); server.setLoadProbe(probe); server.setPort(0); server.start(); remoteObjects.put(CACHE_KEY, cache); return server.getPort(); }
/** 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; } } }
if (cache != null) { GatewaySender serialSender = cache.createGatewaySenderFactory().setManualStart(true).setPersistenceEnabled(false) .setDiskStoreName("LN_" + remoteDsId).create("LN_" + remoteDsId, remoteDsId); System.out.println("Sender Created : " + serialSender.getId()); Region region = cache.createRegionFactory() Region region = cache.createRegionFactory().create("MyRegion"); System.out.println("Created Region :" + region.getName()); cache.createGatewayReceiverFactory().setStartPort(12345).setManualStart(true).create(); System.out.println("Created GatewayReceiver : " + receiver); try {
region = proxyCaches[multiUserIndex].getRegion(REGION_NAME); } else { region = getCache().getRegion(REGION_NAME); getCache().getCacheTransactionManager().begin(); getCache().getCacheTransactionManager().commit();
protected void disconnect(Cache cache) { DistributedSystem dsys = cache.getDistributedSystem(); cache.close(); dsys.disconnect(); }
@Before public void before() throws Exception { locator = lsRule.startLocatorVM(0, l -> l.withHttpService()); server = lsRule.startServerVM(1, locator.getPort()); server.invoke(() -> { Cache cache = ClusterStartupRule.getCache(); RegionFactory factory = cache.createRegionFactory(RegionShortcut.REPLICATE); Region region = factory.create(REGION_1); cache.getQueryService().createIndex(INDEX_1, "key", INDEX_REGION_NAME); region.put(1, new Stock("SUNW", 10)); region.get(1); }); connectGfsh(locator); }
factory.setConcurrencyChecksEnabled(true); RegionAttributes myAttrs = factory.create(); Region r1 = cache.createRegion(REGION_NAME1, myAttrs); Region r2 = cache.createRegion(REGION_NAME2, myAttrs); factory = new AttributesFactory(); factory.setDataPolicy(DataPolicy.PARTITION); Region pr = cache.createRegion(PR_REGION_NAME, prAttrs); assertNotNull(r1); assertNotNull(r2); assertNotNull(pr); CacheServer server = cache.addCacheServer(); int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); r1.getCache().getDistributedSystem().getLogWriter().info("Starting server on port " + port); server.setPort(port); server.setMaxThreads(maxThreads); server.setNotifyBySubscription(notifyBySubscription); server.start(); r1.getCache().getDistributedSystem().getLogWriter() .info("Started server on port " + server.getPort()); return server.getPort();
@Override public void execute(final FunctionContext context) { try { final Set<IndexDetails> indexDetailsSet = new HashSet<IndexDetails>(); final Cache cache = context.getCache(); final DistributedMember member = cache.getDistributedSystem().getDistributedMember(); for (final Index index : cache.getQueryService().getIndexes()) { indexDetailsSet.add(new IndexDetails(member, index)); } context.getResultSender().lastResult(indexDetailsSet); } catch (Exception e) { context.getResultSender().sendException(e); } } }
Boolean result = false; final boolean isDebugEnabled = logger.isDebugEnabled(); if (cache.getDistributedSystem().getDistributedMember().equals(member)) { if (isDebugEnabled) { logger.debug("RollbackFunction: for transaction: {} rolling back locally", txId); CacheTransactionManager txMgr = cache.getCacheTransactionManager(); if (txMgr.tryResume(txId)) { if (isDebugEnabled) {
public static Integer createCacheServer(String regionName1, String regionName2, Boolean notifyBySubscription) throws Exception { new CacheServerTestUtil().createCache(new Properties()); AttributesFactory factory = new AttributesFactory(); factory.setScope(Scope.DISTRIBUTED_ACK); factory.setEnableBridgeConflation(true); factory.setDataPolicy(DataPolicy.REPLICATE); RegionAttributes attrs = factory.create(); if (!regionName1.equals("")) { cache.createRegion(regionName1, attrs); } if (!regionName2.equals("")) { cache.createRegion(regionName2, attrs); } CacheServer server1 = cache.addCacheServer(); int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET); server1.setPort(port); server1.setNotifyBySubscription(notifyBySubscription.booleanValue()); server1.start(); return new Integer(server1.getPort()); }
protected Cache createCache() { cache = new CacheFactory(props).create(); ds = cache.getDistributedSystem(); logWriter = cache.getLogger(); return cache; }
public static QueryService getQueryService() { return cache.getQueryService(); }