From 9e881978452ce3bec19e67995e7a725d87e11abe Mon Sep 17 00:00:00 2001 From: Fangjin Yang Date: Fri, 1 Feb 2013 14:08:52 -0800 Subject: [PATCH] change endpoints for killing segments --- .../com/metamx/druid/http/InfoResource.java | 18 +++++++++++++++--- .../com/metamx/druid/http/MasterResource.java | 9 --------- .../src/main/resources/static/js/kill-0.0.1.js | 9 ++------- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/server/src/main/java/com/metamx/druid/http/InfoResource.java b/server/src/main/java/com/metamx/druid/http/InfoResource.java index 090e311ad31..e434bff995d 100644 --- a/server/src/main/java/com/metamx/druid/http/InfoResource.java +++ b/server/src/main/java/com/metamx/druid/http/InfoResource.java @@ -33,7 +33,10 @@ import com.metamx.druid.client.ServerInventoryManager; import com.metamx.druid.coordination.DruidClusterInfo; import com.metamx.druid.db.DatabaseRuleManager; import com.metamx.druid.db.DatabaseSegmentManager; +import com.metamx.druid.master.DruidMaster; import com.metamx.druid.master.rules.Rule; +import com.metamx.druid.merge.ClientKillQuery; +import org.joda.time.Interval; import javax.annotation.Nullable; import javax.inject.Inject; @@ -58,6 +61,7 @@ import java.util.TreeSet; @Path("/info") public class InfoResource { + private final DruidMaster master; private final ServerInventoryManager serverInventoryManager; private final DatabaseSegmentManager databaseSegmentManager; private final DatabaseRuleManager databaseRuleManager; @@ -65,12 +69,14 @@ public class InfoResource @Inject public InfoResource( + DruidMaster master, ServerInventoryManager serverInventoryManager, DatabaseSegmentManager databaseSegmentManager, DatabaseRuleManager databaseRuleManager, DruidClusterInfo druidClusterInfo ) { + this.master = master; this.serverInventoryManager = serverInventoryManager; this.databaseSegmentManager = databaseSegmentManager; this.databaseRuleManager = databaseRuleManager; @@ -362,11 +368,17 @@ public class InfoResource @DELETE @Path("/datasources/{dataSourceName}") public Response deleteDataSource( - @PathParam("dataSourceName") final String dataSourceName + @PathParam("dataSourceName") final String dataSourceName, + @QueryParam("kill") final String kill, + @QueryParam("interval") final String interval ) { - if (!databaseSegmentManager.removeDatasource(dataSourceName)) { - return Response.status(Response.Status.NOT_FOUND).build(); + if (kill != null && Boolean.valueOf(kill)) { + master.killSegments(new ClientKillQuery(dataSourceName, new Interval(interval))); + } else { + if (!databaseSegmentManager.removeDatasource(dataSourceName)) { + return Response.status(Response.Status.NOT_FOUND).build(); + } } return Response.status(Response.Status.OK).build(); diff --git a/server/src/main/java/com/metamx/druid/http/MasterResource.java b/server/src/main/java/com/metamx/druid/http/MasterResource.java index c73e74e528c..b725ed7f358 100644 --- a/server/src/main/java/com/metamx/druid/http/MasterResource.java +++ b/server/src/main/java/com/metamx/druid/http/MasterResource.java @@ -111,15 +111,6 @@ public class MasterResource return resp; } - @POST - @Path("/kill") - @Consumes("application/json") - public Response killSegments(ClientKillQuery killQuery) - { - master.killSegments(killQuery); - return Response.ok().build(); - } - @GET @Path("/loadstatus") @Produces("application/json") diff --git a/server/src/main/resources/static/js/kill-0.0.1.js b/server/src/main/resources/static/js/kill-0.0.1.js index 495c6c47f2d..666651128f1 100644 --- a/server/src/main/resources/static/js/kill-0.0.1.js +++ b/server/src/main/resources/static/js/kill-0.0.1.js @@ -20,14 +20,9 @@ $(document).ready(function() { Yes : function() { var selected = $('#datasources option:selected').text(); var interval = $('#interval').val(); - var toSend = { - "dataSource" : selected, - "interval" : interval - } $.ajax({ - type: 'POST', - url:'/master/kill', - data: JSON.stringify(toSend), + type: 'DELETE', + url:'/info/datasources/' + selected +'?kill=true&interval=' + interval, contentType:"application/json; charset=utf-8", dataType:"json", error: function(xhr, status, error) {