【问题标题】:How to do connection pooling for Google Cloud Bigtable如何为 Google Cloud Bigtable 进行连接池
【发布时间】:2019-04-09 14:27:09
【问题描述】:

是否存在任何内置库或者是否需要实现自定义库?

我试图在这里查看,但不知道如何从这里开始:Bigtable connection pool

我已经尝试了下面的代码,但不确定如何从这里开始:

import com.google.cloud.bigtable.config.BigtableOptions;
import com.google.cloud.bigtable.config.CredentialOptions;
import com.google.cloud.bigtable.grpc.BigtableSession;
import com.google.cloud.bigtable.grpc.io.ChannelPool;
import com.mahindra.digisense.config.AppConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.security.GeneralSecurityException;

@Component
public class BigTableConnectionPoolingExample {

    @Autowired
    private AppConfig.BigTableConfig bigTableConfig;

    private void bigTableConnectionPooling() throws IOException, GeneralSecurityException {
        CredentialOptions credentialOptions = CredentialOptions.jsonCredentials(new FileInputStream(new File(bigTableConfig.getCredentialsJson())));
        BigtableOptions.Builder builder = new BigtableOptions.Builder();
        builder.setCredentialOptions(credentialOptions);
        ChannelPool.ChannelFactory channelFactory = (ChannelPool.ChannelFactory) BigtableSession.createChannelPool(bigTableConfig.getInstanceId(), builder.build());
        ChannelPool channelPool = new ChannelPool(channelFactory,3);
    }
}

这里是another Stack Overflow question,没有答案。

【问题讨论】:

标签: java java-8 hbase bigtable google-cloud-bigtable


【解决方案1】:

正如 Solomon Duskis 所说,我们鼓励新人开始使用 google-cloud-java 中惯用的 Bigtable 客户端。客户端适合生产使用,但我们尚未最终确定客户端 API,因此我们可能会进行向后不兼容的更改。

如果您使用来自 Cloud Bigtable Client 存储库的 HBase 客户端,则可以选择调整下面使用的数据通道数量以及每个通道的飞行 RPC 数量。但我们建议您先配置应用程序,因为您应该能够获得良好的性能并使集群饱和,而无需手动调整这些参数的默认值。

【讨论】:

    猜你喜欢
    • 2017-12-24
    • 1970-01-01
    • 2018-02-16
    • 2016-06-13
    • 2015-09-15
    • 1970-01-01
    • 1970-01-01
    • 2022-01-12
    • 2017-12-29
    相关资源
    最近更新 更多