Skip to content

Commit 4f4b81f

Browse files
committed
Add "restarted": true or false to POST supervisor update API
Including this in the response will help indicate if the superivsor was restarted or not if skipRestartIfUnmodified is set to true
1 parent a4d4921 commit 4f4b81f

5 files changed

Lines changed: 19 additions & 9 deletions

File tree

docs/api-reference/supervisor-api.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2508,11 +2508,16 @@ curl "http://ROUTER_IP:ROUTER_PORT/druid/indexer/v1/supervisor?skipRestartIfUnmo
25082508

25092509
```json
25102510
{
2511-
"id": "social_media"
2511+
"id": "social_media",
2512+
"restarted": true
25122513
}
25132514
```
25142515
</details>
25152516

2517+
The response includes the following fields:
2518+
- `id`: The supervisor ID.
2519+
- `restarted`: A boolean indicating whether the supervisor was restarted. When `skipRestartIfUnmodified` is set to `true` and the supervisor spec is unchanged, this field will be `false`; otherwise, it will be `true`.
2520+
25162521
### Suspend a running supervisor
25172522

25182523
Suspends a single running supervisor. Returns the updated supervisor spec, where the `suspended` property is set to `true`. The suspended supervisor continues to emit logs and metrics.

indexing-service/src/main/java/org/apache/druid/indexing/overlord/supervisor/SupervisorResource.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public Response specPost(
166166
}
167167

168168
if (Boolean.TRUE.equals(skipRestartIfUnmodified) && !manager.shouldUpdateSupervisor(spec)) {
169-
return Response.ok(ImmutableMap.of("id", spec.getId())).build();
169+
return Response.ok(ImmutableMap.of("id", spec.getId(), "restarted", false)).build();
170170
}
171171

172172
manager.createOrUpdateAndStartSupervisor(spec);
@@ -183,7 +183,7 @@ public Response specPost(
183183
.build()
184184
);
185185

186-
return Response.ok(ImmutableMap.of("id", spec.getId())).build();
186+
return Response.ok(ImmutableMap.of("id", spec.getId(), "restarted", true)).build();
187187
}
188188
);
189189
}

indexing-service/src/test/java/org/apache/druid/indexing/overlord/supervisor/SupervisorResourceTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ public List<String> getDataSources()
178178
verifyAll();
179179

180180
Assert.assertEquals(200, response.getStatus());
181-
Assert.assertEquals(ImmutableMap.of("id", "my-id"), response.getEntity());
181+
Assert.assertEquals(ImmutableMap.of("id", "my-id", "restarted", true), response.getEntity());
182182
resetAll();
183183

184184
EasyMock.expect(taskMaster.getSupervisorManager()).andReturn(Optional.absent());
@@ -248,7 +248,7 @@ public List<String> getDataSources()
248248
verifyAll();
249249

250250
Assert.assertEquals(200, response.getStatus());
251-
Assert.assertEquals(ImmutableMap.of("id", "my-id"), response.getEntity());
251+
Assert.assertEquals(ImmutableMap.of("id", "my-id", "restarted", false), response.getEntity());
252252

253253
resetAll();
254254

@@ -269,7 +269,7 @@ public List<String> getDataSources()
269269
verifyAll();
270270

271271
Assert.assertEquals(200, response.getStatus());
272-
Assert.assertEquals(ImmutableMap.of("id", "my-id"), response.getEntity());
272+
Assert.assertEquals(ImmutableMap.of("id", "my-id", "restarted", true), response.getEntity());
273273
}
274274

275275
@Test
@@ -300,7 +300,7 @@ public List<String> getDataSources()
300300
verifyAll();
301301

302302
Assert.assertEquals(200, response.getStatus());
303-
Assert.assertEquals(ImmutableMap.of("id", "my-id"), response.getEntity());
303+
Assert.assertEquals(ImmutableMap.of("id", "my-id", "restarted", true), response.getEntity());
304304
resetAll();
305305

306306
EasyMock.expect(taskMaster.getSupervisorManager()).andReturn(Optional.absent());

processing/src/main/java/org/apache/druid/java/util/emitter/service/ServiceMetricEvent.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ public String getHost()
9393
return serviceDims.get(HOST);
9494
}
9595

96+
public ImmutableMap<String, String> getServiceDims()
97+
{
98+
return serviceDims;
99+
}
100+
96101
public Map<String, Object> getUserDims()
97102
{
98103
return userDims;

server/src/test/java/org/apache/druid/rpc/indexing/OverlordClientImplTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,11 +283,11 @@ public void test_postSupervisor() throws Exception
283283
.jsonContent(jsonMapper, supervisorSpec),
284284
HttpResponseStatus.OK,
285285
ImmutableMap.of(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON),
286-
jsonMapper.writeValueAsBytes(Map.of("id", supervisorId))
286+
jsonMapper.writeValueAsBytes(Map.of("id", supervisorId, "restarted", true))
287287
);
288288

289289
Assert.assertEquals(
290-
Map.of("id", supervisorId),
290+
Map.of("id", supervisorId, "restarted", true),
291291
overlordClient.postSupervisor(supervisorSpec).get()
292292
);
293293
}

0 commit comments

Comments
 (0)