-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Allow setting custom time boundary for hybrid table queries #9356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
9f7c2a4
Add controller API to enforce hybrid table time boundary
382fa47
Add delete API
41a6ac2
Fix timebounday null cases
bad91e1
Fix lint
7793971
Fix lint + bindings
34a4553
Fix tests
bae34ad
Review comments
597636d
Review comments
0d92260
Review comments
9fc8787
Simplify time boundary handling
Jackie-Jiang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,13 +32,15 @@ | |
| import org.apache.helix.zookeeper.impl.client.ZkClient; | ||
| import org.apache.pinot.common.metadata.ZKMetadataProvider; | ||
| import org.apache.pinot.common.metadata.segment.SegmentZKMetadata; | ||
| import org.apache.pinot.common.metrics.BrokerMetrics; | ||
| import org.apache.pinot.controller.helix.ControllerTest; | ||
| import org.apache.pinot.core.routing.TimeBoundaryInfo; | ||
| import org.apache.pinot.spi.config.table.TableConfig; | ||
| import org.apache.pinot.spi.config.table.TableType; | ||
| import org.apache.pinot.spi.data.FieldSpec; | ||
| import org.apache.pinot.spi.data.Schema; | ||
| import org.apache.pinot.spi.data.TimeGranularitySpec; | ||
| import org.apache.pinot.spi.utils.CommonConstants; | ||
| import org.apache.pinot.spi.utils.builder.TableConfigBuilder; | ||
| import org.apache.pinot.spi.utils.builder.TableNameBuilder; | ||
| import org.mockito.Mockito; | ||
|
|
@@ -48,7 +50,6 @@ | |
|
|
||
| import static org.apache.pinot.spi.utils.CommonConstants.Helix.StateModel.SegmentStateModel.OFFLINE; | ||
| import static org.apache.pinot.spi.utils.CommonConstants.Helix.StateModel.SegmentStateModel.ONLINE; | ||
| import static org.mockito.Mockito.mock; | ||
| import static org.testng.Assert.assertEquals; | ||
| import static org.testng.Assert.assertNotNull; | ||
| import static org.testng.Assert.assertNull; | ||
|
|
@@ -112,10 +113,11 @@ private void testDailyPushTable(String rawTableName, TableConfig tableConfig, Ti | |
| Map<String, String> offlineInstanceStateMap = Collections.singletonMap("server", OFFLINE); | ||
| Set<String> onlineSegments = new HashSet<>(); | ||
| // NOTE: Ideal state is not used in the current implementation. | ||
| IdealState idealState = mock(IdealState.class); | ||
| IdealState idealState = new IdealState(""); | ||
|
||
|
|
||
| // Start with no segment | ||
| TimeBoundaryManager timeBoundaryManager = new TimeBoundaryManager(tableConfig, _propertyStore); | ||
| TimeBoundaryManager timeBoundaryManager = | ||
| new TimeBoundaryManager(tableConfig, _propertyStore, Mockito.mock(BrokerMetrics.class)); | ||
| timeBoundaryManager.init(idealState, externalView, onlineSegments); | ||
| assertNull(timeBoundaryManager.getTimeBoundaryInfo()); | ||
|
|
||
|
|
@@ -170,14 +172,34 @@ private void testDailyPushTable(String rawTableName, TableConfig tableConfig, Ti | |
| // Refresh the changed segment should update the time boundary | ||
| timeBoundaryManager.refreshSegment(segment2); | ||
| verifyTimeBoundaryInfo(timeBoundaryManager.getTimeBoundaryInfo(), timeUnit.convert(4, TimeUnit.DAYS)); | ||
|
|
||
| // Setting the enforced time boundary in ideal state should update the time boundary | ||
| idealState.getRecord().setSimpleField(CommonConstants.IdealState.HYBRID_TABLE_TIME_BOUNDARY, | ||
| Long.toString(TimeUnit.MILLISECONDS.convert(50, TimeUnit.DAYS))); | ||
| timeBoundaryManager.onAssignmentChange(idealState, externalView, onlineSegments); | ||
| verifyTimeBoundaryInfo(timeBoundaryManager.getTimeBoundaryInfo(), timeUnit.convert(50, TimeUnit.DAYS)); | ||
|
|
||
| // Refresh with more recent segment should not update the enforced time boundary | ||
| String segment3 = "segment3"; | ||
| setSegmentZKMetadata(rawTableName, segment3, 100, timeUnit); | ||
| onlineSegments.add(segment3); | ||
| segmentAssignment.put(segment3, onlineInstanceStateMap); | ||
| timeBoundaryManager.refreshSegment(segment3); | ||
| verifyTimeBoundaryInfo(timeBoundaryManager.getTimeBoundaryInfo(), timeUnit.convert(50, TimeUnit.DAYS)); | ||
|
|
||
| // Unsetting the enforced time boundary should change it to most recent time boundary | ||
| idealState.getRecord().getSimpleFields().remove(CommonConstants.IdealState.HYBRID_TABLE_TIME_BOUNDARY); | ||
| timeBoundaryManager.onAssignmentChange(idealState, externalView, onlineSegments); | ||
| verifyTimeBoundaryInfo(timeBoundaryManager.getTimeBoundaryInfo(), timeUnit.convert(99, TimeUnit.DAYS)); | ||
| } | ||
|
|
||
| private void testHourlyPushTable(String rawTableName, TableConfig tableConfig, TimeUnit timeUnit) { | ||
| // NOTE: External view and ideal state are not used in the current implementation. | ||
| ExternalView externalView = Mockito.mock(ExternalView.class); | ||
| IdealState idealState = Mockito.mock(IdealState.class); | ||
| IdealState idealState = new IdealState(""); | ||
|
|
||
| TimeBoundaryManager timeBoundaryManager = new TimeBoundaryManager(tableConfig, _propertyStore); | ||
| TimeBoundaryManager timeBoundaryManager = | ||
| new TimeBoundaryManager(tableConfig, _propertyStore, Mockito.mock(BrokerMetrics.class)); | ||
| Set<String> onlineSegments = new HashSet<>(); | ||
| String segment0 = "segment0"; | ||
| onlineSegments.add(segment0); | ||
|
|
@@ -192,6 +214,17 @@ private void testHourlyPushTable(String rawTableName, TableConfig tableConfig, T | |
| expectedTimeValue = timeUnit.convert(47, TimeUnit.HOURS); | ||
| } | ||
| verifyTimeBoundaryInfo(timeBoundaryManager.getTimeBoundaryInfo(), expectedTimeValue); | ||
|
|
||
| // Setting the enforced time boundary in ideal state should update the time boundary | ||
| idealState.getRecord().setSimpleField(CommonConstants.IdealState.HYBRID_TABLE_TIME_BOUNDARY, | ||
| Long.toString(TimeUnit.MILLISECONDS.convert(50, TimeUnit.HOURS))); | ||
| timeBoundaryManager.onAssignmentChange(idealState, externalView, onlineSegments); | ||
| verifyTimeBoundaryInfo(timeBoundaryManager.getTimeBoundaryInfo(), timeUnit.convert(50, TimeUnit.HOURS)); | ||
|
|
||
| // Unsetting the enforced time boundary should change it back to original time boundary | ||
| idealState.getRecord().getSimpleFields().remove(CommonConstants.IdealState.HYBRID_TABLE_TIME_BOUNDARY); | ||
| timeBoundaryManager.onAssignmentChange(idealState, externalView, onlineSegments); | ||
| verifyTimeBoundaryInfo(timeBoundaryManager.getTimeBoundaryInfo(), expectedTimeValue); | ||
| } | ||
|
|
||
| private TableConfig getTableConfig(String rawTableName, String pushFrequency) { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...n/src/main/java/org/apache/pinot/common/restlet/resources/TableSegmentValidationInfo.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| /** | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you 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 org.apache.pinot.common.restlet.resources; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonCreator; | ||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
|
||
|
|
||
| public class TableSegmentValidationInfo { | ||
| private final boolean _valid; | ||
| private final long _maxEndTimeMs; | ||
|
|
||
| @JsonCreator | ||
| public TableSegmentValidationInfo(@JsonProperty("valid") boolean valid, | ||
| @JsonProperty("maxEndTimeMs") long maxEndTimeMs) { | ||
| _valid = valid; | ||
| _maxEndTimeMs = maxEndTimeMs; | ||
| } | ||
|
|
||
| public boolean isValid() { | ||
| return _valid; | ||
| } | ||
|
|
||
| public long getMaxEndTimeMs() { | ||
| return _maxEndTimeMs; | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be marked @volatile
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't need to be because it is always under the synchronized block. Maybe worth adding a comment