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


Java BoneCPConfig.setMaxConnectionsPerPartition方法代码示例

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


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

示例1: createConfig

import com.jolbox.bonecp.BoneCPConfig; //导入方法依赖的package包/类
private BoneCPConfig createConfig() {
  final BoneCPConfig config = new BoneCPConfig();
  config.setPartitionCount(1);
  config.setLazyInit(false);
  config.setMinConnectionsPerPartition(3);
  config.setMaxConnectionsPerPartition(3);
  config.setDatasourceBean(new AbstractDataSource() {

    @Override
    public Connection getConnection() throws SQLException {
      return Mockito.mock(Connection.class);
    }

    @Override
    public Connection getConnection(String username, String password) throws SQLException {
      return getConnection();
    }
    
    public Logger getParentLogger() {
      return null;
    }
  });
  config.setConnectionTimeoutInMs(Timeout.standardTimeoutMillis());
  config.setConnectionHook(new BoneCPHack(config.getConnectionHook()));
  return config;
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:27,代码来源:BoneCPHackTest.java

示例2: createConnectionPool

import com.jolbox.bonecp.BoneCPConfig; //导入方法依赖的package包/类
public static void createConnectionPool() {
BoneCPConfig config = new BoneCPConfig();
      config.setMaxConnectionsPerPartition(DatabaseConfiguration.getCpMaxConnections());
      config.setAcquireRetryAttempts(DatabaseConfiguration.getCpAcquireRetryAttempts());
      config.setAcquireRetryDelayInMs(DatabaseConfiguration.getCpAcquireRetryDelay());
      config.setConnectionTimeoutInMs(DatabaseConfiguration.getCpConnectionTimeout());
      config.setStatisticsEnabled(DatabaseConfiguration.isCpEnableStatistics());
      config.setDisableConnectionTracking(true); // set this to true to avoid bonecp closing connections erroniously
      
config.setJdbcUrl(jdbc_);
      config.setUsername(DatabaseConfiguration.getUsername());
      config.setPassword(DatabaseConfiguration.getPassword());
      config.setDefaultAutoCommit(DatabaseConfiguration.getCpDefaultAutoCommit());

      try {
          connectionPool_ = new BoneCP(config);
      }
      catch (Exception e) {
          connectionPool_ = null;
          logger.error(e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e));  
      }
  }
 
开发者ID:PearsonEducation,项目名称:StatsAgg,代码行数:23,代码来源:DatabaseConnections.java

示例3: BoneCPDataSource

import com.jolbox.bonecp.BoneCPConfig; //导入方法依赖的package包/类
public BoneCPDataSource(ConfigMap<String, String> datasource) throws IOException {
	BoneCPConfig config = new BoneCPConfig();
	config.setJdbcUrl(datasource.get("url"));
	config.setUsername(datasource.get("user")); 
	config.setPassword(datasource.get("password"));
	
	config.setMinConnectionsPerPartition(datasource.getInteger("min_pool_size", 1));
	config.setMaxConnectionsPerPartition(datasource.getInteger("max_pool_size", 10));
	config.setPartitionCount(datasource.getInteger("partition_size", 1));
	
	try {
		this.datasource = new BoneCP(config);
	} catch (SQLException e) {
		throw new IOException(e);
	}
}
 
开发者ID:PinaeOS,项目名称:timon,代码行数:17,代码来源:BoneCPDataSource.java

示例4: ConnectionPool

import com.jolbox.bonecp.BoneCPConfig; //导入方法依赖的package包/类
public ConnectionPool(String dbcUrl, String user, String pass, int minConns,
		int maxConns, int partCount) throws ClassNotFoundException, SQLException {
	/*
	 * Initialize our connection pool.
	 * 
	 * We'll use a connection pool and reuse connections on a per-thread basis. 
	 */
			
	/* setup the connection pool */
	BoneCPConfig config = new BoneCPConfig();
	config.setJdbcUrl(dbcUrl); 
	config.setUsername(user); 
	config.setPassword(pass);
	config.setMinConnectionsPerPartition(minConns);
	config.setMaxConnectionsPerPartition(maxConns);
	config.setPartitionCount(partCount);
	// Enable only for debugging.
	//config.setCloseConnectionWatch(true);
	
	pool = new BoneCP(config);
}
 
开发者ID:netizen539,项目名称:civcraft,代码行数:22,代码来源:ConnectionPool.java

