-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
IGNITE-24286 Implement recording sytemViews to perfStart report #11826
base: master
Are you sure you want to change the base?
Changes from all commits
f898b72
209eb6d
5205b66
5605eec
05363b2
8736f6a
9d19924
fb529f7
672b625
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 |
---|---|---|
|
@@ -17,13 +17,18 @@ | |
|
||
package org.apache.ignite.internal.management.performancestatistics; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import org.apache.ignite.IgniteCheckedException; | ||
import org.apache.ignite.IgniteException; | ||
import org.apache.ignite.internal.dto.IgniteDataTransferObject; | ||
import org.apache.ignite.internal.management.performancestatistics.PerformanceStatisticsCommand.PerformanceStatisticsRotateCommandArg; | ||
import org.apache.ignite.internal.management.performancestatistics.PerformanceStatisticsCommand.PerformanceStatisticsStartCommandArg; | ||
import org.apache.ignite.internal.management.performancestatistics.PerformanceStatisticsCommand.PerformanceStatisticsStatusCommandArg; | ||
import org.apache.ignite.internal.management.performancestatistics.PerformanceStatisticsCommand.PerformanceStatisticsStopCommandArg; | ||
import org.apache.ignite.internal.managers.systemview.GridSystemViewManager; | ||
import org.apache.ignite.internal.processors.performancestatistics.PerformanceStatisticsProcessor; | ||
import org.apache.ignite.internal.processors.task.GridInternal; | ||
import org.apache.ignite.internal.util.typedef.internal.U; | ||
import org.apache.ignite.internal.visor.VisorJob; | ||
|
@@ -65,7 +70,22 @@ protected PerformanceStatisticsJob(IgniteDataTransferObject arg, boolean debug) | |
@Override protected String run(IgniteDataTransferObject arg) throws IgniteException { | ||
try { | ||
if (arg instanceof PerformanceStatisticsStartCommandArg) { | ||
ignite.context().performanceStatistics().startCollectStatistics(); | ||
PerformanceStatisticsStartCommandArg startCmdArg = (PerformanceStatisticsStartCommandArg)arg; | ||
|
||
PerformanceStatisticsProcessor performanceStatisticsProc = ignite.context().performanceStatistics(); | ||
GridSystemViewManager sysViewMgr = ignite.context().systemView(); | ||
|
||
List<String> views; | ||
|
||
if (startCmdArg.allSystemViews()) { | ||
views = new ArrayList<>(); | ||
sysViewMgr.forEach(view -> views.add(view.name())); | ||
} | ||
else if (startCmdArg.systemViews() != null) views = List.of(startCmdArg.systemViews()); | ||
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. Block of code after condition should be on own line |
||
else views = Collections.emptyList(); | ||
|
||
performanceStatisticsProc.addSystemViews(views); | ||
performanceStatisticsProc.startCollectStatistics(); | ||
|
||
return "Started."; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,13 +20,15 @@ | |
import java.util.LinkedHashMap; | ||
import java.util.Map; | ||
import java.util.regex.Pattern; | ||
import org.apache.ignite.internal.managers.systemview.GridSystemViewManager; | ||
import org.apache.ignite.internal.processors.metric.GridMetricManager; | ||
import org.apache.ignite.internal.util.typedef.F; | ||
import org.apache.ignite.internal.util.typedef.T2; | ||
import org.apache.ignite.metric.MetricRegistry; | ||
import org.apache.ignite.spi.metric.HistogramMetric; | ||
import org.apache.ignite.spi.systemview.view.SystemView; | ||
import org.apache.ignite.spi.systemview.view.SystemViewRowAttributeWalker; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import static org.apache.ignite.internal.processors.cache.CacheGroupMetricsImpl.CACHE_GROUP_METRICS_PREFIX; | ||
import static org.apache.ignite.internal.processors.cache.CacheMetricsImpl.CACHE_METRICS; | ||
|
@@ -234,4 +236,29 @@ public static Map<String, Class<?>> systemViewAttributes(SystemView<?> sysView) | |
|
||
return attrs; | ||
} | ||
|
||
/** | ||
* Extract system view from systemViewManager. Both "SQL" and "Java" styles of system view name are supported. | ||
* | ||
* @param systemViewManager Manager to extract view from. | ||
* @param viewName System view name. | ||
* @return System view with viewName. Null if the view does not exist. | ||
*/ | ||
@Nullable public static SystemView<?> getSystemViewByName(GridSystemViewManager systemViewManager, String viewName) { | ||
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 don't use prefixes like |
||
SystemView<?> view = systemViewManager.view(viewName); | ||
if (view != null) | ||
return view; | ||
|
||
if (view == null) { | ||
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. At this line view is always |
||
for (SystemView<?> sysView : systemViewManager) { | ||
if (toSqlName(sysView.name()).equalsIgnoreCase(viewName)) { | ||
view = sysView; | ||
|
||
break; | ||
} | ||
} | ||
} | ||
|
||
return view; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* 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.ignite.internal.processors.performancestatistics; | ||
|
||
import java.util.Map; | ||
import java.util.Objects; | ||
import org.apache.ignite.spi.systemview.view.SystemViewRowAttributeWalker; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
/** Fullfill {@code data} Map for specific row. */ | ||
class AttributeToMapVisitor implements SystemViewRowAttributeWalker.AttributeWithValueVisitor { | ||
/** Map to store data. */ | ||
private Map<String, String> data; | ||
|
||
/** | ||
* Sets map. | ||
* | ||
* @param data Map to fill. | ||
*/ | ||
public void data(Map<String, String> data) { | ||
this.data = data; | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override public <T> void accept(int idx, String name, Class<T> clazz, @Nullable T val) { | ||
data.put(name, Objects.toString(val)); | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override public void acceptBoolean(int idx, String name, boolean val) { | ||
data.put(name, String.valueOf(val)); | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override public void acceptChar(int idx, String name, char val) { | ||
data.put(name, String.valueOf(val)); | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override public void acceptByte(int idx, String name, byte val) { | ||
data.put(name, String.valueOf(val)); | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override public void acceptShort(int idx, String name, short val) { | ||
data.put(name, String.valueOf(val)); | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override public void acceptInt(int idx, String name, int val) { | ||
data.put(name, String.valueOf(val)); | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override public void acceptLong(int idx, String name, long val) { | ||
data.put(name, String.valueOf(val)); | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override public void acceptFloat(int idx, String name, float val) { | ||
data.put(name, String.valueOf(val)); | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override public void acceptDouble(int idx, String name, double val) { | ||
data.put(name, String.valueOf(val)); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,7 @@ | |
import static org.apache.ignite.internal.processors.performancestatistics.OperationType.QUERY_PROPERTY; | ||
import static org.apache.ignite.internal.processors.performancestatistics.OperationType.QUERY_READS; | ||
import static org.apache.ignite.internal.processors.performancestatistics.OperationType.QUERY_ROWS; | ||
import static org.apache.ignite.internal.processors.performancestatistics.OperationType.SYSYTEM_VIEW; | ||
import static org.apache.ignite.internal.processors.performancestatistics.OperationType.TASK; | ||
import static org.apache.ignite.internal.processors.performancestatistics.OperationType.TX_COMMIT; | ||
import static org.apache.ignite.internal.processors.performancestatistics.OperationType.cacheOperation; | ||
|
@@ -292,6 +293,33 @@ else if (opType == QUERY) { | |
|
||
return true; | ||
} | ||
else if (opType == SYSYTEM_VIEW) { | ||
String viewName = readCacheableString(buf); | ||
if (viewName == null) | ||
return false; | ||
|
||
if (buf.remaining() < 4) | ||
return false; | ||
int attrsNumber = buf.getInt(); | ||
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. Add NL before |
||
|
||
Map<String, String> data = new HashMap<>(); | ||
for (int i = 0; i < attrsNumber; i++) { | ||
String key = readCacheableString(buf); | ||
if (key == null) | ||
return false; | ||
|
||
String val = readCacheableString(buf); | ||
if (val == null) | ||
return false; | ||
|
||
data.put(key, val); | ||
} | ||
|
||
for (PerformanceStatisticsHandler hnd : curHnd) | ||
hnd.systemView(nodeId, viewName, data); | ||
|
||
return true; | ||
} | ||
else if (opType == QUERY_READS) { | ||
if (buf.remaining() < queryReadsRecordSize()) | ||
return false; | ||
|
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.
Do we actually need to provide options here? Why just collecting all views is not a default behavior?