igorbernstein2 commented on code in PR #24015:
URL: https://github.com/apache/beam/pull/24015#discussion_r1110186660


##########
sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigtable/BigtableServiceFactory.java:
##########
@@ -131,53 +131,72 @@ synchronized BigtableServiceEntry getServiceForWriting(
       return entry;
     }
 
+    BigtableOptions effectiveOptions = getEffectiveOptions(config);
+    if (effectiveOptions != null) {
+      // If BigtableOptions is set, convert it to BigtableConfig and 
BigtableWriteOptions
+      config = BigtableConfigTranslator.translateToBigtableConfig(config, 
effectiveOptions);
+      opts = BigtableConfigTranslator.translateToBigtableWriteOptions(opts, 
effectiveOptions);
+    }
+
     BigtableDataSettings settings =
         BigtableConfigTranslator.translateWriteToVeneerSettings(config, opts, 
pipelineOptions);
     BigtableService service = new BigtableServiceImpl(settings);
-    RetrySettings retrySettings =
-        settings.getStubSettings().bulkMutateRowsSettings().getRetrySettings();
-    entry =
-        BigtableServiceEntry.create(
-            configId,
-            service,
-            new AtomicInteger(1),
-            retrySettings.getInitialRpcTimeout(),
-            retrySettings.getTotalTimeout());
+    entry = BigtableServiceEntry.create(this, configId, service, new 
AtomicInteger(1), "write");
     writeEntries.put(configId, entry);
     return entry;
   }
 
   synchronized void releaseReadService(BigtableServiceEntry entry) {
     if (entry.getRefCount().decrementAndGet() == 0) {
-      //      entry.getService().close();
+      entry.getService().close();
       readEntries.remove(entry.getConfigId());
     }
   }
 
   synchronized void releaseWriteService(BigtableServiceEntry entry) {
     if (entry.getRefCount().decrementAndGet() == 0) {
-      //      entry.getService().close();
+      entry.getService().close();
       writeEntries.remove(entry.getConfigId());
     }
   }
 
-  synchronized ConfigId newId() {
-    return ConfigId.create(nextId++);
+  boolean checkTableExists(BigtableConfig config, PipelineOptions 
pipelineOptions, String tableId)
+      throws IOException {
+    BigtableOptions effectiveOptions = getEffectiveOptions(config);
+    if (effectiveOptions != null) {
+      config = BigtableConfigTranslator.translateToBigtableConfig(config, 
effectiveOptions);
+    }
+
+    if (config.isDataAccessible()) {
+      BigtableDataSettings settings =
+          BigtableConfigTranslator.translateToVeneerSettings(config, 
pipelineOptions);
+
+      try (BigtableDataClient client = BigtableDataClient.create(settings)) {
+        try {
+          client.readRow(tableId, "non-exist-row");
+        } catch (StatusRuntimeException e) {

Review Comment:
   I dont think I believe that this is the error that will be thrown for a not 
found. veneer should be throwing ApiExceptions. So I think you want to catch 
NotFoundException from gax



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to