You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by ja...@apache.org on 2018/12/01 04:34:13 UTC
[incubator-pinot] branch resource_allocation updated (e79b208 ->
0cec099)
This is an automated email from the ASF dual-hosted git repository.
jackie pushed a change to branch resource_allocation
in repository https://gitbox.apache.org/repos/asf/incubator-pinot.git.
discard e79b208 commit
add 61b4814 [TE] Make new alerter tag old anomalies as notified (#3554)
add ac74d13 [TE] frontend - harleyjj/manage - pass correct granularity to buildMetricDataUrl (#3557)
add a834a49 [TE] pom - fix javassist dependency (#3559)
add 232360f Fixes to doc (#3558)
add d9ad5c3 Removing warnings in docs (#3560)
add 1e6fc74 Adding pluggable storage support for realtime upload (#3541)
add 44c2859 [TE] detection - copy nested property in wrapper (#3562)
add 45063b0 Re-org documentation (#3563)
add b62c611 [TE] frontend - harleyjj/create-alert - make minor improvements to YAML alert creator (#3564)
add eceaf76 [TE] Legacy Alert Filter should pick recipients from new alerter configs (#3565)
add 5a610be Add metric gauge to track the number of llc simultaneous segment builds (#3566)
add 9dfb949 [TE] rootcause - rich metric selector (#3567)
add 8b2efec [TE] detection - filter out child anomaly in anomaly fetching (#3570)
add f1559a7 Docs: Fix formatting for UDF docs. (#3569)
add 88ba23a [TE] rootcause - change frontend hack for baseline for new pipeline (#3571)
add 213ff9c [TE] Configure Filters per Alert in Legacy Alerter (#3572)
add f1512e6 [TE] rootcause - hide heatmap tooltip on click (#3574)
add c752a4f Improve the logging for segment merge command (#3573)
add 75a4f85 Adding support for bloom filter (#3528)
new 0cec099 Initial commit on the interfaces
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (e79b208)
\
N -- N -- N refs/heads/resource_allocation (0cec099)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
docs/architecture.rst | 128 +++++++++++------
docs/client_api.rst | 56 ++++----
docs/conf.py | 4 +-
docs/creating_pinot_segments.rst | 98 -------------
docs/expressions_udf.rst | 25 ++--
docs/index.rst | 36 +++--
docs/intro.rst | 30 ++--
docs/llc.rst | 26 +++-
docs/management_api.rst | 6 +-
docs/multitenancy.rst | 24 ++--
docs/partition_aware_routing.rst | 6 +-
docs/pinot_hadoop.rst | 157 ++++++++++++++++----
docs/pluggable_streams.rst | 64 ++++-----
docs/pql_examples.rst | 140 ++++++++++--------
docs/reference.rst | 7 +-
docs/schema_timespec.rst | 82 +++++------
docs/segment_fetcher.rst | 16 +--
docs/trying_pinot.rst | 46 +++---
.../pinot/common/config/AssignmentConfig.java | 6 +-
.../pinot/common/config/IndexingConfig.java | 12 ++
.../linkedin/pinot/common/config/TableConfig.java | 7 +
.../pinot/common/metrics/AbstractMetrics.java | 29 +++-
.../linkedin/pinot/common/metrics/ServerGauge.java | 3 +-
.../pinot/common/segment/SegmentMetadata.java | 2 +
.../resources/LLCSegmentCompletionHandlers.java | 77 +++++-----
.../core/assignment/instance/InstanceRole.java | 9 +-
.../instance/InstanceSelectionResult.java | 45 ++++++
.../instance/InstanceSelectionResultUtils.java | 35 ++---
.../instance/InstanceSelectionStrategy.java | 10 +-
.../core/assignment/instance/InstanceTags.java | 116 +++++++++++++++
.../assignment/instance/InstanceTagsUtils.java | 42 ++++++
.../instance/constraint/InstanceConstraint.java | 21 ++-
.../constraint/NumInstancesConstraint.java | 15 +-
.../constraint/ReplicaGroupInstanceConstraint.java | 14 +-
.../TagExactMatchInstanceConstraint.java | 48 +++++++
.../segment/SegmentAssignmentStrategy.java | 34 +++++
.../helix/core/instance/InstanceAttributes.java | 68 ---------
.../helix/core/instance/InstancePoolUtils.java | 34 -----
.../helix/core/instance/InstanceRole.java | 5 -
.../instance/assignment/AssignmentStrategy.java | 4 -
.../instances/AllInstancesConstraint.java | 22 ---
.../FixedNumInstancesPerReplicaConstraint.java | 42 ------
.../instances/NumInstancesConstraint.java | 17 ---
.../replicagroup/CustomReplicaGroupConstraint.java | 12 --
.../DefaultReplicaGroupConstraint.java | 43 ------
.../replicagroup/NoReplicaGroupConstraint.java | 13 --
.../replicagroup/ReplicaGroupConstraint.java | 16 ---
.../instance/selection/result/SelectionResult.java | 32 -----
.../selection/result/SelectionResultUtils.java | 20 ---
.../selection/strategy/SelectionStrategy.java | 12 --
.../core/assignment/instance/InstanceTagsTest.java | 117 +++++++++++++++
.../com/linkedin/pinot/core/bloom/BloomFilter.java | 69 +++++++++
.../linkedin/pinot/core/bloom/BloomFilterType.java | 50 +++++++
.../linkedin/pinot/core/bloom/BloomFilterUtil.java | 54 +++++++
.../pinot/core/bloom/GuavaOnHeapBloomFilter.java | 74 ++++++++++
.../core/bloom/SegmentBloomFilterFactory.java | 48 +++++++
.../com/linkedin/pinot/core/common/DataSource.java | 3 +
.../realtime/LLRealtimeSegmentDataManager.java | 5 +
.../indexsegment/mutable/MutableSegmentImpl.java | 5 +-
.../core/query/pruner/AbstractSegmentPruner.java | 17 ++-
.../query/pruner/ColumnValueSegmentPruner.java | 44 ++++--
.../core/query/pruner/PartitionSegmentPruner.java | 10 +-
.../core/segment/creator/impl/V1Constants.java | 1 +
.../creator/impl/bloom/BloomFilterCreator.java | 66 +++++++++
.../core/segment/index/SegmentMetadataImpl.java | 5 +
.../segment/index/column/ColumnIndexContainer.java | 3 +
.../index/column/PhysicalColumnIndexContainer.java | 21 +++
.../index/data/source/ColumnDataSource.java | 17 ++-
.../segment/index/loader/IndexLoadingConfig.java | 17 +++
.../segment/index/loader/SegmentPreProcessor.java | 7 +-
.../loader/bloomfilter/BloomFilterHandler.java | 160 +++++++++++++++++++++
.../segment/index/readers/BloomFilterReader.java | 54 +++++++
.../core/segment/store/ColumnIndexDirectory.java | 18 ++-
.../pinot/core/segment/store/ColumnIndexType.java | 3 +-
.../core/segment/store/FilePerIndexDirectory.java | 17 +++
.../segment/store/SegmentLocalFSDirectory.java | 5 +
.../segment/store/SingleFileIndexDirectory.java | 12 ++
.../virtualcolumn/VirtualColumnIndexContainer.java | 6 +
.../v2/store/StarTreeDimensionDataSource.java | 6 +
.../v2/store/StarTreeMetricDataSource.java | 6 +
.../core/common/RealtimeNoDictionaryTest.java | 8 +-
.../index/creator/BloomFilterCreatorTest.java | 150 +++++++++++++++++++
.../store/ColumnIndexDirectoryTestHelper.java | 15 ++
.../query/pruner/ColumnValueSegmentPrunerTest.java | 4 +-
.../com/linkedin/pinot/filesystem/PinotFS.java | 2 +-
.../tests/BaseClusterIntegrationTest.java | 6 +
.../pinot/integration/tests/ClusterTest.java | 26 ++--
...mentBuildPushOfflineClusterIntegrationTest.java | 2 +-
.../tests/HybridClusterIntegrationTest.java | 4 +-
...ridClusterIntegrationTestCommandLineRunner.java | 2 +-
.../tests/OfflineClusterIntegrationTest.java | 39 ++++-
.../tests/RealtimeClusterIntegrationTest.java | 4 +-
.../tests/SimpleMinionClusterIntegrationTest.java | 6 +-
.../linkedin/pinot/perf/PerfBenchmarkRunner.java | 71 ---------
.../com/linkedin/pinot/perf/PerfBenchmarkTest.java | 77 ----------
.../pinot/tools/perf/PerfBenchmarkDriver.java | 6 +-
.../pinot/tools/perf/PerfBenchmarkRunner.java | 16 ++-
.../segment/converter/SegmentMergeCommand.java | 47 +++---
pom.xml | 1 +
thirdeye/pom.xml | 7 +
.../app/mirage/endpoints/rootcause.js | 3 +-
.../app/pods/components/filter-select/component.js | 14 +-
.../app/pods/components/heatmap-chart/component.js | 3 +
.../rootcause-select-metric-dimension/component.js | 9 +-
.../rootcause-select-metric-dimension/template.hbs | 2 +-
.../rootcause-select-metric/component.js | 46 ++++--
.../rootcause-select-metric/template.hbs | 6 +-
.../pods/custom/metrics-table-metric/template.hbs | 2 +-
.../app/pods/manage/alert/explore/route.js | 3 +-
.../rootcause/select-metric-label/template.hbs | 6 +
.../app/pods/self-serve/create-alert/controller.js | 36 ++++-
.../app/pods/self-serve/create-alert/template.hbs | 8 +-
.../styles/components/rootcause-select-metric.scss | 28 +++-
.../tests/acceptance/rootcause-test.js | 7 +-
thirdeye/thirdeye-pinot/pom.xml | 4 +
.../MultipleAnomaliesEmailContentFormatter.java | 4 +-
.../thirdeye/anomaly/events/EventFilter.java | 7 +
.../anomaly/events/HolidayEventProvider.java | 3 +-
.../v2/rootcause/AnomalyEventFormatter.java | 4 -
.../thirdeye/detection/DefaultDataProvider.java | 9 +-
.../detection/DetectionMigrationResource.java | 15 +-
.../thirdeye/detection/DetectionResource.java | 35 +++--
.../detection/alert/DetectionAlertTaskRunner.java | 11 ++
.../detection/alert/filter/LegacyAlertFilter.java | 61 +++++---
.../thirdeye/detection/algorithm/MergeWrapper.java | 37 +++--
.../detection/wrapper/AnomalyFilterWrapper.java | 13 +-
.../wrapper/BaselineFillingMergeWrapper.java | 2 +-
.../wrapper/ChildKeepingMergeWrapper.java | 9 +-
.../detector/email/filter/BaseAlertFilter.java | 2 +-
.../alert/filter/LegacyAlertFilterTest.java | 31 ++--
.../wrapper/ChildKeepingMergeWrapperTest.java | 13 +-
131 files changed, 2411 insertions(+), 1251 deletions(-)
delete mode 100644 docs/creating_pinot_segments.rst
copy thirdeye/thirdeye-hadoop/src/main/java/com/linkedin/thirdeye/hadoop/join/MapOutputKey.java => pinot-common/src/main/java/com/linkedin/pinot/common/config/AssignmentConfig.java (89%)
copy pinot-common/src/main/java/com/linkedin/pinot/common/metadata/ZKMetadata.java => pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/assignment/instance/InstanceRole.java (80%)
create mode 100644 pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/assignment/instance/InstanceSelectionResult.java
copy pinot-core/src/main/java/com/linkedin/pinot/core/common/BlockMultiValIterator.java => pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/assignment/instance/InstanceSelectionResultUtils.java (54%)
copy thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/datalayer/dto/RootcauseSessionDTO.java => pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/assignment/instance/InstanceSelectionStrategy.java (64%)
create mode 100644 pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/assignment/instance/InstanceTags.java
create mode 100644 pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/assignment/instance/InstanceTagsUtils.java
copy thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/detection/algorithm/stage/BaseDetectionStage.java => pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/assignment/instance/constraint/InstanceConstraint.java (59%)
copy thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/anomaly/classification/classifier/BaseAnomalyClassifier.java => pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/assignment/instance/constraint/NumInstancesConstraint.java (61%)
copy thirdeye/thirdeye-pinot/src/main/java/com/linkedin/thirdeye/anomaly/alert/grouping/BaseAlertGrouper.java => pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/assignment/instance/constraint/ReplicaGroupInstanceConstraint.java (60%)
create mode 100644 pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/assignment/instance/constraint/TagExactMatchInstanceConstraint.java
create mode 100644 pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/assignment/segment/SegmentAssignmentStrategy.java
delete mode 100644 pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/instance/InstanceAttributes.java
delete mode 100644 pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/instance/InstancePoolUtils.java
delete mode 100644 pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/instance/InstanceRole.java
delete mode 100644 pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/instance/assignment/AssignmentStrategy.java
delete mode 100644 pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/instance/selection/constraint/instances/AllInstancesConstraint.java
delete mode 100644 pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/instance/selection/constraint/instances/FixedNumInstancesPerReplicaConstraint.java
delete mode 100644 pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/instance/selection/constraint/instances/NumInstancesConstraint.java
delete mode 100644 pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/instance/selection/constraint/replicagroup/CustomReplicaGroupConstraint.java
delete mode 100644 pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/instance/selection/constraint/replicagroup/DefaultReplicaGroupConstraint.java
delete mode 100644 pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/instance/selection/constraint/replicagroup/NoReplicaGroupConstraint.java
delete mode 100644 pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/instance/selection/constraint/replicagroup/ReplicaGroupConstraint.java
delete mode 100644 pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/instance/selection/result/SelectionResult.java
delete mode 100644 pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/instance/selection/result/SelectionResultUtils.java
delete mode 100644 pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/instance/selection/strategy/SelectionStrategy.java
create mode 100644 pinot-controller/src/test/java/com/linkedin/pinot/controller/helix/core/assignment/instance/InstanceTagsTest.java
create mode 100644 pinot-core/src/main/java/com/linkedin/pinot/core/bloom/BloomFilter.java
create mode 100644 pinot-core/src/main/java/com/linkedin/pinot/core/bloom/BloomFilterType.java
create mode 100644 pinot-core/src/main/java/com/linkedin/pinot/core/bloom/BloomFilterUtil.java
create mode 100644 pinot-core/src/main/java/com/linkedin/pinot/core/bloom/GuavaOnHeapBloomFilter.java
create mode 100644 pinot-core/src/main/java/com/linkedin/pinot/core/bloom/SegmentBloomFilterFactory.java
create mode 100644 pinot-core/src/main/java/com/linkedin/pinot/core/segment/creator/impl/bloom/BloomFilterCreator.java
create mode 100644 pinot-core/src/main/java/com/linkedin/pinot/core/segment/index/loader/bloomfilter/BloomFilterHandler.java
create mode 100644 pinot-core/src/main/java/com/linkedin/pinot/core/segment/index/readers/BloomFilterReader.java
create mode 100644 pinot-core/src/test/java/com/linkedin/pinot/core/segment/index/creator/BloomFilterCreatorTest.java
delete mode 100644 pinot-perf/src/main/java/com/linkedin/pinot/perf/PerfBenchmarkRunner.java
delete mode 100644 pinot-perf/src/main/java/com/linkedin/pinot/perf/PerfBenchmarkTest.java
create mode 100644 thirdeye/thirdeye-frontend/app/pods/partials/rootcause/select-metric-label/template.hbs
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[incubator-pinot] 01/01: Initial commit on the interfaces
Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jackie pushed a commit to branch resource_allocation
in repository https://gitbox.apache.org/repos/asf/incubator-pinot.git
commit 0cec0992433d1031a033ab15a1800aef196fd3d2
Author: Xiaotian (Jackie) Jiang <xa...@linkedin.com>
AuthorDate: Fri Nov 30 20:32:34 2018 -0800
Initial commit on the interfaces
---
.../pinot/common/config/AssignmentConfig.java | 19 ++++
.../core/assignment/instance/InstanceRole.java | 20 ++++
.../instance/InstanceSelectionResult.java | 45 ++++++++
.../instance/InstanceSelectionResultUtils.java | 38 +++++++
.../instance/InstanceSelectionStrategy.java | 26 +++++
.../core/assignment/instance/InstanceTags.java | 116 ++++++++++++++++++++
.../assignment/instance/InstanceTagsUtils.java | 42 ++++++++
.../instance/constraint/InstanceConstraint.java | 30 ++++++
.../constraint/NumInstancesConstraint.java | 30 ++++++
.../constraint/ReplicaGroupInstanceConstraint.java | 30 ++++++
.../TagExactMatchInstanceConstraint.java | 48 +++++++++
.../segment/SegmentAssignmentStrategy.java | 34 ++++++
.../core/assignment/instance/InstanceTagsTest.java | 117 +++++++++++++++++++++
13 files changed, 595 insertions(+)
diff --git a/pinot-common/src/main/java/com/linkedin/pinot/common/config/AssignmentConfig.java b/pinot-common/src/main/java/com/linkedin/pinot/common/config/AssignmentConfig.java
new file mode 100644
index 0000000..51093dd
--- /dev/null
+++ b/pinot-common/src/main/java/com/linkedin/pinot/common/config/AssignmentConfig.java
@@ -0,0 +1,19 @@
+/**
+ * Copyright (C) 2014-2018 LinkedIn Corp. (pinot-core@linkedin.com)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.linkedin.pinot.common.config;
+
+public class AssignmentConfig {
+}
diff --git a/pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/assignment/instance/InstanceRole.java b/pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/assignment/instance/InstanceRole.java
new file mode 100644
index 0000000..8221a3c
--- /dev/null
+++ b/pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/assignment/instance/InstanceRole.java
@@ -0,0 +1,20 @@
+/**
+ * Copyright (C) 2014-2018 LinkedIn Corp. (pinot-core@linkedin.com)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.linkedin.pinot.controller.helix.core.assignment.instance;
+
+public enum InstanceRole {
+ CONTROLLER, BROKER, SERVER, OFFLINE, REALTIME, MINION
+}
diff --git a/pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/assignment/instance/InstanceSelectionResult.java b/pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/assignment/instance/InstanceSelectionResult.java
new file mode 100644
index 0000000..5e12f6c
--- /dev/null
+++ b/pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/assignment/instance/InstanceSelectionResult.java
@@ -0,0 +1,45 @@
+/**
+ * Copyright (C) 2014-2018 LinkedIn Corp. (pinot-core@linkedin.com)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.linkedin.pinot.controller.helix.core.assignment.instance;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+
+public class InstanceSelectionResult {
+ private final Map<Integer, List<String>> _replicaIdToInstancesMap;
+
+ public InstanceSelectionResult() {
+ _replicaIdToInstancesMap = new HashMap<>();
+ }
+
+ public InstanceSelectionResult(Map<Integer, List<String>> replicaIdToInstancesMap) {
+ _replicaIdToInstancesMap = replicaIdToInstancesMap;
+ }
+
+ public int getNumReplicas() {
+ return _replicaIdToInstancesMap.size();
+ }
+
+ public List<String> getInstances(int replicaId) {
+ return _replicaIdToInstancesMap.get(replicaId);
+ }
+
+ public void setInstances(int replicaId, List<String> instances) {
+ _replicaIdToInstancesMap.put(replicaId, instances);
+ }
+}
diff --git a/pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/assignment/instance/InstanceSelectionResultUtils.java b/pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/assignment/instance/InstanceSelectionResultUtils.java
new file mode 100644
index 0000000..1e22e58
--- /dev/null
+++ b/pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/assignment/instance/InstanceSelectionResultUtils.java
@@ -0,0 +1,38 @@
+/**
+ * Copyright (C) 2014-2018 LinkedIn Corp. (pinot-core@linkedin.com)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.linkedin.pinot.controller.helix.core.assignment.instance;
+
+import java.util.Map;
+import org.apache.helix.ZNRecord;
+import org.apache.helix.store.zk.ZkHelixPropertyStore;
+
+
+public class InstanceSelectionResultUtils {
+ private InstanceSelectionResultUtils() {
+ }
+
+ public static Map<InstanceRole, InstanceSelectionResult> readFromZK(ZkHelixPropertyStore<ZNRecord> propertyStore,
+ String resource) {
+ //TODO: implement it
+ throw new UnsupportedOperationException();
+ }
+
+ public static boolean writeToZK(ZkHelixPropertyStore<ZNRecord> propertyStore, String resource,
+ Map<InstanceRole, InstanceSelectionResult> instanceSelectionResults) {
+ //TODO: implement it
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/assignment/instance/InstanceSelectionStrategy.java b/pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/assignment/instance/InstanceSelectionStrategy.java
new file mode 100644
index 0000000..7ecd234
--- /dev/null
+++ b/pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/assignment/instance/InstanceSelectionStrategy.java
@@ -0,0 +1,26 @@
+/**
+ * Copyright (C) 2014-2018 LinkedIn Corp. (pinot-core@linkedin.com)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.linkedin.pinot.controller.helix.core.assignment.instance;
+
+import com.linkedin.pinot.common.config.AssignmentConfig;
+import javax.annotation.Nullable;
+
+
+public interface InstanceSelectionStrategy {
+
+ InstanceSelectionResult selectInstances(AssignmentConfig assignmentConfig,
+ @Nullable InstanceSelectionResult existingSelectionResult);
+}
diff --git a/pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/assignment/instance/InstanceTags.java b/pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/assignment/instance/InstanceTags.java
new file mode 100644
index 0000000..a242e85
--- /dev/null
+++ b/pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/assignment/instance/InstanceTags.java
@@ -0,0 +1,116 @@
+/**
+ * Copyright (C) 2014-2018 LinkedIn Corp. (pinot-core@linkedin.com)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.linkedin.pinot.controller.helix.core.assignment.instance;
+
+import com.google.common.base.Preconditions;
+import java.util.HashMap;
+import java.util.Map;
+import javax.annotation.Nullable;
+import org.apache.commons.lang3.EnumUtils;
+import org.apache.commons.lang3.StringUtils;
+
+
+public class InstanceTags {
+ private static final char TAG_DELIMITER = ';';
+ private static final char KEY_VALUE_DELIMITER = ':';
+ private static final char LEGACY_DELIMITER = '_';
+ private static final String UNTAGGED = "untagged";
+
+ public static final String ROLE_KEY = "role";
+ public static final String POOL_NAME_KEY = "poolName";
+ public static final String GROUP_ID_KEY = "groupId";
+
+ private final String _instanceName;
+ private final Map<String, String> _tags;
+
+ public InstanceTags(String instanceName, Map<String, String> tags) {
+ _instanceName = instanceName;
+ _tags = tags;
+ }
+
+ public static InstanceTags fromHelixTag(String instanceName, String helixTag) {
+ Map<String, String> tags = new HashMap<>();
+
+ // For backward-compatible
+ if (helixTag.indexOf(KEY_VALUE_DELIMITER) == -1) {
+ int delimiterIndex = helixTag.lastIndexOf(LEGACY_DELIMITER);
+ Preconditions.checkArgument(delimiterIndex != -1, "Invalid Helix tag: " + helixTag);
+
+ String part1 = helixTag.substring(0, delimiterIndex);
+ String part2 = helixTag.substring(delimiterIndex + 1);
+ if (part2.equals(UNTAGGED)) {
+ // Untagged instances, e.g. broker_untagged, server_untagged, minion_untagged
+ InstanceRole role = InstanceRole.valueOf(part1.toUpperCase());
+ tags.put(ROLE_KEY, role.toString());
+ tags.put(POOL_NAME_KEY, UNTAGGED);
+ tags.put(GROUP_ID_KEY, Integer.toString(0));
+ } else {
+ // Tagged instances, e.g. poolName_OFFLINE, poolName_REALTIME, poolName_BROKER
+ String poolName = helixTag.substring(0, delimiterIndex);
+ String role = helixTag.substring(delimiterIndex + 1);
+ Preconditions.checkArgument(EnumUtils.isValidEnum(InstanceRole.class, role), "Invalid role: " + role);
+
+ tags.put(ROLE_KEY, role);
+ tags.put(POOL_NAME_KEY, poolName);
+ tags.put(GROUP_ID_KEY, Integer.toString(0));
+ }
+ } else {
+ // E.g. role:BROKER;poolName:brokerPool;groupId:0
+ String[] pairs = StringUtils.split(helixTag, TAG_DELIMITER);
+ for (String pair : pairs) {
+ String[] keyAndValue = StringUtils.split(pair, KEY_VALUE_DELIMITER);
+ Preconditions.checkArgument(keyAndValue.length == 2, "Invalid ket-value pair: " + pair);
+ tags.put(keyAndValue[0], keyAndValue[1]);
+ }
+ }
+
+ return new InstanceTags(instanceName, tags);
+ }
+
+ public static String toHelixTag(InstanceTags instanceTags) {
+ StringBuilder stringBuilder = new StringBuilder();
+ for (Map.Entry<String, String> entry : instanceTags._tags.entrySet()) {
+ stringBuilder.append(entry.getKey()).append(KEY_VALUE_DELIMITER).append(entry.getValue()).append(TAG_DELIMITER);
+ }
+ return stringBuilder.substring(0, stringBuilder.length() - 1);
+ }
+
+ public String getInstanceName() {
+ return _instanceName;
+ }
+
+ @Nullable
+ public String getTag(String key) {
+ return _tags.get(key);
+ }
+
+ @Override
+ public int hashCode() {
+ return 37 * _instanceName.hashCode() + _tags.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof InstanceTags) {
+ InstanceTags that = (InstanceTags) obj;
+ return _instanceName.equals(that._instanceName) && _tags.equals(that._tags);
+ }
+ return false;
+ }
+}
diff --git a/pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/assignment/instance/InstanceTagsUtils.java b/pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/assignment/instance/InstanceTagsUtils.java
new file mode 100644
index 0000000..df7b213
--- /dev/null
+++ b/pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/assignment/instance/InstanceTagsUtils.java
@@ -0,0 +1,42 @@
+/**
+ * Copyright (C) 2014-2018 LinkedIn Corp. (pinot-core@linkedin.com)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.linkedin.pinot.controller.helix.core.assignment.instance;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import org.apache.helix.model.InstanceConfig;
+
+
+public class InstanceTagsUtils {
+ private InstanceTagsUtils() {
+ }
+
+ public static Set<InstanceTags> extractAllInstanceTags(List<InstanceConfig> instanceConfigs) {
+ Set<InstanceTags> instanceTagsSet = new HashSet<>();
+ for (InstanceConfig instanceConfig : instanceConfigs) {
+ // Skip disabled instances
+ if (!instanceConfig.getInstanceEnabled()) {
+ continue;
+ }
+ String instanceName = instanceConfig.getInstanceName();
+ for (String tag : instanceConfig.getTags()) {
+ instanceTagsSet.add(InstanceTags.fromHelixTag(instanceName, tag));
+ }
+ }
+ return instanceTagsSet;
+ }
+}
diff --git a/pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/assignment/instance/constraint/InstanceConstraint.java b/pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/assignment/instance/constraint/InstanceConstraint.java
new file mode 100644
index 0000000..c391bbd
--- /dev/null
+++ b/pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/assignment/instance/constraint/InstanceConstraint.java
@@ -0,0 +1,30 @@
+/**
+ * Copyright (C) 2014-2018 LinkedIn Corp. (pinot-core@linkedin.com)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.linkedin.pinot.controller.helix.core.assignment.instance.constraint;
+
+import com.linkedin.pinot.controller.helix.core.assignment.instance.InstanceTags;
+import java.util.Map;
+import java.util.Set;
+
+
+public interface InstanceConstraint {
+ int UNASSIGNED_REPLICA_ID = -1;
+
+ /**
+ * Applies the instance constraint, and returns a map from replica Id to satisfied instances.
+ */
+ Map<Integer, Set<InstanceTags>> apply(Map<Integer, Set<InstanceTags>> replicaIdToInstanceTagsMap);
+}
diff --git a/pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/assignment/instance/constraint/NumInstancesConstraint.java b/pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/assignment/instance/constraint/NumInstancesConstraint.java
new file mode 100644
index 0000000..713d8c0
--- /dev/null
+++ b/pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/assignment/instance/constraint/NumInstancesConstraint.java
@@ -0,0 +1,30 @@
+/**
+ * Copyright (C) 2014-2018 LinkedIn Corp. (pinot-core@linkedin.com)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.linkedin.pinot.controller.helix.core.assignment.instance.constraint;
+
+import com.linkedin.pinot.controller.helix.core.assignment.instance.InstanceTags;
+import java.util.Map;
+import java.util.Set;
+
+
+public class NumInstancesConstraint implements InstanceConstraint {
+
+ @Override
+ public Map<Integer, Set<InstanceTags>> apply(Map<Integer, Set<InstanceTags>> replicaIdToInstanceTagsMap) {
+ //TODO: implement it
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/assignment/instance/constraint/ReplicaGroupInstanceConstraint.java b/pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/assignment/instance/constraint/ReplicaGroupInstanceConstraint.java
new file mode 100644
index 0000000..1efdf21
--- /dev/null
+++ b/pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/assignment/instance/constraint/ReplicaGroupInstanceConstraint.java
@@ -0,0 +1,30 @@
+/**
+ * Copyright (C) 2014-2018 LinkedIn Corp. (pinot-core@linkedin.com)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.linkedin.pinot.controller.helix.core.assignment.instance.constraint;
+
+import com.linkedin.pinot.controller.helix.core.assignment.instance.InstanceTags;
+import java.util.Map;
+import java.util.Set;
+
+
+public class ReplicaGroupInstanceConstraint implements InstanceConstraint {
+
+ @Override
+ public Map<Integer, Set<InstanceTags>> apply(Map<Integer, Set<InstanceTags>> replicaIdToInstanceTagsMap) {
+ //TODO: implement it
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/assignment/instance/constraint/TagExactMatchInstanceConstraint.java b/pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/assignment/instance/constraint/TagExactMatchInstanceConstraint.java
new file mode 100644
index 0000000..c6e79b8
--- /dev/null
+++ b/pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/assignment/instance/constraint/TagExactMatchInstanceConstraint.java
@@ -0,0 +1,48 @@
+/**
+ * Copyright (C) 2014-2018 LinkedIn Corp. (pinot-core@linkedin.com)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.linkedin.pinot.controller.helix.core.assignment.instance.constraint;
+
+import com.linkedin.pinot.controller.helix.core.assignment.instance.InstanceTags;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+
+public class TagExactMatchInstanceConstraint implements InstanceConstraint {
+ private final Map<String, String> _exactMatchTags;
+
+ public TagExactMatchInstanceConstraint(Map<String, String> exactMatchTags) {
+ _exactMatchTags = exactMatchTags;
+ }
+
+ @Override
+ public Map<Integer, Set<InstanceTags>> apply(Map<Integer, Set<InstanceTags>> replicaIdToInstanceTagsMap) {
+ for (Set<InstanceTags> instanceTagsSet : replicaIdToInstanceTagsMap.values()) {
+ Iterator<InstanceTags> iterator = instanceTagsSet.iterator();
+ while (iterator.hasNext()) {
+ InstanceTags instanceTags = iterator.next();
+ for (Map.Entry<String, String> entry : _exactMatchTags.entrySet()) {
+ String tag = instanceTags.getTag(entry.getKey());
+ if (!entry.getValue().equals(tag)) {
+ iterator.remove();
+ break;
+ }
+ }
+ }
+ }
+ return replicaIdToInstanceTagsMap;
+ }
+}
diff --git a/pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/assignment/segment/SegmentAssignmentStrategy.java b/pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/assignment/segment/SegmentAssignmentStrategy.java
new file mode 100644
index 0000000..ab1de3c
--- /dev/null
+++ b/pinot-controller/src/main/java/com/linkedin/pinot/controller/helix/core/assignment/segment/SegmentAssignmentStrategy.java
@@ -0,0 +1,34 @@
+/**
+ * Copyright (C) 2014-2018 LinkedIn Corp. (pinot-core@linkedin.com)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.linkedin.pinot.controller.helix.core.assignment.segment;
+
+import com.linkedin.pinot.common.config.AssignmentConfig;
+import com.linkedin.pinot.common.metadata.segment.SegmentZKMetadata;
+import com.linkedin.pinot.controller.helix.core.assignment.instance.InstanceSelectionResult;
+import java.util.List;
+import java.util.Map;
+import javax.annotation.Nullable;
+
+
+public interface SegmentAssignmentStrategy {
+
+ Map<String, List<String>> assignNewSegment(AssignmentConfig assignmentConfig, SegmentZKMetadata segmentZKMetadata,
+ InstanceSelectionResult selectedInstances, @Nullable Map<String, List<String>> existingAssignmentResult);
+
+ Map<String, List<String>> rebalanceSegments(AssignmentConfig assignmentConfig,
+ List<SegmentZKMetadata> segmentZKMetadataList, InstanceSelectionResult selectedInstances,
+ Map<String, List<String>> existingAssignmentResult);
+}
diff --git a/pinot-controller/src/test/java/com/linkedin/pinot/controller/helix/core/assignment/instance/InstanceTagsTest.java b/pinot-controller/src/test/java/com/linkedin/pinot/controller/helix/core/assignment/instance/InstanceTagsTest.java
new file mode 100644
index 0000000..a1ad642
--- /dev/null
+++ b/pinot-controller/src/test/java/com/linkedin/pinot/controller/helix/core/assignment/instance/InstanceTagsTest.java
@@ -0,0 +1,117 @@
+/**
+ * Copyright (C) 2014-2018 LinkedIn Corp. (pinot-core@linkedin.com)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.linkedin.pinot.controller.helix.core.assignment.instance;
+
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.*;
+
+
+public class InstanceTagsTest {
+
+ @Test
+ public void testUntaggedInstance() {
+ InstanceTags instanceTags = InstanceTags.fromHelixTag("instance", "controller_untagged");
+ assertEquals(instanceTags.getInstanceName(), "instance");
+ assertEquals(instanceTags.getTag(InstanceTags.ROLE_KEY), InstanceRole.CONTROLLER.toString());
+ assertEquals(instanceTags.getTag(InstanceTags.POOL_NAME_KEY), "untagged");
+ assertEquals(instanceTags.getTag(InstanceTags.GROUP_ID_KEY), "0");
+
+ instanceTags = InstanceTags.fromHelixTag("instance", "broker_untagged");
+ assertEquals(instanceTags.getInstanceName(), "instance");
+ assertEquals(instanceTags.getTag(InstanceTags.ROLE_KEY), InstanceRole.BROKER.toString());
+ assertEquals(instanceTags.getTag(InstanceTags.POOL_NAME_KEY), "untagged");
+ assertEquals(instanceTags.getTag(InstanceTags.GROUP_ID_KEY), "0");
+
+ instanceTags = InstanceTags.fromHelixTag("instance", "server_untagged");
+ assertEquals(instanceTags.getInstanceName(), "instance");
+ assertEquals(instanceTags.getTag(InstanceTags.ROLE_KEY), InstanceRole.SERVER.toString());
+ assertEquals(instanceTags.getTag(InstanceTags.POOL_NAME_KEY), "untagged");
+ assertEquals(instanceTags.getTag(InstanceTags.GROUP_ID_KEY), "0");
+
+ instanceTags = InstanceTags.fromHelixTag("instance", "minion_untagged");
+ assertEquals(instanceTags.getInstanceName(), "instance");
+ assertEquals(instanceTags.getTag(InstanceTags.ROLE_KEY), InstanceRole.MINION.toString());
+ assertEquals(instanceTags.getTag(InstanceTags.POOL_NAME_KEY), "untagged");
+ assertEquals(instanceTags.getTag(InstanceTags.GROUP_ID_KEY), "0");
+ }
+
+ @Test
+ public void testLegacyHelixTag() {
+ InstanceTags instanceTags = InstanceTags.fromHelixTag("instance", "controllerPool_CONTROLLER");
+ assertEquals(instanceTags.getInstanceName(), "instance");
+ assertEquals(instanceTags.getTag(InstanceTags.ROLE_KEY), InstanceRole.CONTROLLER.toString());
+ assertEquals(instanceTags.getTag(InstanceTags.POOL_NAME_KEY), "controllerPool");
+ assertEquals(instanceTags.getTag(InstanceTags.GROUP_ID_KEY), "0");
+
+ instanceTags = InstanceTags.fromHelixTag("instance", "brokerPool_BROKER");
+ assertEquals(instanceTags.getInstanceName(), "instance");
+ assertEquals(instanceTags.getTag(InstanceTags.ROLE_KEY), InstanceRole.BROKER.toString());
+ assertEquals(instanceTags.getTag(InstanceTags.POOL_NAME_KEY), "brokerPool");
+ assertEquals(instanceTags.getTag(InstanceTags.GROUP_ID_KEY), "0");
+
+ instanceTags = InstanceTags.fromHelixTag("instance", "offlineServerPool_OFFLINE");
+ assertEquals(instanceTags.getInstanceName(), "instance");
+ assertEquals(instanceTags.getTag(InstanceTags.ROLE_KEY), InstanceRole.OFFLINE.toString());
+ assertEquals(instanceTags.getTag(InstanceTags.POOL_NAME_KEY), "offlineServerPool");
+ assertEquals(instanceTags.getTag(InstanceTags.GROUP_ID_KEY), "0");
+
+ instanceTags = InstanceTags.fromHelixTag("instance", "realtimeServerPool_REALTIME");
+ assertEquals(instanceTags.getInstanceName(), "instance");
+ assertEquals(instanceTags.getTag(InstanceTags.ROLE_KEY), InstanceRole.REALTIME.toString());
+ assertEquals(instanceTags.getTag(InstanceTags.POOL_NAME_KEY), "realtimeServerPool");
+ assertEquals(instanceTags.getTag(InstanceTags.GROUP_ID_KEY), "0");
+
+ instanceTags = InstanceTags.fromHelixTag("instance", "minionPool_MINION");
+ assertEquals(instanceTags.getInstanceName(), "instance");
+ assertEquals(instanceTags.getTag(InstanceTags.ROLE_KEY), InstanceRole.MINION.toString());
+ assertEquals(instanceTags.getTag(InstanceTags.POOL_NAME_KEY), "minionPool");
+ assertEquals(instanceTags.getTag(InstanceTags.GROUP_ID_KEY), "0");
+ }
+
+ @Test
+ public void testKeyValuePairs() {
+ InstanceTags instanceTags = InstanceTags.fromHelixTag("instance", "key1:value1;key2:value2;key3:value3");
+ assertEquals(instanceTags.getInstanceName(), "instance");
+ assertEquals(instanceTags.getTag("key1"), "value1");
+ assertEquals(instanceTags.getTag("key2"), "value2");
+ assertEquals(instanceTags.getTag("key3"), "value3");
+ }
+
+ @Test
+ public void testIllegalHelixTag() {
+ try {
+ InstanceTags.fromHelixTag("instance", "illegalRole_untagged");
+ fail();
+ } catch (IllegalArgumentException e) {
+ // Expected
+ }
+
+ try {
+ InstanceTags.fromHelixTag("instance", "somePool_ILLEGALROLE");
+ fail();
+ } catch (IllegalArgumentException e) {
+ // Expected
+ }
+
+ try {
+ InstanceTags.fromHelixTag("instance", "illegal:key:value:pair;key:value");
+ fail();
+ } catch (IllegalArgumentException e) {
+ // Expected
+ }
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org