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

dimuthuupe pushed a commit to branch airavata-v2-refactoring
in repository https://gitbox.apache.org/repos/asf/airavata.git


The following commit(s) were added to refs/heads/airavata-v2-refactoring by 
this push:
     new 6f506542e2 Framework to connect launch request with meta scheduler
6f506542e2 is described below

commit 6f506542e2bc68757ca385e1119e45a17fb8e450
Author: DImuthuUpe <[email protected]>
AuthorDate: Mon May 15 11:40:36 2023 -0400

    Framework to connect launch request with meta scheduler
---
 .../apache/airavata/apis/config/ConfigBeans.java   | 13 ++++++
 .../airavata/apis/db/entity/ExperimentEntity.java  |  8 ++++
 .../apis/db/entity/RunConfigurationEntity.java     | 48 ++++++++++++++++++++++
 .../airavata/apis/handlers/ExecutionHandler.java   | 34 ++++++++++++++-
 .../airavata/apis/scheduling/MetaScheduler.java    | 19 +++++++++
 5 files changed, 120 insertions(+), 2 deletions(-)

diff --git 
a/modules/airavata-apis/airavata-apis-server/src/main/java/org/apache/airavata/apis/config/ConfigBeans.java
 
b/modules/airavata-apis/airavata-apis-server/src/main/java/org/apache/airavata/apis/config/ConfigBeans.java
new file mode 100644
index 0000000000..c421330640
--- /dev/null
+++ 
b/modules/airavata-apis/airavata-apis-server/src/main/java/org/apache/airavata/apis/config/ConfigBeans.java
@@ -0,0 +1,13 @@
+package org.apache.airavata.apis.config;
+
+import org.apache.airavata.apis.scheduling.MetaScheduler;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class ConfigBeans {
+    @Bean
+    public MetaScheduler metaScheduler() {
+        return new MetaScheduler();
+    }
+}
diff --git 
a/modules/airavata-apis/airavata-apis-server/src/main/java/org/apache/airavata/apis/db/entity/ExperimentEntity.java
 
b/modules/airavata-apis/airavata-apis-server/src/main/java/org/apache/airavata/apis/db/entity/ExperimentEntity.java
index db402fb4de..d1073c0017 100644
--- 
a/modules/airavata-apis/airavata-apis-server/src/main/java/org/apache/airavata/apis/db/entity/ExperimentEntity.java
+++ 
b/modules/airavata-apis/airavata-apis-server/src/main/java/org/apache/airavata/apis/db/entity/ExperimentEntity.java
@@ -80,4 +80,12 @@ public class ExperimentEntity {
     public void setDescription(String description) {
         this.description = description;
     }
+
+    public List<RunConfigurationEntity> getRunConfigs() {
+        return runConfigs;
+    }
+
+    public void setRunConfigs(List<RunConfigurationEntity> runConfigs) {
+        this.runConfigs = runConfigs;
+    }
 }
diff --git 
a/modules/airavata-apis/airavata-apis-server/src/main/java/org/apache/airavata/apis/db/entity/RunConfigurationEntity.java
 
b/modules/airavata-apis/airavata-apis-server/src/main/java/org/apache/airavata/apis/db/entity/RunConfigurationEntity.java
index 58deef412d..b4546b8066 100644
--- 
a/modules/airavata-apis/airavata-apis-server/src/main/java/org/apache/airavata/apis/db/entity/RunConfigurationEntity.java
+++ 
b/modules/airavata-apis/airavata-apis-server/src/main/java/org/apache/airavata/apis/db/entity/RunConfigurationEntity.java
@@ -24,4 +24,52 @@ public class RunConfigurationEntity {
     LocalBackendEntity local;
     ApplicationRunInfoEntity appRunInfo;
     List<DataMovementConfigurationEntity> dataMovementConfigs;
+
+    public String getRunConfigId() {
+        return runConfigId;
+    }
+
+    public void setRunConfigId(String runConfigId) {
+        this.runConfigId = runConfigId;
+    }
+
+    public ServerBackendEntity getServer() {
+        return server;
+    }
+
+    public void setServer(ServerBackendEntity server) {
+        this.server = server;
+    }
+
+    public EC2BackendEntity getEc2() {
+        return ec2;
+    }
+
+    public void setEc2(EC2BackendEntity ec2) {
+        this.ec2 = ec2;
+    }
+
+    public LocalBackendEntity getLocal() {
+        return local;
+    }
+
+    public void setLocal(LocalBackendEntity local) {
+        this.local = local;
+    }
+
+    public ApplicationRunInfoEntity getAppRunInfo() {
+        return appRunInfo;
+    }
+
+    public void setAppRunInfo(ApplicationRunInfoEntity appRunInfo) {
+        this.appRunInfo = appRunInfo;
+    }
+
+    public List<DataMovementConfigurationEntity> getDataMovementConfigs() {
+        return dataMovementConfigs;
+    }
+
+    public void setDataMovementConfigs(List<DataMovementConfigurationEntity> 
dataMovementConfigs) {
+        this.dataMovementConfigs = dataMovementConfigs;
+    }
 }
