From f0698058b4a018e3e3953407d663ee2d7dcdca6c Mon Sep 17 00:00:00 2001 From: "leon.li" Date: Wed, 31 Aug 2016 14:50:16 +0800 Subject: [PATCH] add fetch status api --- .../agent/web/controller/ApiController.java | 18 ++++++++++++++++-- .../platform/slb/agent/web/model/Response.java | 6 +++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/camel-agent/src/main/java/com/dianping/platform/slb/agent/web/controller/ApiController.java b/camel-agent/src/main/java/com/dianping/platform/slb/agent/web/controller/ApiController.java index 46a675f..7e30acf 100644 --- a/camel-agent/src/main/java/com/dianping/platform/slb/agent/web/controller/ApiController.java +++ b/camel-agent/src/main/java/com/dianping/platform/slb/agent/web/controller/ApiController.java @@ -8,6 +8,7 @@ import com.dianping.platform.slb.agent.task.model.SubmitResult; import com.dianping.platform.slb.agent.task.model.config.upgrade.ConfigUpgradeTask; import com.dianping.platform.slb.agent.task.processor.TransactionProcessor; import com.dianping.platform.slb.agent.transaction.Transaction; +import com.dianping.platform.slb.agent.transaction.manager.TransactionManager; import com.dianping.platform.slb.agent.web.api.API; import com.dianping.platform.slb.agent.web.model.Response; import com.dianping.platform.slb.agent.web.wrapper.ResponseAction; @@ -45,6 +46,9 @@ public class ApiController implements API { @Autowired private TransactionProcessor m_transactionProcessor; + @Autowired + private TransactionManager m_transactionManager; + @Override @RequestMapping(params = "op=deploy", method = RequestMethod.POST) public Response deploy( @@ -112,8 +116,18 @@ public class ApiController implements API { } @Override - public Response fetchStatus(long deployId) { - return null; + public Response fetchStatus(final long deployId) { + final Response response = new Response(); + + return m_responseAction.doTransaction(response, "load transaction error", new Wrapper() { + @Override + public Response doAction() throws Exception { + Transaction transaction = m_transactionManager.loadTransaction(deployId); + + response.setStatus(transaction.getStatus().toString().toLowerCase()); + return response; + } + }); } @Override diff --git a/camel-agent/src/main/java/com/dianping/platform/slb/agent/web/model/Response.java b/camel-agent/src/main/java/com/dianping/platform/slb/agent/web/model/Response.java index a2fb74e..38f026f 100644 --- a/camel-agent/src/main/java/com/dianping/platform/slb/agent/web/model/Response.java +++ b/camel-agent/src/main/java/com/dianping/platform/slb/agent/web/model/Response.java @@ -17,7 +17,11 @@ public class Response { } public void setStatus(Status status) { - this.status = status.getMessage(); + setStatus(status.getMessage()); + } + + public void setStatus(String status) { + this.status = status; } public String getMessage() {