Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/querying/sql-metadata-tables.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ Servers table lists all discovered servers in the cluster.
|max_size|BIGINT|Max size in bytes this server recommends to assign to segments see [druid.server.maxSize](../configuration/index.md#historical-general-configuration). Only valid for HISTORICAL type, for other types it's 0|
|is_leader|BIGINT|1 if the server is currently the 'leader' (for services which have the concept of leadership), otherwise 0 if the server is not the leader, or null if the server type does not have the concept of leadership|
|start_time|STRING|Timestamp in ISO8601 format when the server was announced in the cluster|
|version|VARCHAR|Druid version running on the server|
To retrieve information about all servers, use the query:

```sql
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ public void test_systemSchemaAccess_admin() throws Exception
verifySystemSchemaServerQuery(
adminClient,
SYS_SCHEMA_SERVERS_QUERY,
getServersWithoutCurrentSizeAndStartTime(adminServers)
getServersWithoutNonConfigurableFields(adminServers)
);

LOG.info("Checking sys.server_segments query as admin...");
Expand Down Expand Up @@ -858,7 +858,7 @@ protected void verifySystemSchemaQueryBase(
String content = responseHolder.getContent();
List<Map<String, Object>> responseMap = jsonMapper.readValue(content, SYS_SCHEMA_RESULTS_TYPE_REFERENCE);
if (isServerQuery) {
responseMap = getServersWithoutCurrentSizeAndStartTime(responseMap);
responseMap = getServersWithoutNonConfigurableFields(responseMap);
}
Assert.assertEquals(responseMap, expectedResults);
}
Expand Down Expand Up @@ -1005,7 +1005,7 @@ protected void setExpectedSystemSchemaObjects() throws IOException
SYS_SCHEMA_RESULTS_TYPE_REFERENCE
);

adminServers = getServersWithoutCurrentSizeAndStartTime(
adminServers = getServersWithoutNonConfigurableFields(
jsonMapper.readValue(
fillServersTemplate(
config,
Expand All @@ -1025,17 +1025,20 @@ protected void setExpectedSystemSchemaObjects() throws IOException
}

/**
* curr_size on historicals changes because cluster state is not isolated across different
* curr_size on historicals changes because cluster state is not isolated across
* different
* integration tests, zero it out for consistent test results
* version and start_time are not configurable therefore we zero them as well
*/
protected static List<Map<String, Object>> getServersWithoutCurrentSizeAndStartTime(List<Map<String, Object>> servers)
protected static List<Map<String, Object>> getServersWithoutNonConfigurableFields(List<Map<String, Object>> servers)
{
return Lists.transform(
servers,
(server) -> {
Map<String, Object> newServer = new HashMap<>(server);
newServer.put("curr_size", 0);
newServer.put("start_time", "0");
newServer.put("version", "0.0.0");
return newServer;
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"curr_size": 2208932412,
"max_size": 5000000000,
"is_leader": null,
"start_time": "0"
"start_time": "0",
"version": "0.0.0"
},
{
"server": "%%BROKER%%:8282",
Expand All @@ -21,6 +22,7 @@
"curr_size": 0,
"max_size": 1000000000,
"is_leader": null,
"start_time": "0"
"start_time": "0",
"version": "0.0.0"
}
]
4 changes: 3 additions & 1 deletion server/src/main/java/org/apache/druid/server/DruidNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
*/
public class DruidNode
{
public static final String UNKNOWN_VERSION = "unknown";

@JsonProperty("service")
@NotNull
private String serviceName;
Expand Down Expand Up @@ -86,7 +88,7 @@ public class DruidNode
@NotNull
private final String version = GuavaUtils.firstNonNull(
DruidNode.class.getPackage().getImplementationVersion(),
"unknown"
UNKNOWN_VERSION
);

public DruidNode(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void testDefaultsAndSanity()
// Hosts which report only ipv6 will have getDefaultHost() report something like fe80::6e40:8ff:fe93:9230
// but getHostAndPort() reports [fe80::6e40:8ff:fe93:9230]
Assert.assertEquals(HostAndPort.fromString(DruidNode.getDefaultHost()).toString(), node.getHostAndPort());
Assert.assertEquals("unknown", node.getVersion()); // unknown because not compiled with version
Assert.assertEquals(DruidNode.UNKNOWN_VERSION, node.getVersion()); // unknown because not compiled with version

node = new DruidNode(service, "2001:db8:85a3::8a2e:370:7334", false, -1, null, true, false);
Assert.assertEquals("2001:db8:85a3::8a2e:370:7334", node.getHost());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ public class SystemSchema extends AbstractSchema
.add("max_size", ColumnType.LONG)
.add("is_leader", ColumnType.LONG)
.add("start_time", ColumnType.STRING)
.add("version", ColumnType.STRING)
.build();

static final RowSignature SERVER_SEGMENTS_SIGNATURE = RowSignature
Expand Down Expand Up @@ -639,7 +640,8 @@ private static Object[] buildRowForNonDataServer(DiscoveryDruidNode discoveryDru
UNKNOWN_SIZE,
UNKNOWN_SIZE,
null,
toStringOrNull(discoveryDruidNode.getStartTime())
toStringOrNull(discoveryDruidNode.getStartTime()),
node.getVersion()
};
}

Expand All @@ -662,7 +664,8 @@ private static Object[] buildRowForNonDataServerWithLeadership(
UNKNOWN_SIZE,
UNKNOWN_SIZE,
isLeader ? 1L : 0L,
toStringOrNull(discoveryDruidNode.getStartTime())
toStringOrNull(discoveryDruidNode.getStartTime()),
node.getVersion()
};
}

Expand Down Expand Up @@ -697,7 +700,8 @@ private static Object[] buildRowForDiscoverableDataServer(
currentSize,
druidServerToUse.getMaxSize(),
null,
toStringOrNull(discoveryDruidNode.getStartTime())
toStringOrNull(discoveryDruidNode.getStartTime()),
node.getVersion()
Comment thread
GabrielCWT marked this conversation as resolved.
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.apache.druid.client.TimelineServerView;
import org.apache.druid.client.coordinator.CoordinatorClient;
import org.apache.druid.client.coordinator.NoopCoordinatorClient;
import org.apache.druid.common.guava.GuavaUtils;
import org.apache.druid.data.input.InputRow;
import org.apache.druid.data.input.impl.DimensionsSpec;
import org.apache.druid.data.input.impl.StringDimensionSchema;
Expand Down Expand Up @@ -381,6 +382,11 @@ public void setUp(@TempDir File tmpDir) throws Exception

private final DateTime startTime = DateTimes.nowUtc();

private final String version = GuavaUtils.firstNonNull(
SystemSchemaTest.class.getPackage().getImplementationVersion(),
DruidNode.UNKNOWN_VERSION
);

private final DiscoveryDruidNode coordinator = new DiscoveryDruidNode(
new DruidNode("s1", "localhost", false, 8081, null, true, false),
NodeRole.COORDINATOR,
Expand Down Expand Up @@ -552,7 +558,7 @@ public void testGetTableMap()
final SystemSchema.ServersTable serversTable = (SystemSchema.ServersTable) schema.getTableMap().get("servers");
final RelDataType serverRowType = serversTable.getRowType(new JavaTypeFactoryImpl());
final List<RelDataTypeField> serverFields = serverRowType.getFieldList();
Assert.assertEquals(10, serverFields.size());
Assert.assertEquals(11, serverFields.size());
Assert.assertEquals("server", serverFields.get(0).getName());
Assert.assertEquals(SqlTypeName.VARCHAR, serverFields.get(0).getType().getSqlTypeName());
}
Expand Down Expand Up @@ -851,7 +857,8 @@ public void testServersTable() throws URISyntaxException
0L,
0L,
nonLeader,
startTimeStr
startTimeStr,
version
)
);
expectedRows.add(
Expand All @@ -865,7 +872,8 @@ public void testServersTable() throws URISyntaxException
0L,
1000L,
nonLeader,
startTimeStr
startTimeStr,
version
)
);
expectedRows.add(
Expand All @@ -879,7 +887,8 @@ public void testServersTable() throws URISyntaxException
400L,
1000L,
nonLeader,
startTimeStr
startTimeStr,
version
)
);
expectedRows.add(
Expand All @@ -893,7 +902,8 @@ public void testServersTable() throws URISyntaxException
0L,
1000L,
nonLeader,
startTimeStr
startTimeStr,
version
)
);
expectedRows.add(
Expand All @@ -907,7 +917,8 @@ public void testServersTable() throws URISyntaxException
0L,
1000L,
nonLeader,
startTimeStr
startTimeStr,
version
)
);
expectedRows.add(createExpectedRow(
Expand All @@ -920,7 +931,8 @@ public void testServersTable() throws URISyntaxException
0L,
1000L,
nonLeader,
startTimeStr
startTimeStr,
version
));
expectedRows.add(
createExpectedRow(
Expand All @@ -933,7 +945,8 @@ public void testServersTable() throws URISyntaxException
0L,
0L,
1L,
startTimeStr
startTimeStr,
version
)
);
expectedRows.add(
Expand All @@ -947,7 +960,8 @@ public void testServersTable() throws URISyntaxException
0L,
0L,
nonLeader,
startTimeStr
startTimeStr,
version
)
);
expectedRows.add(
Expand All @@ -961,7 +975,8 @@ public void testServersTable() throws URISyntaxException
200L,
1000L,
nonLeader,
startTimeStr
startTimeStr,
version
)
);
expectedRows.add(
Expand All @@ -975,7 +990,8 @@ public void testServersTable() throws URISyntaxException
0L,
0L,
1L,
startTimeStr
startTimeStr,
version
)
);
expectedRows.add(
Expand All @@ -989,7 +1005,8 @@ public void testServersTable() throws URISyntaxException
0L,
0L,
0L,
startTimeStr
startTimeStr,
version
)
);
expectedRows.add(
Expand All @@ -1003,7 +1020,8 @@ public void testServersTable() throws URISyntaxException
0L,
0L,
0L,
startTimeStr
startTimeStr,
version
)
);
expectedRows.add(
Expand All @@ -1017,7 +1035,8 @@ public void testServersTable() throws URISyntaxException
0L,
0L,
nonLeader,
startTimeStr
startTimeStr,
version
)
);
expectedRows.add(
Expand All @@ -1031,7 +1050,8 @@ public void testServersTable() throws URISyntaxException
0L,
0L,
nonLeader,
startTimeStr
startTimeStr,
version
)
);
expectedRows.add(createExpectedRow(
Expand All @@ -1044,7 +1064,8 @@ public void testServersTable() throws URISyntaxException
0L,
1000L,
nonLeader,
startTimeStr
startTimeStr,
version
));
Assert.assertEquals(expectedRows.size(), rows.size());
for (int i = 0; i < rows.size(); i++) {
Expand Down Expand Up @@ -1077,7 +1098,8 @@ private Object[] createExpectedRow(
@Nullable Long currSize,
@Nullable Long maxSize,
@Nullable Long isLeader,
String startTime
String startTime,
String version
)
{
return new Object[]{
Expand All @@ -1090,7 +1112,8 @@ private Object[] createExpectedRow(
currSize,
maxSize,
isLeader,
startTime
startTime,
version
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ exports[`ServicesView renders data 1`] = `
"Max size",
"Usage",
"Start time",
"Version",
"Detail",
]
}
Expand Down Expand Up @@ -208,6 +209,14 @@ exports[`ServicesView renders data 1`] = `
"show": true,
"width": 200,
},
{
"Aggregated": [Function],
"Cell": [Function],
"Header": "Version",
"accessor": "version",
"show": true,
"width": 200,
},
{
"Aggregated": [Function],
"Cell": [Function],
Expand Down
Loading