Skip to content

Commit

Permalink
DartWorkerContext: Return the correct workerId(). (#17280) (#17306)
Browse files Browse the repository at this point in the history
Prior to this patch, the workerId() method did not actually return
the worker ID. It returned some other string that had similar information,
but was different.

This caused the /druid/dart-worker/workers API, to return an internal
server error. The API is useful for debugging, although it is not used
during actual queries.

Co-authored-by: Gian Merlino <[email protected]>
  • Loading branch information
AmatyaAvadhanula and gianm authored Oct 9, 2024
1 parent 9b90d9c commit a035fb8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class DartWorkerContext implements WorkerContext
{
private final String queryId;
private final String controllerHost;
private final String workerId;
private final WorkerId workerId;
private final DruidNode selfNode;
private final ObjectMapper jsonMapper;
private final Injector injector;
Expand All @@ -82,7 +82,6 @@ public class DartWorkerContext implements WorkerContext
DartWorkerContext(
final String queryId,
final String controllerHost,
final String workerId,
final DruidNode selfNode,
final ObjectMapper jsonMapper,
final Injector injector,
Expand All @@ -100,7 +99,7 @@ public class DartWorkerContext implements WorkerContext
{
this.queryId = queryId;
this.controllerHost = controllerHost;
this.workerId = workerId;
this.workerId = WorkerId.fromDruidNode(selfNode, queryId);
this.selfNode = selfNode;
this.jsonMapper = jsonMapper;
this.injector = injector;
Expand All @@ -125,7 +124,7 @@ public String queryId()
@Override
public String workerId()
{
return workerId;
return workerId.toString();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.apache.druid.messages.server.Outbox;
import org.apache.druid.msq.dart.Dart;
import org.apache.druid.msq.dart.controller.messages.ControllerMessage;
import org.apache.druid.msq.dart.worker.http.DartWorkerResource;
import org.apache.druid.msq.exec.MemoryIntrospector;
import org.apache.druid.msq.exec.ProcessingBuffersProvider;
import org.apache.druid.msq.exec.Worker;
Expand All @@ -44,15 +43,12 @@
import org.apache.druid.server.DruidNode;

import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;

/**
* Production implementation of {@link DartWorkerFactory}.
*/
public class DartWorkerFactoryImpl implements DartWorkerFactory
{
private final String id;
private final DruidNode selfNode;
private final ObjectMapper jsonMapper;
private final ObjectMapper smileMapper;
Expand Down Expand Up @@ -82,7 +78,6 @@ public DartWorkerFactoryImpl(
Outbox<ControllerMessage> outbox
)
{
this.id = makeWorkerId(selfNode);
this.selfNode = selfNode;
this.jsonMapper = jsonMapper;
this.smileMapper = smileMapper;
Expand All @@ -103,7 +98,6 @@ public Worker build(String queryId, String controllerHost, File tempDir, QueryCo
final WorkerContext workerContext = new DartWorkerContext(
queryId,
controllerHost,
id,
selfNode,
jsonMapper,
injector,
Expand All @@ -121,22 +115,4 @@ public Worker build(String queryId, String controllerHost, File tempDir, QueryCo

return new WorkerImpl(null, workerContext);
}

private static String makeWorkerId(final DruidNode selfNode)
{
try {
return new URI(
selfNode.getServiceScheme(),
null,
selfNode.getHost(),
selfNode.getPortToUse(),
DartWorkerResource.PATH,
null,
null
).toString();
}
catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}
}

0 comments on commit a035fb8

Please sign in to comment.