Search in sources :

Example 1 with ClientRegionFactory

use of org.apache.geode.cache.client.ClientRegionFactory in project geode by apache.

the class ClientServerCCEDUnitTest method createDurableClientRegion.

// For durable client QRM testing we need a backup queue (redundancy=1) and
// durable attributes. We also need to invoke readyForEvents()
private void createDurableClientRegion(final VM vm, final String regionName, final int port1, final int port2, final boolean ccEnabled) {
    SerializableCallable createRegion = new SerializableCallable() {

        public Object call() throws Exception {
            ClientCacheFactory cf = new ClientCacheFactory();
            cf.addPoolServer(NetworkUtils.getServerHostName(vm.getHost()), port1);
            cf.addPoolServer(NetworkUtils.getServerHostName(vm.getHost()), port2);
            cf.setPoolSubscriptionEnabled(true);
            cf.setPoolSubscriptionRedundancy(1);
            // bug #50683 - secondary durable queue retains all GC messages
            cf.set(DURABLE_CLIENT_ID, "" + vm.getPid());
            cf.set(DURABLE_CLIENT_TIMEOUT, "" + 200);
            cf.set(LOG_LEVEL, LogWriterUtils.getDUnitLogLevel());
            ClientCache cache = getClientCache(cf);
            ClientRegionFactory crf = cache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY);
            crf.setConcurrencyChecksEnabled(ccEnabled);
            TestRegion = (LocalRegion) crf.create(regionName);
            TestRegion.registerInterestRegex(".*", InterestResultPolicy.KEYS_VALUES, true, true);
            cache.readyForEvents();
            return null;
        }
    };
    vm.invoke(createRegion);
}
Also used : SerializableCallable(org.apache.geode.test.dunit.SerializableCallable) ClientCache(org.apache.geode.cache.client.ClientCache) ClientRegionFactory(org.apache.geode.cache.client.ClientRegionFactory) ClientCacheFactory(org.apache.geode.cache.client.ClientCacheFactory)

Example 2 with ClientRegionFactory

use of org.apache.geode.cache.client.ClientRegionFactory in project geode by apache.

the class ClientServerCCEDUnitTest method createClientRegion.

private void createClientRegion(final VM vm, final String regionName, final int port, final boolean ccEnabled, final ClientRegionShortcut clientRegionShortcut, final boolean registerInterest) {
    SerializableCallable createRegion = new SerializableCallable() {

        public Object call() throws Exception {
            ClientCacheFactory cf = new ClientCacheFactory();
            cf.addPoolServer(NetworkUtils.getServerHostName(vm.getHost()), port);
            if (registerInterest) {
                cf.setPoolSubscriptionEnabled(true);
            }
            cf.set(LOG_LEVEL, LogWriterUtils.getDUnitLogLevel());
            ClientCache cache = getClientCache(cf);
            ClientRegionFactory crf = cache.createClientRegionFactory(clientRegionShortcut);
            crf.setConcurrencyChecksEnabled(ccEnabled);
            crf.setStatisticsEnabled(true);
            TestRegion = (LocalRegion) crf.create(regionName);
            if (registerInterest) {
                TestRegion.registerInterestRegex(".*", InterestResultPolicy.KEYS_VALUES, false, true);
            }
            return null;
        }
    };
    vm.invoke(createRegion);
}
Also used : SerializableCallable(org.apache.geode.test.dunit.SerializableCallable) ClientCache(org.apache.geode.cache.client.ClientCache) ClientRegionFactory(org.apache.geode.cache.client.ClientRegionFactory) ClientCacheFactory(org.apache.geode.cache.client.ClientCacheFactory)

Example 3 with ClientRegionFactory

use of org.apache.geode.cache.client.ClientRegionFactory in project geode by apache.

the class UnregisterInterestDUnitTest method createClientCache.

