Java Code Examples for org.apache.kudu.client.KuduClient#KuduClientBuilder
The following examples show how to use
org.apache.kudu.client.KuduClient#KuduClientBuilder .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KuduModule.java From presto with Apache License 2.0 | 6 votes |
@Singleton @Provides KuduClientSession createKuduClientSession(KuduClientConfig config) { requireNonNull(config, "config is null"); KuduClient.KuduClientBuilder builder = new KuduClient.KuduClientBuilder(config.getMasterAddresses()); builder.defaultAdminOperationTimeoutMs(config.getDefaultAdminOperationTimeout().toMillis()); builder.defaultOperationTimeoutMs(config.getDefaultOperationTimeout().toMillis()); builder.defaultSocketReadTimeoutMs(config.getDefaultSocketReadTimeout().toMillis()); if (config.isDisableStatistics()) { builder.disableStatistics(); } KuduClient client = builder.build(); SchemaEmulation strategy; if (config.isSchemaEmulationEnabled()) { strategy = new SchemaEmulationByTableNameConvention(config.getSchemaEmulationPrefix()); } else { strategy = new NoSchemaEmulation(); } return new KuduClientSession(client, strategy); }
Example 2
Source File: KuduModule.java From presto-kudu with Apache License 2.0 | 6 votes |
@Singleton @Provides KuduClientSession createKuduClientSession( KuduConnectorId connectorId, KuduClientConfig config) { requireNonNull(config, "config is null"); KuduClient.KuduClientBuilder builder = new KuduClient.KuduClientBuilder(config.getMasterAddresses()); builder.defaultAdminOperationTimeoutMs(config.getDefaultAdminOperationTimeout().toMillis()); builder.defaultOperationTimeoutMs(config.getDefaultOperationTimeout().toMillis()); builder.defaultSocketReadTimeoutMs(config.getDefaultSocketReadTimeout().toMillis()); if (config.isDisableStatistics()) { builder.disableStatistics(); } KuduClient client = builder.build(); String tenant = config.getTenant(); return new NativeKuduClientSession(connectorId, client, tenant); }
Example 3
Source File: ApexKuduConnection.java From attic-apex-malhar with Apache License 2.0 | 5 votes |
private ApexKuduConnection(ApexKuduConnectionBuilder builder) { checkNotNull(builder,"Builder cannot be null to establish kudu session"); checkArgument(builder.mastersCollection.size() > 0, "Atleast one kudu master needs to be specified"); checkNotNull(builder.tableName,"Kudu table cannot be null"); builderForThisConnection = builder; KuduClient.KuduClientBuilder kuduClientBuilder = new KuduClient.KuduClientBuilder(builder.mastersCollection); if (builder.isOperationTimeOutSet) { kuduClientBuilder.defaultOperationTimeoutMs(builder.operationTimeOutMs); } if (builder.isBossThreadCountSet) { kuduClientBuilder.bossCount(builder.numBossThreads); } if (builder.isWorkerThreadsCountSet) { kuduClientBuilder.workerCount(builder.workerThreads); } if (builder.isSocketReadTimeOutSet) { kuduClientBuilder.defaultSocketReadTimeoutMs(builder.socketReadTimeOutMs); } kuduClient = kuduClientBuilder.build(); kuduSession = kuduClient.newSession(); if (builder.isFlushModeSet) { kuduSession.setFlushMode(builder.flushMode); } if (builder.isExternalConsistencyModeSet) { kuduSession.setExternalConsistencyMode(builder.externalConsistencyMode); } try { if (!kuduClient.tableExists(builder.tableName)) { throw new Exception("Table " + builder.tableName + " does not exist. "); } else { kuduTable = kuduClient.openTable(builder.tableName); } } catch (Exception e) { throw new RuntimeException("Kudu table existence could not be ascertained " + e.getMessage(), e); } }
Example 4
Source File: KuduTarget.java From datacollector with Apache License 2.0 | 5 votes |
@NotNull @VisibleForTesting KuduClient buildKuduClient() { KuduClient.KuduClientBuilder builder = new KuduClient.KuduClientBuilder(kuduMaster) .defaultOperationTimeoutMs(configBean.operationTimeout) .defaultAdminOperationTimeoutMs(configBean.adminOperationTimeout); // Caution: if number of worker thread is not configured, Kudu client may start a massive amount of worker threads. // The formula is "2 x available cores" if (configBean.numWorkers > 0) { builder.workerCount(configBean.numWorkers); } return builder.build(); }
Example 5
Source File: KuduClientTestCommons.java From attic-apex-malhar with Apache License 2.0 | 4 votes |
private static KuduClient getClientHandle() throws Exception { KuduClient.KuduClientBuilder builder = new KuduClient.KuduClientBuilder(kuduMasterAddresses); KuduClient client = builder.build(); return client; }