Skip to content

Commit 8dc1857

Browse files
committed
delete & create agent
1 parent f8b0a90 commit 8dc1857

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

platform-api/src/main/java/com/flow/platform/api/service/AgentServiceImpl.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,7 @@ public void delete(AgentPath agentPath){
177177
HttpClient.build(platformURL.getAgentDeleteUrl())
178178
.post(agent.toJson())
179179
.withContentType(ContentType.APPLICATION_JSON)
180-
.retry(httpRetryTimes)
181-
.bodyAsString().getBody();
180+
.retry(httpRetryTimes);
182181

183182
} catch (UnsupportedEncodingException e) {
184183
throw new IllegalStatusException(e.getMessage());
@@ -194,15 +193,17 @@ private String buildAgentWebhook() {
194193
*/
195194
private Agent findAgent(AgentPath agentPath){
196195
String url = platformURL.getAgentFindUrl() + "?" + "zone=" + agentPath.getZone() + "&" + "name=" + agentPath.getName();
197-
String res = HttpClient.build(url)
196+
HttpResponse<String> response = HttpClient.build(url)
198197
.get()
199198
.retry(httpRetryTimes)
200-
.bodyAsString().getBody();
199+
.bodyAsString();
201200

202-
if (Strings.isNullOrEmpty(res)) {
201+
if (!response.hasSuccess()) {
203202
throw new HttpException("Unable to delete agent");
204203
}
205-
Agent agent = Agent.parse(res, Agent.class);
204+
205+
Agent agent = Agent.parse(response.getBody(), Agent.class);
206+
206207
if (agent.getStatus() == AgentStatus.BUSY){
207208
throw new IllegalStatusException("agent is busy, please wait");
208209
}

platform-control-center/src/main/java/com/flow/platform/cc/service/AgentServiceImpl.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import com.flow.platform.util.Logger;
3636
import com.google.common.base.Strings;
3737
import com.google.gson.annotations.Expose;
38+
import java.sql.SQLDataException;
3839
import java.time.ZonedDateTime;
3940
import java.time.temporal.ChronoUnit;
4041
import java.util.Collection;
@@ -227,6 +228,11 @@ public AgentSettings settings(String token) {
227228

228229
@Override
229230
public void delete(Agent agent){
230-
agentDao.delete(agent);
231+
try {
232+
agentDao.delete(agent);
233+
} catch (Throwable e){
234+
throw new UnsupportedOperationException("delete agent failure " + e.getMessage());
235+
}
236+
231237
}
232238
}

0 commit comments

Comments
 (0)