示例5: run

import com.jolbox.bonecp.BoneCPConfig; //导入方法依赖的package包/类
@Override
public void run(KenshoConfiguration configuration,
                Environment environment) throws ClassNotFoundException {

    final BoneCPConfig config = new BoneCPConfig();
    config.setJdbcUrl(configuration.getDataSourceFactory().getUrl());
    config.setUsername(configuration.getDataSourceFactory().getUser());
    config.setPassword(configuration.getDataSourceFactory().getPassword());
    config.setMinConnectionsPerPartition(1);
    config.setMaxConnectionsPerPartition(2);
    config.setPartitionCount(1);

    try {
        final BoneCP connectionPool = new BoneCP(config);
        final PgStatus status = new PgStatus(connectionPool);
        final StatsEngine statsEngine = new StatsEngine(status);

        environment.jersey().register(new DashboardResource(statsEngine));
        environment.jersey().register(new DataResource(statsEngine));
        environment.jersey().register(new QueryResource());

    } catch (SQLException e) {
        System.exit(0);
        e.printStackTrace();
    }
}
 
开发者ID:johnewart,项目名称:kensho,代码行数:27,代码来源:KenshoApplication.java

示例6: preStart

import com.jolbox.bonecp.BoneCPConfig; //导入方法依赖的package包/类
@Override
public void preStart() throws Exception {
	String driver = ConfigUtils.getOptionalString(config, "driver");
	if(driver != null) {
		Class.forName(driver);
	}
	
	BoneCPConfig boneCpConfig = new BoneCPConfig();
	boneCpConfig.setJdbcUrl(config.getString("url"));
	boneCpConfig.setUsername(config.getString("user"));
	boneCpConfig.setPassword(config.getString("password"));
	boneCpConfig.setPoolName(poolName);
	boneCpConfig.setDefaultAutoCommit(false);
	boneCpConfig.setConnectionTimeout(10, TimeUnit.SECONDS);
	boneCpConfig.setMaxConnectionsPerPartition(poolSize);
	
	log.debug("creating database pool");
	connectionPool = new BoneCP(boneCpConfig);
	
	f = new FutureUtils(getContext());
	
	transactionHandler = new TransactionHandler<>(new JdbcTransactionSupplier(getSelf(), f), log);
}
 
开发者ID:IDgis,项目名称:geo-publisher,代码行数:24,代码来源:JdbcDatabase.java

示例7: init

import com.jolbox.bonecp.BoneCPConfig; //导入方法依赖的package包/类
@Override
protected void init() throws Exception {
    BoneCPConfig connPoolConfig = new BoneCPConfig();
    connPoolConfig.setJdbcUrl(JDBC_URL);
    connPoolConfig.setUsername(DB_USER);
    connPoolConfig.setPassword(DB_PASS);
    connPoolConfig.setMaxConnectionsPerPartition(DB_POOL_SIZE);
    connPoolConfig.setMaxConnectionAgeInSeconds(600);
    connPoolConfig.setDefaultAutoCommit(true);
    connPoolConfig.setIdleConnectionTestPeriodInSeconds(30);
    connPoolConfig.setConnectionTestStatement("SELECT 1");
    this.connPool = new BoneCP(connPoolConfig);

    // todo: shutdown pool
}
 
开发者ID:tascape,项目名称:reactor,代码行数:16,代码来源:MysqlHandler.java

示例8: BigCloneBenchDB

import com.jolbox.bonecp.BoneCPConfig; //导入方法依赖的package包/类
private BigCloneBenchDB() throws SQLException {
	BoneCPConfig config = new BoneCPConfig();
	Path db = Paths.get("bigclonebenchdb/bcb").toAbsolutePath();
	config.setJdbcUrl("jdbc:h2:" + db.toString());
	config.setUsername("sa");
	config.setPassword("");
	config.setMinConnectionsPerPartition(1);
	config.setMaxConnectionsPerPartition(10);
	config.setPartitionCount(1);
	connectionPool = new BoneCP(config);
}
 
开发者ID:jeffsvajlenko,项目名称:BigCloneEval,代码行数:12,代码来源:BigCloneBenchDB.java

示例9: ToolsDB

