Github user hyunsik commented on a diff in the pull request:
https://github.com/apache/tajo/pull/621#discussion_r34640894
--- Diff:
tajo-catalog/tajo-catalog-client/src/main/java/org/apache/tajo/catalog/AbstractCatalogClient.java
---
@@ -51,113 +55,132 @@ public AbstractCatalogClient(TajoConf conf) {
this.conf = conf;
}
- abstract CatalogProtocolService.BlockingInterface getStub() throws
ServiceException;
+ abstract BlockingInterface getStub() throws ServiceException;
@Override
public final Boolean createTablespace(final String tablespaceName, final
String tablespaceUri) {
+
try {
- CatalogProtocolService.BlockingInterface stub = getStub();
+ final BlockingInterface stub = getStub();
+ final CreateTablespaceRequest request =
CreateTablespaceRequest.newBuilder()
+ .setTablespaceName(tablespaceName)
+ .setTablespaceUri(tablespaceUri)
+ .build();
- CreateTablespaceRequest.Builder builder =
CreateTablespaceRequest.newBuilder();
- builder.setTablespaceName(tablespaceName);
- builder.setTablespaceUri(tablespaceUri);
- return stub.createTablespace(null, builder.build()).getValue();
- } catch (Exception e) {
- LOG.error(e.getMessage(), e);
- return Boolean.FALSE;
+ return isSuccess(stub.createTablespace(null, request));
+
+ } catch (ServiceException e) {
+ throw new RuntimeException(e);
--- End diff --
I used RuntimeException for unexpected error. In my design, the server API
call never throws ServiceException, only communication or netty will throw
ServiceException. This case will occur rarely, so I used RuntimeException.
In addition, catalog and client API will be improved further to have API
specific exceptions. For example, createTablespace will throw
DuplicateTablespaceException and dropTable will throw UndefinedTableException.
But, this approach significantly changes lots of parts. So, I'll do it in
following works.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---