-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Enhance SegmentStatusChecker to honor no-queryable servers and instance assignment config #14536
Changes from all commits
87308b4
1f10cbf
28df5a8
d77cc4e
bf098d3
d5d5973
7ef229c
eec01cc
57e8bdc
bbba882
d49e8ab
9007e0a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,95 @@ | ||||||||
/** | ||||||||
* 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.controller.util; | ||||||||
|
||||||||
import java.util.HashMap; | ||||||||
import java.util.List; | ||||||||
import java.util.Map; | ||||||||
import javax.annotation.Nullable; | ||||||||
import org.apache.helix.model.InstanceConfig; | ||||||||
import org.apache.helix.zookeeper.datamodel.ZNRecord; | ||||||||
import org.apache.pinot.controller.helix.core.PinotHelixResourceManager; | ||||||||
import org.apache.pinot.spi.utils.CommonConstants; | ||||||||
import org.apache.pinot.spi.utils.InstanceTypeUtils; | ||||||||
|
||||||||
|
||||||||
/** | ||||||||
* This is a helper class that fetch server information from Helix/ZK. It caches the server information to avoid | ||||||||
* repeated ZK access. This class is NOT thread-safe. | ||||||||
*/ | ||||||||
public class ServerQueryInfoFetcher { | ||||||||
private final PinotHelixResourceManager _pinotHelixResourceManager; | ||||||||
private final Map<String, ServerQueryInfo> _cache; | ||||||||
|
||||||||
public ServerQueryInfoFetcher(PinotHelixResourceManager pinotHelixResourceManager) { | ||||||||
_pinotHelixResourceManager = pinotHelixResourceManager; | ||||||||
_cache = new HashMap<>(); | ||||||||
} | ||||||||
|
||||||||
@Nullable | ||||||||
public ServerQueryInfo getServerQueryInfo(String instanceId) { | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Annotate the return as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||||||||
return _cache.computeIfAbsent(instanceId, this::getServerQueryInfoOndemand); | ||||||||
} | ||||||||
|
||||||||
@Nullable | ||||||||
private ServerQueryInfo getServerQueryInfoOndemand(String instanceId) { | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||||||||
InstanceConfig instanceConfig = _pinotHelixResourceManager.getHelixInstanceConfig(instanceId); | ||||||||
if (instanceConfig == null || !InstanceTypeUtils.isServer(instanceId)) { | ||||||||
return null; | ||||||||
} | ||||||||
List<String> tags = instanceConfig.getTags(); | ||||||||
ZNRecord record = instanceConfig.getRecord(); | ||||||||
boolean helixEnabled = instanceConfig.getInstanceEnabled(); | ||||||||
boolean queriesDisabled = record.getBooleanField(CommonConstants.Helix.QUERIES_DISABLED, false); | ||||||||
boolean shutdownInProgress = record.getBooleanField(CommonConstants.Helix.IS_SHUTDOWN_IN_PROGRESS, false); | ||||||||
|
||||||||
return new ServerQueryInfo(instanceId, tags, null, helixEnabled, queriesDisabled, shutdownInProgress); | ||||||||
} | ||||||||
|
||||||||
public static class ServerQueryInfo { | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We shouldn't need setters for this class, and we can make all fields There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems most of the fields are not used. Are you planning to use them? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, @jasperjiaguo will need those fields very soon |
||||||||
private final String _instanceName; | ||||||||
private final List<String> _tags; | ||||||||
private final List<String> _tables; | ||||||||
private final boolean _helixEnabled; | ||||||||
private final boolean _queriesDisabled; | ||||||||
private final boolean _shutdownInProgress; | ||||||||
|
||||||||
private ServerQueryInfo(String instanceName, List<String> tags, List<String> tables, boolean helixEnabled, | ||||||||
boolean queriesDisabled, boolean shutdownInProgress) { | ||||||||
_instanceName = instanceName; | ||||||||
_tags = tags; | ||||||||
_tables = tables; | ||||||||
_helixEnabled = helixEnabled; | ||||||||
_queriesDisabled = queriesDisabled; | ||||||||
_shutdownInProgress = shutdownInProgress; | ||||||||
} | ||||||||
|
||||||||
public boolean isHelixEnabled() { | ||||||||
return _helixEnabled; | ||||||||
} | ||||||||
|
||||||||
public boolean isQueriesDisabled() { | ||||||||
return _queriesDisabled; | ||||||||
} | ||||||||
|
||||||||
public boolean isShutdownInProgress() { | ||||||||
return _shutdownInProgress; | ||||||||
} | ||||||||
} | ||||||||
} |
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.
@sajjad-moradi This log need to be deleted, as
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.
Can we add some new logging instead? Meanwhile, it would be great if we have a list of segments having min replicas and print them out as well? I feel sometimes the debuggability of alerts on this metric is not so great.nvm [L388-L392] should be good