ololo3000 commented on a change in pull request #8284: URL: https://github.com/apache/ignite/pull/8284#discussion_r499007041
########## File path: modules/core/src/main/java/org/apache/ignite/internal/visor/metric/VisorMetricTask.java ########## @@ -0,0 +1,130 @@ +/* + * 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.visor.metric; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import org.apache.ignite.IgniteException; +import org.apache.ignite.internal.processors.metric.GridMetricManager; +import org.apache.ignite.internal.processors.task.GridInternal; +import org.apache.ignite.internal.processors.task.GridVisorManagementTask; +import org.apache.ignite.internal.visor.VisorJob; +import org.apache.ignite.internal.visor.VisorOneNodeTask; +import org.apache.ignite.spi.metric.BooleanMetric; +import org.apache.ignite.spi.metric.DoubleMetric; +import org.apache.ignite.spi.metric.IntMetric; +import org.apache.ignite.spi.metric.LongMetric; +import org.apache.ignite.spi.metric.Metric; +import org.apache.ignite.spi.metric.ObjectMetric; +import org.apache.ignite.spi.metric.ReadOnlyMetricRegistry; +import org.jetbrains.annotations.Nullable; + +import static org.apache.ignite.internal.processors.metric.impl.MetricUtils.SEPARATOR; +import static org.apache.ignite.spi.metric.jmx.MetricRegistryMBean.searchHistogram; + +/** Reperesents visor task for obtaining metric values. */ +@GridInternal +@GridVisorManagementTask +public class VisorMetricTask extends VisorOneNodeTask<VisorMetricTaskArg, Map<String, ?>> { + /** */ + private static final long serialVersionUID = 0L; + + /** {@inheritDoc} */ + @Override protected VisorJob<VisorMetricTaskArg, Map<String, ?>> job(VisorMetricTaskArg arg) { + return new VisorMetricJob(arg, false); + } + + /** */ + private static class VisorMetricJob extends VisorJob<VisorMetricTaskArg, Map<String, ?>> { + /** */ + private static final long serialVersionUID = 0L; + + /** + * Create job with specified argument. + * + * @param arg Job argument. + * @param debug Flag indicating whether debug information should be printed into node log. + */ + protected VisorMetricJob(@Nullable VisorMetricTaskArg arg, boolean debug) { + super(arg, debug); + } + + /** {@inheritDoc} */ + @Override protected Map<String, ?> run(@Nullable VisorMetricTaskArg arg) throws IgniteException { + String name = arg.name(); + + GridMetricManager mMgr = ignite.context().metric(); Review comment: Done. ########## File path: modules/core/src/main/java/org/apache/ignite/internal/visor/metric/VisorMetricTask.java ########## @@ -0,0 +1,130 @@ +/* + * 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.visor.metric; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import org.apache.ignite.IgniteException; +import org.apache.ignite.internal.processors.metric.GridMetricManager; +import org.apache.ignite.internal.processors.task.GridInternal; +import org.apache.ignite.internal.processors.task.GridVisorManagementTask; +import org.apache.ignite.internal.visor.VisorJob; +import org.apache.ignite.internal.visor.VisorOneNodeTask; +import org.apache.ignite.spi.metric.BooleanMetric; +import org.apache.ignite.spi.metric.DoubleMetric; +import org.apache.ignite.spi.metric.IntMetric; +import org.apache.ignite.spi.metric.LongMetric; +import org.apache.ignite.spi.metric.Metric; +import org.apache.ignite.spi.metric.ObjectMetric; +import org.apache.ignite.spi.metric.ReadOnlyMetricRegistry; +import org.jetbrains.annotations.Nullable; + +import static org.apache.ignite.internal.processors.metric.impl.MetricUtils.SEPARATOR; +import static org.apache.ignite.spi.metric.jmx.MetricRegistryMBean.searchHistogram; + +/** Reperesents visor task for obtaining metric values. */ +@GridInternal +@GridVisorManagementTask +public class VisorMetricTask extends VisorOneNodeTask<VisorMetricTaskArg, Map<String, ?>> { + /** */ + private static final long serialVersionUID = 0L; + + /** {@inheritDoc} */ + @Override protected VisorJob<VisorMetricTaskArg, Map<String, ?>> job(VisorMetricTaskArg arg) { + return new VisorMetricJob(arg, false); + } + + /** */ + private static class VisorMetricJob extends VisorJob<VisorMetricTaskArg, Map<String, ?>> { + /** */ + private static final long serialVersionUID = 0L; + + /** + * Create job with specified argument. + * + * @param arg Job argument. + * @param debug Flag indicating whether debug information should be printed into node log. + */ + protected VisorMetricJob(@Nullable VisorMetricTaskArg arg, boolean debug) { + super(arg, debug); + } + + /** {@inheritDoc} */ + @Override protected Map<String, ?> run(@Nullable VisorMetricTaskArg arg) throws IgniteException { + String name = arg.name(); + + GridMetricManager mMgr = ignite.context().metric(); + + for (ReadOnlyMetricRegistry mReg : mMgr) { Review comment: Done. ########## File path: modules/core/src/main/java/org/apache/ignite/internal/visor/metric/VisorMetricTask.java ########## @@ -0,0 +1,130 @@ +/* + * 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.visor.metric; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import org.apache.ignite.IgniteException; +import org.apache.ignite.internal.processors.metric.GridMetricManager; +import org.apache.ignite.internal.processors.task.GridInternal; +import org.apache.ignite.internal.processors.task.GridVisorManagementTask; +import org.apache.ignite.internal.visor.VisorJob; +import org.apache.ignite.internal.visor.VisorOneNodeTask; +import org.apache.ignite.spi.metric.BooleanMetric; +import org.apache.ignite.spi.metric.DoubleMetric; +import org.apache.ignite.spi.metric.IntMetric; +import org.apache.ignite.spi.metric.LongMetric; +import org.apache.ignite.spi.metric.Metric; +import org.apache.ignite.spi.metric.ObjectMetric; +import org.apache.ignite.spi.metric.ReadOnlyMetricRegistry; +import org.jetbrains.annotations.Nullable; + +import static org.apache.ignite.internal.processors.metric.impl.MetricUtils.SEPARATOR; +import static org.apache.ignite.spi.metric.jmx.MetricRegistryMBean.searchHistogram; + +/** Reperesents visor task for obtaining metric values. */ +@GridInternal +@GridVisorManagementTask +public class VisorMetricTask extends VisorOneNodeTask<VisorMetricTaskArg, Map<String, ?>> { + /** */ + private static final long serialVersionUID = 0L; + + /** {@inheritDoc} */ + @Override protected VisorJob<VisorMetricTaskArg, Map<String, ?>> job(VisorMetricTaskArg arg) { + return new VisorMetricJob(arg, false); + } + + /** */ + private static class VisorMetricJob extends VisorJob<VisorMetricTaskArg, Map<String, ?>> { + /** */ + private static final long serialVersionUID = 0L; + + /** + * Create job with specified argument. + * + * @param arg Job argument. + * @param debug Flag indicating whether debug information should be printed into node log. + */ + protected VisorMetricJob(@Nullable VisorMetricTaskArg arg, boolean debug) { + super(arg, debug); + } + + /** {@inheritDoc} */ + @Override protected Map<String, ?> run(@Nullable VisorMetricTaskArg arg) throws IgniteException { + String name = arg.name(); + + GridMetricManager mMgr = ignite.context().metric(); + + for (ReadOnlyMetricRegistry mReg : mMgr) { + String mRegName = mReg.name(); Review comment: Done. ########## File path: modules/core/src/main/java/org/apache/ignite/internal/visor/metric/VisorMetricTask.java ########## @@ -0,0 +1,130 @@ +/* + * 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.visor.metric; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import org.apache.ignite.IgniteException; +import org.apache.ignite.internal.processors.metric.GridMetricManager; +import org.apache.ignite.internal.processors.task.GridInternal; +import org.apache.ignite.internal.processors.task.GridVisorManagementTask; +import org.apache.ignite.internal.visor.VisorJob; +import org.apache.ignite.internal.visor.VisorOneNodeTask; +import org.apache.ignite.spi.metric.BooleanMetric; +import org.apache.ignite.spi.metric.DoubleMetric; +import org.apache.ignite.spi.metric.IntMetric; +import org.apache.ignite.spi.metric.LongMetric; +import org.apache.ignite.spi.metric.Metric; +import org.apache.ignite.spi.metric.ObjectMetric; +import org.apache.ignite.spi.metric.ReadOnlyMetricRegistry; +import org.jetbrains.annotations.Nullable; + +import static org.apache.ignite.internal.processors.metric.impl.MetricUtils.SEPARATOR; +import static org.apache.ignite.spi.metric.jmx.MetricRegistryMBean.searchHistogram; + +/** Reperesents visor task for obtaining metric values. */ +@GridInternal +@GridVisorManagementTask +public class VisorMetricTask extends VisorOneNodeTask<VisorMetricTaskArg, Map<String, ?>> { + /** */ + private static final long serialVersionUID = 0L; + + /** {@inheritDoc} */ + @Override protected VisorJob<VisorMetricTaskArg, Map<String, ?>> job(VisorMetricTaskArg arg) { + return new VisorMetricJob(arg, false); + } + + /** */ + private static class VisorMetricJob extends VisorJob<VisorMetricTaskArg, Map<String, ?>> { + /** */ + private static final long serialVersionUID = 0L; + + /** + * Create job with specified argument. + * + * @param arg Job argument. + * @param debug Flag indicating whether debug information should be printed into node log. + */ + protected VisorMetricJob(@Nullable VisorMetricTaskArg arg, boolean debug) { + super(arg, debug); + } + + /** {@inheritDoc} */ + @Override protected Map<String, ?> run(@Nullable VisorMetricTaskArg arg) throws IgniteException { + String name = arg.name(); + + GridMetricManager mMgr = ignite.context().metric(); + + for (ReadOnlyMetricRegistry mReg : mMgr) { + String mRegName = mReg.name(); + + if (mRegName.equals(name)) { + Map<String, Object> res = new HashMap<>(); + + mReg.forEach(metric -> res.put(metric.name(), valueOf(metric))); + + return res; + } + + String mRegPrefix = mRegName + SEPARATOR; Review comment: Done. ########## File path: modules/control-utility/src/main/java/org/apache/ignite/internal/commandline/TablePrinter.java ########## @@ -0,0 +1,149 @@ +/* + * 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.commandline; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.logging.Logger; +import java.util.stream.Collectors; +import org.apache.ignite.util.SimpleType; + +import static java.util.Collections.nCopies; +import static org.apache.ignite.util.SimpleType.DATE; +import static org.apache.ignite.util.SimpleType.NUMBER; +import static org.apache.ignite.util.SimpleType.STRING; + +/** Represents utility class for table content printing. */ +public class TablePrinter { + /** Column separator. */ + public static final String COLUMN_SEPARATOR = " "; + + /** Titles of the table columns. */ + private final List<String> titles; + + /** Types of the table columns. */ + private final List<SimpleType> types; + + /** Number of table columns. */ + private final int colsCnt; + + /** + * @param titles Titles of the table columns. Number of titles determines the number of columns in table. + * @param types Types of the table columns. + */ + public TablePrinter(List<String> titles, List<SimpleType> types) { Review comment: Done. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
