当前位置: 首页>>代码示例>>Java>>正文


Java GenericKeyedObjectPoolConfig类代码示例

本文整理汇总了Java中org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig的典型用法代码示例。如果您正苦于以下问题:Java GenericKeyedObjectPoolConfig类的具体用法?Java GenericKeyedObjectPoolConfig怎么用?Java GenericKeyedObjectPoolConfig使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


GenericKeyedObjectPoolConfig类属于org.apache.commons.pool2.impl包,在下文中一共展示了GenericKeyedObjectPoolConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ClientSelector

import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
public ClientSelector(String servers, int loadBalance, ConnectionValidator validator, GenericKeyedObjectPoolConfig poolConfig, FailoverStrategy strategy, int connTimeout, String backupServers, int serviceLevel) {
   	this.failoverChecker = new FailoverChecker(validator, strategy, serviceLevel);
   	this.poolProvider = new DefaultThriftConnectionPool(new ThriftConnectionFactory(failoverChecker, connTimeout), poolConfig);
   	failoverChecker.setConnectionPool(poolProvider);
   	failoverChecker.setServerList(ThriftServer.parse(servers));
       if (StringUtils.isNotEmpty(backupServers)) {
       	failoverChecker.setBackupServerList(ThriftServer.parse(backupServers));
       } else{
       	failoverChecker.setBackupServerList(new ArrayList<ThriftServer>());
       }
       failoverChecker.startChecking();
   }
 
开发者ID:cyfonly,项目名称:ThriftJ,代码行数:14,代码来源:ClientSelector.java

示例2: initialize

import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig; //导入依赖的package包/类
/**
 * Lifecycle method. Initializes the pool using the supplied KeyedPooledObjectFactory and the configuration.
 * @param factory
 * @param configuration
 * @throws java.lang.IllegalStateException if the pool instance has already been initialized.
 */
