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/01/02 04:17:31 UTC
[airavata-mft] branch master updated: Checking agent connectivity
before reading messages
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 ab5a69f Checking agent connectivity before reading messages
ab5a69f is described below
commit ab5a69f22272339cd18715777e8a63850cac23d2
Author: Dimuthu Wannipurage <di...@gmail.com>
AuthorDate: Wed Jan 1 23:17:16 2020 -0500
Checking agent connectivity before reading messages
---
.../java/org/apache/airavata/mft/agent/MFTAgent.java | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
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 e52dd3d..fba770f 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
@@ -106,7 +106,7 @@ public class MFTAgent {
messageCache.start();
}
- public void connectAgent() {
+ private boolean connectAgent() {
ImmutableSession session = ImmutableSession.builder().name(agentId).behavior("delete").ttl(sessionTTLSeconds + "s").build();
SessionCreatedResponse sessResp = client.sessionClient().createSession(session);
String lockPath = "mft/agent/live/" + agentId;
@@ -135,6 +135,7 @@ public class MFTAgent {
}
System.out.println("Lock status " + acquired);
+ return acquired;
}
public void disconnectAgent() {
@@ -145,21 +146,26 @@ public class MFTAgent {
}
public void stop() {
+ System.out.println("Stopping Agent " + agentId);
disconnectAgent();
mainHold.release();
}
- public void start() {
+ public void start() throws Exception {
+ System.out.println("Starting Agent");
init();
- connectAgent();
+ boolean connected = connectAgent();
+ if (!connected) {
+ throw new Exception("Failed to connect to the cluster");
+ }
acceptRequests();
}
- public static void main(String args[]) throws InterruptedException {
+ public static void main(String args[]) throws Exception {
MFTAgent agent = new MFTAgent();
agent.start();
agent.mainHold.acquire();
- System.out.println("Shutting down agent");
+ System.out.println("Agent exited");
}
// TODO load from reflection to avoid dependencies