Search in sources :

Example 11 with PoolFactoryImpl

use of org.apache.geode.internal.cache.PoolFactoryImpl in project geode by apache.

the class CacheServerTestUtil method createCacheClient.

public static void createCacheClient(Pool poolAttr, String regionName1, String regionName2) throws Exception {
    new CacheServerTestUtil().createCache(getClientProperties());
    PoolFactoryImpl pf = (PoolFactoryImpl) PoolManager.createFactory();
    pf.init(poolAttr);
    PoolImpl p = (PoolImpl) pf.create("CacheServerTestUtil");
    AttributesFactory factory = new AttributesFactory();
    factory.setScope(Scope.LOCAL);
    factory.setPoolName(p.getName());
    RegionAttributes attrs = factory.create();
    cache.createRegion(regionName1, attrs);
    cache.createRegion(regionName2, attrs);
    pool = p;
}
Also used : AttributesFactory(org.apache.geode.cache.AttributesFactory) RegionAttributes(org.apache.geode.cache.RegionAttributes) PoolImpl(org.apache.geode.cache.client.internal.PoolImpl) PoolFactoryImpl(org.apache.geode.internal.cache.PoolFactoryImpl)

Example 12 with PoolFactoryImpl

use of org.apache.geode.internal.cache.PoolFactoryImpl in project geode by apache.

the class CacheServerTestUtil method createCacheClients.

/**
   * Create client regions
   */
public static void createCacheClients(Pool poolAttr, String regionName1, String regionName2, Properties dsProperties) throws Exception {
    new CacheServerTestUtil().createCache(dsProperties);
    // Initialize region1
    PoolFactoryImpl pf = (PoolFactoryImpl) PoolManager.createFactory();
    pf.init(poolAttr);
    Pool p = pf.create("CacheServerTestUtil1");
    AttributesFactory factory1 = new AttributesFactory();
    factory1.setScope(Scope.LOCAL);
    factory1.setPoolName(p.getName());
    cache.createRegion(regionName1, factory1.create());
    // Initialize region2
    p = pf.create("CacheServerTestUtil2");
    AttributesFactory factory2 = new AttributesFactory();
    factory2.setScope(Scope.LOCAL);
    factory2.setPoolName(p.getName());
    cache.createRegion(regionName2, factory2.create());
}
Also used : AttributesFactory(org.apache.geode.cache.AttributesFactory) Pool(org.apache.geode.cache.client.Pool) PoolFactoryImpl(org.apache.geode.internal.cache.PoolFactoryImpl)

Example 13 with PoolFactoryImpl

use of org.apache.geode.internal.cache.PoolFactoryImpl in project geode by apache.

the class InterestListFailoverDUnitTest method getClientPool.

private Pool getClientPool(String host, int redundancyLevel) {
    PoolFactory pf = PoolManager.createFactory();
    pf.addServer(host, PORT1).addServer(host, PORT2).setSubscriptionEnabled(true).setReadTimeout(500).setSocketBufferSize(32768).setMinConnections(4).setSubscriptionRedundancy(redundancyLevel);
    return ((PoolFactoryImpl) pf).getPoolAttributes();
}
Also used : PoolFactory(org.apache.geode.cache.client.PoolFactory) PoolFactoryImpl(org.apache.geode.internal.cache.PoolFactoryImpl)

Example 14 with PoolFactoryImpl

use of org.apache.geode.internal.cache.PoolFactoryImpl in project geode by apache.

the class DurableClientStatsDUnitTest method getClientPool.

private Pool getClientPool(String host, int server1Port, boolean establishCallbackConnection, int redundancyLevel) {
    PoolFactory pf = PoolManager.createFactory();
    pf.addServer(host, server1Port).setSubscriptionEnabled(establishCallbackConnection).setSubscriptionRedundancy(redundancyLevel);
    return ((PoolFactoryImpl) pf).getPoolAttributes();
}
Also used : PoolFactory(org.apache.geode.cache.client.PoolFactory) PoolFactoryImpl(org.apache.geode.internal.cache.PoolFactoryImpl)

Example 15 with PoolFactoryImpl

use of org.apache.geode.internal.cache.PoolFactoryImpl in project geode by apache.

the class AbstractRemoteGatewaySender method initProxy.