public static void initialize(KeyedPooledObjectFactory<APNSConnectionKey, APNSConnection> factory,
    GenericKeyedObjectPoolConfig configuration) {
  if (initialized.get()) {
    throw new IllegalStateException("Can't initialize multiple times");
  }
  instance.connectionPool = new GenericKeyedObjectPool<APNSConnectionKey, APNSConnection>(
      factory, configuration);
  instance.connectionPool.setMaxWaitMillis(1000L * getIntProperty(
      MMXConfigKeys.APNS_POOL_WAIT_SECONDS,
      MMXServerConstants.APNS_POOL_WAIT_SECONDS));
  initialized.set(true);
  LOGGER.info("APNS Connection pool is initialized");
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:20,代码来源:APNSConnectionPoolImpl.java

示例3: createEventPool

import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig; //导入依赖的package包/类
private KeyedObjectPool<Event.Type, Event> createEventPool() {
    final CoreConfigure cfg = CoreConfigure.getInstance();
    if (cfg.isEventPoolEnable()) {
        final GenericKeyedObjectPoolConfig poolConfig = new GenericKeyedObjectPoolConfig();
        poolConfig.setMaxTotalPerKey(cfg.getEventPoolMaxTotalPerEvent());
        poolConfig.setMinIdlePerKey(cfg.getEventPoolMinIdlePerEvent());
        poolConfig.setMaxIdlePerKey(cfg.getEventPoolMaxIdlePerEvent());
        poolConfig.setMaxTotal(cfg.getEventPoolMaxTotal());
        logger.info("enable event-pool[per-key-idle-min={};per-key-idle-max={};per-key-max={};total={};]",
                cfg.getEventPoolMinIdlePerEvent(),
                cfg.getEventPoolMaxIdlePerEvent(),
                cfg.getEventPoolMaxTotalPerEvent(),
                cfg.getEventPoolMaxTotal()
        );
        return new GenericKeyedObjectPool<Event.Type, Event>(new EventFactory(), poolConfig);
    } else {
        logger.info("disable event-pool.");
        return null;
    }
}
 
开发者ID:alibaba,项目名称:jvm-sandbox,代码行数:21,代码来源:EventPool.java

示例4: init

import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig; //导入依赖的package包/类
@Before
public void init() throws InterruptedException {
    this.appKey = "proxytest" + NumUtil.nextNum();
    ServiceFactoryTest serviceFactoryTest = new ServiceFactoryTest();
    ServerArgs serverArgs = serviceFactoryTest.getServerArgs(this.appKey, "127.0.0.1", NumUtil.nextPort());
    ZkRegistry zkRegistry = serviceFactoryTest.getZkRegistry();
    serverArgs.setRegistrys(ImmutableList.of(zkRegistry));

    ThriftServerPublisher publisher = new ThriftServerPublisher(serverArgs);
    Thread thread = new Thread(publisher::init);
    thread.setDaemon(true);
    thread.start();
    TimeUnit.MILLISECONDS.sleep(400);

    poolConfig = new GenericKeyedObjectPoolConfig();
    poolConfig.setMaxTotal(MAX_CONN);
    poolConfig.setMaxTotalPerKey(MAX_CONN);
    poolConfig.setMaxIdlePerKey(MAX_CONN);
    poolConfig.setMinIdlePerKey(MIN_CONN);
    poolConfig.setTestOnBorrow(true);
    poolConfig.setMinEvictableIdleTimeMillis(MINUTES.toMillis(1));
    poolConfig.setSoftMinEvictableIdleTimeMillis(MINUTES.toMillis(1));
    poolConfig.setJmxEnabled(false);
}
 
开发者ID:sofn,项目名称:trpc,代码行数:25,代码来源:TrpcClientProxyTest.java

示例5: init

import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig; //导入依赖的package包/类
@Before
public void init() throws InterruptedException {
    ServiceFactoryTest serviceFactoryTest = new ServiceFactoryTest();
    ServerArgs serverArgs = serviceFactoryTest.getServerArgs(appKey, "127.0.0.1", port);

    ThriftServerPublisher publisher = new ThriftServerPublisher(serverArgs);
    Thread thread = new Thread(publisher::init);
    thread.setDaemon(true);
    thread.start();
    TimeUnit.MILLISECONDS.sleep(400);

    poolConfig = new GenericKeyedObjectPoolConfig();
    poolConfig.setMaxTotal(MAX_CONN);
    poolConfig.setMaxTotalPerKey(MAX_CONN);
    poolConfig.setMaxIdlePerKey(MAX_CONN);
    poolConfig.setMinIdlePerKey(MIN_CONN);
    poolConfig.setTestOnBorrow(true);
    poolConfig.setMinEvictableIdleTimeMillis(MINUTES.toMillis(1));
    poolConfig.setSoftMinEvictableIdleTimeMillis(MINUTES.toMillis(1));
    poolConfig.setJmxEnabled(false);
}
 
开发者ID:sofn,项目名称:trpc,代码行数:22,代码来源:StaticMonitorTest.java

示例6: getFastdfsClient

import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig; //导入依赖的package包/类
public static FastdfsClient getFastdfsClient(){
    if (fastdfsClient == null) {
        synchronized (FastdfsClient.class) {
            if (fastdfsClient == null) {
                try {
                    config = new FastdfsClientConfig(configFile);
                } catch (ConfigurationException e) {
                    logger.warn("Load fastdfs config failed.",e);
                }
                int connectTimeout = config.getConnectTimeout();
                int networkTimeout = config.getNetworkTimeout();
                TrackerClientFactory trackerClientFactory = new TrackerClientFactory(connectTimeout, networkTimeout);
                StorageClientFactory storageClientFactory = new StorageClientFactory(connectTimeout, networkTimeout);
                GenericKeyedObjectPoolConfig trackerClientPoolConfig = config.getTrackerClientPoolConfig();
                GenericKeyedObjectPoolConfig storageClientPoolConfig = config.getStorageClientPoolConfig();
                GenericKeyedObjectPool<String,TrackerClient> trackerClientPool = new GenericKeyedObjectPool<String,TrackerClient>(trackerClientFactory, trackerClientPoolConfig);
                GenericKeyedObjectPool<String,StorageClient> storageClientPool = new GenericKeyedObjectPool<String,StorageClient>(storageClientFactory, storageClientPoolConfig);
                List<String> trackerAddrs = config.getTrackerAddrs();
                fastdfsClient = new FastdfsClientImpl(trackerAddrs,trackerClientPool,storageClientPool);
            }
        }
    }
    return fastdfsClient;
}
 
开发者ID:simbest,项目名称:simbest-cores,代码行数:25,代码来源:FastdfsClientFactory.java

示例7: test

import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig; //导入依赖的package包/类
@Test
public void test() {
    PooledConnectionFactory pooledConnectionFactory = new PooledConnectionFactory(500, 500);

    GenericKeyedObjectPoolConfig conf = new GenericKeyedObjectPoolConfig();
    conf.setMaxTotal(20);
    ConnectionPool connectionPool = new ConnectionPool(pooledConnectionFactory, conf);

    Set<String> trackerSet = new HashSet<String>();
    trackerSet.add("192.168.10.128:22122");

    DefaultCommandExecutor connectionManager = new DefaultCommandExecutor(trackerSet, connectionPool);

    connectionManager.dumpPoolInfo();

    GetStorageNodeCommand command = new GetStorageNodeCommand();
    StorageNode storageNode = connectionManager.execute(command);
    logger.info(storageNode.toString());

    connectionManager.dumpPoolInfo();

    connectionPool.close();
}
 
开发者ID:Lzw2016,项目名称:fastdfs-java-client,代码行数:24,代码来源:ConnectionManagerTest.java

示例8: getPool

import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig; //导入依赖的package包/类
private synchronized GenericKeyedObjectPool<String, Script> getPool() {
    if (pool == null) {
        GenericKeyedObjectPoolConfig poolConfig = new GenericKeyedObjectPoolConfig();
        poolConfig.setMaxTotalPerKey(-1);
        poolConfig.setMaxIdlePerKey(globalConfig.getGroovyEvaluationPoolMaxIdle());
        pool = new GenericKeyedObjectPool<>(
                new BaseKeyedPooledObjectFactory<String, Script>() {
                    @Override
                    public Script create(String key) throws Exception {
                        return createScript(key);
                    }

                    @Override
                    public PooledObject<Script> wrap(Script value) {
                        return new DefaultPooledObject<>(value);
                    }
                },
                poolConfig
        );
    }
    return pool;
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:23,代码来源:AbstractScripting.java

示例9: initializeAPNSConnectionPool

import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig; //导入依赖的package包/类
public void initializeAPNSConnectionPool() {

    MMXConfiguration configuration = MMXConfiguration.getConfiguration();
    int maxObjectsPerKey = configuration.getInt(MMXConfigKeys.APNS_POOL_MAX_CONNECTIONS_PER_APP, MMXServerConstants.APNS_POOL_MAX_CONNECTIONS_PER_APP);
    int maxIdleObjectsPerKey = configuration.getInt(MMXConfigKeys.APNS_POOL_MAX_IDLE_CONNECTIONS_PER_APP, MMXServerConstants.APNS_POOL_MAX_IDLE_CONNECTIONS_PER_APP);
    int ttlForIdleObjectsInMinutes = configuration.getInt(MMXConfigKeys.APNS_POOL_IDLE_TTL_MINUTES, MMXServerConstants.APNS_POOL_IDLE_TTL_MINUTES);
    int maxTotal = configuration.getInt(MMXConfigKeys.APNS_POOL_MAX_TOTAL_CONNECTIONS, MMXServerConstants.APNS_POOL_MAX_TOTAL_CONNECTIONS);

    Log.info("Configuring APNS Connection pool with following values: maxObjects:{}, maxObjectsPerKey:{}, " +
        "maxIdleObjectsPerKey:{}, ttlForIdleObjectsInMinutes:{}", maxTotal, maxObjectsPerKey, maxIdleObjectsPerKey, ttlForIdleObjectsInMinutes);

    GenericKeyedObjectPoolConfig config = new GenericKeyedObjectPoolConfig();
    config.setMaxTotalPerKey(maxObjectsPerKey);
    config.setMaxTotal(maxTotal);
    config.setMaxIdlePerKey(maxIdleObjectsPerKey);
    config.setMinEvictableIdleTimeMillis(ttlForIdleObjectsInMinutes * 60 * 1000L);

    APNSConnectionPoolImpl.initialize(config);
  }
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:20,代码来源:MMXPlugin.java

示例10: SshPool

import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig; //导入依赖的package包/类
/**
 * create Ssh Pool
 * @param config
 * @param poolConfig
 */
public SshPool(final SshConfig config,
        final GenericKeyedObjectPoolConfig poolConfig) {
    this.config = config;

    this.pool = AccessController.doPrivileged(
            new PrivilegedAction<GenericKeyedObjectPool<SshConfig, Session>>() {
                @Override
                public GenericKeyedObjectPool<SshConfig, Session> run() {
                    try {
                        return new GenericKeyedObjectPool<>(
                                new SshPoolFactory(), poolConfig);
                    } catch (final Exception e) {
                        throw new SshPoolException("could not init pool.",
                                e);
                    }
                }
            });
}
 
开发者ID:codelibs,项目名称:elasticsearch-repository-ssh,代码行数:24,代码来源:SshPool.java

示例11: getColorSpacePoolConfig

import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig; //导入依赖的package包/类
public GenericKeyedObjectPoolConfig getColorSpacePoolConfig() {
	GenericKeyedObjectPoolConfig result = new GenericKeyedObjectPoolConfig();
	if (colorSpacePoolMaxTotal != null) {
		result.setMaxTotal(colorSpacePoolMaxTotal);
	}
	if (colorSpacePoolMaxPerKey != null) {
		result.setMaxTotalPerKey(colorSpacePoolMaxPerKey);
	}
	if (colorSpacePoolMaxIdlePerKey != null) {
		result.setMaxIdlePerKey(colorSpacePoolMaxIdlePerKey);
	}
	if (colorSpacePoolMinIdlePerKey != null) {
		result.setMinIdlePerKey(colorSpacePoolMinIdlePerKey);
	}
	if (colorSpacePoolMaxWait != null) {
		result.setMaxWaitMillis(colorSpacePoolMaxWait);
	}
	if (colorSpacePoolMinEvictableIdleTime != null) {
		result.setMinEvictableIdleTimeMillis(colorSpacePoolMinEvictableIdleTime);
	}
	if (colorSpacePoolSoftMinEvictableIdleTime != null) {
		result.setSoftMinEvictableIdleTimeMillis(colorSpacePoolSoftMinEvictableIdleTime);
	}
	if (colorSpacePoolTimeBetweenEvictionRuns != null) {
		result.setTimeBetweenEvictionRunsMillis(colorSpacePoolTimeBetweenEvictionRuns);
	}
	if (colorSpacePoolBlockWhenExhausted != null) {
		result.setBlockWhenExhausted(colorSpacePoolBlockWhenExhausted);
	}
	return result;
}
 
开发者ID:marrow16,项目名称:ColorConverter,代码行数:32,代码来源:Configuration.java

示例12: getChannelPool

import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig; //导入依赖的package包/类
@Bean
public GenericKeyedObjectPool<ChannelSessionKey, Channel> getChannelPool(final SshConfig sshConfig) throws JSchException {
    final GenericKeyedObjectPoolConfig genericKeyedObjectPoolConfig = new GenericKeyedObjectPoolConfig();
    genericKeyedObjectPoolConfig.setMaxTotalPerKey(10);
    genericKeyedObjectPoolConfig.setBlockWhenExhausted(true);
    return new GenericKeyedObjectPool(new KeyedPooledJschChannelFactory(sshConfig.getJschBuilder().build()));
}
 
开发者ID:cerner,项目名称:jwala,代码行数:8,代码来源:AemServiceConfiguration.java

示例13: checkAndInit

import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig; //导入依赖的package包/类
private void checkAndInit() {
	if (this.servers == null || StringUtils.isEmpty(this.servers)) {
		throw new ValidationException("servers can not be null or empty.");
	}
	if (!checkLoadBalance()) {
		this.loadBalance = Constant.LoadBalance.RANDOM;
	}
	if (this.validator == null) {
		this.validator = new ConnectionValidator() {
			@Override
			public boolean isValid(TTransport object) {
				return object.isOpen();
			}
		};
	}
	if (this.poolConfig == null) {
		this.poolConfig = new GenericKeyedObjectPoolConfig();
	}
	if (this.failoverStrategy == null) {
		this.failoverStrategy = new FailoverStrategy<>();
	}
	if (this.connTimeout == 0) {
		this.connTimeout = DEFAULT_CONN_TIMEOUT;
	}
	if (!checkServiceLevel()) {
		this.serviceLevel = Constant.ServiceLevel.NOT_EMPTY;
	}
}
 
开发者ID:cyfonly,项目名称:ThriftJ,代码行数:29,代码来源:ThriftClient.java

示例14: TrpcClientPoolImpl

import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public TrpcClientPoolImpl(GenericKeyedObjectPoolConfig config, boolean async) {
    Function<ThriftServerInfo, AbstractTrpcClient> creater;
    if (async) {
        creater = AsyncTrpcClient::new;
    } else {
        creater = BlockTrpcClient::new;
    }
    connections = new GenericKeyedObjectPool(new TrpcClientFactory<>(creater), config);
}
 
开发者ID:sofn,项目名称:trpc,代码行数:11,代码来源:TrpcClientPoolImpl.java

示例15: ClientArgs

import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig; //导入依赖的package包/类
@Builder
public ClientArgs(GenericKeyedObjectPoolConfig poolConfig, List<AbstractMonitor> monitors, List<String> serviceInterfaces, String serviceInterface, String localAppKey, String remoteAppKey, String ipPorts, int timeout, boolean async) {
    this.poolConfig = poolConfig;
    this.monitors = monitors;
    this.serviceInterfaces = serviceInterfaces;
    this.serviceInterface = serviceInterface;
    this.localAppKey = localAppKey;
    this.remoteAppKey = remoteAppKey;
    this.ipPorts = ipPorts;
    this.timeout = timeout;
    this.async = async;
    afterPropertiesSet();
}
 
开发者ID:sofn,项目名称:trpc,代码行数:14,代码来源:ClientArgs.java


注:本文中的org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。