• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java IDBI类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: connectToDatasource

import org.skife.jdbi.v2.IDBI; //导入依赖的package包/类
private IDBI connectToDatasource(ShardInfo shardInfo) {
    PooledDataSourceFactory urlReplacedCopy =
            copyAndReplaceURL(dropwizardDSFactory, shardInfo);

    // we cannot re-register using the same name (dropwizard metrics do not merge on name collision)
    String dbShardName = humanFriendlyShardNamer.nameShard(shardInfo);
    DBI jdbi = dropwizardDbiFactory.build(
            dropwizardEnvironment,
            urlReplacedCopy,
            dbShardName);
    if (DBIInitializer != null) {
        DBIInitializer.initialize(jdbi);
    }
    logger.info("New shard connection created: " + dbShardName);

    return jdbi;
}
 
开发者ID:toasttab,项目名称:jdbishard,代码行数:18,代码来源:JDBIManager.java


示例2: ShardIterator

import org.skife.jdbi.v2.IDBI; //导入依赖的package包/类
public ShardIterator(long tableId, TupleDomain<RaptorColumnHandle> effectivePredicate, IDBI dbi)
{
    ShardPredicate predicate = ShardPredicate.create(effectivePredicate);

    String sql = format(
            "SELECT shard_uuid, node_ids FROM %s WHERE %s",
            shardIndexTable(tableId),
            predicate.getPredicate());

    dao = onDemandDao(dbi, ShardManagerDao.class);
    fetchNodes();

    try {
        connection = dbi.open().getConnection();
        statement = connection.prepareStatement(sql);
        enableStreamingResults(statement);
        predicate.bind(statement);
        log.debug("Running query: %s", statement);
        resultSet = statement.executeQuery();
    }
    catch (SQLException e) {
        close();
        throw metadataError(e);
    }
}
 
开发者ID:y-lan,项目名称:presto,代码行数:26,代码来源:ShardIterator.java


示例3: ShardCleaner

import org.skife.jdbi.v2.IDBI; //导入依赖的package包/类
@Inject
public ShardCleaner(
        @ForMetadata IDBI dbi,
        NodeManager nodeManager,
        StorageService storageService,
        Optional<BackupStore> backupStore,
        ShardCleanerConfig config)
{
    this(dbi,
            nodeManager.getCurrentNode().getNodeIdentifier(),
            nodeManager.getCoordinators().contains(nodeManager.getCurrentNode()),
            storageService,
            backupStore,
            config.getMaxTransactionAge(),
            config.getLocalCleanerInterval(),
            config.getLocalCleanTime(),
            config.getLocalPurgeTime(),
            config.getBackupCleanerInterval(),
            config.getBackupCleanTime(),
            config.getBackupPurgeTime(),
            config.getBackupDeletionThreads());
}
 
开发者ID:y-lan,项目名称:presto,代码行数:23,代码来源:ShardCleaner.java


示例4: setup

import org.skife.jdbi.v2.IDBI; //导入依赖的package包/类
@BeforeMethod
public void setup()
        throws Exception
{
    temporary = createTempDir();
    File directory = new File(temporary, "data");
    File backupDirectory = new File(temporary, "backup");
    backupStore = new FileBackupStore(backupDirectory);
    backupStore.start();
    storageService = new FileStorageService(directory);
    storageService.start();

    IDBI dbi = new DBI("jdbc:h2:mem:test" + System.nanoTime());
    dummyHandle = dbi.open();
    ShardManager shardManager = createShardManager(dbi);
    recoveryManager = createShardRecoveryManager(storageService, Optional.of(backupStore), shardManager);
}
 
开发者ID:y-lan,项目名称:presto,代码行数:18,代码来源:TestShardRecovery.java


示例5: setup

