use of com.google.cloud.bigtable.data.v2.BigtableDataSettings in project java-bigtable-hbase by googleapis.
the class TestBigtableHBaseVeneerSettings method testDataSettingsBasicKeys.
@Test
public void testDataSettingsBasicKeys() throws IOException {
String appProfileId = "appProfileId";
String userAgent = "test-user-agent";
String fakeTracingCookie = "fake-tracing-cookie";
Credentials credentials = Mockito.mock(Credentials.class);
configuration.set(BIGTABLE_PORT_KEY, String.valueOf(TEST_PORT));
configuration.set(APP_PROFILE_ID_KEY, appProfileId);
configuration.setBoolean(BIGTABLE_USE_PLAINTEXT_NEGOTIATION, true);
configuration.set(CUSTOM_USER_AGENT_KEY, userAgent);
configuration.set(BIGTABLE_USE_CACHED_DATA_CHANNEL_POOL, "true");
configuration.set(BIGTABLE_USE_SERVICE_ACCOUNTS_KEY, "true");
configuration.set(ALLOW_NO_TIMESTAMP_RETRIES_KEY, "true");
configuration.set(BIGTABLE_TRACING_COOKIE, fakeTracingCookie);
configuration = BigtableConfiguration.withCredentials(configuration, credentials);
BigtableHBaseVeneerSettings settingUtils = (BigtableHBaseVeneerSettings) BigtableHBaseSettings.create(configuration);
BigtableDataSettings dataSettings = settingUtils.getDataSettings();
assertEquals(TEST_PROJECT_ID, dataSettings.getProjectId());
assertEquals(TEST_INSTANCE_ID, dataSettings.getInstanceId());
assertEquals(appProfileId, dataSettings.getAppProfileId());
assertEquals(TEST_HOST, settingUtils.getDataHost());
assertEquals(TEST_PORT, settingUtils.getPort());
assertEquals(TEST_HOST, settingUtils.getAdminHost());
assertEquals(TEST_HOST + ":" + TEST_PORT, dataSettings.getStubSettings().getEndpoint());
Map<String, String> headers = dataSettings.getStubSettings().getHeaderProvider().getHeaders();
assertTrue(headers.get(GrpcUtil.USER_AGENT_KEY.name()).contains(userAgent));
assertTrue(headers.get(GrpcUtil.USER_AGENT_KEY.name()).contains("bigtable-hbase/" + BigtableHBaseVersion.getVersion()));
assertTrue(headers.get("cookie").equals(fakeTracingCookie));
assertEquals(credentials, dataSettings.getStubSettings().getCredentialsProvider().getCredentials());
assertTrue(settingUtils.isChannelPoolCachingEnabled());
assertTrue(settingUtils.isRetriesWithoutTimestampAllowed());
assertTrue(dataSettings.getStubSettings().getTracerFactory() instanceof MetricsApiTracerAdapterFactory);
}
use of com.google.cloud.bigtable.data.v2.BigtableDataSettings in project java-bigtable by googleapis.
the class HelloWorldTest method beforeClass.
@BeforeClass
public static void beforeClass() throws IOException {
initializeVariables();
BigtableDataSettings settings = BigtableDataSettings.newBuilder().setProjectId(projectId).setInstanceId(instanceId).build();
dataClient = BigtableDataClient.create(settings);
BigtableTableAdminSettings adminSettings = BigtableTableAdminSettings.newBuilder().setProjectId(projectId).setInstanceId(instanceId).build();
adminClient = BigtableTableAdminClient.create(adminSettings);
}
use of com.google.cloud.bigtable.data.v2.BigtableDataSettings in project java-bigtable-hbase by googleapis.
the class TestBigtableHBaseVeneerSettings method testRpcMethodWithoutRetry.
@Ignore("Re-enable this test once veneer default align with hbase")
@Test
public void testRpcMethodWithoutRetry() throws IOException {
configuration.set(ENABLE_GRPC_RETRIES_KEY, "false");
BigtableHBaseVeneerSettings settingUtils = BigtableHBaseVeneerSettings.create(configuration);
BigtableDataSettings settings = settingUtils.getDataSettings();
assertTrue(settings.getStubSettings().readRowsSettings().getRetryableCodes().isEmpty());
BigtableDataSettings defaultSettings = BigtableDataSettings.newBuilder().setProjectId(TEST_PROJECT_ID).setInstanceId(TEST_INSTANCE_ID).build();
assertEquals(settings.getStubSettings().readRowsSettings().getRetrySettings().toString(), defaultSettings.getStubSettings().readRowsSettings().getRetrySettings().toString());
assertEquals(settings.getStubSettings().mutateRowSettings().getRetrySettings().toString(), defaultSettings.getStubSettings().mutateRowSettings().getRetrySettings().toString());
}
use of com.google.cloud.bigtable.data.v2.BigtableDataSettings in project java-bigtable-hbase by googleapis.
the class TestBigtableHBaseVeneerSettings method testWithNullCredentials.
@Test
public void testWithNullCredentials() throws IOException {
configuration.set(ADDITIONAL_RETRY_CODES, "UNAVAILABLE,ABORTED");
configuration.setBoolean(BIGTABLE_USE_SERVICE_ACCOUNTS_KEY, false);
configuration.setBoolean(BIGTABLE_NULL_CREDENTIAL_ENABLE_KEY, true);
BigtableDataSettings dataSettings = ((BigtableHBaseVeneerSettings) BigtableHBaseVeneerSettings.create(configuration)).getDataSettings();
assertTrue(dataSettings.getStubSettings().getCredentialsProvider() instanceof NoCredentialsProvider);
assertNull(dataSettings.getStubSettings().getCredentialsProvider().getCredentials());
BigtableTableAdminSettings adminSettings = ((BigtableHBaseVeneerSettings) BigtableHBaseVeneerSettings.create(configuration)).getTableAdminSettings();
assertTrue(adminSettings.getStubSettings().getCredentialsProvider() instanceof NoCredentialsProvider);
assertNull(adminSettings.getStubSettings().getCredentialsProvider().getCredentials());
}
use of com.google.cloud.bigtable.data.v2.BigtableDataSettings in project java-bigtable-hbase by googleapis.
the class TestBigtableHBaseVeneerSettings method testTimeoutBeingPassed.
@Test
public void testTimeoutBeingPassed() throws IOException {
int initialElapsedMs = 100;
int rpcAttemptTimeoutMs = 100;
int rpcTimeoutMs = 500;
int perRowTimeoutMs = 1001;
int maxElapsedMs = 1000;
int maxAttempt = 10;
int readRowStreamTimeout = 30000;
int readRowStreamAttemptTimeout = 3000;
configuration.setBoolean(BIGTABLE_USE_TIMEOUTS_KEY, true);
configuration.setInt(INITIAL_ELAPSED_BACKOFF_MILLIS_KEY, initialElapsedMs);
configuration.setInt(MAX_ELAPSED_BACKOFF_MILLIS_KEY, maxElapsedMs);
configuration.setInt(BIGTABLE_RPC_ATTEMPT_TIMEOUT_MS_KEY, rpcAttemptTimeoutMs);
configuration.setInt(BIGTABLE_RPC_TIMEOUT_MS_KEY, rpcTimeoutMs);
configuration.setInt(READ_PARTIAL_ROW_TIMEOUT_MS, perRowTimeoutMs);
configuration.setLong(MAX_SCAN_TIMEOUT_RETRIES, maxAttempt);
configuration.setInt(BIGTABLE_READ_RPC_TIMEOUT_MS_KEY, readRowStreamTimeout);
configuration.setInt(BIGTABLE_READ_RPC_ATTEMPT_TIMEOUT_MS_KEY, readRowStreamAttemptTimeout);
BigtableHBaseVeneerSettings settings = BigtableHBaseVeneerSettings.create(configuration);
BigtableDataSettings dataSettings = settings.getDataSettings();
assertEquals(Optional.of(Duration.ofMillis(rpcTimeoutMs)), settings.getClientTimeouts().getUnaryTimeouts().getOperationTimeout());
assertEquals(Optional.of(Duration.ofMillis(rpcAttemptTimeoutMs)), settings.getClientTimeouts().getUnaryTimeouts().getAttemptTimeout());
assertEquals(Optional.of(Duration.ofMillis(readRowStreamTimeout)), settings.getClientTimeouts().getScanTimeouts().getOperationTimeout());
assertEquals(Optional.of(Duration.ofMillis(readRowStreamAttemptTimeout)), settings.getClientTimeouts().getScanTimeouts().getAttemptTimeout());
assertEquals(Optional.of(Duration.ofMillis(perRowTimeoutMs)), settings.getClientTimeouts().getScanTimeouts().getResponseTimeout());
RetrySettings readRowRetrySettings = dataSettings.getStubSettings().readRowSettings().getRetrySettings();
assertEquals(initialElapsedMs, readRowRetrySettings.getInitialRetryDelay().toMillis());
assertEquals(rpcTimeoutMs, readRowRetrySettings.getTotalTimeout().toMillis());
assertEquals(rpcAttemptTimeoutMs, readRowRetrySettings.getInitialRpcTimeout().toMillis());
assertEquals(rpcAttemptTimeoutMs, readRowRetrySettings.getMaxRpcTimeout().toMillis());
RetrySettings checkAndMutateRetrySettings = dataSettings.getStubSettings().checkAndMutateRowSettings().getRetrySettings();
assertEquals(rpcTimeoutMs, checkAndMutateRetrySettings.getTotalTimeout().toMillis());
// CheckAndMutate is non-retriable so its rpc timeout = overall timeout
assertEquals(rpcTimeoutMs, checkAndMutateRetrySettings.getInitialRpcTimeout().toMillis());
assertEquals(rpcTimeoutMs, checkAndMutateRetrySettings.getMaxRpcTimeout().toMillis());
RetrySettings readRowsRetrySettings = dataSettings.getStubSettings().readRowsSettings().getRetrySettings();
assertEquals(initialElapsedMs, readRowsRetrySettings.getInitialRetryDelay().toMillis());
assertEquals(perRowTimeoutMs, readRowsRetrySettings.getInitialRpcTimeout().toMillis());
assertEquals(perRowTimeoutMs, readRowsRetrySettings.getMaxRpcTimeout().toMillis());
assertEquals(maxAttempt, readRowsRetrySettings.getMaxAttempts());
assertEquals(readRowStreamTimeout, readRowsRetrySettings.getTotalTimeout().toMillis());
}
Aggregations