This is an automated email from the ASF dual-hosted git repository.
karan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/druid.git
The following commit(s) were added to refs/heads/master by this push:
new 2309aa7bdfe DartSqlResource: Add controllerHost to GetQueriesResponse.
(#17283)
2309aa7bdfe is described below
commit 2309aa7bdfe6c9a8398f44b45059f8a47380983b
Author: Gian Merlino <[email protected]>
AuthorDate: Tue Oct 8 03:17:32 2024 -0700
DartSqlResource: Add controllerHost to GetQueriesResponse. (#17283)
This helps find the specific Broker that is executing a query.
---
.../msq/dart/controller/ControllerHolder.java | 8 ++++++++
.../msq/dart/controller/http/DartQueryInfo.java | 23 +++++++++++++++++++---
.../msq/dart/controller/sql/DartQueryMaker.java | 1 +
.../dart/controller/http/DartSqlResourceTest.java | 14 +++++++++++--
.../controller/http/GetQueriesResponseTest.java | 1 +
.../dart/controller/sql/DartSqlClientImplTest.java | 2 ++
6 files changed, 44 insertions(+), 5 deletions(-)
diff --git
a/extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/dart/controller/ControllerHolder.java
b/extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/dart/controller/ControllerHolder.java
index 9644444dad2..ca60ee3cbc1 100644
---
a/extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/dart/controller/ControllerHolder.java
+++
b/extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/dart/controller/ControllerHolder.java
@@ -59,6 +59,7 @@ public class ControllerHolder
private final ControllerContext controllerContext;
private final String sqlQueryId;
private final String sql;
+ private final String controllerHost;
private final AuthenticationResult authenticationResult;
private final DateTime startTime;
private final AtomicReference<State> state = new
AtomicReference<>(State.ACCEPTED);
@@ -68,6 +69,7 @@ public class ControllerHolder
final ControllerContext controllerContext,
final String sqlQueryId,
final String sql,
+ final String controllerHost,
final AuthenticationResult authenticationResult,
final DateTime startTime
)
@@ -76,6 +78,7 @@ public class ControllerHolder
this.controllerContext = controllerContext;
this.sqlQueryId = Preconditions.checkNotNull(sqlQueryId, "sqlQueryId");
this.sql = sql;
+ this.controllerHost = controllerHost;
this.authenticationResult = authenticationResult;
this.startTime = Preconditions.checkNotNull(startTime, "startTime");
}
@@ -95,6 +98,11 @@ public class ControllerHolder
return sql;
}
+ public String getControllerHost()
+ {
+ return controllerHost;
+ }
+
public AuthenticationResult getAuthenticationResult()
{
return authenticationResult;
diff --git
a/extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/dart/controller/http/DartQueryInfo.java
b/extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/dart/controller/http/DartQueryInfo.java
index e5f3abb894e..2bc5d08704d 100644
---
a/extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/dart/controller/http/DartQueryInfo.java
+++
b/extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/dart/controller/http/DartQueryInfo.java
@@ -26,6 +26,7 @@ import com.google.common.base.Preconditions;
import org.apache.druid.msq.dart.controller.ControllerHolder;
import org.apache.druid.msq.util.MSQTaskQueryMakerUtils;
import org.apache.druid.query.QueryContexts;
+import org.apache.druid.server.DruidNode;
import org.joda.time.DateTime;
import java.util.Objects;
@@ -38,6 +39,7 @@ public class DartQueryInfo
private final String sqlQueryId;
private final String dartQueryId;
private final String sql;
+ private final String controllerHost;
private final String authenticator;
private final String identity;
private final DateTime startTime;
@@ -48,6 +50,7 @@ public class DartQueryInfo
@JsonProperty("sqlQueryId") final String sqlQueryId,
@JsonProperty("dartQueryId") final String dartQueryId,
@JsonProperty("sql") final String sql,
+ @JsonProperty("controllerHost") final String controllerHost,
@JsonProperty("authenticator") final String authenticator,
@JsonProperty("identity") final String identity,
@JsonProperty("startTime") final DateTime startTime,
@@ -57,6 +60,7 @@ public class DartQueryInfo
this.sqlQueryId = Preconditions.checkNotNull(sqlQueryId, "sqlQueryId");
this.dartQueryId = Preconditions.checkNotNull(dartQueryId, "dartQueryId");
this.sql = sql;
+ this.controllerHost = controllerHost;
this.authenticator = authenticator;
this.identity = identity;
this.startTime = startTime;
@@ -69,6 +73,7 @@ public class DartQueryInfo
holder.getSqlQueryId(),
holder.getController().queryId(),
MSQTaskQueryMakerUtils.maskSensitiveJsonKeys(holder.getSql()),
+ holder.getControllerHost(),
holder.getAuthenticationResult().getAuthenticatedBy(),
holder.getAuthenticationResult().getIdentity(),
holder.getStartTime(),
@@ -104,6 +109,16 @@ public class DartQueryInfo
return sql;
}
+ /**
+ * Controller host:port, from {@link DruidNode#getHostAndPortToUse()}, that
is executing this query.
+ */
+ @JsonProperty
+ @JsonInclude(JsonInclude.Include.NON_NULL)
+ public String getControllerHost()
+ {
+ return controllerHost;
+ }
+
/**
* Authenticator that authenticated the identity from {@link #getIdentity()}.
*/
@@ -145,7 +160,7 @@ public class DartQueryInfo
*/
public DartQueryInfo withoutAuthenticationResult()
{
- return new DartQueryInfo(sqlQueryId, dartQueryId, sql, null, null,
startTime, state);
+ return new DartQueryInfo(sqlQueryId, dartQueryId, sql, controllerHost,
null, null, startTime, state);
}
@Override
@@ -161,6 +176,7 @@ public class DartQueryInfo
return Objects.equals(sqlQueryId, that.sqlQueryId)
&& Objects.equals(dartQueryId, that.dartQueryId)
&& Objects.equals(sql, that.sql)
+ && Objects.equals(controllerHost, that.controllerHost)
&& Objects.equals(authenticator, that.authenticator)
&& Objects.equals(identity, that.identity)
&& Objects.equals(startTime, that.startTime)
@@ -170,7 +186,7 @@ public class DartQueryInfo
@Override
public int hashCode()
{
- return Objects.hash(sqlQueryId, dartQueryId, sql, authenticator, identity,
startTime, state);
+ return Objects.hash(sqlQueryId, dartQueryId, sql, controllerHost,
authenticator, identity, startTime, state);
}
@Override
@@ -180,10 +196,11 @@ public class DartQueryInfo
"sqlQueryId='" + sqlQueryId + '\'' +
", dartQueryId='" + dartQueryId + '\'' +
", sql='" + sql + '\'' +
+ ", controllerHost='" + controllerHost + '\'' +
", authenticator='" + authenticator + '\'' +
", identity='" + identity + '\'' +
", startTime=" + startTime +
- ", state=" + state +
+ ", state='" + state + '\'' +
'}';
}
}
diff --git
a/extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/dart/controller/sql/DartQueryMaker.java
b/extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/dart/controller/sql/DartQueryMaker.java
index 37ed936a117..66686f7640f 100644
---
a/extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/dart/controller/sql/DartQueryMaker.java
+++
b/extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/dart/controller/sql/DartQueryMaker.java
@@ -154,6 +154,7 @@ public class DartQueryMaker implements QueryMaker
controllerContext,
plannerContext.getSqlQueryId(),
plannerContext.getSql(),
+ controllerContext.selfNode().getHostAndPortToUse(),
plannerContext.getAuthenticationResult(),
DateTimes.nowUtc()
);
diff --git
a/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/dart/controller/http/DartSqlResourceTest.java
b/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/dart/controller/http/DartSqlResourceTest.java
index 7ad994cff9e..8a8ce5fd3e8 100644
---
a/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/dart/controller/http/DartSqlResourceTest.java
+++
b/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/dart/controller/http/DartSqlResourceTest.java
@@ -331,6 +331,7 @@ public class DartSqlResourceTest extends MSQTestBase
"sid",
"did2",
"SELECT 2",
+ "localhost:1002",
AUTHENTICATOR_NAME,
DIFFERENT_REGULAR_USER_NAME,
DateTimes.of("2001"),
@@ -398,6 +399,7 @@ public class DartSqlResourceTest extends MSQTestBase
"sid",
"did2",
"SELECT 2",
+ "localhost:1002",
AUTHENTICATOR_NAME,
DIFFERENT_REGULAR_USER_NAME,
DateTimes.of("2000"),
@@ -434,6 +436,7 @@ public class DartSqlResourceTest extends MSQTestBase
"sid",
"did2",
"SELECT 2",
+ "localhost:1002",
AUTHENTICATOR_NAME,
DIFFERENT_REGULAR_USER_NAME,
DateTimes.of("2000"),
@@ -739,8 +742,15 @@ public class DartSqlResourceTest extends MSQTestBase
Mockito.when(controller.queryId()).thenReturn("did_" + identity);
final AuthenticationResult authenticationResult =
makeAuthenticationResult(identity);
- final ControllerHolder holder =
- new ControllerHolder(controller, null, "sid", "SELECT 1",
authenticationResult, DateTimes.of("2000"));
+ final ControllerHolder holder = new ControllerHolder(
+ controller,
+ null,
+ "sid",
+ "SELECT 1",
+ "localhost:1001",
+ authenticationResult,
+ DateTimes.of("2000")
+ );
controllerRegistry.register(holder);
return holder;
diff --git
a/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/dart/controller/http/GetQueriesResponseTest.java
b/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/dart/controller/http/GetQueriesResponseTest.java
index 7b43c863c9d..bffaace5745 100644
---
a/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/dart/controller/http/GetQueriesResponseTest.java
+++
b/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/dart/controller/http/GetQueriesResponseTest.java
@@ -41,6 +41,7 @@ public class GetQueriesResponseTest
"xyz",
"abc",
"SELECT 1",
+ "localhost:1001",
"auth",
"anon",
DateTimes.of("2000"),
diff --git
a/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/dart/controller/sql/DartSqlClientImplTest.java
b/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/dart/controller/sql/DartSqlClientImplTest.java
index 19a4eaf0b15..114ea9c7207 100644
---
a/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/dart/controller/sql/DartSqlClientImplTest.java
+++
b/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/dart/controller/sql/DartSqlClientImplTest.java
@@ -69,6 +69,7 @@ public class DartSqlClientImplTest
"sid",
"did",
"SELECT 1",
+ "localhost:1001",
"",
"",
DateTimes.of("2000"),
@@ -97,6 +98,7 @@ public class DartSqlClientImplTest
"sid",
"did",
"SELECT 1",
+ "localhost:1001",
"",
"",
DateTimes.of("2000"),
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]