import org.skife.jdbi.v2.IDBI; //导入依赖的package包/类
@BeforeMethod
public void setup()
        throws Exception
{
    temporary = createTempDir();
    File directory = new File(temporary, "data");
    storageService = new FileStorageService(directory);
    storageService.start();

    File backupDirectory = new File(temporary, "backup");
    fileBackupStore = new FileBackupStore(backupDirectory);
    fileBackupStore.start();
    backupStore = Optional.of(fileBackupStore);

    IDBI dbi = new DBI("jdbc:h2:mem:test" + System.nanoTime());
    dummyHandle = dbi.open();
    ShardManager shardManager = createShardManager(dbi);
    Duration discoveryInterval = new Duration(5, TimeUnit.MINUTES);
    recoveryManager = new ShardRecoveryManager(storageService, backupStore, nodeManager, shardManager, discoveryInterval, 10);

    shardRecorder = new InMemoryShardRecorder();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:23,代码来源:TestOrcStorageManager.java


示例6: ShardMetadataRecordCursor

import org.skife.jdbi.v2.IDBI; //导入依赖的package包/类
public ShardMetadataRecordCursor(IDBI dbi, TupleDomain<Integer> tupleDomain)
{
    requireNonNull(dbi, "dbi is null");
    this.dbi = dbi;
    this.metadataDao = onDemandDao(dbi, MetadataDao.class);
    this.tupleDomain = requireNonNull(tupleDomain, "tupleDomain is null");
    this.tableIds = getTableIds(dbi, tupleDomain);
    this.columnNames = createQualifiedColumnNames();
    this.resultSetValues = new ResultSetValues(TYPES);
    this.resultSet = getNextResultSet();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:12,代码来源:ShardMetadataRecordCursor.java


示例7: getTableIds

import org.skife.jdbi.v2.IDBI; //导入依赖的package包/类
@VisibleForTesting
static Iterator<Long> getTableIds(IDBI dbi, TupleDomain<Integer> tupleDomain)
{
    Map<Integer, Domain> domains = tupleDomain.getDomains().get();
    Domain schemaNameDomain = domains.get(getColumnIndex(SHARD_METADATA, SCHEMA_NAME));
    Domain tableNameDomain = domains.get(getColumnIndex(SHARD_METADATA, TABLE_NAME));

    StringBuilder sql = new StringBuilder("SELECT table_id FROM tables ");
    if (schemaNameDomain != null || tableNameDomain != null) {
        sql.append("WHERE ");
        List<String> predicates = new ArrayList<>();
        if (tableNameDomain != null && tableNameDomain.isSingleValue()) {
            predicates.add(format("table_name = '%s'", getStringValue(tableNameDomain.getSingleValue())));
        }
        if (schemaNameDomain != null && schemaNameDomain.isSingleValue()) {
            predicates.add(format("schema_name = '%s'", getStringValue(schemaNameDomain.getSingleValue())));
        }
        sql.append(Joiner.on(" AND ").join(predicates));
    }

    ImmutableList.Builder<Long> tableIds = ImmutableList.builder();
    try (Connection connection = dbi.open().getConnection();
            Statement statement = connection.createStatement();
            ResultSet resultSet = statement.executeQuery(sql.toString())) {
        while (resultSet.next()) {
            tableIds.add(resultSet.getLong("table_id"));
        }
    }
    catch (SQLException e) {
        throw metadataError(e);
    }
    return tableIds.build().iterator();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:34,代码来源:ShardMetadataRecordCursor.java


示例8: createDBI

import org.skife.jdbi.v2.IDBI; //导入依赖的package包/类
@ForMetadata
@Singleton
@Provides
public IDBI createDBI(@ForMetadata ConnectionFactory connectionFactory, TypeManager typeManager)
{
    DBI dbi = new DBI(connectionFactory);
    dbi.registerMapper(new TableColumn.Mapper(typeManager));
    return dbi;
}
 
开发者ID:y-lan,项目名称:presto,代码行数:10,代码来源:RaptorModule.java


示例9: RaptorMetadata

import org.skife.jdbi.v2.IDBI; //导入依赖的package包/类
public RaptorMetadata(
        String connectorId,
        IDBI dbi,
        ShardManager shardManager,
        JsonCodec<ShardInfo> shardInfoCodec,
        JsonCodec<ShardDelta> shardDeltaCodec)
{
    this.connectorId = requireNonNull(connectorId, "connectorId is null");
    this.dbi = requireNonNull(dbi, "dbi is null");
    this.dao = onDemandDao(dbi, MetadataDao.class);
    this.shardManager = requireNonNull(shardManager, "shardManager is null");
    this.shardInfoCodec = requireNonNull(shardInfoCodec, "shardInfoCodec is null");
    this.shardDeltaCodec = requireNonNull(shardDeltaCodec, "shardDeltaCodec is null");
}
 
开发者ID:y-lan,项目名称:presto,代码行数:15,代码来源:RaptorMetadata.java


示例10: createTablesWithRetry

import org.skife.jdbi.v2.IDBI; //导入依赖的package包/类
public static void createTablesWithRetry(IDBI dbi)
{
    Duration delay = new Duration(2, TimeUnit.SECONDS);
    while (true) {
        try (Handle handle = dbi.open()) {
            createTables(handle.attach(SchemaDao.class));
            return;
        }
        catch (UnableToObtainConnectionException e) {
            log.warn("Failed to connect to database. Will retry again in %s. Exception: %s", delay, e.getMessage());
            sleep(delay);
        }
    }
}
 
开发者ID:y-lan,项目名称:presto,代码行数:15,代码来源:SchemaDaoUtil.java


示例11: DatabaseShardManager

import org.skife.jdbi.v2.IDBI; //导入依赖的package包/类
@Inject
public DatabaseShardManager(@ForMetadata IDBI dbi, NodeSupplier nodeSupplier)
{
    this.dbi = requireNonNull(dbi, "dbi is null");
    this.dao = onDemandDao(dbi, ShardManagerDao.class);
    this.nodeSupplier = requireNonNull(nodeSupplier, "nodeSupplier is null");

    createTablesWithRetry(dbi);
}
 
开发者ID:y-lan,项目名称:presto,代码行数:10,代码来源:DatabaseShardManager.java


示例12: runTransaction

import org.skife.jdbi.v2.IDBI; //导入依赖的package包/类
public static <T> T runTransaction(IDBI dbi, TransactionCallback<T> callback)
{
    try {
        return dbi.inTransaction(callback);
    }
    catch (DBIException e) {
        propagateIfInstanceOf(e.getCause(), PrestoException.class);
        throw metadataError(e);
    }
}
 
开发者ID:y-lan,项目名称:presto,代码行数:11,代码来源:DatabaseUtil.java


示例13: ShardCompactionManager

import org.skife.jdbi.v2.IDBI; //导入依赖的package包/类
@Inject
public ShardCompactionManager(@ForMetadata IDBI dbi, NodeManager nodeManager, ShardManager shardManager, ShardCompactor compactor, StorageManagerConfig config)
{
    this(dbi,
            nodeManager.getCurrentNode().getNodeIdentifier(),
            shardManager,
            compactor,
            config.getCompactionInterval(),
            config.getMaxShardSize(),
            config.getMaxShardRows(),
            config.getCompactionThreads(),
            config.isCompactionEnabled());
}
 
开发者ID:y-lan,项目名称:presto,代码行数:14,代码来源:ShardCompactionManager.java


示例14: RaptorMetadataFactory

import org.skife.jdbi.v2.IDBI; //导入依赖的package包/类
@Inject
public RaptorMetadataFactory(
        RaptorConnectorId connectorId,
        @ForMetadata IDBI dbi,
        ShardManager shardManager,
        JsonCodec<ShardInfo> shardInfoCodec,
        JsonCodec<ShardDelta> shardDeltaCodec)
{
    this.connectorId = requireNonNull(connectorId, "connectorId is null").toString();
    this.dbi = requireNonNull(dbi, "dbi is null");
    this.shardManager = requireNonNull(shardManager, "shardManager is null");
    this.shardInfoCodec = requireNonNull(shardInfoCodec, "shardInfoCodec is null");
    this.shardDeltaCodec = requireNonNull(shardDeltaCodec, "shardDeltaCodec is null");
}
 
开发者ID:y-lan,项目名称:presto,代码行数:15,代码来源:RaptorMetadataFactory.java


示例15: setup

import org.skife.jdbi.v2.IDBI; //导入依赖的package包/类
@BeforeMethod
public void setup()
        throws Exception
{
    IDBI dbi = new DBI("jdbc:h2:mem:test" + System.nanoTime());
    dummyHandle = dbi.open();
    dao = dbi.onDemand(MetadataDao.class);
    createTablesWithRetry(dbi);
}
 
开发者ID:y-lan,项目名称:presto,代码行数:10,代码来源:TestMetadataDao.java


示例16: setup

import org.skife.jdbi.v2.IDBI; //导入依赖的package包/类
@BeforeMethod
public void setup()
        throws Exception
{
    temporary = createTempDir();
    IDBI dbi = new DBI("jdbc:h2:mem:test" + System.nanoTime());
    dummyHandle = dbi.open();
    storageManager = createOrcStorageManager(dbi, temporary, MAX_SHARD_ROWS);
    compactor = new ShardCompactor(storageManager, READER_ATTRIBUTES);
}
 
开发者ID:y-lan,项目名称:presto,代码行数:11,代码来源:TestShardCompactor.java


示例17: createOrcStorageManager

import org.skife.jdbi.v2.IDBI; //导入依赖的package包/类
public static OrcStorageManager createOrcStorageManager(IDBI dbi, File temporary, int maxShardRows)
        throws IOException
{
    File directory = new File(temporary, "data");
    StorageService storageService = new FileStorageService(directory);
    storageService.start();

    File backupDirectory = new File(temporary, "backup");
    FileBackupStore fileBackupStore = new FileBackupStore(backupDirectory);
    fileBackupStore.start();
    Optional<BackupStore> backupStore = Optional.of(fileBackupStore);

    ShardManager shardManager = createShardManager(dbi);
    ShardRecoveryManager recoveryManager = new ShardRecoveryManager(
            storageService,
            backupStore,
            new InMemoryNodeManager(),
            shardManager,
            MISSING_SHARD_DISCOVERY,
            10);
    return createOrcStorageManager(
            storageService,
            backupStore,
            recoveryManager,
            new InMemoryShardRecorder(),
            maxShardRows,
            MAX_FILE_SIZE);
}
 
开发者ID:y-lan,项目名称:presto,代码行数:29,代码来源:TestOrcStorageManager.java


示例18: getDBI

import org.skife.jdbi.v2.IDBI; //导入依赖的package包/类
@VisibleForTesting
public IDBI getDBI() {
    final DBI dbi = new DBI(dataSource);
    dbi.registerArgumentFactory(new DateTimeArgumentFactory());
    dbi.registerArgumentFactory(new DateTimeZoneArgumentFactory());
    dbi.registerArgumentFactory(new UUIDArgumentFactory());
    return dbi;
}
 
开发者ID:killbill,项目名称:killbill-meter-plugin,代码行数:9,代码来源:MeterModule.java


示例19: TimelineAggregator

import org.skife.jdbi.v2.IDBI; //导入依赖的package包/类
@Inject
public TimelineAggregator(final IDBI dbi, final TimelineDao timelineDao, final TimelineCoder timelineCoder,
                          final SampleCoder sampleCoder, final MeterConfig config) {
    this.dbi = dbi;
    this.timelineDao = timelineDao;
    this.timelineCoder = timelineCoder;
    this.sampleCoder = sampleCoder;
    this.config = config;
    this.aggregatorSqlDao = dbi.onDemand(TimelineAggregatorSqlDao.class);
    this.timelineChunkMapper = new TimelineChunkMapper();
}
 
开发者ID:killbill,项目名称:killbill-meter-plugin,代码行数:12,代码来源:TimelineAggregator.java


示例20: getDBI

import org.skife.jdbi.v2.IDBI; //导入依赖的package包/类
public static IDBI getDBI() {
    try {
        final MeterModule meterModule = new MeterModule(helper.getDataSource());
        return meterModule.getDBI();
    } catch (IOException e) {
        Assert.fail(e.toString());
        return null;
    }
}
 
开发者ID:killbill,项目名称:killbill-meter-plugin,代码行数:10,代码来源:MeterTestSuiteWithEmbeddedDB.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java InvalidConfigurationException类代码示例发布时间:2022-05-23
下一篇:
Java ProcessDefinitionBuilder类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap