mirror of https://github.com/apache/druid.git
better exception for invalid interval
This commit is contained in:
parent
b82b487f20
commit
6b3c96c63a
|
@ -166,6 +166,12 @@ public class DatasourcesResource
|
||||||
return Response.ok().build();
|
return Response.ok().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* When this method is removed, a new method needs to be introduced corresponding to
|
||||||
|
the end point "DELETE /druid/coordinator/v1/datasources/{dataSourceName}" (with no query parameters).
|
||||||
|
Ultimately we want to have no method with kill parameter -
|
||||||
|
DELETE `{dataSourceName}` will be used to disable datasource and
|
||||||
|
DELETE `{dataSourceName}/intervals/{interval}` will be used to nuke segments
|
||||||
|
*/
|
||||||
@DELETE
|
@DELETE
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@Path("/{dataSourceName}")
|
@Path("/{dataSourceName}")
|
||||||
|
@ -179,15 +185,30 @@ public class DatasourcesResource
|
||||||
if (indexingServiceClient == null) {
|
if (indexingServiceClient == null) {
|
||||||
return Response.ok(ImmutableMap.of("error", "no indexing service found")).build();
|
return Response.ok(ImmutableMap.of("error", "no indexing service found")).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kill != null && Boolean.valueOf(kill)) {
|
if (kill != null && Boolean.valueOf(kill)) {
|
||||||
try {
|
try {
|
||||||
indexingServiceClient.killSegments(dataSourceName, new Interval(interval));
|
indexingServiceClient.killSegments(dataSourceName, new Interval(interval));
|
||||||
}
|
}
|
||||||
|
catch (IllegalArgumentException e) {
|
||||||
|
return Response.status(Response.Status.BAD_REQUEST)
|
||||||
|
.entity(
|
||||||
|
ImmutableMap.of(
|
||||||
|
"error",
|
||||||
|
"Exception occurred. Probably the interval is invalid",
|
||||||
|
"message",
|
||||||
|
e.toString()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
return Response.serverError().entity(
|
return Response.serverError().entity(
|
||||||
ImmutableMap.of(
|
ImmutableMap.of(
|
||||||
"error",
|
"error",
|
||||||
"Exception occurred. Are you sure you have an indexing service?"
|
"Exception occurred. Are you sure you have an indexing service?",
|
||||||
|
"message",
|
||||||
|
e.toString()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.build();
|
.build();
|
||||||
|
@ -220,7 +241,9 @@ public class DatasourcesResource
|
||||||
return Response.serverError()
|
return Response.serverError()
|
||||||
.entity(ImmutableMap.of(
|
.entity(ImmutableMap.of(
|
||||||
"error",
|
"error",
|
||||||
"Exception occurred. Are you sure you have an indexing service?"
|
"Exception occurred. Are you sure you have an indexing service?",
|
||||||
|
"message",
|
||||||
|
e.toString()
|
||||||
))
|
))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
|
@ -403,4 +403,17 @@ public class DatasourcesResourceTest
|
||||||
EasyMock.verify(indexingServiceClient, server);
|
EasyMock.verify(indexingServiceClient, server);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDeleteDataSource() {
|
||||||
|
IndexingServiceClient indexingServiceClient = EasyMock.createStrictMock(IndexingServiceClient.class);
|
||||||
|
EasyMock.replay(indexingServiceClient, server);
|
||||||
|
DatasourcesResource datasourcesResource = new DatasourcesResource(inventoryView, null, indexingServiceClient);
|
||||||
|
Response response = datasourcesResource.deleteDataSource("datasource", "true", "???");
|
||||||
|
Assert.assertEquals(400, response.getStatus());
|
||||||
|
Assert.assertNotNull(response.getEntity());
|
||||||
|
Assert.assertTrue(response.getEntity().toString().contains("java.lang.IllegalArgumentException"));
|
||||||
|
|
||||||
|
EasyMock.verify(indexingServiceClient, server);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue