Skip to content

Commit df73191

Browse files
committed
move system table to a different package
1 parent 9d22496 commit df73191

File tree

9 files changed

+580
-168
lines changed

9 files changed

+580
-168
lines changed

pinot-common/src/main/java/org/apache/pinot/common/systemtable/provider/InstancesSystemTableProvider.java

Lines changed: 0 additions & 68 deletions
This file was deleted.
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
4+
Licensed to the Apache Software Foundation (ASF) under one
5+
or more contributor license agreements. See the NOTICE file
6+
distributed with this work for additional information
7+
regarding copyright ownership. The ASF licenses this file
8+
to you under the Apache License, Version 2.0 (the
9+
"License"); you may not use this file except in compliance
10+
with the License. You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing,
15+
software distributed under the License is distributed on an
16+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
KIND, either express or implied. See the License for the
18+
specific language governing permissions and limitations
19+
under the License.
20+
21+
-->
22+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
23+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
24+
<modelVersion>4.0.0</modelVersion>
25+
<parent>
26+
<artifactId>pinot-plugins</artifactId>
27+
<groupId>org.apache.pinot</groupId>
28+
<version>1.5.0-SNAPSHOT</version>
29+
</parent>
30+
31+
<artifactId>pinot-system-table</artifactId>
32+
<name>Pinot System Table</name>
33+
<url>https://pinot.apache.org/</url>
34+
<properties>
35+
<pinot.root>${basedir}/../..</pinot.root>
36+
</properties>
37+
38+
<dependencies>
39+
<dependency>
40+
<groupId>org.apache.pinot</groupId>
41+
<artifactId>pinot-common</artifactId>
42+
<scope>provided</scope>
43+
</dependency>
44+
45+
<dependency>
46+
<groupId>org.apache.pinot</groupId>
47+
<artifactId>pinot-java-client</artifactId>
48+
<exclusions>
49+
<exclusion>
50+
<groupId>org.apache.pinot</groupId>
51+
<artifactId>pinot-common</artifactId>
52+
</exclusion>
53+
</exclusions>
54+
</dependency>
55+
56+
<dependency>
57+
<groupId>org.mockito</groupId>
58+
<artifactId>mockito-core</artifactId>
59+
<scope>test</scope>
60+
</dependency>
61+
</dependencies>
62+
63+
<profiles>
64+
<profile>
65+
<id>build-shaded-jar</id>
66+
<activation>
67+
<property>
68+
<name>skipShade</name>
69+
<value>!true</value>
70+
</property>
71+
</activation>
72+
<properties>
73+
<shade.phase.prop>package</shade.phase.prop>
74+
</properties>
75+
</profile>
76+
<profile>
77+
<id>pinot-fastdev</id>
78+
<properties>
79+
<shade.phase.prop>none</shade.phase.prop>
80+
</properties>
81+
</profile>
82+
</profiles>
83+
</project>
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.pinot.systemtable.provider;
20+
21+
import java.util.ArrayList;
22+
import java.util.List;
23+
import javax.annotation.Nullable;
24+
import org.apache.helix.HelixAdmin;
25+
import org.apache.helix.model.InstanceConfig;
26+
import org.apache.pinot.common.utils.config.InstanceUtils;
27+
import org.apache.pinot.spi.utils.InstanceTypeUtils;
28+
import org.slf4j.Logger;
29+
30+
31+
final class HelixControllerUtils {
32+
private HelixControllerUtils() {
33+
}
34+
35+
static List<String> discoverControllerBaseUrls(HelixAdmin helixAdmin, String clusterName, Logger logger) {
36+
List<String> urls = new ArrayList<>();
37+
List<String> instanceIds;
38+
try {
39+
instanceIds = helixAdmin.getInstancesInCluster(clusterName);
40+
} catch (Exception e) {
41+
logger.warn("Failed to list instances in cluster '{}' while discovering controllers", clusterName, e);
42+
return List.of();
43+
}
44+
for (String instanceId : instanceIds) {
45+
if (!InstanceTypeUtils.isController(instanceId)) {
46+
continue;
47+
}
48+
String baseUrl = getInstanceBaseUrl(helixAdmin, clusterName, instanceId, logger);
49+
if (baseUrl != null) {
50+
urls.add(baseUrl);
51+
}
52+
}
53+
return urls;
54+
}
55+
56+
private static @Nullable String getInstanceBaseUrl(HelixAdmin helixAdmin, String clusterName, String instanceId,
57+
Logger logger) {
58+
InstanceConfig instanceConfig;
59+
try {
60+
instanceConfig = helixAdmin.getInstanceConfig(clusterName, instanceId);
61+
} catch (Exception e) {
62+
logger.warn("Failed to fetch Helix InstanceConfig for instance '{}' in cluster '{}'", instanceId, clusterName, e);
63+
return null;
64+
}
65+
if (instanceConfig == null) {
66+
logger.warn("Missing Helix InstanceConfig for instance '{}' in cluster '{}'", instanceId, clusterName);
67+
return null;
68+
}
69+
String baseUrl = InstanceUtils.getInstanceBaseUri(instanceConfig);
70+
if (baseUrl.isEmpty()) {
71+
logger.warn("Failed to build instance base URL from Helix InstanceConfig for instance '{}' in cluster '{}'",
72+
instanceId, clusterName);
73+
return null;
74+
}
75+
return baseUrl;
76+
}
77+
}

0 commit comments

Comments
 (0)