diff --git 
a/modules/airavata-apis/airavata-apis-server/src/main/java/org/apache/airavata/apis/handlers/ExecutionHandler.java
 
b/modules/airavata-apis/airavata-apis-server/src/main/java/org/apache/airavata/apis/handlers/ExecutionHandler.java
index c267ca6d6a..eb4415d721 100644
--- 
a/modules/airavata-apis/airavata-apis-server/src/main/java/org/apache/airavata/apis/handlers/ExecutionHandler.java
+++ 
b/modules/airavata-apis/airavata-apis-server/src/main/java/org/apache/airavata/apis/handlers/ExecutionHandler.java
@@ -1,18 +1,48 @@
 package org.apache.airavata.apis.handlers;
 
 import io.grpc.stub.StreamObserver;
+import org.apache.airavata.api.execution.stubs.RunConfiguration;
 import org.apache.airavata.api.gateway.*;
+import org.apache.airavata.apis.db.entity.ExperimentEntity;
+import org.apache.airavata.apis.db.entity.RunConfigurationEntity;
+import org.apache.airavata.apis.db.repository.ExperimentRepository;
+import org.apache.airavata.apis.scheduling.MetaScheduler;
 import org.lognet.springboot.grpc.GRpcService;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.ArrayList;
+import java.util.List;
 
 @GRpcService
 public class ExecutionHandler extends 
ExecutionServiceGrpc.ExecutionServiceImplBase {
+
+    @Autowired
+    private MetaScheduler metaScheduler;
+
+    @Autowired
+    ExperimentRepository experimentRepository;
+
     @Override
     public void registerExperiment(ExperimentRegisterRequest request, 
StreamObserver<ExperimentRegisterResponse> responseObserver) {
-        super.registerExperiment(request, responseObserver);
+
+        ExperimentEntity experimentEntity = new ExperimentEntity();
+        
experimentEntity.setExperimentName(request.getExperiment().getExperimentName());
+        
experimentEntity.setDescription(request.getExperiment().getDescription());
+
+        List<RunConfigurationEntity> runConfigs = new ArrayList<>();
+        for(RunConfiguration rc: request.getExperiment().getRunConfigsList()) {
+            RunConfigurationEntity runConfigurationEntity = new 
RunConfigurationEntity();
+            // Fill
+
+        }
+        experimentEntity.setRunConfigs(runConfigs);
+        experimentRepository.save(experimentEntity);
     }
 
     @Override
     public void launchExperiment(ExperimentLaunchRequest request, 
StreamObserver<ExperimentLaunchResponse> responseObserver) {
-        super.launchExperiment(request, responseObserver);
+        metaScheduler.scheduleExperiment(request);
+        
responseObserver.onNext(ExperimentLaunchResponse.newBuilder().setStatus(true).build());
+        responseObserver.onCompleted();
     }
 }
diff --git 
a/modules/airavata-apis/airavata-apis-server/src/main/java/org/apache/airavata/apis/scheduling/MetaScheduler.java
 
b/modules/airavata-apis/airavata-apis-server/src/main/java/org/apache/airavata/apis/scheduling/MetaScheduler.java
new file mode 100644
index 0000000000..72e08e01e5
--- /dev/null
+++ 
b/modules/airavata-apis/airavata-apis-server/src/main/java/org/apache/airavata/apis/scheduling/MetaScheduler.java
@@ -0,0 +1,19 @@
+package org.apache.airavata.apis.scheduling;
+
+import org.apache.airavata.api.gateway.ExperimentLaunchRequest;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+public class MetaScheduler {
+    private final ExecutorService schedulerPool = 
Executors.newFixedThreadPool(10);
+    public void scheduleExperiment(ExperimentLaunchRequest request) {
+        schedulerPool.submit(() -> scheduleAsync(request));
+    }
+
+    private void scheduleAsync(ExperimentLaunchRequest request) {
+        // Persist state in zk or DB
+        // Run meta scheduler logic
+        // Submit to Helix
+    }
+}

Reply via email to