You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by di...@apache.org on 2020/03/09 07:03:57 UTC
[airavata-mft] branch master updated: Removing all database level
repositories and externalizing consul connection strings
This is an automated email from the ASF dual-hosted git repository.
dimuthuupe pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airavata-mft.git
The following commit(s) were added to refs/heads/master by this push:
new c2dc3b1 Removing all database level repositories and externalizing consul connection strings
c2dc3b1 is described below
commit c2dc3b11108af98c5fedd218c0e017f9342b00b6
Author: Dimuthu Wannipurage <di...@gmail.com>
AuthorDate: Mon Mar 9 03:03:45 2020 -0400
Removing all database level repositories and externalizing consul connection strings
---
.../apache/airavata/mft/admin/MFTConsulClient.java | 32 +++-
.../org/apache/airavata/mft/agent/AppConfig.java | 23 ++-
.../org/apache/airavata/mft/agent/MFTAgent.java | 23 +--
agent/src/main/resources/application.properties | 4 +-
.../distribution/conf/application.properties | 4 +-
api/api-entities/pom.xml | 36 ----
.../mft/api/db/entities/TargetAgentEntity.java | 73 --------
.../mft/api/db/entities/TargetAgentPK.java | 48 -----
.../mft/api/db/entities/TransferEntity.java | 205 ---------------------
.../api/db/entities/TransferExecutionEntity.java | 70 -------
.../mft/api/db/entities/TransferStatusEntity.java | 98 ----------
.../api/db/repositories/TransferRepository.java | 26 ---
.../db/repositories/TransferStatusRepository.java | 33 ----
api/pom.xml | 3 +-
api/service/pom.xml | 5 -
.../org/apache/airavata/mft/api/AppConfig.java | 9 +-
.../src/main/resources/application.properties | 7 +-
.../distribution/conf/application.properties | 7 +-
controller/pom.xml | 19 +-
.../apache/airavata/mft/controller/AppConfig.java | 13 ++
.../airavata/mft/controller/MFTController.java | 17 +-
.../src/main/resources/application.properties | 8 +-
.../distribution/conf/application.properties | 8 +-
23 files changed, 99 insertions(+), 672 deletions(-)
diff --git a/admin/src/main/java/org/apache/airavata/mft/admin/MFTConsulClient.java b/admin/src/main/java/org/apache/airavata/mft/admin/MFTConsulClient.java
index f3f2c14..46a82ee 100644
--- a/admin/src/main/java/org/apache/airavata/mft/admin/MFTConsulClient.java
+++ b/admin/src/main/java/org/apache/airavata/mft/admin/MFTConsulClient.java
@@ -20,9 +20,11 @@ package org.apache.airavata.mft.admin;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.net.HostAndPort;
import com.orbitz.consul.Consul;
import com.orbitz.consul.ConsulException;
import com.orbitz.consul.KeyValueClient;
+import com.orbitz.consul.SessionClient;
import com.orbitz.consul.model.kv.Value;
import org.apache.airavata.mft.admin.models.AgentInfo;
import org.apache.airavata.mft.admin.models.TransferCommand;
@@ -36,6 +38,8 @@ import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
+import static com.google.common.net.HostAndPort.*;
+
/*
mft/agents/messages/{agent-id} -> message
mft/agent/info/{agent-id} -> agent infos
@@ -47,10 +51,26 @@ public class MFTConsulClient {
private static final Logger logger = LoggerFactory.getLogger(MFTConsulClient.class);
- private Consul client = Consul.builder().build();
- private KeyValueClient kvClient = client.keyValueClient();
+ private Consul client;
+ private KeyValueClient kvClient;
+ private SessionClient sessionClient;
private ObjectMapper mapper = new ObjectMapper();
+ public MFTConsulClient(Map<String, Integer> consulHostPorts) {
+ List<HostAndPort> hostAndPorts = consulHostPorts.entrySet().stream()
+ .map(entry -> fromParts(entry.getKey(), entry.getValue()))
+ .collect(Collectors.toList());
+ this.client = Consul.builder().withMultipleHostAndPort(hostAndPorts, 100000).build();
+ this.kvClient = client.keyValueClient();
+ this.sessionClient = client.sessionClient();
+ }
+
+ public MFTConsulClient(String host, int port) {
+ this.client = Consul.builder().withHostAndPort(HostAndPort.fromParts(host, port)).build();
+ this.kvClient = client.keyValueClient();
+ this.sessionClient = client.sessionClient();
+ }
+
public String submitTransfer(TransferRequest transferRequest) throws MFTAdminException{
try {
String asStr = mapper.writeValueAsString(transferRequest);
@@ -178,4 +198,12 @@ public class MFTConsulClient {
List<String> liveAgentIds = getLiveAgentIds();
return liveAgentIds.stream().map(id -> getAgentInfo(id).get()).collect(Collectors.toList());
}
+
+ public KeyValueClient getKvClient() {
+ return kvClient;
+ }
+
+ public SessionClient getSessionClient() {
+ return sessionClient;
+ }
}
diff --git a/api/api-entities/src/main/java/org/apache/airavata/mft/api/db/repositories/TargetAgentRepository.java b/agent/src/main/java/org/apache/airavata/mft/agent/AppConfig.java
similarity index 58%
rename from api/api-entities/src/main/java/org/apache/airavata/mft/api/db/repositories/TargetAgentRepository.java
rename to agent/src/main/java/org/apache/airavata/mft/agent/AppConfig.java
index 4ed3d9d..cb0c5f8 100644
--- a/api/api-entities/src/main/java/org/apache/airavata/mft/api/db/repositories/TargetAgentRepository.java
+++ b/agent/src/main/java/org/apache/airavata/mft/agent/AppConfig.java
@@ -15,12 +15,23 @@
* limitations under the License.
*/
-package org.apache.airavata.mft.api.db.repositories;
+package org.apache.airavata.mft.agent;
-import org.apache.airavata.mft.api.db.entities.TargetAgentEntity;
-import org.springframework.data.repository.CrudRepository;
-import org.springframework.stereotype.Repository;
+import org.apache.airavata.mft.admin.MFTConsulClient;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
-@Repository
-public interface TargetAgentRepository extends CrudRepository<TargetAgentEntity, String> {
+@Configuration
+public class AppConfig {
+
+ @org.springframework.beans.factory.annotation.Value("${consul.host}")
+ String consulHost;
+
+ @org.springframework.beans.factory.annotation.Value("${consul.port}")
+ Integer consulPort;
+
+ @Bean
+ public MFTConsulClient mftConsulClient() {
+ return new MFTConsulClient(consulHost, consulPort);
+ }
}
diff --git a/agent/src/main/java/org/apache/airavata/mft/agent/MFTAgent.java b/agent/src/main/java/org/apache/airavata/mft/agent/MFTAgent.java
index 3c14483..20ebc86 100644
--- a/agent/src/main/java/org/apache/airavata/mft/agent/MFTAgent.java
+++ b/agent/src/main/java/org/apache/airavata/mft/agent/MFTAgent.java
@@ -18,9 +18,7 @@
package org.apache.airavata.mft.agent;
import com.fasterxml.jackson.databind.ObjectMapper;
-import com.orbitz.consul.Consul;
import com.orbitz.consul.ConsulException;
-import com.orbitz.consul.KeyValueClient;
import com.orbitz.consul.cache.ConsulCache;
import com.orbitz.consul.cache.KVCache;
import com.orbitz.consul.model.kv.Value;
@@ -39,6 +37,7 @@ import org.apache.airavata.mft.core.api.MetadataCollector;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -72,8 +71,6 @@ public class MFTAgent implements CommandLineRunner {
private final Semaphore mainHold = new Semaphore(0);
- private Consul client;
- private KeyValueClient kvClient;
private KVCache messageCache;
private ConsulCache.Listener<String, Value> cacheListener;
@@ -83,13 +80,11 @@ public class MFTAgent implements CommandLineRunner {
private ObjectMapper mapper = new ObjectMapper();
+ @Autowired
private MFTConsulClient mftConsulClient;
public void init() {
- client = Consul.builder().build();
- kvClient = client.keyValueClient();
- messageCache = KVCache.newCache(kvClient, "mft/agents/messages/" + agentId );
- mftConsulClient = new MFTConsulClient();
+ messageCache = KVCache.newCache(mftConsulClient.getKvClient(), "mft/agents/messages/" + agentId );
}
private void acceptRequests() {
@@ -155,7 +150,7 @@ public class MFTAgent implements CommandLineRunner {
}
} finally {
logger.info("Deleting key " + value.getKey());
- kvClient.deleteKey(value.getKey()); // Due to bug in consul https://github.com/hashicorp/consul/issues/571
+ mftConsulClient.getKvClient().deleteKey(value.getKey()); // Due to bug in consul https://github.com/hashicorp/consul/issues/571
}
});
@@ -171,15 +166,15 @@ public class MFTAgent implements CommandLineRunner {
.behavior("delete")
.ttl(sessionTTLSeconds + "s").build();
- final SessionCreatedResponse sessResp = client.sessionClient().createSession(session);
+ final SessionCreatedResponse sessResp = mftConsulClient.getSessionClient().createSession(session);
final String lockPath = "mft/agent/live/" + agentId;
- boolean acquired = kvClient.acquireLock(lockPath, sessResp.getId());
+ boolean acquired = mftConsulClient.getKvClient().acquireLock(lockPath, sessResp.getId());
if (acquired) {
sessionRenewPool.scheduleAtFixedRate(() -> {
try {
- client.sessionClient().renewSession(sessResp.getId());
+ mftConsulClient.getSessionClient().renewSession(sessResp.getId());
} catch (ConsulException e) {
if (e.getCode() == 404) {
logger.error("Can not renew session as it is expired");
@@ -187,7 +182,7 @@ public class MFTAgent implements CommandLineRunner {
}
logger.warn("Errored while renewing the session", e);
try {
- boolean status = kvClient.acquireLock(lockPath, sessResp.getId());
+ boolean status = mftConsulClient.getKvClient().acquireLock(lockPath, sessResp.getId());
if (!status) {
logger.error("Can not renew session as it is expired");
stop();
@@ -198,7 +193,7 @@ public class MFTAgent implements CommandLineRunner {
}
} catch (Exception e) {
try {
- boolean status = kvClient.acquireLock(lockPath, sessResp.getId());
+ boolean status = mftConsulClient.getKvClient().acquireLock(lockPath, sessResp.getId());
if (!status) {
logger.error("Can not renew session as it is expired");
stop();
diff --git a/agent/src/main/resources/application.properties b/agent/src/main/resources/application.properties
index 463b513..0f480e9 100644
--- a/agent/src/main/resources/application.properties
+++ b/agent/src/main/resources/application.properties
@@ -19,4 +19,6 @@ spring.main.web-application-type=NONE
agent.id=agent0
agent.host=localhost
agent.user=dimuthu
-agent.supported.protocols=SCP,LOCAL
\ No newline at end of file
+agent.supported.protocols=SCP,LOCAL
+consul.host=localhost
+consul.port=8500
\ No newline at end of file
diff --git a/agent/src/main/resources/distribution/conf/application.properties b/agent/src/main/resources/distribution/conf/application.properties
index 463b513..0f480e9 100644
--- a/agent/src/main/resources/distribution/conf/application.properties
+++ b/agent/src/main/resources/distribution/conf/application.properties
@@ -19,4 +19,6 @@ spring.main.web-application-type=NONE
agent.id=agent0
agent.host=localhost
agent.user=dimuthu
-agent.supported.protocols=SCP,LOCAL
\ No newline at end of file
+agent.supported.protocols=SCP,LOCAL
+consul.host=localhost
+consul.port=8500
\ No newline at end of file
diff --git a/api/api-entities/pom.xml b/api/api-entities/pom.xml
deleted file mode 100644
index b5f9f13..0000000
--- a/api/api-entities/pom.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
-
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
-
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <parent>
- <artifactId>mft-api</artifactId>
- <groupId>org.apache.airavata</groupId>
- <version>0.01-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
-
- <artifactId>mft-api-entities</artifactId>
-
-
-</project>
\ No newline at end of file
diff --git a/api/api-entities/src/main/java/org/apache/airavata/mft/api/db/entities/TargetAgentEntity.java b/api/api-entities/src/main/java/org/apache/airavata/mft/api/db/entities/TargetAgentEntity.java
deleted file mode 100644
index 8c24cf4..0000000
--- a/api/api-entities/src/main/java/org/apache/airavata/mft/api/db/entities/TargetAgentEntity.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.airavata.mft.api.db.entities;
-
-import javax.persistence.*;
-
-@Entity
-@IdClass(TargetAgentPK.class)
-public class TargetAgentEntity {
-
- @Id
- @Column(name = "TRANSFER_ID")
- private String transferId;
-
- @ManyToOne()
- @PrimaryKeyJoinColumn(name="TRANSFER_ID", referencedColumnName="TRANSFER_ID")
- private TransferEntity transfer;
-
- @Id
- @Column(name = "AGENT_ID")
- private String agentId;
-
- @Column(name = "PRIORITY")
- private int priority;
-
- public TransferEntity getTransfer() {
- return transfer;
- }
-
- public void setTransfer(TransferEntity transfer) {
- this.transfer = transfer;
- }
-
- public String getAgentId() {
- return agentId;
- }
-
- public void setAgentId(String agentId) {
- this.agentId = agentId;
- }
-
- public int getPriority() {
- return priority;
- }
-
- public void setPriority(int priority) {
- this.priority = priority;
- }
-
- public String getTransferId() {
- return transferId;
- }
-
- public TargetAgentEntity setTransferId(String transferId) {
- this.transferId = transferId;
- return this;
- }
-}
diff --git a/api/api-entities/src/main/java/org/apache/airavata/mft/api/db/entities/TargetAgentPK.java b/api/api-entities/src/main/java/org/apache/airavata/mft/api/db/entities/TargetAgentPK.java
deleted file mode 100644
index 5d2aeb6..0000000
--- a/api/api-entities/src/main/java/org/apache/airavata/mft/api/db/entities/TargetAgentPK.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.airavata.mft.api.db.entities;
-
-import java.io.Serializable;
-import java.util.Objects;
-
-public class TargetAgentPK implements Serializable {
- private String transferId;
- private String agentId;
-
- public TargetAgentPK() {
- }
-
- public TargetAgentPK(String transferId, String agentId) {
- this.transferId = transferId;
- this.agentId = agentId;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- TargetAgentPK agentId1 = (TargetAgentPK) o;
- if (!transferId.equals(agentId1.transferId)) return false;
- return agentId.equals(agentId1.agentId);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(transferId, agentId);
- }
-}
diff --git a/api/api-entities/src/main/java/org/apache/airavata/mft/api/db/entities/TransferEntity.java b/api/api-entities/src/main/java/org/apache/airavata/mft/api/db/entities/TransferEntity.java
deleted file mode 100644
index 5bcf6fa..0000000
--- a/api/api-entities/src/main/java/org/apache/airavata/mft/api/db/entities/TransferEntity.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.airavata.mft.api.db.entities;
-
-import javax.persistence.*;
-import java.util.Set;
-
-@Entity
-public class TransferEntity {
- @Id
- @Column(name = "TRANSFER_ID")
- private String transferId;
-
- @Column(name = "SOURCE_ID")
- private String sourceId;
-
- @Column(name = "SOURCE_TYPE")
- private String sourceType;
-
- @Column(name = "SOURCE_TOKEN")
- private String sourceToken;
-
- @Column(name = "SOURCE_RESOURCE_BACKEND")
- private String sourceResourceBackend;
-
- @Column(name = "SOURCE_CREDENTIAL_BACKEND")
- private String sourceCredentialBackend;
-
- @Column(name = "DESTINATION_ID")
- private String destinationId;
-
- @Column(name = "DESTINATION_TYPE")
- private String destinationType;
-
- @Column(name = "DESTINATION_TOKEN")
- private String destinationToken;
-
- @Column(name = "DEST_RESOURCE_BACKEND")
- private String destResourceBackend;
-
- @Column(name = "DEST_CREDENTIAL_BACKEND")
- private String destCredentialBackend;
-
- @Column(name = "AFFINITY_TRANSFER")
- private boolean affinityTransfer;
-
- @OneToMany(targetEntity = TargetAgentEntity.class, cascade = CascadeType.ALL, fetch = FetchType.EAGER)
- private Set<TargetAgentEntity> targetAgents;
-
- @OneToMany(targetEntity = TransferExecutionEntity.class, cascade = CascadeType.ALL, fetch = FetchType.EAGER)
- private Set<TransferExecutionEntity> executions;
-
- @OneToMany(targetEntity = TransferStatusEntity.class, cascade = CascadeType.ALL, fetch = FetchType.EAGER)
- private Set<TransferStatusEntity> statuses;
-
- public String getTransferId() {
- return transferId;
- }
-
- public TransferEntity setTransferId(String transferId) {
- this.transferId = transferId;
- return this;
- }
-
- public String getSourceId() {
- return sourceId;
- }
-
- public TransferEntity setSourceId(String sourceId) {
- this.sourceId = sourceId;
- return this;
- }
-
- public String getSourceType() {
- return sourceType;
- }
-
- public TransferEntity setSourceType(String sourceType) {
- this.sourceType = sourceType;
- return this;
- }
-
- public String getSourceToken() {
- return sourceToken;
- }
-
- public TransferEntity setSourceToken(String sourceToken) {
- this.sourceToken = sourceToken;
- return this;
- }
-
- public String getSourceResourceBackend() {
- return sourceResourceBackend;
- }
-
- public TransferEntity setSourceResourceBackend(String sourceResourceBackend) {
- this.sourceResourceBackend = sourceResourceBackend;
- return this;
- }
-
- public String getSourceCredentialBackend() {
- return sourceCredentialBackend;
- }
-
- public TransferEntity setSourceCredentialBackend(String sourceCredentialBackend) {
- this.sourceCredentialBackend = sourceCredentialBackend;
- return this;
- }
-
- public String getDestinationId() {
- return destinationId;
- }
-
- public TransferEntity setDestinationId(String destinationId) {
- this.destinationId = destinationId;
- return this;
- }
-
- public String getDestinationType() {
- return destinationType;
- }
-
- public TransferEntity setDestinationType(String destinationType) {
- this.destinationType = destinationType;
- return this;
- }
-
- public String getDestinationToken() {
- return destinationToken;
- }
-
- public TransferEntity setDestinationToken(String destinationToken) {
- this.destinationToken = destinationToken;
- return this;
- }
-
- public String getDestResourceBackend() {
- return destResourceBackend;
- }
-
- public TransferEntity setDestResourceBackend(String destResourceBackend) {
- this.destResourceBackend = destResourceBackend;
- return this;
- }
-
- public String getDestCredentialBackend() {
- return destCredentialBackend;
- }
-
- public TransferEntity setDestCredentialBackend(String destCredentialBackend) {
- this.destCredentialBackend = destCredentialBackend;
- return this;
- }
-
- public boolean isAffinityTransfer() {
- return affinityTransfer;
- }
-
- public TransferEntity setAffinityTransfer(boolean affinityTransfer) {
- this.affinityTransfer = affinityTransfer;
- return this;
- }
-
- public Set<TargetAgentEntity> getTargetAgents() {
- return targetAgents;
- }
-
- public TransferEntity setTargetAgents(Set<TargetAgentEntity> targetAgents) {
- this.targetAgents = targetAgents;
- return this;
- }
-
- public Set<TransferExecutionEntity> getExecutions() {
- return executions;
- }
-
- public TransferEntity setExecutions(Set<TransferExecutionEntity> executions) {
- this.executions = executions;
- return this;
- }
-
- public Set<TransferStatusEntity> getStatuses() {
- return statuses;
- }
-
- public TransferEntity setStatuses(Set<TransferStatusEntity> statuses) {
- this.statuses = statuses;
- return this;
- }
-}
diff --git a/api/api-entities/src/main/java/org/apache/airavata/mft/api/db/entities/TransferExecutionEntity.java b/api/api-entities/src/main/java/org/apache/airavata/mft/api/db/entities/TransferExecutionEntity.java
deleted file mode 100644
index 4f79b38..0000000
--- a/api/api-entities/src/main/java/org/apache/airavata/mft/api/db/entities/TransferExecutionEntity.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.airavata.mft.api.db.entities;
-
-import javax.persistence.*;
-
-@Entity
-public class TransferExecutionEntity {
- @Id
- @Column(name = "ID")
- @GeneratedValue
- private int id;
-
- @ManyToOne()
- @JoinColumn(name = "TRANSFER_ID", referencedColumnName = "TRANSFER_ID")
- private TransferEntity transfer;
-
- @Column(name = "EXECUTING_AGENT")
- private String executingAgent;
-
- @Column(name = "TIME_OF_CHANGE")
- private long timeOfChange;
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public TransferEntity getTransfer() {
- return transfer;
- }
-
- public void setTransfer(TransferEntity transfer) {
- this.transfer = transfer;
- }
-
- public String getExecutingAgent() {
- return executingAgent;
- }
-
- public void setExecutingAgent(String executingAgent) {
- this.executingAgent = executingAgent;
- }
-
- public long getTimeOfChange() {
- return timeOfChange;
- }
-
- public void setTimeOfChange(long timeOfChange) {
- this.timeOfChange = timeOfChange;
- }
-}
diff --git a/api/api-entities/src/main/java/org/apache/airavata/mft/api/db/entities/TransferStatusEntity.java b/api/api-entities/src/main/java/org/apache/airavata/mft/api/db/entities/TransferStatusEntity.java
deleted file mode 100644
index e8ee8b7..0000000
--- a/api/api-entities/src/main/java/org/apache/airavata/mft/api/db/entities/TransferStatusEntity.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.airavata.mft.api.db.entities;
-
-import javax.persistence.*;
-
-@Entity
-public class TransferStatusEntity {
- @Id
- @Column(name = "ID")
- @GeneratedValue
- private int id;
-
- @ManyToOne()
- @JoinColumn(name = "TRANSFER_ID", referencedColumnName = "TRANSFER_ID")
- private TransferEntity transfer;
-
- @Column(name = "STATE")
- private String state;
-
- @Column(name = "UPDATE_TIME")
- private long updateTimeMils;
-
- @Column(name = "PERCENTAGE")
- private double percentage;
-
- @Column(name = "DESCRIPTION", columnDefinition = "varchar(2048) default ''")
- private String description;
-
- public int getId() {
- return id;
- }
-
- public TransferStatusEntity setId(int id) {
- this.id = id;
- return this;
- }
-
- public TransferEntity getTransfer() {
- return transfer;
- }
-
- public TransferStatusEntity setTransfer(TransferEntity transfer) {
- this.transfer = transfer;
- return this;
- }
-
- public String getState() {
- return state;
- }
-
- public TransferStatusEntity setState(String state) {
- this.state = state;
- return this;
- }
-
- public long getUpdateTimeMils() {
- return updateTimeMils;
- }
-
- public TransferStatusEntity setUpdateTimeMils(long updateTimeMils) {
- this.updateTimeMils = updateTimeMils;
- return this;
- }
-
- public double getPercentage() {
- return percentage;
- }
-
- public TransferStatusEntity setPercentage(double percentage) {
- this.percentage = percentage;
- return this;
- }
-
- public String getDescription() {
- return description;
- }
-
- public TransferStatusEntity setDescription(String description) {
- this.description = description;
- return this;
- }
-}
diff --git a/api/api-entities/src/main/java/org/apache/airavata/mft/api/db/repositories/TransferRepository.java b/api/api-entities/src/main/java/org/apache/airavata/mft/api/db/repositories/TransferRepository.java
deleted file mode 100644
index e21d943..0000000
--- a/api/api-entities/src/main/java/org/apache/airavata/mft/api/db/repositories/TransferRepository.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.airavata.mft.api.db.repositories;
-
-import org.apache.airavata.mft.api.db.entities.TransferEntity;
-import org.springframework.data.repository.CrudRepository;
-import org.springframework.stereotype.Repository;
-
-@Repository
-public interface TransferRepository extends CrudRepository<TransferEntity, String> {
-}
diff --git a/api/api-entities/src/main/java/org/apache/airavata/mft/api/db/repositories/TransferStatusRepository.java b/api/api-entities/src/main/java/org/apache/airavata/mft/api/db/repositories/TransferStatusRepository.java
deleted file mode 100644
index f801e0c..0000000
--- a/api/api-entities/src/main/java/org/apache/airavata/mft/api/db/repositories/TransferStatusRepository.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.airavata.mft.api.db.repositories;
-
-import org.apache.airavata.mft.api.db.entities.TransferStatusEntity;
-import org.springframework.data.jpa.repository.Query;
-import org.springframework.data.repository.CrudRepository;
-import org.springframework.stereotype.Repository;
-
-import java.util.List;
-import java.util.Optional;
-
-@Repository
-public interface TransferStatusRepository extends CrudRepository<TransferStatusEntity, Integer> {
-
- @Query("SELECT ts from TransferStatusEntity ts WHERE ts.transfer.transferId = ?1 ORDER BY ts.updateTimeMils DESC")
- public List<TransferStatusEntity> getByTransferId(String transferId);
-}
diff --git a/api/pom.xml b/api/pom.xml
index f7eb249..88a6bd4 100644
--- a/api/pom.xml
+++ b/api/pom.xml
@@ -36,7 +36,6 @@
<module>stub</module>
<module>service</module>
<module>client</module>
- <module>api-entities</module>
</modules>
<dependencies>
@@ -58,7 +57,7 @@
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-data-jpa</artifactId>
+ <artifactId>spring-boot-starter</artifactId>
<version>${spring.boot.data.jpa}</version>
</dependency>
<dependency>
diff --git a/api/service/pom.xml b/api/service/pom.xml
index 1c8f5d6..d145462 100644
--- a/api/service/pom.xml
+++ b/api/service/pom.xml
@@ -52,11 +52,6 @@
</dependency>
<dependency>
<groupId>org.apache.airavata</groupId>
- <artifactId>mft-api-entities</artifactId>
- <version>0.01-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.apache.airavata</groupId>
<artifactId>mft-admin</artifactId>
<version>0.01-SNAPSHOT</version>
</dependency>
diff --git a/api/service/src/main/java/org/apache/airavata/mft/api/AppConfig.java b/api/service/src/main/java/org/apache/airavata/mft/api/AppConfig.java
index f10c3a7..1d0e3e3 100644
--- a/api/service/src/main/java/org/apache/airavata/mft/api/AppConfig.java
+++ b/api/service/src/main/java/org/apache/airavata/mft/api/AppConfig.java
@@ -27,9 +27,16 @@ import org.springframework.context.annotation.Configuration;
@Configuration
public class AppConfig {
+
+ @org.springframework.beans.factory.annotation.Value("${consul.host}")
+ String consulHost;
+
+ @org.springframework.beans.factory.annotation.Value("${consul.port}")
+ Integer consulPort;
+
@Bean
public MFTConsulClient mftConsulClient() {
- return new MFTConsulClient();
+ return new MFTConsulClient(consulHost, consulPort);
}
@Bean
diff --git a/api/service/src/main/resources/application.properties b/api/service/src/main/resources/application.properties
index cea44d3..2348a32 100644
--- a/api/service/src/main/resources/application.properties
+++ b/api/service/src/main/resources/application.properties
@@ -17,8 +17,5 @@
server.port=8088
grpc.port=7004
-spring.datasource.url=jdbc:mariadb://localhost:3306/controllerdb
-spring.datasource.username=root
-spring.datasource.password=root
-spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
-spring.jpa.hibernate.ddl-auto=create-drop
\ No newline at end of file
+consul.host=localhost
+consul.port=8500
\ No newline at end of file
diff --git a/api/service/src/main/resources/distribution/conf/application.properties b/api/service/src/main/resources/distribution/conf/application.properties
index cea44d3..2348a32 100644
--- a/api/service/src/main/resources/distribution/conf/application.properties
+++ b/api/service/src/main/resources/distribution/conf/application.properties
@@ -17,8 +17,5 @@
server.port=8088
grpc.port=7004
-spring.datasource.url=jdbc:mariadb://localhost:3306/controllerdb
-spring.datasource.username=root
-spring.datasource.password=root
-spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
-spring.jpa.hibernate.ddl-auto=create-drop
\ No newline at end of file
+consul.host=localhost
+consul.port=8500
\ No newline at end of file
diff --git a/controller/pom.xml b/controller/pom.xml
index 77cb5ae..e588470 100644
--- a/controller/pom.xml
+++ b/controller/pom.xml
@@ -39,11 +39,6 @@
<version>0.01-SNAPSHOT</version>
</dependency>
<dependency>
- <groupId>org.apache.airavata</groupId>
- <artifactId>mft-api-entities</artifactId>
- <version>0.01-SNAPSHOT</version>
- </dependency>
- <dependency>
<groupId>com.orbitz.consul</groupId>
<artifactId>consul-client</artifactId>
<version>${consul.client}</version>
@@ -66,22 +61,10 @@
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-data-jpa</artifactId>
+ <artifactId>spring-boot-starter</artifactId>
<version>${spring.boot.data.jpa}</version>
</dependency>
<dependency>
- <groupId>com.h2database</groupId>
- <artifactId>h2</artifactId>
- <version>${h2}</version>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>org.mariadb.jdbc</groupId>
- <artifactId>mariadb-java-client</artifactId>
- <version>${mariadb.jdbc}</version>
- <scope>runtime</scope>
- </dependency>
- <dependency>
<groupId>net.sf.dozer</groupId>
<artifactId>dozer</artifactId>
<version>${dozer}</version>
diff --git a/controller/src/main/java/org/apache/airavata/mft/controller/AppConfig.java b/controller/src/main/java/org/apache/airavata/mft/controller/AppConfig.java
index c9fdbd0..203b50b 100644
--- a/controller/src/main/java/org/apache/airavata/mft/controller/AppConfig.java
+++ b/controller/src/main/java/org/apache/airavata/mft/controller/AppConfig.java
@@ -17,8 +17,21 @@
package org.apache.airavata.mft.controller;
+import org.apache.airavata.mft.admin.MFTConsulClient;
+import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class AppConfig {
+
+ @org.springframework.beans.factory.annotation.Value("${consul.host}")
+ String consulHost;
+
+ @org.springframework.beans.factory.annotation.Value("${consul.port}")
+ Integer consulPort;
+
+ @Bean
+ public MFTConsulClient mftConsulClient() {
+ return new MFTConsulClient(consulHost, consulPort);
+ }
}
diff --git a/controller/src/main/java/org/apache/airavata/mft/controller/MFTController.java b/controller/src/main/java/org/apache/airavata/mft/controller/MFTController.java
index 6a1532d..af24221 100644
--- a/controller/src/main/java/org/apache/airavata/mft/controller/MFTController.java
+++ b/controller/src/main/java/org/apache/airavata/mft/controller/MFTController.java
@@ -31,13 +31,13 @@ import org.apache.airavata.mft.admin.models.TransferRequest;
import org.dozer.DozerBeanMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.PropertySource;
-import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import java.util.List;
import java.util.Optional;
@@ -46,7 +46,6 @@ import java.util.concurrent.Semaphore;
@PropertySource("classpath:application.properties")
@SpringBootApplication()
@ComponentScan(basePackages = {"org.apache.airavata.mft"})
-@EnableJpaRepositories("org.apache.airavata.mft.api.db.repositories")
@EntityScan("org.apache.airavata.mft.api.db.entities")
public class MFTController implements CommandLineRunner {
@@ -54,13 +53,12 @@ public class MFTController implements CommandLineRunner {
private final Semaphore mainHold = new Semaphore(0);
- private Consul client;
- private KeyValueClient kvClient;
private KVCache messageCache;
private KVCache stateCache;
private ConsulCache.Listener<String, Value> messageCacheListener;
private ConsulCache.Listener<String, Value> stateCacheListener;
+ @Autowired
private MFTConsulClient mftConsulClient;
private ObjectMapper jsonMapper = new ObjectMapper();
@@ -68,11 +66,8 @@ public class MFTController implements CommandLineRunner {
public void init() {
- client = Consul.builder().build();
- kvClient = client.keyValueClient();
- messageCache = KVCache.newCache(kvClient, "mft/controller/messages");
- stateCache = KVCache.newCache(kvClient, "mft/transfer/state");
- mftConsulClient = new MFTConsulClient();
+ messageCache = KVCache.newCache(mftConsulClient.getKvClient(), "mft/controller/messages");
+ stateCache = KVCache.newCache(mftConsulClient.getKvClient(), "mft/transfer/state");
}
private void acceptRequests() {
@@ -91,7 +86,7 @@ public class MFTController implements CommandLineRunner {
logger.error("Failed to process the request", e);
} finally {
logger.info("Deleting key " + value.getKey());
- kvClient.deleteKey(value.getKey()); // Due to bug in consul https://github.com/hashicorp/consul/issues/571
+ mftConsulClient.getKvClient().deleteKey(value.getKey()); // Due to bug in consul https://github.com/hashicorp/consul/issues/571
}
});
});
@@ -123,7 +118,7 @@ public class MFTController implements CommandLineRunner {
private TransferCommand saveAndCreateTransferCommand(String transferId, TransferRequest transferRequest) throws JsonProcessingException {
- kvClient.putValue("mft/transfer/processed/" +transferId, jsonMapper.writeValueAsString(transferRequest));
+ mftConsulClient.getKvClient().putValue("mft/transfer/processed/" +transferId, jsonMapper.writeValueAsString(transferRequest));
TransferCommand transferCommand = new TransferCommand();
transferCommand.setSourceId(transferRequest.getSourceId())
diff --git a/controller/src/main/resources/application.properties b/controller/src/main/resources/application.properties
index 101a8fe..8ad1c58 100644
--- a/controller/src/main/resources/application.properties
+++ b/controller/src/main/resources/application.properties
@@ -14,9 +14,5 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-
-spring.datasource.url=jdbc:mariadb://localhost:3306/controllerdb
-spring.datasource.username=root
-spring.datasource.password=root
-spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
-spring.jpa.hibernate.ddl-auto=create-drop
\ No newline at end of file
+consul.host=localhost
+consul.port=8500
\ No newline at end of file
diff --git a/controller/src/main/resources/distribution/conf/application.properties b/controller/src/main/resources/distribution/conf/application.properties
index 101a8fe..8ad1c58 100644
--- a/controller/src/main/resources/distribution/conf/application.properties
+++ b/controller/src/main/resources/distribution/conf/application.properties
@@ -14,9 +14,5 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-
-spring.datasource.url=jdbc:mariadb://localhost:3306/controllerdb
-spring.datasource.username=root
-spring.datasource.password=root
-spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
-spring.jpa.hibernate.ddl-auto=create-drop
\ No newline at end of file
+consul.host=localhost
+consul.port=8500
\ No newline at end of file