-
Notifications
You must be signed in to change notification settings - Fork 5.5k
A new end point to get resource group stats #14177
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
Changes from all commits
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 |
|---|---|---|
|
|
@@ -87,6 +87,7 @@ public class InternalResourceGroup | |
| private final ResourceGroupId id; | ||
| private final BiConsumer<InternalResourceGroup, Boolean> jmxExportListener; | ||
| private final Executor executor; | ||
| private final boolean staticResourceGroup; | ||
|
|
||
| // Configuration | ||
| // ============= | ||
|
|
@@ -140,7 +141,12 @@ public class InternalResourceGroup | |
| @GuardedBy("root") | ||
| private final CounterStat timeBetweenStartsSec = new CounterStat(); | ||
|
|
||
| protected InternalResourceGroup(Optional<InternalResourceGroup> parent, String name, BiConsumer<InternalResourceGroup, Boolean> jmxExportListener, Executor executor) | ||
| protected InternalResourceGroup( | ||
| Optional<InternalResourceGroup> parent, | ||
| String name, | ||
| BiConsumer<InternalResourceGroup, Boolean> jmxExportListener, | ||
| Executor executor, | ||
| boolean staticResourceGroup) | ||
| { | ||
| this.parent = requireNonNull(parent, "parent is null"); | ||
| this.jmxExportListener = requireNonNull(jmxExportListener, "jmxExportListener is null"); | ||
|
|
@@ -154,9 +160,10 @@ protected InternalResourceGroup(Optional<InternalResourceGroup> parent, String n | |
| id = new ResourceGroupId(name); | ||
| root = this; | ||
| } | ||
| this.staticResourceGroup = staticResourceGroup; | ||
| } | ||
|
|
||
| public ResourceGroupInfo getFullInfo() | ||
| public ResourceGroupInfo getResourceGroupInfo(boolean includeQueryInfo, boolean summarizeSubgroups, boolean includeStaticSubgroupsOnly) | ||
| { | ||
| synchronized (root) { | ||
| return new ResourceGroupInfo( | ||
|
|
@@ -174,9 +181,10 @@ public ResourceGroupInfo getFullInfo() | |
| eligibleSubGroups.size(), | ||
| subGroups.values().stream() | ||
| .filter(group -> group.getRunningQueries() + group.getQueuedQueries() > 0) | ||
| .map(InternalResourceGroup::getSummaryInfo) | ||
| .filter(group -> !includeStaticSubgroupsOnly || group.isStaticResourceGroup()) | ||
| .map(group -> summarizeSubgroups ? group.getSummaryInfo() : group.getResourceGroupInfo(includeQueryInfo, false, includeStaticSubgroupsOnly)) | ||
| .collect(toImmutableList()), | ||
| getAggregatedRunningQueriesInfo()); | ||
| includeQueryInfo ? getAggregatedRunningQueriesInfo() : null); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -225,6 +233,11 @@ private ResourceGroupInfo getSummaryInfo() | |
| } | ||
| } | ||
|
|
||
| boolean isStaticResourceGroup() | ||
| { | ||
| return staticResourceGroup; | ||
| } | ||
|
|
||
| private ResourceGroupState getState() | ||
| { | ||
| synchronized (root) { | ||
|
|
@@ -565,15 +578,22 @@ public void setJmxExport(boolean export) | |
| jmxExportListener.accept(this, export); | ||
| } | ||
|
|
||
| public InternalResourceGroup getOrCreateSubGroup(String name) | ||
| public InternalResourceGroup getOrCreateSubGroup(String name, boolean staticSegment) | ||
|
Contributor
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. i think this should have been named as |
||
| { | ||
| requireNonNull(name, "name is null"); | ||
| synchronized (root) { | ||
| checkArgument(runningQueries.isEmpty() && queuedQueries.isEmpty(), "Cannot add sub group to %s while queries are running", id); | ||
| if (subGroups.containsKey(name)) { | ||
| return subGroups.get(name); | ||
| } | ||
| InternalResourceGroup subGroup = new InternalResourceGroup(Optional.of(this), name, jmxExportListener, executor); | ||
| // parent segments size equals to subgroup segment index | ||
| int subGroupSegmentIndex = id.getSegments().size(); | ||
| InternalResourceGroup subGroup = new InternalResourceGroup( | ||
| Optional.of(this), | ||
| name, | ||
| jmxExportListener, | ||
| executor, | ||
| staticResourceGroup && staticSegment); | ||
| // Sub group must use query priority to ensure ordering | ||
| if (schedulingPolicy == QUERY_PRIORITY) { | ||
| subGroup.setSchedulingPolicy(QUERY_PRIORITY); | ||
|
|
@@ -941,9 +961,12 @@ public static final class RootInternalResourceGroup | |
| { | ||
| private AtomicBoolean taskLimitExceeded = new AtomicBoolean(); | ||
|
|
||
| public RootInternalResourceGroup(String name, BiConsumer<InternalResourceGroup, Boolean> jmxExportListener, Executor executor) | ||
| public RootInternalResourceGroup( | ||
| String name, | ||
| BiConsumer<InternalResourceGroup, Boolean> jmxExportListener, | ||
| Executor executor) | ||
| { | ||
| super(Optional.empty(), name, jmxExportListener, executor); | ||
| super(Optional.empty(), name, jmxExportListener, executor, true); | ||
|
Contributor
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. Why is this
Member
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. I guess the root resource group is always static
Contributor
Author
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! |
||
| } | ||
|
|
||
| public synchronized void processQueuedQueries() | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,6 +44,7 @@ | |
| import java.util.HashMap; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.OptionalInt; | ||
| import java.util.concurrent.ConcurrentHashMap; | ||
| import java.util.concurrent.ConcurrentMap; | ||
| import java.util.concurrent.CopyOnWriteArrayList; | ||
|
|
@@ -103,10 +104,10 @@ public InternalResourceGroupManager( | |
| } | ||
|
|
||
| @Override | ||
| public ResourceGroupInfo getResourceGroupInfo(ResourceGroupId id) | ||
| public ResourceGroupInfo getResourceGroupInfo(ResourceGroupId id, boolean includeQueryInfo, boolean summarizeSubgroups, boolean includeStaticSubgroupsOnly) | ||
|
Contributor
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.
|
||
| { | ||
| checkArgument(groups.containsKey(id), "Group %s does not exist", id); | ||
| return groups.get(id).getFullInfo(); | ||
| return groups.get(id).getResourceGroupInfo(includeQueryInfo, summarizeSubgroups, includeStaticSubgroupsOnly); | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -239,7 +240,9 @@ private synchronized void createGroupIfNecessary(SelectionContext<C> context, Ex | |
| createGroupIfNecessary(new SelectionContext<>(id.getParent().get(), context.getContext()), executor); | ||
| InternalResourceGroup parent = groups.get(id.getParent().get()); | ||
| requireNonNull(parent, "parent is null"); | ||
| group = parent.getOrCreateSubGroup(id.getLastSegment()); | ||
| // parent segments size equals to subgroup segment index | ||
| int subGroupSegmentIndex = parent.getId().getSegments().size(); | ||
| group = parent.getOrCreateSubGroup(id.getLastSegment(), !context.getFirstDynamicSegmentPosition().equals(OptionalInt.of(subGroupSegmentIndex))); | ||
| } | ||
| else { | ||
| RootInternalResourceGroup root = new RootInternalResourceGroup(id.getSegments().get(0), this::exportGroup, executor); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.