public synchronized void initProxy() {
    // return if it is being used for WBCL or proxy is already created
    if (this.remoteDSId == DEFAULT_DISTRIBUTED_SYSTEM_ID || this.proxy != null && !this.proxy.isDestroyed()) {
        return;
    }
    int locatorCount = 0;
    PoolFactoryImpl pf = (PoolFactoryImpl) PoolManager.createFactory();
    pf.setPRSingleHopEnabled(false);
    if (this.locatorDiscoveryCallback != null) {
        pf.setLocatorDiscoveryCallback(locatorDiscoveryCallback);
    }
    pf.setReadTimeout(this.socketReadTimeout);
    pf.setIdleTimeout(connectionIdleTimeOut);
    pf.setSocketBufferSize(socketBufferSize);
    pf.setServerGroup(GatewayReceiver.RECEIVER_GROUP);
    RemoteLocatorRequest request = new RemoteLocatorRequest(this.remoteDSId, pf.getPoolAttributes().getServerGroup());
    String locators = this.cache.getInternalDistributedSystem().getConfig().getLocators();
    if (logger.isDebugEnabled()) {
        logger.debug("Gateway Sender is attempting to configure pool with remote locator information");
    }
    StringTokenizer locatorsOnThisVM = new StringTokenizer(locators, ",");
    while (locatorsOnThisVM.hasMoreTokens()) {
        String localLocator = locatorsOnThisVM.nextToken();
        DistributionLocatorId locatorID = new DistributionLocatorId(localLocator);
        try {
            RemoteLocatorResponse response = (RemoteLocatorResponse) new TcpClient().requestToServer(locatorID.getHost(), locatorID.getPort(), request, WanLocatorDiscoverer.WAN_LOCATOR_CONNECTION_TIMEOUT);
            if (response != null) {
                if (response.getLocators() == null) {
                    if (logProxyFailure()) {
                        logger.warn(LocalizedMessage.create(LocalizedStrings.AbstractGatewaySender_REMOTE_LOCATOR_FOR_REMOTE_SITE_0_IS_NOT_AVAILABLE_IN_LOCAL_LOCATOR_1, new Object[] { remoteDSId, localLocator }));
                    }
                    continue;
                }
                if (logger.isDebugEnabled()) {
                    logger.debug("Received the remote site {} location information:", this.remoteDSId, response.getLocators());
                }
                Iterator<String> itr = response.getLocators().iterator();
                while (itr.hasNext()) {
                    String remoteLocator = itr.next();
                    try {
                        DistributionLocatorId locatorId = new DistributionLocatorId(remoteLocator);
                        pf.addLocator(locatorId.getHost().getHostName(), locatorId.getPort());
                        locatorCount++;
                    } catch (Exception e) {
                        if (logProxyFailure()) {
                            logger.warn(LocalizedMessage.create(LocalizedStrings.PoolFactoryImpl_CAUGHT_EXCEPTION_ATTEMPTING_TO_ADD_REMOTE_LOCATOR_0, new Object[] { remoteLocator }), e);
                        }
                    }
                }
                break;
            }
        } catch (IOException ioe) {
            if (logProxyFailure()) {
                // don't print stack trace for connection failures
                String ioeStr = "";
                if (!logger.isDebugEnabled() && ioe instanceof ConnectException) {
                    ioeStr = ": " + ioe.toString();
                    ioe = null;
                }
                logger.warn(LocalizedMessage.create(LocalizedStrings.AbstractGatewaySender_SENDER_0_IS_NOT_ABLE_TO_CONNECT_TO_LOCAL_LOCATOR_1, new Object[] { this.id, localLocator + ioeStr }), ioe);
            }
            continue;
        } catch (ClassNotFoundException e) {
            if (logProxyFailure()) {
                logger.warn(LocalizedMessage.create(LocalizedStrings.AbstractGatewaySender_SENDER_0_IS_NOT_ABLE_TO_CONNECT_TO_LOCAL_LOCATOR_1, new Object[] { this.id, localLocator }), e);
            }
            continue;
        }
    }
    if (locatorCount == 0) {
        if (logProxyFailure()) {
            logger.fatal(LocalizedMessage.create(LocalizedStrings.AbstractGatewaySender_SENDER_0_COULD_NOT_GET_REMOTE_LOCATOR_INFORMATION_FOR_SITE_1, new Object[] { this.id, this.remoteDSId }));
        }
        this.proxyFailureTries++;
        throw new GatewaySenderConfigurationException(LocalizedStrings.AbstractGatewaySender_SENDER_0_COULD_NOT_GET_REMOTE_LOCATOR_INFORMATION_FOR_SITE_1.toLocalizedString(new Object[] { this.id, this.remoteDSId }));
    }
    pf.init(this);
    this.proxy = ((PoolImpl) pf.create(this.getId()));
    if (this.proxyFailureTries > 0) {
        logger.info(LocalizedMessage.create(LocalizedStrings.AbstractGatewaySender_SENDER_0_GOT_REMOTE_LOCATOR_INFORMATION_FOR_SITE_1, new Object[] { this.id, this.remoteDSId, this.proxyFailureTries }));
        this.proxyFailureTries = 0;
    }
}
Also used : DistributionLocatorId(org.apache.geode.internal.admin.remote.DistributionLocatorId) RemoteLocatorResponse(org.apache.geode.cache.client.internal.locator.wan.RemoteLocatorResponse) IOException(java.io.IOException) PoolImpl(org.apache.geode.cache.client.internal.PoolImpl) IOException(java.io.IOException) ConnectException(java.net.ConnectException) PoolFactoryImpl(org.apache.geode.internal.cache.PoolFactoryImpl) StringTokenizer(java.util.StringTokenizer) TcpClient(org.apache.geode.distributed.internal.tcpserver.TcpClient) RemoteLocatorRequest(org.apache.geode.cache.client.internal.locator.wan.RemoteLocatorRequest) ConnectException(java.net.ConnectException)

Aggregations

PoolFactoryImpl (org.apache.geode.internal.cache.PoolFactoryImpl)27 PoolFactory (org.apache.geode.cache.client.PoolFactory)10 Test (org.junit.Test)9 AttributesFactory (org.apache.geode.cache.AttributesFactory)7 ClientServerTest (org.apache.geode.test.junit.categories.ClientServerTest)7 Pool (org.apache.geode.cache.client.Pool)6 RegionAttributes (org.apache.geode.cache.RegionAttributes)5 PoolImpl (org.apache.geode.cache.client.internal.PoolImpl)5 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)5 Host (org.apache.geode.test.dunit.Host)4 VM (org.apache.geode.test.dunit.VM)4 ServerLocation (org.apache.geode.distributed.internal.ServerLocation)3 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Properties (java.util.Properties)2 DiskStore (org.apache.geode.cache.DiskStore)2 ServerLoad (org.apache.geode.cache.server.ServerLoad)2 IgnoredException (org.apache.geode.test.dunit.IgnoredException)2 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)2