import com.jolbox.bonecp.BoneCPConfig; //导入方法依赖的package包/类
private ToolsDB() throws SQLException {
	BoneCPConfig config = new BoneCPConfig();
	Path db = Paths.get("toolsdb/tools").toAbsolutePath();
	config.setJdbcUrl("jdbc:h2:" + db.toString());
	config.setUsername("sa");
	config.setPassword("bigclonebencheval");
	config.setMinConnectionsPerPartition(1);
	config.setMaxConnectionsPerPartition(10);
	config.setPartitionCount(1);
	connectionPool = new BoneCP(config);
}
 
开发者ID:jeffsvajlenko,项目名称:BigCloneEval,代码行数:12,代码来源:ToolsDB.java

示例10: getDataSource

import com.jolbox.bonecp.BoneCPConfig; //导入方法依赖的package包/类
public DataSource getDataSource()
    throws ClassNotFoundException
{
    if (!isInited)
    {
        lock.lock();
        try
        {
            if (!isInited)
            {
                Class.forName(getDriver());
                boneCPConfig = new BoneCPConfig();
                boneCPConfig.setJdbcUrl(getUrl());
                boneCPConfig.setUsername(getUsername());
                boneCPConfig.setPassword(getPassword());
                // ����ÿ60�������ݿ��еĿ���������
                boneCPConfig.setIdleConnectionTestPeriod(idleConnectionTestPeriod, TimeUnit.MINUTES);
                // �������ӿ���ʱ��
                boneCPConfig.setIdleMaxAge(idleMaxAge, TimeUnit.MINUTES);
                boneCPConfig.setPartitionCount(partitionCount);
                // ����ÿ�������е����������
                boneCPConfig.setMaxConnectionsPerPartition(maxConnectionsPerPartition);
                // ����ÿ�������е���С������
                boneCPConfig.setMinConnectionsPerPartition(minConnectionsPerPartition);
                // �����ӳ��е����Ӻľ���ʱ�� BoneCPһ��ͬʱ��ȡ��������
                boneCPConfig.setAcquireIncrement(acquireIncrement);
                // �����ͷŴ���
                boneCPConfig.setReleaseHelperThreads(releaseHelperThreads);
                ds = new BoneCPDataSource(boneCPConfig);
                isInited = true;
            }
        }
        finally
        {
            lock.unlock();
        }
    }
    return ds;
}
 
开发者ID:liulhdarks,项目名称:darks-orm,代码行数:40,代码来源:BoneCPConfiguration.java

示例11: init

import com.jolbox.bonecp.BoneCPConfig; //导入方法依赖的package包/类
/**
 * Initialize the connection pool.
 */
public static final void init(String database, String username, String password, 
		String server, int maxConn, int minConn, String jndi) {
	String dbUrl = StringUtil.concat("jdbc:mysql://", server, ":3306/", database, 
			"?connectTimeout=", 10000, "&useUnicode=true&characterEncoding=utf8");
	
	logger.info("Try to connect to Mysql with url: {}", dbUrl);
	
  // create a new configuration object
 	BoneCPConfig config = new BoneCPConfig();
  // set the JDBC url
 	config.setJdbcUrl(dbUrl);
 	config.setPartitionCount(2);
 	config.setMaxConnectionsPerPartition(maxConn);
 	config.setMinConnectionsPerPartition(minConn);
 	config.setUsername(username);
 	config.setPassword(password);
	
  // setup the connection pool
	try {
		BoneCPDataSource dataSource = new BoneCPDataSource(config);
		Context jndiContext = GameContext.getInstance().getJndiContext();
		jndiContext.bind(jndi, dataSource);
		dataSourceMap.put(jndi, dataSource);
		dataSourceReadyMap.put(jndi, Boolean.TRUE);
	} catch (Exception e) {
		logger.warn("The connection to Mysql database is unavailable. Exception:{}", e.getMessage());
		dataSourceReadyMap.put(jndi, Boolean.FALSE);
	}
}
 
开发者ID:wangqi,项目名称:gameserver,代码行数:33,代码来源:MysqlUtil.java

示例12: createBoneCP

import com.jolbox.bonecp.BoneCPConfig; //导入方法依赖的package包/类
private void createBoneCP() {
    try {
        BoneCPConfig config = new BoneCPConfig();
        config.setJdbcUrl(String.format("jdbc:mysql://%s:%d/%s", this.host, this.port, this.database));
        config.setUsername(this.username);
        config.setPassword(this.password);
        config.setPartitionCount(2);
        config.setMinConnectionsPerPartition(this.minPoolSize);
        config.setMaxConnectionsPerPartition(this.maxPoolSize);
        boneCP = new BoneCP(config);
        this.createConnection();
    } catch (Exception ex) {
        throw new Error("Unrecoverable error when creating the BoneCP object.", ex);
    }
}
 
