You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by is...@apache.org on 2022/05/10 23:11:15 UTC

[airavata-custos] branch develop updated: remove try-with-resource from clients

This is an automated email from the ASF dual-hosted git repository.

isjarana pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/airavata-custos.git


The following commit(s) were added to refs/heads/develop by this push:
     new 6ed0cb37 remove try-with-resource from clients
     new e7b9ad52 Merge pull request #273 from isururanawaka/develop
6ed0cb37 is described below

commit 6ed0cb377e6e45be6c3ab0e87d1208801b2b2a8e
Author: Isuru Ranawaka <ir...@gmail.com>
AuthorDate: Tue May 10 19:10:38 2022 -0400

    remove try-with-resource from clients
---
 .../agent-management-client/pom.xml                | 40 +++++++++++++++++++-
 .../apache/custos/clients/core/AbstractClient.java | 12 +++---
 .../group-management-client/pom.xml                | 39 ++++++++++++++++++-
 .../identity-management-client/pom.xml             | 41 +++++++++++++++++++-
 .../client/IdentityManagementClient.java           |  6 +++
 .../resource-secret-management-client/pom.xml      | 44 +++++++++++++++++++++-
 .../sharing-management-client/pom.xml              | 40 +++++++++++++++++++-
 .../tenant-management-client/pom.xml               | 41 +++++++++++++++++++-
 .../user-management-client/pom.xml                 | 40 +++++++++++++++++++-
 .../custos/clients/CustosClientProvider.java       | 33 ++++------------
 10 files changed, 290 insertions(+), 46 deletions(-)

diff --git a/custos-client-sdks/custos-java-clients/agent-management-client/pom.xml b/custos-client-sdks/custos-java-clients/agent-management-client/pom.xml
index 42197fe5..7d860d06 100644
--- a/custos-client-sdks/custos-java-clients/agent-management-client/pom.xml
+++ b/custos-client-sdks/custos-java-clients/agent-management-client/pom.xml
@@ -44,14 +44,50 @@
         </dependency>
         <dependency>
             <groupId>org.apache.custos</groupId>
-            <artifactId>agent-management-service</artifactId>
+            <artifactId>custos-clients-core</artifactId>
             <version>${project.version}</version>
         </dependency>
         <dependency>
             <groupId>org.apache.custos</groupId>
