Merge pull request #946 from metamx/MoreMediaTypes

Changed all "application/json" to MediaType.APPLICATION_JSON  except for in druid.js
This commit is contained in:
Fangjin Yang 2014-12-08 15:24:21 -07:00
commit 623443a145
18 changed files with 81 additions and 63 deletions

View File

@ -36,6 +36,7 @@ import io.druid.indexing.common.task.Task;
import org.jboss.netty.channel.ChannelException; import org.jboss.netty.channel.ChannelException;
import org.joda.time.Duration; import org.joda.time.Duration;
import javax.ws.rs.core.MediaType;
import java.io.IOException; import java.io.IOException;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
@ -94,7 +95,7 @@ public class RemoteTaskActionClient implements TaskActionClient
try { try {
response = httpClient.post(serviceUri.toURL()) response = httpClient.post(serviceUri.toURL())
.setContent("application/json", dataToSend) .setContent(MediaType.APPLICATION_JSON, dataToSend)
.go(new StatusResponseHandler(Charsets.UTF_8)) .go(new StatusResponseHandler(Charsets.UTF_8))
.get(); .get();
} }

View File

@ -58,6 +58,7 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam; import javax.ws.rs.PathParam;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam; import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -100,8 +101,8 @@ public class OverlordResource
@POST @POST
@Path("/task") @Path("/task")
@Consumes("application/json") @Consumes(MediaType.APPLICATION_JSON)
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public Response taskPost(final Task task) public Response taskPost(final Task task)
{ {
return asLeaderWith( return asLeaderWith(
@ -127,7 +128,7 @@ public class OverlordResource
@GET @GET
@Path("/task/{taskid}") @Path("/task/{taskid}")
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public Response getTaskPayload(@PathParam("taskid") String taskid) public Response getTaskPayload(@PathParam("taskid") String taskid)
{ {
return optionalTaskResponse(taskid, "payload", taskStorageQueryAdapter.getTask(taskid)); return optionalTaskResponse(taskid, "payload", taskStorageQueryAdapter.getTask(taskid));
@ -135,7 +136,7 @@ public class OverlordResource
@GET @GET
@Path("/task/{taskid}/status") @Path("/task/{taskid}/status")
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public Response getTaskStatus(@PathParam("taskid") String taskid) public Response getTaskStatus(@PathParam("taskid") String taskid)
{ {
return optionalTaskResponse(taskid, "status", taskStorageQueryAdapter.getStatus(taskid)); return optionalTaskResponse(taskid, "status", taskStorageQueryAdapter.getStatus(taskid));
@ -143,7 +144,7 @@ public class OverlordResource
@GET @GET
@Path("/task/{taskid}/segments") @Path("/task/{taskid}/segments")
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public Response getTaskSegments(@PathParam("taskid") String taskid) public Response getTaskSegments(@PathParam("taskid") String taskid)
{ {
final Set<DataSegment> segments = taskStorageQueryAdapter.getInsertedSegments(taskid); final Set<DataSegment> segments = taskStorageQueryAdapter.getInsertedSegments(taskid);
@ -152,7 +153,7 @@ public class OverlordResource
@POST @POST
@Path("/task/{taskid}/shutdown") @Path("/task/{taskid}/shutdown")
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public Response doShutdown(@PathParam("taskid") final String taskid) public Response doShutdown(@PathParam("taskid") final String taskid)
{ {
return asLeaderWith( return asLeaderWith(
@ -171,7 +172,7 @@ public class OverlordResource
@GET @GET
@Path("/worker") @Path("/worker")
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public Response getWorkerConfig() public Response getWorkerConfig()
{ {
if (workerConfigRef == null) { if (workerConfigRef == null) {
@ -183,7 +184,7 @@ public class OverlordResource
@POST @POST
@Path("/worker") @Path("/worker")
@Consumes("application/json") @Consumes(MediaType.APPLICATION_JSON)
public Response setWorkerConfig( public Response setWorkerConfig(
final WorkerBehaviorConfig workerBehaviorConfig final WorkerBehaviorConfig workerBehaviorConfig
) )
@ -201,7 +202,7 @@ public class OverlordResource
@Deprecated @Deprecated
@GET @GET
@Path("/worker/setup") @Path("/worker/setup")
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public Response getWorkerSetupData() public Response getWorkerSetupData()
{ {
if (workerSetupDataRef == null) { if (workerSetupDataRef == null) {
@ -214,7 +215,7 @@ public class OverlordResource
@Deprecated @Deprecated
@POST @POST
@Path("/worker/setup") @Path("/worker/setup")
@Consumes("application/json") @Consumes(MediaType.APPLICATION_JSON)
public Response setWorkerSetupData( public Response setWorkerSetupData(
final WorkerSetupData workerSetupData final WorkerSetupData workerSetupData
) )
@ -230,7 +231,7 @@ public class OverlordResource
@POST @POST
@Path("/action") @Path("/action")
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public <T> Response doAction(final TaskActionHolder<T> holder) public <T> Response doAction(final TaskActionHolder<T> holder)
{ {
return asLeaderWith( return asLeaderWith(
@ -264,7 +265,7 @@ public class OverlordResource
@GET @GET
@Path("/waitingTasks") @Path("/waitingTasks")
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public Response getWaitingTasks() public Response getWaitingTasks()
{ {
return workItemsResponse( return workItemsResponse(
@ -311,7 +312,7 @@ public class OverlordResource
@GET @GET
@Path("/pendingTasks") @Path("/pendingTasks")
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public Response getPendingTasks() public Response getPendingTasks()
{ {
return workItemsResponse( return workItemsResponse(
@ -328,7 +329,7 @@ public class OverlordResource
@GET @GET
@Path("/runningTasks") @Path("/runningTasks")
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public Response getRunningTasks() public Response getRunningTasks()
{ {
return workItemsResponse( return workItemsResponse(
@ -345,7 +346,7 @@ public class OverlordResource
@GET @GET
@Path("/completeTasks") @Path("/completeTasks")
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public Response getCompleteTasks() public Response getCompleteTasks()
{ {
final List<TaskResponseObject> completeTasks = Lists.transform( final List<TaskResponseObject> completeTasks = Lists.transform(
@ -370,7 +371,7 @@ public class OverlordResource
@GET @GET
@Path("/workers") @Path("/workers")
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public Response getWorkers() public Response getWorkers()
{ {
return asLeaderWith( return asLeaderWith(
@ -388,7 +389,7 @@ public class OverlordResource
@GET @GET
@Path("/scaling") @Path("/scaling")
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public Response getScalingState() public Response getScalingState()
{ {
// Don't use asLeaderWith, since we want to return 200 instead of 503 when missing an autoscaler. // Don't use asLeaderWith, since we want to return 200 instead of 503 when missing an autoscaler.

View File

@ -39,6 +39,7 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam; import javax.ws.rs.PathParam;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam; import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.io.InputStream; import java.io.InputStream;
@ -72,7 +73,7 @@ public class WorkerResource
@POST @POST
@Path("/disable") @Path("/disable")
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public Response doDisable() public Response doDisable()
{ {
try { try {
@ -86,7 +87,7 @@ public class WorkerResource
@POST @POST
@Path("/enable") @Path("/enable")
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public Response doEnable() public Response doEnable()
{ {
try { try {
@ -100,7 +101,7 @@ public class WorkerResource
@GET @GET
@Path("/enabled") @Path("/enabled")
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public Response isEnabled() public Response isEnabled()
{ {
try { try {
@ -115,7 +116,7 @@ public class WorkerResource
@GET @GET
@Path("/tasks") @Path("/tasks")
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public Response getTasks() public Response getTasks()
{ {
try { try {
@ -142,7 +143,7 @@ public class WorkerResource
@POST @POST
@Path("/task/{taskid}/shutdown") @Path("/task/{taskid}/shutdown")
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public Response doShutdown(@PathParam("taskid") String taskid) public Response doShutdown(@PathParam("taskid") String taskid)
{ {
try { try {

View File

@ -32,6 +32,7 @@ import io.druid.guice.annotations.Global;
import io.druid.timeline.DataSegment; import io.druid.timeline.DataSegment;
import org.joda.time.Interval; import org.joda.time.Interval;
import javax.ws.rs.core.MediaType;
import java.io.InputStream; import java.io.InputStream;
import java.net.URL; import java.net.URL;
import java.util.Iterator; import java.util.Iterator;
@ -94,7 +95,7 @@ public class IndexingServiceClient
{ {
try { try {
return client.post(new URL(String.format("%s/task", baseUrl()))) return client.post(new URL(String.format("%s/task", baseUrl())))
.setContent("application/json", jsonMapper.writeValueAsBytes(queryObject)) .setContent(MediaType.APPLICATION_JSON, jsonMapper.writeValueAsBytes(queryObject))
.go(RESPONSE_HANDLER) .go(RESPONSE_HANDLER)
.get(); .get();
} }

View File

@ -38,6 +38,7 @@ import io.druid.data.input.impl.MapInputRowParser;
import javax.ws.rs.POST; import javax.ws.rs.POST;
import javax.ws.rs.Path; import javax.ws.rs.Path;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.io.IOException; import java.io.IOException;
import java.util.Collection; import java.util.Collection;
@ -125,7 +126,7 @@ public class EventReceiverFirehoseFactory implements FirehoseFactory<MapInputRow
@POST @POST
@Path("/push-events") @Path("/push-events")
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public Response addAll(Collection<Map<String, Object>> events) public Response addAll(Collection<Map<String, Object>> events)
{ {
log.debug("Adding %,d events to firehose: %s", events.size(), serviceName); log.debug("Adding %,d events to firehose: %s", events.size(), serviceName);

View File

@ -36,6 +36,7 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam; import javax.ws.rs.PathParam;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam; import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -73,7 +74,7 @@ public class ClientInfoResource
} }
@GET @GET
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public Iterable<String> getDataSources() public Iterable<String> getDataSources()
{ {
return getSegmentsForDatasources().keySet(); return getSegmentsForDatasources().keySet();
@ -81,7 +82,7 @@ public class ClientInfoResource
@GET @GET
@Path("/{dataSourceName}") @Path("/{dataSourceName}")
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public Map<String, Object> getDatasource( public Map<String, Object> getDatasource(
@PathParam("dataSourceName") String dataSourceName, @PathParam("dataSourceName") String dataSourceName,
@QueryParam("interval") String interval @QueryParam("interval") String interval
@ -95,7 +96,7 @@ public class ClientInfoResource
@GET @GET
@Path("/{dataSourceName}/dimensions") @Path("/{dataSourceName}/dimensions")
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public Iterable<String> getDatasourceDimensions( public Iterable<String> getDatasourceDimensions(
@PathParam("dataSourceName") String dataSourceName, @PathParam("dataSourceName") String dataSourceName,
@QueryParam("interval") String interval @QueryParam("interval") String interval
@ -127,7 +128,7 @@ public class ClientInfoResource
@GET @GET
@Path("/{dataSourceName}/metrics") @Path("/{dataSourceName}/metrics")
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public Iterable<String> getDatasourceMetrics( public Iterable<String> getDatasourceMetrics(
@PathParam("dataSourceName") String dataSourceName, @PathParam("dataSourceName") String dataSourceName,
@QueryParam("interval") String interval @QueryParam("interval") String interval

View File

@ -27,6 +27,7 @@ import io.druid.initialization.Initialization;
import javax.ws.rs.GET; import javax.ws.rs.GET;
import javax.ws.rs.Path; import javax.ws.rs.Path;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
@ -37,7 +38,7 @@ import java.util.List;
public class StatusResource public class StatusResource
{ {
@GET @GET
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public Status doGet() public Status doGet()
{ {
return new Status(Initialization.getLoadedModules(DruidModule.class)); return new Status(Initialization.getLoadedModules(DruidModule.class));

View File

@ -38,6 +38,7 @@ import io.druid.query.QuerySegmentWalker;
import io.druid.query.SegmentDescriptor; import io.druid.query.SegmentDescriptor;
import org.joda.time.Interval; import org.joda.time.Interval;
import javax.ws.rs.core.MediaType;
import java.net.URL; import java.net.URL;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -102,7 +103,7 @@ public class BridgeQuerySegmentWalker implements QuerySegmentWalker
StatusResponseHolder response = httpClient.post(new URL(url)) StatusResponseHolder response = httpClient.post(new URL(url))
.setContent( .setContent(
"application/json", MediaType.APPLICATION_JSON,
jsonMapper.writeValueAsBytes(query) jsonMapper.writeValueAsBytes(query)
) )
.go(responseHandler) .go(responseHandler)

View File

@ -28,6 +28,7 @@ import javax.ws.rs.GET;
import javax.ws.rs.POST; import javax.ws.rs.POST;
import javax.ws.rs.Path; import javax.ws.rs.Path;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
/** /**
@ -46,7 +47,7 @@ public class CoordinatorDynamicConfigsResource
} }
@GET @GET
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public Response getDynamicConfigs() public Response getDynamicConfigs()
{ {
return Response.ok( return Response.ok(
@ -58,7 +59,7 @@ public class CoordinatorDynamicConfigsResource
} }
@POST @POST
@Consumes("application/json") @Consumes(MediaType.APPLICATION_JSON)
public Response setDynamicConfigs(final CoordinatorDynamicConfig dynamicConfig) public Response setDynamicConfigs(final CoordinatorDynamicConfig dynamicConfig)
{ {
if (!manager.set(CoordinatorDynamicConfig.CONFIG_KEY, dynamicConfig)) { if (!manager.set(CoordinatorDynamicConfig.CONFIG_KEY, dynamicConfig)) {

View File

@ -32,6 +32,7 @@ import javax.ws.rs.GET;
import javax.ws.rs.Path; import javax.ws.rs.Path;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam; import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
/** /**
@ -51,7 +52,7 @@ public class CoordinatorResource
@GET @GET
@Path("/leader") @Path("/leader")
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public Response getLeader() public Response getLeader()
{ {
return Response.ok(coordinator.getCurrentLeader()).build(); return Response.ok(coordinator.getCurrentLeader()).build();
@ -59,7 +60,7 @@ public class CoordinatorResource
@GET @GET
@Path("/loadstatus") @Path("/loadstatus")
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public Response getLoadStatus( public Response getLoadStatus(
@QueryParam("simple") String simple, @QueryParam("simple") String simple,
@QueryParam("full") String full @QueryParam("full") String full
@ -77,7 +78,7 @@ public class CoordinatorResource
@GET @GET
@Path("/loadqueue") @Path("/loadqueue")
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public Response getLoadQueue( public Response getLoadQueue(
@QueryParam("simple") String simple, @QueryParam("simple") String simple,
@QueryParam("full") String full @QueryParam("full") String full

View File

@ -47,6 +47,7 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam; import javax.ws.rs.PathParam;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam; import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
@ -76,7 +77,7 @@ public class DatasourcesResource
} }
@GET @GET
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public Response getQueryableDataSources( public Response getQueryableDataSources(
@QueryParam("full") String full, @QueryParam("full") String full,
@QueryParam("simple") String simple @QueryParam("simple") String simple
@ -122,7 +123,7 @@ public class DatasourcesResource
@GET @GET
@Path("/{dataSourceName}") @Path("/{dataSourceName}")
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public Response getTheDataSource( public Response getTheDataSource(
@PathParam("dataSourceName") final String dataSourceName, @PathParam("dataSourceName") final String dataSourceName,
@QueryParam("full") final String full @QueryParam("full") final String full
@ -142,7 +143,7 @@ public class DatasourcesResource
@POST @POST
@Path("/{dataSourceName}") @Path("/{dataSourceName}")
@Consumes("application/json") @Consumes(MediaType.APPLICATION_JSON)
public Response enableDataSource( public Response enableDataSource(
@PathParam("dataSourceName") final String dataSourceName @PathParam("dataSourceName") final String dataSourceName
) )
@ -156,7 +157,7 @@ public class DatasourcesResource
@DELETE @DELETE
@Path("/{dataSourceName}") @Path("/{dataSourceName}")
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public Response deleteDataSource( public Response deleteDataSource(
@PathParam("dataSourceName") final String dataSourceName, @PathParam("dataSourceName") final String dataSourceName,
@QueryParam("kill") final String kill, @QueryParam("kill") final String kill,
@ -190,7 +191,7 @@ public class DatasourcesResource
@GET @GET
@Path("/{dataSourceName}/intervals") @Path("/{dataSourceName}/intervals")
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public Response getSegmentDataSourceIntervals( public Response getSegmentDataSourceIntervals(
@PathParam("dataSourceName") String dataSourceName, @PathParam("dataSourceName") String dataSourceName,
@QueryParam("simple") String simple, @QueryParam("simple") String simple,
@ -250,7 +251,7 @@ public class DatasourcesResource
@GET @GET
@Path("/{dataSourceName}/intervals/{interval}") @Path("/{dataSourceName}/intervals/{interval}")
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public Response getSegmentDataSourceSpecificInterval( public Response getSegmentDataSourceSpecificInterval(
@PathParam("dataSourceName") String dataSourceName, @PathParam("dataSourceName") String dataSourceName,
@PathParam("interval") String interval, @PathParam("interval") String interval,
@ -317,7 +318,7 @@ public class DatasourcesResource
@GET @GET
@Path("/{dataSourceName}/segments") @Path("/{dataSourceName}/segments")
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public Response getSegmentDataSourceSegments( public Response getSegmentDataSourceSegments(
@PathParam("dataSourceName") String dataSourceName, @PathParam("dataSourceName") String dataSourceName,
@QueryParam("full") String full @QueryParam("full") String full
@ -350,7 +351,7 @@ public class DatasourcesResource
@GET @GET
@Path("/{dataSourceName}/segments/{segmentId}") @Path("/{dataSourceName}/segments/{segmentId}")
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public Response getSegmentDataSourceSegment( public Response getSegmentDataSourceSegment(
@PathParam("dataSourceName") String dataSourceName, @PathParam("dataSourceName") String dataSourceName,
@PathParam("segmentId") String segmentId @PathParam("segmentId") String segmentId
@ -388,7 +389,7 @@ public class DatasourcesResource
@POST @POST
@Path("/{dataSourceName}/segments/{segmentId}") @Path("/{dataSourceName}/segments/{segmentId}")
@Consumes("application/json") @Consumes(MediaType.APPLICATION_JSON)
public Response enableDatasourceSegment( public Response enableDatasourceSegment(
@PathParam("dataSourceName") String dataSourceName, @PathParam("dataSourceName") String dataSourceName,
@PathParam("segmentId") String segmentId @PathParam("segmentId") String segmentId
@ -403,7 +404,7 @@ public class DatasourcesResource
@GET @GET
@Path("/{dataSourceName}/tiers") @Path("/{dataSourceName}/tiers")
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public Response getSegmentDataSourceTiers( public Response getSegmentDataSourceTiers(
@PathParam("dataSourceName") String dataSourceName @PathParam("dataSourceName") String dataSourceName
) )

View File

@ -7,6 +7,7 @@ import javax.inject.Inject;
import javax.ws.rs.GET; import javax.ws.rs.GET;
import javax.ws.rs.Path; import javax.ws.rs.Path;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
@Path("/druid/historical/v1") @Path("/druid/historical/v1")
@ -24,7 +25,7 @@ public class HistoricalResource
@GET @GET
@Path("/loadstatus") @Path("/loadstatus")
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public Response getLoadStatus() public Response getLoadStatus()
{ {
return Response.ok(ImmutableMap.of("cacheInitialized", coordinator.isStarted())).build(); return Response.ok(ImmutableMap.of("cacheInitialized", coordinator.isStarted())).build();

View File

@ -32,6 +32,7 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam; import javax.ws.rs.PathParam;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam; import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -53,7 +54,7 @@ public class MetadataResource
@GET @GET
@Path("/datasources") @Path("/datasources")
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public Response getDatabaseDataSources( public Response getDatabaseDataSources(
@QueryParam("full") String full, @QueryParam("full") String full,
@QueryParam("includeDisabled") String includeDisabled @QueryParam("includeDisabled") String includeDisabled
@ -88,7 +89,7 @@ public class MetadataResource
@GET @GET
@Path("/datasources/{dataSourceName}") @Path("/datasources/{dataSourceName}")
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public Response getDatabaseSegmentDataSource( public Response getDatabaseSegmentDataSource(
@PathParam("dataSourceName") final String dataSourceName @PathParam("dataSourceName") final String dataSourceName
) )
@ -103,7 +104,7 @@ public class MetadataResource
@GET @GET
@Path("/datasources/{dataSourceName}/segments") @Path("/datasources/{dataSourceName}/segments")
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public Response getDatabaseSegmentDataSourceSegments( public Response getDatabaseSegmentDataSourceSegments(
@PathParam("dataSourceName") String dataSourceName, @PathParam("dataSourceName") String dataSourceName,
@QueryParam("full") String full @QueryParam("full") String full
@ -136,7 +137,7 @@ public class MetadataResource
@GET @GET
@Path("/datasources/{dataSourceName}/segments/{segmentId}") @Path("/datasources/{dataSourceName}/segments/{segmentId}")
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public Response getDatabaseSegmentDataSourceSegment( public Response getDatabaseSegmentDataSourceSegment(
@PathParam("dataSourceName") String dataSourceName, @PathParam("dataSourceName") String dataSourceName,
@PathParam("segmentId") String segmentId @PathParam("segmentId") String segmentId

View File

@ -30,6 +30,7 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam; import javax.ws.rs.PathParam;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam; import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.util.List; import java.util.List;
@ -49,7 +50,7 @@ public class RulesResource
} }
@GET @GET
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public Response getRules() public Response getRules()
{ {
return Response.ok(databaseRuleManager.getAllRules()).build(); return Response.ok(databaseRuleManager.getAllRules()).build();
@ -57,7 +58,7 @@ public class RulesResource
@GET @GET
@Path("/{dataSourceName}") @Path("/{dataSourceName}")
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public Response getDatasourceRules( public Response getDatasourceRules(
@PathParam("dataSourceName") final String dataSourceName, @PathParam("dataSourceName") final String dataSourceName,
@QueryParam("full") final String full @QueryParam("full") final String full
@ -74,7 +75,7 @@ public class RulesResource
@POST @POST
@Path("/{dataSourceName}") @Path("/{dataSourceName}")
@Consumes("application/json") @Consumes(MediaType.APPLICATION_JSON)
public Response setDatasourceRules( public Response setDatasourceRules(
@PathParam("dataSourceName") final String dataSourceName, @PathParam("dataSourceName") final String dataSourceName,
final List<Rule> rules final List<Rule> rules

View File

@ -35,6 +35,7 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam; import javax.ws.rs.PathParam;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam; import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.util.Map; import java.util.Map;
@ -66,7 +67,7 @@ public class ServersResource
} }
@GET @GET
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public Response getClusterServers( public Response getClusterServers(
@QueryParam("full") String full, @QueryParam("full") String full,
@QueryParam("simple") String simple @QueryParam("simple") String simple
@ -113,7 +114,7 @@ public class ServersResource
@GET @GET
@Path("/{serverName}") @Path("/{serverName}")
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public Response getServer( public Response getServer(
@PathParam("serverName") String serverName, @PathParam("serverName") String serverName,
@QueryParam("simple") String simple @QueryParam("simple") String simple
@ -136,7 +137,7 @@ public class ServersResource
@GET @GET
@Path("/{serverName}/segments") @Path("/{serverName}/segments")
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public Response getServerSegments( public Response getServerSegments(
@PathParam("serverName") String serverName, @PathParam("serverName") String serverName,
@QueryParam("full") String full @QueryParam("full") String full
@ -169,7 +170,7 @@ public class ServersResource
@GET @GET
@Path("/{serverName}/segments/{segmentId}") @Path("/{serverName}/segments/{segmentId}")
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public Response getServerSegment( public Response getServerSegment(
@PathParam("serverName") String serverName, @PathParam("serverName") String serverName,
@PathParam("segmentId") String segmentId @PathParam("segmentId") String segmentId

View File

@ -39,6 +39,7 @@ import javax.ws.rs.Path;
import javax.ws.rs.PathParam; import javax.ws.rs.PathParam;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam; import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -59,7 +60,7 @@ public class TiersResource
} }
@GET @GET
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public Response getTiers( public Response getTiers(
@QueryParam("simple") String simple @QueryParam("simple") String simple
) )
@ -95,7 +96,7 @@ public class TiersResource
@GET @GET
@Path("/{tierName}") @Path("/{tierName}")
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public Response getTierDatasources( public Response getTierDatasources(
@PathParam("tierName") String tierName, @PathParam("tierName") String tierName,
@QueryParam("simple") String simple @QueryParam("simple") String simple

View File

@ -50,6 +50,7 @@ import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Options; import org.apache.commons.cli.Options;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import javax.ws.rs.core.MediaType;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.net.URL; import java.net.URL;
@ -143,7 +144,7 @@ public class SQLRunner
URL url = new URL(String.format("http://%s/druid/v2/?pretty", hostname)); URL url = new URL(String.format("http://%s/druid/v2/?pretty", hostname));
final URLConnection urlConnection = url.openConnection(); final URLConnection urlConnection = url.openConnection();
urlConnection.addRequestProperty("content-type", "application/json"); urlConnection.addRequestProperty("content-type", MediaType.APPLICATION_JSON);
urlConnection.getOutputStream().write(queryStr.getBytes(Charsets.UTF_8)); urlConnection.getOutputStream().write(queryStr.getBytes(Charsets.UTF_8));
BufferedReader stdInput = new BufferedReader(new InputStreamReader(urlConnection.getInputStream(), Charsets.UTF_8)); BufferedReader stdInput = new BufferedReader(new InputStreamReader(urlConnection.getInputStream(), Charsets.UTF_8));

View File

@ -63,6 +63,7 @@ import javax.ws.rs.GET;
import javax.ws.rs.Path; import javax.ws.rs.Path;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import javax.ws.rs.core.Context; import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -275,7 +276,7 @@ public class JettyTest
@GET @GET
@Path("/hello") @Path("/hello")
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public Response hello() public Response hello()
{ {
try { try {
@ -293,7 +294,7 @@ public class JettyTest
{ {
@GET @GET
@Path("/exception") @Path("/exception")
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public Response exception( public Response exception(
@Context HttpServletResponse resp @Context HttpServletResponse resp
) throws IOException ) throws IOException