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


Java GenericKeyedObjectPoolConfig.setMaxIdlePerKey方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: init

import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig; //导入方法依赖的package包/类
@Before
public void init() {
    this.port = RandomUtils.nextInt(10000, 20000);
    new DemoServer().startDaemon(this.port);

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

示例8: startPool

import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig; //导入方法依赖的package包/类
/**
 * Apply Pool Configurations read from config/connection.properties Start Keyed pool for IpmiTaskConnectorFactory
 */
public void startPool()
{
    GenericKeyedObjectPoolConfig config = new GenericKeyedObjectPoolConfig();
    config.setMaxTotalPerKey( maxObjectPerKey );
    config.setMaxTotal( maxTotalPerKey );
    config.setMinIdlePerKey( minIdlePerKey );
    config.setMaxIdlePerKey( maxIdlePerKey );
    config.setBlockWhenExhausted( false );

    pool =
        new GenericKeyedObjectPool<String, ThreadLimitExecuterServiceObject>( new ThreadLimitExecuterServiceObjectFactory(),
                                                                              config );

}
 
开发者ID:vmware,项目名称:OHMS,代码行数:18,代码来源:ThreadLimitExecuterServiceObjectPool.java

示例9: test03

import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig; //导入方法依赖的package包/类
@Test
public void test03() throws InterruptedException {
    PooledConnectionFactory pooledConnectionFactory = new PooledConnectionFactory(5000, 5000);

    GenericKeyedObjectPoolConfig conf = new GenericKeyedObjectPoolConfig();
    conf.setMaxTotal(200);
    conf.setMaxTotalPerKey(200);
    conf.setMaxIdlePerKey(100);
    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);

    for (int i = 0; i <= 50; i++) {
        Thread thread = new PoolTest(connectionManager);
        thread.start();
    }

    for (int i = 0; i <= 2; i++) {
        connectionManager.dumpPoolInfo();
        Thread.sleep(1000 * 2);
    }

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

示例10: init

import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig; //导入方法依赖的package包/类
@Before
public void init() {
    PooledConnectionFactory pooledConnectionFactory = new PooledConnectionFactory(500, 500);
    GenericKeyedObjectPoolConfig conf = new GenericKeyedObjectPoolConfig();
    conf.setMaxTotal(200);
    conf.setMaxTotalPerKey(200);
    conf.setMaxIdlePerKey(100);
    connectionPool = new ConnectionPool(pooledConnectionFactory, conf);
    Set<String> trackerSet = new HashSet<String>();
    trackerSet.add("192.168.10.128:22122");
    DefaultCommandExecutor commandExecutor = new DefaultCommandExecutor(trackerSet, connectionPool);
    trackerClient = new DefaultTrackerClient(commandExecutor);
}
 
开发者ID:Lzw2016,项目名称:fastdfs-java-client,代码行数:14,代码来源:DefaultTrackerClientTest.java

示例11: init

import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig; //导入方法依赖的package包/类
@Before
public void init() {
    PooledConnectionFactory pooledConnectionFactory = new PooledConnectionFactory(500, 500);
    GenericKeyedObjectPoolConfig conf = new GenericKeyedObjectPoolConfig();
    conf.setMaxTotal(200);
    conf.setMaxTotalPerKey(200);
    conf.setMaxIdlePerKey(100);
    connectionPool = new ConnectionPool(pooledConnectionFactory, conf);
    Set<String> trackerSet = new HashSet<String>();
    trackerSet.add("192.168.10.128:22122");
    DefaultCommandExecutor commandExecutor = new DefaultCommandExecutor(trackerSet, connectionPool);
    TrackerClient trackerClient = new DefaultTrackerClient(commandExecutor);
    storageClient = new DefaultStorageClient(commandExecutor, trackerClient);
}
 
开发者ID:Lzw2016,项目名称:fastdfs-java-client,代码行数:15,代码来源:DefaultStorageClientTest.java

示例12: initialize

import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig; //导入方法依赖的package包/类
/**
 * Lifecycle method.
 * Initializes the connection pool with the default object factory and configuration.
 * @throws java.lang.IllegalStateException if the pool instance has already been initialized.
 */
public static void initialize() {
  GenericKeyedObjectPoolConfig config = new GenericKeyedObjectPoolConfig();
  config.setMaxIdlePerKey(getIntProperty(
      MMXConfigKeys.APNS_POOL_MAX_IDLE_CONNECTIONS_PER_APP,
      MMXServerConstants.APNS_POOL_MAX_IDLE_CONNECTIONS_PER_APP));
  config.setMaxTotalPerKey(getIntProperty(
      MMXConfigKeys.APNS_POOL_MAX_CONNECTIONS_PER_APP,
      MMXServerConstants.APNS_POOL_MAX_CONNECTIONS_PER_APP));
  config.setMaxTotal(getIntProperty(
      MMXConfigKeys.APNS_POOL_MAX_TOTAL_CONNECTIONS,
      MMXServerConstants.APNS_POOL_MAX_TOTAL_CONNECTIONS));
  initialize(new APNSConnectionKeyedPooledObjectFactory(
      new OpenFireDBConnectionProvider()), config);
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:20,代码来源:APNSConnectionPoolImpl.java

示例13: setUp

import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
  LOGGER.info("Setting up the pool");
  GenericKeyedObjectPoolConfig config = new GenericKeyedObjectPoolConfig();
  config.setMaxTotalPerKey(MAX_OBJECTS_PER_KEY);
  config.setMaxIdlePerKey(3);
  config.setMinEvictableIdleTimeMillis(10*60*1000L);
  config.setTimeBetweenEvictionRunsMillis(1000L);
  objectFactory = new StubAPNSConnectionKeyedPooledObjectFactory(appWithBadCert);
  APNSConnectionPoolImpl.initialize(objectFactory, config);

}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:13,代码来源:APNSConnectionPoolImplTest.java

示例14: registerPool

import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig; //导入方法依赖的package包/类
private void registerPool(final String username, final String password)
        throws NamingException, SQLException {

    final ConnectionPoolDataSource cpds = testCPDS(username, password);

    // Create an object pool to contain our PooledConnections
    factory = new KeyedCPDSConnectionFactory(cpds, getValidationQuery(),
            getValidationQueryTimeout(), isRollbackAfterValidation());
    factory.setMaxConnLifetimeMillis(getMaxConnLifetimeMillis());

    final GenericKeyedObjectPoolConfig config =
            new GenericKeyedObjectPoolConfig();
    config.setBlockWhenExhausted(getDefaultBlockWhenExhausted());
    config.setEvictionPolicyClassName(getDefaultEvictionPolicyClassName());
    config.setLifo(getDefaultLifo());
    config.setMaxIdlePerKey(getDefaultMaxIdle());
    config.setMaxTotal(getMaxTotal());
    config.setMaxTotalPerKey(getDefaultMaxTotal());
    config.setMaxWaitMillis(getDefaultMaxWaitMillis());
    config.setMinEvictableIdleTimeMillis(
            getDefaultMinEvictableIdleTimeMillis());
    config.setMinIdlePerKey(getDefaultMinIdle());
    config.setNumTestsPerEvictionRun(getDefaultNumTestsPerEvictionRun());
    config.setSoftMinEvictableIdleTimeMillis(
            getDefaultSoftMinEvictableIdleTimeMillis());
    config.setTestOnCreate(getDefaultTestOnCreate());
    config.setTestOnBorrow(getDefaultTestOnBorrow());
    config.setTestOnReturn(getDefaultTestOnReturn());
    config.setTestWhileIdle(getDefaultTestWhileIdle());
    config.setTimeBetweenEvictionRunsMillis(
            getDefaultTimeBetweenEvictionRunsMillis());

    final KeyedObjectPool<UserPassKey,PooledConnectionAndInfo> tmpPool =
            new GenericKeyedObjectPool<>(factory, config);
    factory.setPool(tmpPool);
    pool = tmpPool;
}
 
开发者ID:apache,项目名称:commons-dbcp,代码行数:38,代码来源:SharedPoolDataSource.java

示例15: makeObject

import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig; //导入方法依赖的package包/类
/**
 * Uses the configured XAConnectionFactory to create a {@link PoolableManagedConnection}.
 * Throws <code>IllegalStateException</code> if the connection factory returns null.
 * Also initializes the connection using configured initialization sql (if provided)
 * and sets up a prepared statement pool associated with the PoolableManagedConnection
 * if statement pooling is enabled.
 */
@Override
synchronized public PooledObject<PoolableConnection> makeObject() throws Exception {
    Connection conn = getConnectionFactory().createConnection();
    if (conn == null) {
        throw new IllegalStateException("Connection factory returned null from createConnection");
    }
    initializeConnection(conn);
    if (getPoolStatements()) {
        conn = new PoolingConnection(conn);
        final GenericKeyedObjectPoolConfig config = new GenericKeyedObjectPoolConfig();
        config.setMaxTotalPerKey(-1);
        config.setBlockWhenExhausted(false);
        config.setMaxWaitMillis(0);
        config.setMaxIdlePerKey(1);
        config.setMaxTotal(getMaxOpenPreparedStatements());
        final ObjectName dataSourceJmxName = getDataSourceJmxName();
        final long connIndex = getConnectionIndex().getAndIncrement();
        if (dataSourceJmxName != null) {
            final StringBuilder base = new StringBuilder(dataSourceJmxName.toString());
            base.append(Constants.JMX_CONNECTION_BASE_EXT);
            base.append(Long.toString(connIndex));
            config.setJmxNameBase(base.toString());
            config.setJmxNamePrefix(Constants.JMX_STATEMENT_POOL_PREFIX);
        } else {
            config.setJmxEnabled(false);
        }
        final KeyedObjectPool<PStmtKey,DelegatingPreparedStatement> stmtPool =
            new GenericKeyedObjectPool<>((PoolingConnection)conn, config);
        ((PoolingConnection)conn).setStatementPool(stmtPool);
        ((PoolingConnection) conn).setCacheState(getCacheState());
    }
    final PoolableManagedConnection pmc =
            new PoolableManagedConnection(transactionRegistry, conn, getPool(),
                    getDisconnectionSqlCodes(), isFastFailValidation());
    pmc.setCacheState(getCacheState());
    return new DefaultPooledObject<PoolableConnection>(pmc);
}
 
开发者ID:apache,项目名称:commons-dbcp,代码行数:45,代码来源:PoolableManagedConnectionFactory.java


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