Java Code Examples for com.gemstone.gemfire.cache.Region#registerInterest()
The following examples show how to use
com.gemstone.gemfire.cache.Region#registerInterest() .
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: BridgeWriterMiscDUnitTest.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
public static void registerInterestInBothTheRegions() { try { Cache cache = new BridgeWriterMiscDUnitTest("temp").getCache(); Region r1 = cache.getRegion(Region.SEPARATOR + REGION_NAME1); assertNotNull(r1); Region r2 = cache.getRegion(Region.SEPARATOR + REGION_NAME2); assertNotNull(r2); r1.registerInterest("ALL_KEYS"); r2.registerInterest("ALL_KEYS"); } catch (CacheWriterException e) { e.printStackTrace(); fail( "Test failed due to CacheWriterException during registerInterestnBothRegions", e); } }
Example 2
Source File: Bug36805DUnitTest.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
public static void registerInterest() { cache.getLogger().info( "<ExpectedException action=add>" + "RegionDestroyedException" + "</ExpectedException>"); try { Region r = cache.getRegion("/" + regionName); assertNotNull(r); List listOfKeys = new ArrayList(); listOfKeys.add("key-1"); listOfKeys.add("key-2"); listOfKeys.add("key-3"); listOfKeys.add("key-4"); listOfKeys.add("key-5"); r.registerInterest(listOfKeys); fail("expected RegionDestroyedException"); } catch (ServerOperationException expected) { assertEquals(RegionDestroyedException.class, expected.getCause().getClass()); } finally { cache.getLogger().info( "<ExpectedException action=remove>" + "RegionDestroyedException" + "</ExpectedException>"); } }
Example 3
Source File: InterestListFailoverDUnitTest.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
public static Integer registerInterestList() { try { Region r = CacheServerTestUtil.getCache().getRegion("/"+ REGION_NAME); assertNotNull(r); r.registerInterest("key-1"); r.registerInterest("key-2"); r.registerInterest("key-3"); r.registerInterest("key-4"); r.registerInterest("key-5"); // now return the port of the primary. PoolImpl p = (PoolImpl)PoolManager.find(r.getAttributes().getPoolName()); return new Integer(p.getPrimaryPort()); } catch (Exception ex) { fail("failed while registering keys k1 to k5", ex); return null; } }
Example 4
Source File: PdxDeserializationDUnitTest.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
protected void checkClientValue(final Region<Object, Object> region) { //Because register interest is asynchronous, we need to wait for the value to arrive. waitForCriterion(new WaitCriterion() { public boolean done() { return region.get("A") != null; } public String description() { return "Client region never received value for key A"; } }, 30000, 100, true); assertEquals(TestSerializable.class, region.get("A").getClass()); //do a register interest which will download the value region.registerInterest("B", InterestResultPolicy.KEYS_VALUES); assertEquals(TestSerializable.class, region.get("B").getClass()); }
Example 5
Source File: HAEventIdPropagationDUnitTest.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
/** function to create client cache * */ public static void createClientCache(String hostName, Integer port1) throws Exception { int PORT1 = port1.intValue(); Properties props = new Properties(); props.setProperty("mcast-port", "0"); props.setProperty("locators", ""); new HAEventIdPropagationDUnitTest("temp").createCache(props); AttributesFactory factory = new AttributesFactory(); PoolImpl pi = (PoolImpl)BridgeTestCase.configureConnectionPool(factory, hostName, new int[] {PORT1}, true, -1, 2, null); factory.setScope(Scope.DISTRIBUTED_ACK); CacheListener clientListener = new HAEventIdPropagationListenerForClient(); factory.setCacheListener(clientListener); RegionAttributes attrs = factory.create(); cache.createRegion(REGION_NAME, attrs); Region region = cache.getRegion(Region.SEPARATOR + REGION_NAME); assertNotNull(region); region.registerInterest("ALL_KEYS", InterestResultPolicy.NONE); System.out.println("KKKKKK:["+pi.getName()+"]");; PoolImpl p2 = (PoolImpl)PoolManager.find("testPool"); System.out.println("QQQQ:"+p2); pool = pi; }
Example 6
Source File: FPRExpirationTest.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
/** * Create the regions specified */ public void initializeClients() { if (theCache == null) { theCache = CacheHelper.createCache("cache1"); } Vector regionNames = (Vector)TestConfig.tab().vecAt(RegionPrms.names, null); for (Iterator iter = regionNames.iterator(); iter.hasNext();) { String rName = (String)iter.next(); if (rName.startsWith("edge")) { String regionName = RegionHelper.getRegionDescription(rName) .getRegionName(); Region aRegion = RegionHelper.createRegion(regionName, RegionHelper .getRegionAttributes(rName)); aRegion.registerInterest("ALL_KEYS"); hydra.Log.getLogWriter().info( "Created region " + aRegion.getName() + " with attributes " + aRegion.getAttributes()); } } }
Example 7
Source File: DeltaPropagationClientReceiver.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
public static void main(String[] args) throws Exception { writeToStdout("Connecting to the distributed system and creating the cache."); // Create the cache which causes the cache-xml-file to be parsed ClientCache cache = new ClientCacheFactory() .set("name", "DeltaPropagationClientReceiver") .set("cache-xml-file", "xml/DeltaClient2.xml") .create(); Region<Object, Object> reg = cache.getRegion("exampleRegion"); reg.registerInterest("ALL_KEYS"); writeToStdout("Please press Enter to stop the receiver."); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in)); bufferedReader.readLine(); cache.close(); }
Example 8
Source File: DurableClientsTest.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
/** * Register Interest on Full List of Keys */ public static void registerInterestFull_List() { Log.getLogWriter().info("Registering interest on full list of keys"); int numOfRegion = TestConfig.tab().intAt( durableClients.DurableClientsPrms.numberOfRegions, 1); InterestResultPolicy interestResultPolicy = DurableClientsPrms.getInterestResultPolicy(); for (int i = 0; i < numOfRegion; i++) { Region region = getRegion(REGION_NAME + i); Log.getLogWriter().info( "List size is :" + ((List)(durableClients.DurableClientsBB.getBB().getSharedMap() .get(FULL_LIST))).size()); region.registerInterest(durableClients.DurableClientsBB.getBB() .getSharedMap().get(FULL_LIST), interestResultPolicy, true); hydra.MasterController.sleepForMs(5000); if (TestConfig.tab().booleanAt( durableClients.DurableClientsPrms.putLastKey, false)) { region.registerInterest(durableClients.Feeder.LAST_KEY, interestResultPolicy, true); } } }
Example 9
Source File: DeltaToRegionRelationDUnitTest.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
public static void registerKeys(String regionName, Integer obj1, Integer Obj2) //RegisterInterestListOp { List list = new ArrayList(); try { Region r = cache.getRegion(Region.SEPARATOR + regionName); assertNotNull(r); list.add(obj1); list.add(Obj2); r.registerInterest(list); } catch (Exception ex) { fail("failed while registering keys" + list + "", ex); } }
Example 10
Source File: PutAllDUnitTest.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** function to create client cache with HAEventIdPropagationListenerForClient1 as the listener **/ public static void createClientCache2(String host, Integer port1) throws Exception { PORT1 = port1.intValue(); Properties props = new Properties(); props.setProperty("mcast-port", "0"); props.setProperty("locators", ""); new PutAllDUnitTest("temp").createCache(props); props.setProperty("retryAttempts", "2"); props.setProperty("endpoints", "ep1="+host+":" + PORT1); props.setProperty("redundancyLevel", "-1"); props.setProperty("establishCallbackConnection", "true"); props.setProperty("LBPolicy", "Sticky"); props.setProperty("readTimeout", "2000"); props.setProperty("socketBufferSize", "1000"); props.setProperty("retryInterval", "250"); props.setProperty("connectionsPerServer", "2"); AttributesFactory factory = new AttributesFactory(); factory.setScope(Scope.DISTRIBUTED_ACK); PoolImpl p = (PoolImpl)BridgeTestCase.configureConnectionPool(factory, host, PORT1,-1, true, -1, 2, null); CacheListener clientListener = new HAEventIdPropagationListenerForClient2(); factory.setCacheListener(clientListener); RegionAttributes attrs = factory.create(); cache.createRegion(REGION_NAME, attrs); Region region = cache.getRegion(Region.SEPARATOR + REGION_NAME); assertNotNull(region); region.registerInterest("ALL_KEYS", InterestResultPolicy.NONE); pool = p; }
Example 11
Source File: PdxDeserializationDUnitTest.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
private void createClient(final int port0) { ClientCacheFactory cf = new ClientCacheFactory(); cf.addPoolServer("localhost", port0); cf.setPoolSubscriptionEnabled(true); ClientCache cache = getClientCache(cf); Region replicate = cache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY).create("replicate"); Region pr = cache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY).create("pr"); cache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY).create("overflow_replicate"); cache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY).create("overflow_pr"); //Register interest in a key replicate.registerInterest("A", InterestResultPolicy.KEYS_VALUES); pr.registerInterest("A", InterestResultPolicy.KEYS_VALUES); }
Example 12
Source File: InstantiatorPropogationDUnitTest.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
public static void createClientCache(String host, Integer port1) throws Exception { Properties props = new Properties(); props.setProperty(DistributionConfig.MCAST_PORT_NAME, "0"); props.setProperty(DistributionConfig.LOCATORS_NAME, ""); new InstantiatorPropogationDUnitTest("temp").createCache(props); Pool p = PoolManager.createFactory().addServer(host, port1.intValue()) .setMinConnections(1).setSubscriptionEnabled(true).setPingInterval(200) .create("ClientServerInstantiatorRegistrationDUnitTestPool"); AttributesFactory factory = new AttributesFactory(); factory.setScope(Scope.DISTRIBUTED_ACK); factory.setPoolName(p.getName()); Region r = cache.createRegion(REGION_NAME, factory.create()); r.registerInterest("ALL_KEYS"); }
Example 13
Source File: DeltaTest.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** Register interest with ALL_KEYS, and InterestPolicyResult = KEYS_VALUES * which is equivalent to a full GII. * * @param aRegion The region to register interest on. */ protected static void registerInterest(Region aRegion) { Log.getLogWriter().info("Calling registerInterest for all keys, result interest policy KEYS_VALUES"); aRegion.registerInterest("ALL_KEYS", InterestResultPolicy.KEYS_VALUES); Log.getLogWriter().info("Done calling registerInterest for all keys, " + "result interest policy KEYS_VALUES, " + aRegion.getFullPath() + " size is " + aRegion.size()); }
Example 14
Source File: PdxCompatTest.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** Register interest with ALL_KEYS, and InterestPolicyR /** Register interest with ALL_KEYS, and InterestPolicyResult = KEYS_VALUES * which is equivalent to a full GII. */ protected static void registerInterest() { Set<Region<?,?>> rootRegions = CacheUtil.getCache().rootRegions(); for (Region aRegion: rootRegions) { Log.getLogWriter().info("Calling registerInterest for all keys, result interest policy KEYS_VALUES for region " + aRegion.getFullPath()); aRegion.registerInterest("ALL_KEYS", InterestResultPolicy.KEYS_VALUES); Log.getLogWriter().info("Done calling registerInterest for all keys, " + "result interest policy KEYS_VALUES, " + aRegion.getFullPath() + " size is " + aRegion.size()); } }
Example 15
Source File: HASlowReceiverDUnitTest.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
public static void registerInterest() { try { Region r = cache.getRegion("/" + regionName); assertNotNull(r); r.registerInterest("ALL_KEYS"); } catch (Exception ex) { fail("failed in registerInterestListAll", ex); } }
Example 16
Source File: RollingUpgradeTest.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** Register interest with ALL_KEYS, and InterestPolicyResult = KEYS_VALUES * which is equivalent to a full GII. */ protected static void registerInterest() { Log.getLogWriter().info("Calling registerInterest for different regions"); Set<Region<?,?>> rootRegions = CacheHelper.getCache().rootRegions(); for (Region aRegion: rootRegions) { Log.getLogWriter().info("Calling registerInterest for all keys, result interest policy KEYS_VALUES for region " + aRegion.getFullPath()); aRegion.registerInterest("ALL_KEYS", InterestResultPolicy.KEYS_VALUES); Log.getLogWriter().info("Done calling registerInterest for all keys, " + "result interest policy KEYS_VALUES, " + aRegion.getFullPath() + " size is " + aRegion.size()); } }
Example 17
Source File: CQListGIIDUnitTest.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
public static void registerInterestListAll() { try { Region r = cache.getRegion("/" + regionName); assertNotNull(r); r.registerInterest("ALL_KEYS"); } catch (Exception ex) { fail("failed in registerInterestListAll", ex); } }
Example 18
Source File: HASlowReceiverDUnitTest.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
public static void registerInterest() { try { Region r = cache.getRegion("/" + regionName); assertNotNull(r); r.registerInterest("ALL_KEYS"); } catch (Exception ex) { fail("failed in registerInterestListAll", ex); } }
Example 19
Source File: DeltaPropagationDUnitTest.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
public void testS2S2CDeltaPropagationWithHAOverflow() throws Exception { prepareDeltas(); VM0.invoke(DeltaPropagationDUnitTest.class, "prepareDeltas"); VM1.invoke(DeltaPropagationDUnitTest.class, "prepareDeltas"); VM0.invoke(DeltaPropagationDUnitTest.class, "closeCache"); PORT1 = ((Integer)VM0.invoke(DeltaPropagationDUnitTest.class, "createServerCache", new Object[] { HARegionQueue.HA_EVICTION_POLICY_NONE, new Integer(1) })) .intValue(); PORT2 = ((Integer)VM1.invoke(DeltaPropagationDUnitTest.class, "createServerCache", new Object[] { HARegionQueue.HA_EVICTION_POLICY_ENTRY, new Integer(1) })) .intValue(); VM0.invoke(ConflationDUnitTest.class, "setIsSlowStart", new Object[] { "60000" }); VM1.invoke(ConflationDUnitTest.class, "setIsSlowStart", new Object[] { "60000" }); createClientCache(new Integer(PORT2), new Integer(-1), "0", new Integer( CLIENT_LISTENER)); Region r = cache.getRegion("/" + regionName); assertNotNull(r); r.registerInterest("ALL_KEYS"); VM0.invoke(DeltaPropagationDUnitTest.class, "createAndUpdateDeltas"); VM1.invoke(DeltaPropagationDUnitTest.class, "confirmEviction", new Object[] { new Integer(PORT2) }); VM1.invoke(ConflationDUnitTest.class, "unsetIsSlowStart"); waitForLastKey(); long toDeltasOnServer1 = ((Long)VM0.invoke(DeltaTestImpl.class, "getToDeltaInvokations")).longValue(); long fromDeltasOnServer2 = ((Long)VM1.invoke(DeltaTestImpl.class, "getFromDeltaInvokations")).longValue(); long toDeltasOnServer2 = ((Long)VM1.invoke(DeltaTestImpl.class, "getToDeltaInvokations")).longValue(); long fromDeltasOnClient = DeltaTestImpl.getFromDeltaInvokations() .longValue(); assertTrue((EVENTS_SIZE - 1) + " deltas were to be sent but were " + toDeltasOnServer1, toDeltasOnServer1 == (EVENTS_SIZE - 1)); assertTrue((EVENTS_SIZE - 1) + " deltas were to be received but were " + fromDeltasOnServer2, fromDeltasOnServer2 == (EVENTS_SIZE - 1)); assertTrue("0 toDelta() were to be invoked but were " + toDeltasOnServer2, toDeltasOnServer2 == 0); assertTrue((EVENTS_SIZE - 1) + " deltas were to be received but were " + fromDeltasOnClient, fromDeltasOnClient == (EVENTS_SIZE - 1)); }
Example 20
Source File: PdxDeserializationDUnitTest.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
private void doOperations(Region<Object, Object> region) { //Do a put and a get region.put("A", new TestSerializable()); assertEquals(TestSerializable.class, region.get("A").getClass()); //Do a cache load assertEquals(TestSerializable.class, region.get("B").getClass()); //Make sure the cache load is in the right object form assertEquals(TestSerializable.class, region.get("B").getClass()); //If we're a client region, try a register interest if(region.getAttributes().getPoolName() != null) { region.registerInterest(".*", InterestResultPolicy.KEYS_VALUES); } //Do a query try { SelectResults queryResults = (SelectResults) getCache().getQueryService().newQuery("select * from " + region.getFullPath()).execute(); for(Object result : queryResults.asList()) { assertEquals(TestSerializable.class, result.getClass()); } } catch (Exception e) { fail("got exception from query", e); } //TODO Transactions don't work // CacheTransactionManager txManager = getCache().getCacheTransactionManager(); // //Test puts and get in a transaction // txManager.begin(); // region.put("C", new TestSerializable()); // assertEquals(TestSerializable.class, region.get("C").getClass()); // txManager.commit(); // // txManager.begin(); // assertEquals(TestSerializable.class, region.get("C").getClass()); // txManager.commit(); // // // //Test cache load in a transaction // txManager.begin(); // assertEquals(TestSerializable.class, region.get("D").getClass()); // txManager.commit(); // // txManager.begin(); // assertEquals(TestSerializable.class, region.get("D").getClass()); // txManager.commit(); }