This is an automated email from the ASF dual-hosted git repository. yasith pushed a commit to branch feat/server-collapse in repository https://gitbox.apache.org/repos/asf/airavata.git
commit 10ff384e69639a9014b638a646dc5d11f73dadfb Author: yasithdev <[email protected]> AuthorDate: Sat Mar 28 02:08:24 2026 -0500 refactor: replace Thrift clients in sub-modules with direct service calls --- .../service/handlers/AgentManagementHandler.java | 6 ++-- .../service/services/AiravataFileService.java | 2 +- .../service/services/AiravataService.java | 32 ++++++++-------------- .../file/server/FileServerConfiguration.java | 27 ------------------ .../file/server/service/AirvataFileService.java | 13 ++++----- .../file/server/service/ProcessDataManager.java | 11 ++------ 6 files changed, 24 insertions(+), 67 deletions(-) diff --git a/airavata-api/agent-service/src/main/java/org/apache/airavata/agent/connection/service/handlers/AgentManagementHandler.java b/airavata-api/agent-service/src/main/java/org/apache/airavata/agent/connection/service/handlers/AgentManagementHandler.java index 9939d25c30..da9102fc96 100644 --- a/airavata-api/agent-service/src/main/java/org/apache/airavata/agent/connection/service/handlers/AgentManagementHandler.java +++ b/airavata-api/agent-service/src/main/java/org/apache/airavata/agent/connection/service/handlers/AgentManagementHandler.java @@ -69,7 +69,7 @@ public class AgentManagementHandler { public AgentTerminateResponse terminateExperiment(String experimentId) { try { - Airavata.Client airavata = airavataService.airavata(); + Airavata.Iface airavata = airavataService.airavata(); ExperimentModel experiment = airavata.getExperiment(UserContext.authzToken(), experimentId); airavata.terminateExperiment( UserContext.authzToken(), experiment.getExperimentId(), experiment.getGatewayId()); @@ -82,7 +82,7 @@ public class AgentManagementHandler { public ExperimentModel getExperiment(String experimentId) { try { - Airavata.Client airavata = airavataService.airavata(); + Airavata.Iface airavata = airavataService.airavata(); ExperimentModel experiment = airavata.getExperiment(UserContext.authzToken(), experimentId); GroupResourceProfile groupResourceProfile = airavata.getGroupResourceProfile( UserContext.authzToken(), @@ -206,7 +206,7 @@ public class AgentManagementHandler { private ExperimentModel generateExperiment(AgentLaunchRequest req, String agentId, String envName) throws TException { - Airavata.Client airavataClient = airavataService.airavata(); + Airavata.Iface airavataClient = airavataService.airavata(); String experimentName = req.getExperimentName(); String projectName = req.getProjectName() != null ? req.getProjectName() : "Default Project"; diff --git a/airavata-api/agent-service/src/main/java/org/apache/airavata/agent/connection/service/services/AiravataFileService.java b/airavata-api/agent-service/src/main/java/org/apache/airavata/agent/connection/service/services/AiravataFileService.java index cf990fc8e8..bc646e7978 100644 --- a/airavata-api/agent-service/src/main/java/org/apache/airavata/agent/connection/service/services/AiravataFileService.java +++ b/airavata-api/agent-service/src/main/java/org/apache/airavata/agent/connection/service/services/AiravataFileService.java @@ -63,7 +63,7 @@ public class AiravataFileService { } public void handleReadDirRequest(ReadDirReq request, StreamObserver<ServerMessage> responseObserver) { - Airavata.Client airavataClient = airavataService.airavata(); + Airavata.Iface airavataClient = airavataService.airavata(); String fusePath = request.getName(); ReadDirRes.Builder readDirResBuilder = ReadDirRes.newBuilder(); diff --git a/airavata-api/agent-service/src/main/java/org/apache/airavata/agent/connection/service/services/AiravataService.java b/airavata-api/agent-service/src/main/java/org/apache/airavata/agent/connection/service/services/AiravataService.java index 5df63cc194..ea9cf1d4bb 100644 --- a/airavata-api/agent-service/src/main/java/org/apache/airavata/agent/connection/service/services/AiravataService.java +++ b/airavata-api/agent-service/src/main/java/org/apache/airavata/agent/connection/service/services/AiravataService.java @@ -21,49 +21,39 @@ package org.apache.airavata.agent.connection.service.services; import io.micrometer.common.util.StringUtils; import java.util.List; -import java.util.Map; import java.util.Optional; import java.util.stream.Collectors; import java.util.stream.Stream; import org.apache.airavata.common.security.UserContext; import org.apache.airavata.api.Airavata; -import org.apache.airavata.common.util.AiravataClientFactory; import org.apache.airavata.model.appcatalog.groupresourceprofile.GroupComputeResourcePreference; import org.apache.airavata.model.appcatalog.groupresourceprofile.GroupResourceProfile; -import org.apache.airavata.model.error.AiravataClientException; import org.apache.airavata.model.experiment.ExperimentSearchFields; import org.apache.airavata.model.experiment.ExperimentSummaryModel; import org.apache.airavata.model.workspace.Project; import org.apache.thrift.TException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; +import java.util.Map; + @Service public class AiravataService { private static final Logger LOGGER = LoggerFactory.getLogger(AiravataService.class); - @Value("${airavata.server.url:airavata.host}") - private String serverUrl; + private final Airavata.Iface airavataHandler; - @Value("${airavata.server.port:8930}") - private int port; - - @Value("${airavata.server.secure:false}") - private boolean secure; + public AiravataService(Airavata.Iface airavataHandler) { + this.airavataHandler = airavataHandler; + } - public Airavata.Client airavata() { - try { - return AiravataClientFactory.createAiravataClient(serverUrl, port, secure); - } catch (AiravataClientException e) { - LOGGER.error("Error while creating Airavata client", e); - throw new RuntimeException("Error while creating Airavata client", e); - } + public Airavata.Iface airavata() { + return airavataHandler; } - public String getProjectId(Airavata.Client airavataClient, String projectName) throws TException { + public String getProjectId(Airavata.Iface airavataClient, String projectName) throws TException { int limit = 10; int offset = 0; @@ -88,7 +78,7 @@ public class AiravataService { } public GroupComputeResourcePreference extractGroupComputeResourcePreference( - Airavata.Client airavataClient, String group, String remoteCluster) throws TException { + Airavata.Iface airavataClient, String group, String remoteCluster) throws TException { List<GroupResourceProfile> groupResourceList = airavataClient.getGroupResourceList(UserContext.authzToken(), UserContext.gatewayId()); String groupProfileName = StringUtils.isNotBlank(group) ? group : "Default"; @@ -102,7 +92,7 @@ public class AiravataService { + groupProfileName + " group resource profile for the user: " + UserContext.userId())); } - public List<String> getUserExperimentIDs(Airavata.Client airavataClient) throws TException { + public List<String> getUserExperimentIDs(Airavata.Iface airavataClient) throws TException { int limit = 100; Map<ExperimentSearchFields, String> filters = Map.of(ExperimentSearchFields.PROJECT_ID, getProjectId(airavataClient, "Default Project")); diff --git a/airavata-api/file-server/src/main/java/org/apache/airavata/file/server/FileServerConfiguration.java b/airavata-api/file-server/src/main/java/org/apache/airavata/file/server/FileServerConfiguration.java index 69db3671b8..ec35cc888a 100644 --- a/airavata-api/file-server/src/main/java/org/apache/airavata/file/server/FileServerConfiguration.java +++ b/airavata-api/file-server/src/main/java/org/apache/airavata/file/server/FileServerConfiguration.java @@ -19,13 +19,8 @@ */ package org.apache.airavata.file.server; -import java.time.Duration; -import org.apache.airavata.common.util.ThriftClientPool; import org.apache.airavata.execution.orchestrator.AdaptorSupport; import org.apache.airavata.execution.orchestrator.AdaptorSupportImpl; -import org.apache.airavata.registry.api.RegistryService; -import org.apache.commons.pool2.impl.GenericObjectPoolConfig; -import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.stereotype.Component; @@ -38,26 +33,4 @@ public class FileServerConfiguration { public AdaptorSupport adaptorSupport() { return AdaptorSupportImpl.getInstance(); } - - @Value("${airavata.thrift.host:localhost}") - private String airavataServerHost; - - @Value("${airavata.thrift.port:8930}") - private int airavataServerPort; - - @Bean - public ThriftClientPool<RegistryService.Client> registryClientPool() { - GenericObjectPoolConfig<RegistryService.Client> poolConfig = new GenericObjectPoolConfig<>(); - poolConfig.setMaxTotal(100); - poolConfig.setMinIdle(5); - poolConfig.setBlockWhenExhausted(true); - poolConfig.setTestOnBorrow(true); - poolConfig.setTestWhileIdle(true); - poolConfig.setTimeBetweenEvictionRuns(Duration.ofMinutes(5)); - poolConfig.setNumTestsPerEvictionRun(10); - poolConfig.setMaxWait(Duration.ofSeconds(3)); - - return new ThriftClientPool<>( - RegistryService.Client::new, poolConfig, airavataServerHost, airavataServerPort, "RegistryService"); - } } diff --git a/airavata-api/file-server/src/main/java/org/apache/airavata/file/server/service/AirvataFileService.java b/airavata-api/file-server/src/main/java/org/apache/airavata/file/server/service/AirvataFileService.java index f136f9cbe5..1d14cb53f1 100644 --- a/airavata-api/file-server/src/main/java/org/apache/airavata/file/server/service/AirvataFileService.java +++ b/airavata-api/file-server/src/main/java/org/apache/airavata/file/server/service/AirvataFileService.java @@ -24,7 +24,6 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.StandardCopyOption; import java.util.List; -import org.apache.airavata.common.util.ThriftClientPool; import org.apache.airavata.compute.util.AgentAdaptor; import org.apache.airavata.execution.orchestrator.AdaptorSupport; import org.apache.airavata.file.server.model.AiravataDirectory; @@ -46,7 +45,7 @@ public class AirvataFileService { private AdaptorSupport adaptorSupport; @Autowired - ThriftClientPool<RegistryService.Client> registryClientPool; + RegistryService.Iface registryClient; private AgentAdaptor getAgentAdaptor(ProcessDataManager dataManager, String processId) throws Exception { AgentAdaptor agentAdaptor; @@ -60,7 +59,7 @@ public class AirvataFileService { } public FileMetadata getInfo(String processId, String subPath) throws Exception { - ProcessDataManager dataManager = new ProcessDataManager(registryClientPool, processId, adaptorSupport); + ProcessDataManager dataManager = new ProcessDataManager(registryClient, processId, adaptorSupport); AgentAdaptor agentAdaptor = getAgentAdaptor(dataManager, processId); String absPath = dataManager.getBaseDir() + subPath; @@ -69,7 +68,7 @@ public class AirvataFileService { } public AiravataDirectory listDir(String processId, String subPath) throws Exception { - ProcessDataManager dataManager = new ProcessDataManager(registryClientPool, processId, adaptorSupport); + ProcessDataManager dataManager = new ProcessDataManager(registryClient, processId, adaptorSupport); AgentAdaptor agentAdaptor = getAgentAdaptor(dataManager, processId); String absPath = dataManager.getBaseDir() + subPath; @@ -96,7 +95,7 @@ public class AirvataFileService { } public AiravataFile listFile(String processId, String subPath) throws Exception { - ProcessDataManager dataManager = new ProcessDataManager(registryClientPool, processId, adaptorSupport); + ProcessDataManager dataManager = new ProcessDataManager(registryClient, processId, adaptorSupport); AgentAdaptor agentAdaptor = getAgentAdaptor(dataManager, processId); String absPath = dataManager.getBaseDir() + subPath; @@ -113,7 +112,7 @@ public class AirvataFileService { metadata.setSize(file.getSize()); Files.copy(file.getInputStream(), tempPath, StandardCopyOption.REPLACE_EXISTING); - ProcessDataManager dataManager = new ProcessDataManager(registryClientPool, processId, adaptorSupport); + ProcessDataManager dataManager = new ProcessDataManager(registryClient, processId, adaptorSupport); AgentAdaptor agentAdaptor = getAgentAdaptor(dataManager, processId); String absPath = dataManager.getBaseDir() + subPath; @@ -133,7 +132,7 @@ public class AirvataFileService { public Path downloadFile(String processId, String subPath) throws Exception { - ProcessDataManager dataManager = new ProcessDataManager(registryClientPool, processId, adaptorSupport); + ProcessDataManager dataManager = new ProcessDataManager(registryClient, processId, adaptorSupport); AgentAdaptor agentAdaptor = getAgentAdaptor(dataManager, processId); String absPath = dataManager.getBaseDir() + subPath; diff --git a/airavata-api/file-server/src/main/java/org/apache/airavata/file/server/service/ProcessDataManager.java b/airavata-api/file-server/src/main/java/org/apache/airavata/file/server/service/ProcessDataManager.java index 8d057cbb3a..7993bebbb8 100644 --- a/airavata-api/file-server/src/main/java/org/apache/airavata/file/server/service/ProcessDataManager.java +++ b/airavata-api/file-server/src/main/java/org/apache/airavata/file/server/service/ProcessDataManager.java @@ -20,7 +20,6 @@ package org.apache.airavata.file.server.service; import java.util.UUID; -import org.apache.airavata.common.util.ThriftClientPool; import org.apache.airavata.compute.task.aws.AWSProcessContextManager; import org.apache.airavata.compute.util.AgentAdaptor; import org.apache.airavata.compute.util.AgentUtils; @@ -46,27 +45,23 @@ public class ProcessDataManager extends OutputDataStagingTask { ExperimentModel experiment; public ProcessDataManager( - ThriftClientPool<RegistryService.Client> registryClientPool, + RegistryService.Iface registryClient, String processId, AdaptorSupport adaptorSupport) throws Exception { this.adaptorSupport = adaptorSupport; - RegistryService.Client regClient = registryClientPool.getResource(); try { - process = regClient.getProcess(processId); - experiment = regClient.getExperiment(process.getExperimentId()); + process = registryClient.getProcess(processId); + experiment = registryClient.getExperiment(process.getExperimentId()); setTaskId(UUID.randomUUID().toString()); setProcessId(processId); setExperimentId(process.getExperimentId()); setGatewayId(experiment.getGatewayId()); loadContext(); - - registryClientPool.returnResource(regClient); } catch (Exception e) { logger.error("Failed to initialize the output data mover for process {}", processId, e); - registryClientPool.returnBrokenResource(regClient); throw e; } this.processId = processId;