开发者ID:aaomidi,项目名称:JustSkyblock,代码行数:16,代码来源:MySQLConnector.java

示例13: DBPool

import com.jolbox.bonecp.BoneCPConfig; //导入方法依赖的package包/类
/**
 * 创建一个数据库连接池
 * @param poolName
 * @param host
 * @param port
 * @param dbName
 * @param username
 * @param password
 * @param partitionCount
 * @param minConnCountPerPar
 * @param maxConnCountPerPar
 * @throws Exception
 */
protected DBPool(String poolName, String host, String port, String dbName, String username, String password, int partitionCount, int minConnCountPerPar,
		int maxConnCountPerPar) throws Exception
{
	dbUrl = String.format(URL, host, port, dbName);
	this.poolName = poolName;
	this.partitionCount = partitionCount;
	this.maxConnCountPerPar = maxConnCountPerPar;
	this.minConnCountPerPar = minConnCountPerPar;
	BoneCPConfig config = new BoneCPConfig();
	config.setJdbcUrl(dbUrl);
	config.setUsername(username);
	config.setPassword(password);
	// 分区数
	config.setPartitionCount(partitionCount);
	// 每次创建的新连接个数
	config.setAcquireIncrement(2);
	// 处理释放后的conn线程数
	config.setReleaseHelperThreads(3);
	// 分区最大连接数
	config.setMaxConnectionsPerPartition(maxConnCountPerPar);
	// 分区最小连接数
	config.setMinConnectionsPerPartition(minConnCountPerPar);
	// 空闲连接存活时间
	config.setIdleMaxAgeInMinutes(10);
	// 测试连接时间
	config.setIdleConnectionTestPeriodInMinutes(10);
	// 设置重新获取连接的次数。这个参数默认为5
	config.setAcquireRetryAttempts(5);
	// 重新获取连接的间隔时间
	config.setAcquireRetryDelayInMs(3000);
	boneCP = new BoneCP(config);
}
 
开发者ID:LaoZhongGu,项目名称:RushServer,代码行数:46,代码来源:DBPool.java

示例14: getBoneCPConfig

import com.jolbox.bonecp.BoneCPConfig; //导入方法依赖的package包/类
private static BoneCPConfig getBoneCPConfig(NamingService ns) throws Exception {
    BoneCPConfig config = new BoneCPConfig();

    List<ServiceInstance<NodeType>> dbs = ns.list(NodeType.MDB, Predicates.<ServiceInstance<NodeType>>alwaysTrue());

    if(dbs.isEmpty())
        throw new Exception("unable to find any MDB node");

    ServiceInstance<NodeType> mdb = dbs.get(0);

    log.info("MDB service instance: {}", mdb);

    String host = mdb.getAddress();
    String db = mdb.getUriSpec().getParts().get(0).getValue();
    int port = mdb.getPort();
    String user = "uadmin";
    String pass = "uadmin";
    Integer min = 1;
    Integer max = 5;

    String jdbcUrl = "jdbc:postgresql://" + host + ":" + port + "/" + db;
    config.setJdbcUrl(jdbcUrl);
    config.setUsername(user);
    config.setPassword(pass);
    config.setMinConnectionsPerPartition(min);
    config.setMaxConnectionsPerPartition(max);
    config.setPartitionCount(1);
    config.setLogStatementsEnabled(true);

    return config;
}
 
开发者ID:abbaspour,项目名称:urmia,代码行数:32,代码来源:Main.java

示例15: BoneCPJdbcPool

import com.jolbox.bonecp.BoneCPConfig; //导入方法依赖的package包/类
public BoneCPJdbcPool(String url, String user, String pass, int min, int max) throws SQLException {
    BoneCPConfig config = new BoneCPConfig();
    config.setJdbcUrl(url);
    config.setUsername(user);
    config.setPassword(pass);
    config.setMinConnectionsPerPartition(min);
    config.setMaxConnectionsPerPartition(max);
    config.setPartitionCount(1);
    config.setLogStatementsEnabled(true);

    pool = new BoneCP(config); // setup the connection pool
}
 
开发者ID:abbaspour,项目名称:urmia,代码行数:13,代码来源:JdbcPool.java


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