繁体   English   中英

如何为 Google Cloud Bigtable 建立连接池

[英]How to do connection pooling for Google Cloud Bigtable

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

我试图在这里检查,但不确定如何从这里开始: 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);
    }
}

这是另一个堆栈溢出问题,没有答案。

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM