This package contains the main API for interacting with a cluster member group - this is the way to start a Coherence cluster within a single JVM and then interact with it as a storage disabled member or an Extend client.
This framework has the following motivations:public class SimpleApp { public static void main(String[] args) { final String key = "123"; ClusterMemberGroup memberGroup = null; try { memberGroup = ClusterMemberGroupUtils.newClusterMemberGroupBuilder() .setStorageEnabledCount(2).build(); final NamedCache cache = CacheFactory.getCache("test"); cache.put(key, "hello"); System.out.println(cache.get(key)); } finally { ClusterMemberGroupUtils.shutdownCacheFactoryThenClusterMemberGroups(memberGroup); } } }
public class SimpleTest { private static ClusterMemberGroup memberGroup; @BeforeClass public static void beforeTests() { memberGroup = ClusterMemberGroupUtils.newClusterMemberGroupBuilder() .setStorageEnabledCount(2).build(); } @AfterClass public static void afterTests() { ClusterMemberGroupUtils.shutdownCacheFactoryThenClusterMemberGroups(memberGroup); } @Test public void simpleExample() { NamedCache cache = CacheFactory.getCache("test"); cache.put("key", "hello"); assertEquals(1, cache.size()); } }
... @Test public void exampleOfConfiguringExtendProxyWithSeparateStorageEnabledMembersThroughProperties() { /* This properties could be read from a file. */ Properties properties = new Properties(); properties.setProperty("StorageEnabledCount", "2"); properties.setProperty("ExtendProxyCount", "1"); properties.setProperty("CacheConfiguration", TCMP_CLUSTER_MEMBER_CACHE_CONFIG_FILE); properties.setProperty("ClientCacheConfiguration", EXTEND_CLIENT_CACHE_CONFIG_FILE); memberGroup = ClusterMemberGroupUtils.newClusterMemberGroupBuilder().setBuilderProperties(properties).build(); NamedCache cache = CacheFactory.getCache("known-extend-cache"); cache.put("key", "value"); assertThat(cache.size(), is(1)); assertThat((String) cache.get("key"), is("value")); }