如何为googlecloud bigtable进行连接池

bwleehnv  于 2021-06-09  发布在  Hbase
关注(0)|答案(1)|浏览(455)

是否存在任何内置库或需要实现自定义库?
我试着在这里检查,但不确定如何从这里开始:bigtable连接池
我尝试了以下代码,但不确定如何继续:

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);
    }
}

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

wbrvyc0a

wbrvyc0a1#

正如solomon duskis所指出的,我们鼓励新手开始使用googlecloudjava中惯用的bigtable客户机。客户机适合生产使用,但是我们还没有最终确定客户机api,因此我们可能会进行向后不兼容的更改。
如果您使用的是来自cloud bigtable client repo的hbase客户机,那么可以选择调整下面使用的数据通道数以及每个通道的机上rpc数。但我们建议您首先分析应用程序,因为您应该能够获得良好的性能并使集群饱和,而无需手动调整这些默认参数。

相关问题