BigtableHBaseVeneerSettings extends BigtableHBaseSettings { public BigtableDataSettings getDataSettings() { return dataSettings; } BigtableHBaseVeneerSettings(Configuration configuration); @Override String getDataHost(); @Override String getAdminHost(); @Override int getPort(); @Override int getBulkMaxRowCount(); @Override long getBatchingMaxRequestSize(); @Override boolean isRetriesWithoutTimestampAllowed(); boolean isChannelPoolCachingEnabled(); BigtableDataSettings getDataSettings(); BigtableTableAdminSettings getTableAdminSettings(); @Nullable BigtableInstanceAdminSettings getInstanceAdminSettings();  }
@Test public void testTimeoutBeingPassed() throws IOException { int initialElapsedMs = 100; int rpcTimeoutMs = 500; int maxElapsedMs = 1000; int maxAttempt = 10; int readRowStreamTimeout = 30000; configuration.setBoolean(BIGTABLE_USE_TIMEOUTS_KEY, true); configuration.setInt(INITIAL_ELAPSED_BACKOFF_MILLIS_KEY, initialElapsedMs); configuration.setInt(BIGTABLE_RPC_TIMEOUT_MS_KEY, rpcTimeoutMs); configuration.setInt(MAX_ELAPSED_BACKOFF_MILLIS_KEY, maxElapsedMs); configuration.setInt(READ_PARTIAL_ROW_TIMEOUT_MS, rpcTimeoutMs); configuration.setLong(MAX_SCAN_TIMEOUT_RETRIES, maxAttempt); configuration.setInt(BIGTABLE_READ_RPC_TIMEOUT_MS_KEY, readRowStreamTimeout); BigtableDataSettings settings = ((BigtableHBaseVeneerSettings) BigtableHBaseVeneerSettings.create(configuration)) .getDataSettings(); RetrySettings readRowRetrySettings = settings.getStubSettings().readRowSettings().getRetrySettings(); assertEquals(initialElapsedMs, readRowRetrySettings.getInitialRetryDelay().toMillis()); assertEquals(rpcTimeoutMs, readRowRetrySettings.getInitialRpcTimeout().toMillis()); assertEquals(maxElapsedMs, readRowRetrySettings.getTotalTimeout().toMillis()); RetrySettings checkAndMutateRetrySettings = settings.getStubSettings().checkAndMutateRowSettings().getRetrySettings(); assertEquals(0, checkAndMutateRetrySettings.getInitialRetryDelay().toMillis()); assertEquals(rpcTimeoutMs, checkAndMutateRetrySettings.getTotalTimeout().toMillis()); RetrySettings readRowsRetrySettings = settings.getStubSettings().readRowsSettings().getRetrySettings(); assertEquals(initialElapsedMs, readRowsRetrySettings.getInitialRetryDelay().toMillis()); assertEquals(maxAttempt, readRowsRetrySettings.getMaxAttempts()); assertEquals(readRowStreamTimeout, readRowsRetrySettings.getTotalTimeout().toMillis()); }
@Test public void testWhenRetriesAreDisabled() throws IOException { configuration.setBoolean(ENABLE_GRPC_RETRIES_KEY, false); BigtableDataSettings dataSettings = ((BigtableHBaseVeneerSettings) BigtableHBaseVeneerSettings.create(configuration)) .getDataSettings(); assertTrue( dataSettings.getStubSettings().bulkMutateRowsSettings().getRetryableCodes().isEmpty()); assertTrue(dataSettings.getStubSettings().readRowSettings().getRetryableCodes().isEmpty()); assertTrue(dataSettings.getStubSettings().readRowsSettings().getRetryableCodes().isEmpty()); assertTrue( dataSettings.getStubSettings().sampleRowKeysSettings().getRetryableCodes().isEmpty()); }
@Test public void testVerifyRetrySettings() throws IOException { configuration.set(BIGTABLE_USE_TIMEOUTS_KEY, "true"); BigtableDataSettings dataSettings = ((BigtableHBaseVeneerSettings) BigtableHBaseVeneerSettings.create(configuration)) .getDataSettings(); BigtableDataSettings defaultDataSettings = BigtableDataSettings.newBuilder() .setProjectId("project-id") .setInstanceId("instance-id") .build(); assertEquals( defaultDataSettings.getStubSettings().readRowsSettings().getRetryableCodes(), dataSettings.getStubSettings().readRowsSettings().getRetryableCodes()); assertRetriableOperation( defaultDataSettings.getStubSettings().readRowSettings(), dataSettings.getStubSettings().readRowSettings()); assertRetriableOperation( defaultDataSettings.getStubSettings().mutateRowSettings(), dataSettings.getStubSettings().mutateRowSettings()); assertRetriableOperation( defaultDataSettings.getStubSettings().sampleRowKeysSettings(), dataSettings.getStubSettings().sampleRowKeysSettings()); assertNonRetriableOperation( defaultDataSettings.getStubSettings().readModifyWriteRowSettings(), dataSettings.getStubSettings().readModifyWriteRowSettings()); assertNonRetriableOperation( defaultDataSettings.getStubSettings().checkAndMutateRowSettings(), dataSettings.getStubSettings().checkAndMutateRowSettings()); }
@Test public void testDataSettingsWithEmulator() throws IOException { ServerSocket serverSocket = new ServerSocket(0); final int availablePort = serverSocket.getLocalPort(); serverSocket.close(); String emulatorHost = "localhost:" + availablePort; configuration.set(BIGTABLE_EMULATOR_HOST_KEY, emulatorHost); BigtableDataSettings dataSettings = ((BigtableHBaseVeneerSettings) BigtableHBaseVeneerSettings.create(configuration)) .getDataSettings(); assertEquals(emulatorHost, dataSettings.getStubSettings().getEndpoint()); CredentialsProvider credProvider = dataSettings.getStubSettings().getCredentialsProvider(); assertTrue(credProvider instanceof NoCredentialsProvider); }
@Test public void testRpcMethodWithoutRetry() throws IOException { configuration.set(ENABLE_GRPC_RETRIES_KEY, "false"); BigtableHBaseVeneerSettings settingUtils = ((BigtableHBaseVeneerSettings) BigtableHBaseVeneerSettings.create(configuration)); BigtableDataSettings settings = settingUtils.getDataSettings(); assertTrue(settings.getStubSettings().readRowsSettings().getRetryableCodes().isEmpty()); assertRpcWithoutTimeout(settings.getStubSettings().bulkReadRowsSettings()); assertRpcWithoutTimeout(settings.getStubSettings().bulkMutateRowsSettings()); assertRpcWithoutTimeout(settings.getStubSettings().readRowSettings()); assertRpcWithoutTimeout(settings.getStubSettings().mutateRowSettings()); assertRpcWithoutTimeout(settings.getStubSettings().sampleRowKeysSettings()); }