Package com.gemstone.gemfire.cache.client

Examples of com.gemstone.gemfire.cache.client.Pool


    }
  }

  private void initQueryService() {
    if (StringUtils.hasText(poolName)) {
      Pool pool = PoolManager.find(poolName);
      Assert.notNull(pool, String.format("No GemFire Pool with name '%1$s' was found.", poolName));
      queryService = pool.getQueryService();
    }
  }
View Full Code Here


        beanFactory.getBean(poolName, Pool.class);
      }
      factory.setPoolName(poolName);
    }
    else {
      Pool pool = beanFactory.getBean(Pool.class);
      factory.setPoolName(pool.getName());
    }

    if (diskStoreName != null) {
      factory.setDiskStoreName(diskStoreName);
    }
View Full Code Here

  protected GemFireCache fetchCache() {
    return ClientCacheFactory.getAnyInstance();
  }
 
  private void initializePool(ClientCacheFactory clientCacheFactory) {
    Pool localPool = pool;

    if (localPool == null) {
      if (StringUtils.hasText(poolName)) {
        localPool = PoolManager.find(poolName);
      }
     
       // Bind this client cache to a pool that hasn't been created yet.
      if (localPool == null) {
        PoolFactoryBean.connectToTemporaryDs(this.properties);
      }
     
      if (StringUtils.hasText(poolName)) {
        try {
          getBeanFactory().isTypeMatch(poolName, Pool.class);
          localPool = getBeanFactory().getBean(poolName, Pool.class);
        }
        catch (Exception e) {
          String message = String.format("No bean found with name '%1$s' of type '%2$s'.%3$s", poolName,
            Pool.class.getName(), (GemfireConstants.DEFAULT_GEMFIRE_POOL_NAME.equals(poolName)
              ? " A client cache requires a pool." : ""));

          throw new BeanInitializationException(message);
        }
      }
      else {
        if (log.isDebugEnabled()) {
          log.debug("Checking for a unique pool...");
        }

        localPool = getBeanFactory().getBean(Pool.class);
        this.poolName = localPool.getName();
      }
    
    }

    if (localPool != null) {
      // copy the pool settings - this way if the pool is not found, at
      // least the cache will have a similar config
      clientCacheFactory.setPoolFreeConnectionTimeout(localPool.getFreeConnectionTimeout());
      clientCacheFactory.setPoolIdleTimeout(localPool.getIdleTimeout());
      clientCacheFactory.setPoolLoadConditioningInterval(localPool.getLoadConditioningInterval());
      clientCacheFactory.setPoolMaxConnections(localPool.getMaxConnections());
      clientCacheFactory.setPoolMinConnections(localPool.getMinConnections());
      clientCacheFactory.setPoolMultiuserAuthentication(localPool.getMultiuserAuthentication());
      clientCacheFactory.setPoolPingInterval(localPool.getPingInterval());
      clientCacheFactory.setPoolPRSingleHopEnabled(localPool.getPRSingleHopEnabled());
      clientCacheFactory.setPoolReadTimeout(localPool.getReadTimeout());
      clientCacheFactory.setPoolRetryAttempts(localPool.getRetryAttempts());
      clientCacheFactory.setPoolServerGroup(localPool.getServerGroup());
      clientCacheFactory.setPoolSocketBufferSize(localPool.getSocketBufferSize());
      clientCacheFactory.setPoolStatisticInterval(localPool.getStatisticInterval());
      clientCacheFactory.setPoolSubscriptionAckInterval(localPool.getSubscriptionAckInterval());
      clientCacheFactory.setPoolSubscriptionEnabled(localPool.getSubscriptionEnabled());
      clientCacheFactory.setPoolSubscriptionMessageTrackingTimeout(localPool.getSubscriptionMessageTrackingTimeout());
      clientCacheFactory.setPoolSubscriptionRedundancy(localPool.getSubscriptionRedundancy());
      clientCacheFactory.setPoolThreadLocalConnections(localPool.getThreadLocalConnections());

      List<InetSocketAddress> locators = localPool.getLocators();

      if (locators != null) {
        for (InetSocketAddress socketAddress : locators) {
          clientCacheFactory.addPoolLocator(socketAddress.getHostName(), socketAddress.getPort());
        }
      }

      List<InetSocketAddress> servers = localPool.getServers();

      if (servers != null) {
        for (InetSocketAddress socketAddress : servers) {
          clientCacheFactory.addPoolServer(socketAddress.getHostName(), socketAddress.getPort());
        }
View Full Code Here

      connectToTemporaryDs(properties);
     
    }

    // first check the configured pools
    Pool existingPool = PoolManager.find(name);
    if (existingPool != null) {
      pool = existingPool;
      internalPool = false;
      if (log.isDebugEnabled())
        log.debug("Pool '" + name
View Full Code Here

        ContinuousQueryListenerContainer.class);

      assertSame(container, container2);

      Cache cache = applicationContext.getBean("gemfireCache", Cache.class);
      Pool pool = applicationContext.getBean("client", Pool.class);

      CqQuery[] cqs = cache.getQueryService().getCqs();
      CqQuery[] poolCqs = pool.getQueryService().getCqs();

      assertTrue(pool.getQueryService().getCq("test-bean-1") != null);
      assertEquals(3, cqs.length);
      assertEquals(3, poolCqs.length);
    }
    finally {
      ForkUtil.sendSignal();
View Full Code Here

  @SuppressWarnings("unused")
  @Test
  public void testServerDataSource() {
    Cache cache = ctx.getBean("gemfireCache", Cache.class);
    Pool pool = ctx.getBean("gemfirePool", Pool.class);
    assertEquals(true, pool.getSubscriptionEnabled());

    String regions[] = ctx.getBeanNamesForType(Region.class);
    List<String> regionList = Arrays.asList(regions);
    assertTrue(regionList.contains("r1"));
    assertTrue(regionList.contains("r2"));
View Full Code Here

  @Test
  public void testContextCreated() throws Exception {

    ClientCache cache = context.getBean("gemfireCache", ClientCache.class);
    Pool pool = context.getBean("gemfirePool", Pool.class);
    assertEquals("gemfirePool", pool.getName());
    assertEquals(1, cache.getDefaultPool().getServers().size());
    assertEquals(pool.getServers().get(0), cache.getDefaultPool().getServers().get(0));

    context.getBean("r1", Region.class);

    GemfireOnServerFunctionTemplate template = context.getBean(GemfireOnServerFunctionTemplate.class);
    assertTrue(template.getResultCollector() instanceof MyResultCollector);
View Full Code Here

  @Test
  public void testLookupFallbackFailingToUseProvidedShortcut() throws Exception {
    factoryBean.setShortcut(ClientRegionShortcut.CACHING_PROXY);

    BeanFactory beanFactory = mock(BeanFactory.class);
    Pool pool = mock(Pool.class);

    when(beanFactory.getBean(Pool.class)).thenReturn(pool);

    factoryBean.setBeanFactory(beanFactory);
View Full Code Here

TOP

Related Classes of com.gemstone.gemfire.cache.client.Pool

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.