-            <artifactId>custos-clients-core</artifactId>
+            <artifactId>tenant-profile-core-service-client-stub</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>iam-admin-core-service-client-stub</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>identity-core-service-client-stub</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>user-profile-core-service-client-stub</artifactId>
             <version>${project.version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>federated-authentication-core-service-client-stub</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>credential-store-core-service-client-stubs</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>messaging-core-service-client-stub</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>sharing-core-service-client-stub</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
     </dependencies>
     <build>
         <extensions>
diff --git a/custos-client-sdks/custos-java-clients/custos-clients-core/src/main/java/org/apache/custos/clients/core/AbstractClient.java b/custos-client-sdks/custos-java-clients/custos-clients-core/src/main/java/org/apache/custos/clients/core/AbstractClient.java
index 5953e8d9..2617b528 100644
--- a/custos-client-sdks/custos-java-clients/custos-clients-core/src/main/java/org/apache/custos/clients/core/AbstractClient.java
+++ b/custos-client-sdks/custos-java-clients/custos-clients-core/src/main/java/org/apache/custos/clients/core/AbstractClient.java
@@ -22,6 +22,8 @@ package org.apache.custos.clients.core;
 import io.grpc.ManagedChannel;
 import io.grpc.netty.GrpcSslContexts;
 import io.grpc.netty.NettyChannelBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.io.Closeable;
 import java.io.IOException;
@@ -29,7 +31,9 @@ import java.io.IOException;
 /**
  * This client will work as an Abstract client for all Java clients
  */
-public class AbstractClient implements Closeable {
+public abstract  class AbstractClient implements Closeable {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(AbstractClient.class);
 
     public ManagedChannel managedChannel;
 
@@ -43,12 +47,6 @@ public class AbstractClient implements Closeable {
                 .build();
     }
 
-    @Override
-    public void close() throws IOException {
-        if (managedChannel != null) {
-            managedChannel.shutdown();
-        }
-    }
 
     public boolean isShutdown() {
         return managedChannel.isShutdown();
diff --git a/custos-client-sdks/custos-java-clients/group-management-client/pom.xml b/custos-client-sdks/custos-java-clients/group-management-client/pom.xml
index b854d397..768375be 100644
--- a/custos-client-sdks/custos-java-clients/group-management-client/pom.xml
+++ b/custos-client-sdks/custos-java-clients/group-management-client/pom.xml
@@ -44,12 +44,47 @@
         </dependency>
         <dependency>
             <groupId>org.apache.custos</groupId>
-            <artifactId>group-management-service</artifactId>
+            <artifactId>custos-clients-core</artifactId>
             <version>${project.version}</version>
         </dependency>
         <dependency>
             <groupId>org.apache.custos</groupId>
-            <artifactId>custos-clients-core</artifactId>
+            <artifactId>tenant-profile-core-service-client-stub</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>iam-admin-core-service-client-stub</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>identity-core-service-client-stub</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>user-profile-core-service-client-stub</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>federated-authentication-core-service-client-stub</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>credential-store-core-service-client-stubs</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>messaging-core-service-client-stub</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>sharing-core-service-client-stub</artifactId>
             <version>${project.version}</version>
         </dependency>
     </dependencies>
diff --git a/custos-client-sdks/custos-java-clients/identity-management-client/pom.xml b/custos-client-sdks/custos-java-clients/identity-management-client/pom.xml
index 971e0e1b..375cdbb2 100644
--- a/custos-client-sdks/custos-java-clients/identity-management-client/pom.xml
+++ b/custos-client-sdks/custos-java-clients/identity-management-client/pom.xml
@@ -42,14 +42,51 @@
             <groupId>io.grpc</groupId>
             <artifactId>grpc-netty</artifactId>
         </dependency>
+
         <dependency>
             <groupId>org.apache.custos</groupId>
-            <artifactId>identity-management-service</artifactId>
+            <artifactId>custos-clients-core</artifactId>
             <version>${project.version}</version>
         </dependency>
+
         <dependency>
             <groupId>org.apache.custos</groupId>
-            <artifactId>custos-clients-core</artifactId>
+            <artifactId>tenant-profile-core-service-client-stub</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>iam-admin-core-service-client-stub</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>identity-core-service-client-stub</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>user-profile-core-service-client-stub</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>federated-authentication-core-service-client-stub</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>credential-store-core-service-client-stubs</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>messaging-core-service-client-stub</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>sharing-core-service-client-stub</artifactId>
             <version>${project.version}</version>
         </dependency>
     </dependencies>
diff --git a/custos-client-sdks/custos-java-clients/identity-management-client/src/main/java/org/apache/custos/identity/management/client/IdentityManagementClient.java b/custos-client-sdks/custos-java-clients/identity-management-client/src/main/java/org/apache/custos/identity/management/client/IdentityManagementClient.java
index 825ab466..9f997901 100644
--- a/custos-client-sdks/custos-java-clients/identity-management-client/src/main/java/org/apache/custos/identity/management/client/IdentityManagementClient.java
+++ b/custos-client-sdks/custos-java-clients/identity-management-client/src/main/java/org/apache/custos/identity/management/client/IdentityManagementClient.java
@@ -31,6 +31,8 @@ import org.apache.custos.identity.management.service.GetAgentTokenRequest;
 import org.apache.custos.identity.management.service.GetCredentialsRequest;
 import org.apache.custos.identity.management.service.IdentityManagementServiceGrpc;
 import org.apache.custos.identity.service.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.io.Closeable;
 import java.io.IOException;
@@ -40,6 +42,8 @@ import java.io.IOException;
  */
 public class IdentityManagementClient extends AbstractClient {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(IdentityManagementClient.class);
+
     private IdentityManagementServiceGrpc.IdentityManagementServiceBlockingStub blockingStub;
 
     private IdentityManagementServiceGrpc.IdentityManagementServiceBlockingStub cleanBlockingStub;
@@ -212,7 +216,9 @@ public class IdentityManagementClient extends AbstractClient {
 
     @Override
     public void close() throws IOException {
+        LOGGER.info("Calling close on IdentityManagementClient");
         if (managedChannel != null) {
+            LOGGER.info("Calling channel shutdown");
             managedChannel.shutdown();
         }
     }
diff --git a/custos-client-sdks/custos-java-clients/resource-secret-management-client/pom.xml b/custos-client-sdks/custos-java-clients/resource-secret-management-client/pom.xml
index 6bb34c77..78fcb10f 100644
--- a/custos-client-sdks/custos-java-clients/resource-secret-management-client/pom.xml
+++ b/custos-client-sdks/custos-java-clients/resource-secret-management-client/pom.xml
@@ -44,12 +44,52 @@
         </dependency>
         <dependency>
             <groupId>org.apache.custos</groupId>
-            <artifactId>resource-secret-management-service</artifactId>
+            <artifactId>custos-clients-core</artifactId>
             <version>${project.version}</version>
         </dependency>
         <dependency>
             <groupId>org.apache.custos</groupId>
-            <artifactId>custos-clients-core</artifactId>
+            <artifactId>tenant-profile-core-service-client-stub</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>iam-admin-core-service-client-stub</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>identity-core-service-client-stub</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>user-profile-core-service-client-stub</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>federated-authentication-core-service-client-stub</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>credential-store-core-service-client-stubs</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>messaging-core-service-client-stub</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>sharing-core-service-client-stub</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>resource-secret-core-service-client-stub</artifactId>
             <version>${project.version}</version>
         </dependency>
     </dependencies>
diff --git a/custos-client-sdks/custos-java-clients/sharing-management-client/pom.xml b/custos-client-sdks/custos-java-clients/sharing-management-client/pom.xml
index b8e51610..051f1918 100644
--- a/custos-client-sdks/custos-java-clients/sharing-management-client/pom.xml
+++ b/custos-client-sdks/custos-java-clients/sharing-management-client/pom.xml
@@ -45,12 +45,48 @@
 
         <dependency>
             <groupId>org.apache.custos</groupId>
-            <artifactId>sharing-management-service</artifactId>
+            <artifactId>custos-clients-core</artifactId>
             <version>${project.version}</version>
         </dependency>
+
         <dependency>
             <groupId>org.apache.custos</groupId>
-            <artifactId>custos-clients-core</artifactId>
+            <artifactId>tenant-profile-core-service-client-stub</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>iam-admin-core-service-client-stub</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>identity-core-service-client-stub</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>user-profile-core-service-client-stub</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>federated-authentication-core-service-client-stub</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>credential-store-core-service-client-stubs</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>messaging-core-service-client-stub</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>sharing-core-service-client-stub</artifactId>
             <version>${project.version}</version>
         </dependency>
     </dependencies>
diff --git a/custos-client-sdks/custos-java-clients/tenant-management-client/pom.xml b/custos-client-sdks/custos-java-clients/tenant-management-client/pom.xml
index 06c637e5..e153934b 100644
--- a/custos-client-sdks/custos-java-clients/tenant-management-client/pom.xml
+++ b/custos-client-sdks/custos-java-clients/tenant-management-client/pom.xml
@@ -44,12 +44,49 @@
         </dependency>
         <dependency>
             <groupId>org.apache.custos</groupId>
-            <artifactId>tenant-management-service</artifactId>
+            <artifactId>custos-clients-core</artifactId>
             <version>${project.version}</version>
         </dependency>
+
+
         <dependency>
             <groupId>org.apache.custos</groupId>
-            <artifactId>custos-clients-core</artifactId>
+            <artifactId>tenant-profile-core-service-client-stub</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>iam-admin-core-service-client-stub</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>identity-core-service-client-stub</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>user-profile-core-service-client-stub</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>federated-authentication-core-service-client-stub</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>credential-store-core-service-client-stubs</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>messaging-core-service-client-stub</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>sharing-core-service-client-stub</artifactId>
             <version>${project.version}</version>
         </dependency>
     </dependencies>
diff --git a/custos-client-sdks/custos-java-clients/user-management-client/pom.xml b/custos-client-sdks/custos-java-clients/user-management-client/pom.xml
index d99470a9..119f32bc 100644
--- a/custos-client-sdks/custos-java-clients/user-management-client/pom.xml
+++ b/custos-client-sdks/custos-java-clients/user-management-client/pom.xml
@@ -44,12 +44,48 @@
         </dependency>
         <dependency>
             <groupId>org.apache.custos</groupId>
-            <artifactId>user-management-service</artifactId>
+            <artifactId>custos-clients-core</artifactId>
             <version>${project.version}</version>
         </dependency>
+
         <dependency>
             <groupId>org.apache.custos</groupId>
-            <artifactId>custos-clients-core</artifactId>
+            <artifactId>tenant-profile-core-service-client-stub</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>iam-admin-core-service-client-stub</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>identity-core-service-client-stub</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>user-profile-core-service-client-stub</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>federated-authentication-core-service-client-stub</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>credential-store-core-service-client-stubs</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>messaging-core-service-client-stub</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.custos</groupId>
+            <artifactId>sharing-core-service-client-stub</artifactId>
             <version>${project.version}</version>
         </dependency>
     </dependencies>
diff --git a/custos-client-sdks/custos-java-sdk/src/main/java/org/apache/custos/clients/CustosClientProvider.java b/custos-client-sdks/custos-java-sdk/src/main/java/org/apache/custos/clients/CustosClientProvider.java
index 48fed0b7..3128799e 100644
--- a/custos-client-sdks/custos-java-sdk/src/main/java/org/apache/custos/clients/CustosClientProvider.java
+++ b/custos-client-sdks/custos-java-sdk/src/main/java/org/apache/custos/clients/CustosClientProvider.java
@@ -54,54 +54,37 @@ public class CustosClientProvider {
 
 
     public IdentityManagementClient getIdentityManagementClient() throws IOException {
-        try (IdentityManagementClient identityManagementClient = new IdentityManagementClient(this.serverHost, this.serverPort, this.clientId, this.clientSec)) {
-            return identityManagementClient;
-        }
+        return new IdentityManagementClient(this.serverHost, this.serverPort, this.clientId, this.clientSec);
 
     }
 
 
     public TenantManagementClient getTenantManagementClient() throws IOException {
-        try (TenantManagementClient tenantManagementClient = new TenantManagementClient(this.serverHost, this.serverPort, this.clientId, this.clientSec)) {
-            return tenantManagementClient;
-        }
+        return new TenantManagementClient(this.serverHost, this.serverPort, this.clientId, this.clientSec);
     }
 
     public AgentManagementClient getAgentManagementClient() throws IOException {
-        try (AgentManagementClient agentManagementClient = new AgentManagementClient(this.serverHost, this.serverPort, this.clientId, this.clientSec)) {
-            return agentManagementClient;
-        }
+        return new AgentManagementClient(this.serverHost, this.serverPort, this.clientId, this.clientSec);
     }
 
     public GroupManagementClient getGroupManagementClient() throws IOException {
-        try (GroupManagementClient groupManagementClient = new GroupManagementClient(this.serverHost, this.serverPort, this.clientId, this.clientSec)) {
-            return groupManagementClient;
-        }
+        return new GroupManagementClient(this.serverHost, this.serverPort, this.clientId, this.clientSec);
     }
 
     public ResourceSecretManagementClient getResourceSecretManagementClient() throws IOException {
-        try (ResourceSecretManagementClient resourceSecretManagementClient = new ResourceSecretManagementClient(this.serverHost, this.serverPort, this.clientId, this.clientSec)) {
-            return resourceSecretManagementClient;
-        }
+        return new ResourceSecretManagementClient(this.serverHost, this.serverPort, this.clientId, this.clientSec);
     }
 
     public SharingManagementClient getSharingManagementClient() throws IOException {
-        try (SharingManagementClient sharingManagementClient = new SharingManagementClient(this.serverHost, this.serverPort, this.clientId, this.clientSec)) {
-            return sharingManagementClient;
-        }
+        return new SharingManagementClient(this.serverHost, this.serverPort, this.clientId, this.clientSec);
     }
 
     public UserManagementClient getUserManagementClient() throws IOException {
-        try (UserManagementClient userManagementClient = new UserManagementClient(this.serverHost, this.serverPort, this.clientId, this.clientSec)) {
-            return userManagementClient;
-        }
+        return new UserManagementClient(this.serverHost, this.serverPort, this.clientId, this.clientSec);
     }
 
     public ResourceSecretManagementClient getResourceSecretManagementClientForAgents() throws IOException {
-        try (ResourceSecretManagementClient resourceSecretManagementClient = new ResourceSecretManagementAgentClient
-                (this.serverHost, this.serverPort, this.clientId, this.clientSec)) {
-            return resourceSecretManagementClient;
-        }
+        return  new ResourceSecretManagementAgentClient(this.serverHost, this.serverPort, this.clientId, this.clientSec);
     }