public static void createClientCache(Host host, Integer port) throws Exception {
    DistributedSystem ds = new UnregisterInterestDUnitTest().getSystem();
    ds.disconnect();
    Properties props = new Properties();
    props.setProperty(LOCATORS, "");
    props.setProperty(MCAST_PORT, "0");
    ClientCacheFactory ccf = new ClientCacheFactory(props);
    ccf.setPoolSubscriptionEnabled(true);
    ccf.addPoolServer(host.getHostName(), port);
    cache = ccf.create();
    ClientRegionFactory crf = ((GemFireCacheImpl) cache).createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY);
    crf.create(regionname);
}
Also used : GemFireCacheImpl(org.apache.geode.internal.cache.GemFireCacheImpl) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) DistributedSystem(org.apache.geode.distributed.DistributedSystem) ClientRegionFactory(org.apache.geode.cache.client.ClientRegionFactory) ClientCacheFactory(org.apache.geode.cache.client.ClientCacheFactory)

Example 4 with ClientRegionFactory

use of org.apache.geode.cache.client.ClientRegionFactory in project geode by apache.

the class TestClientIdsDUnitTest method createClientCache.

private void createClientCache(final String host, final int serverPort) {
    ClientCache cache = this.managementTestRule.getClientCache();
    Pool pool = PoolManager.createFactory().addServer(host, serverPort).setSubscriptionEnabled(false).setThreadLocalConnections(true).setMinConnections(1).setReadTimeout(20000).setPingInterval(10000).setRetryAttempts(1).setSubscriptionEnabled(true).setStatisticInterval(1000).create(getClass().getSimpleName());
    ClientRegionFactory factory = cache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY);
    factory.setPoolName(pool.getName());
    factory.create(REGION_NAME);
}
Also used : Pool(org.apache.geode.cache.client.Pool) ClientCache(org.apache.geode.cache.client.ClientCache) ClientRegionFactory(org.apache.geode.cache.client.ClientRegionFactory)

Example 5 with ClientRegionFactory

use of org.apache.geode.cache.client.ClientRegionFactory in project geode by apache.

the class LocalQueryServiceJUnitTest method before.

@Before
public void before() throws Exception {
    this.ignoredException = addIgnoredException(IOException.class.getName());
    this.clientCache = new ClientCacheFactory().create();
    ClientRegionFactory factory = this.clientCache.createClientRegionFactory(ClientRegionShortcut.LOCAL);
    Region region = factory.create("localRegion");
    this.numEntries = 10;
    for (int i = 0; i < this.numEntries; i++) {
        region.put(i, i);
    }
}
Also used : Region(org.apache.geode.cache.Region) ClientRegionFactory(org.apache.geode.cache.client.ClientRegionFactory) ClientCacheFactory(org.apache.geode.cache.client.ClientCacheFactory) Before(org.junit.Before)

Aggregations

ClientRegionFactory (org.apache.geode.cache.client.ClientRegionFactory)10 ClientCache (org.apache.geode.cache.client.ClientCache)7 ClientCacheFactory (org.apache.geode.cache.client.ClientCacheFactory)6 Region (org.apache.geode.cache.Region)4 SerializableCallable (org.apache.geode.test.dunit.SerializableCallable)3 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)3 Test (org.junit.Test)3 Properties (java.util.Properties)2 EntryEvent (org.apache.geode.cache.EntryEvent)2 CacheListenerAdapter (org.apache.geode.cache.util.CacheListenerAdapter)2 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)2 SecurityTestUtil.createClientCache (org.apache.geode.security.SecurityTestUtil.createClientCache)2 SecurityTestUtil.createProxyRegion (org.apache.geode.security.SecurityTestUtil.createProxyRegion)2 SecurityTest (org.apache.geode.test.junit.categories.SecurityTest)2 NamingException (javax.naming.NamingException)1 RollbackException (javax.transaction.RollbackException)1 TXExpiryJUnitTest (org.apache.geode.TXExpiryJUnitTest)1 AttributesFactory (org.apache.geode.cache.AttributesFactory)1 CacheLoaderException (org.apache.geode.cache.CacheLoaderException)1 CacheWriterException (org.apache.geode.cache.CacheWriterException)1