[
https://issues.apache.org/jira/browse/GEODE-3961?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16248069#comment-16248069
]
ASF GitHub Bot commented on GEODE-3961:
---------------------------------------
jinmeiliao commented on a change in pull request #1046: GEODE-3961: Refactor
ShowMetricsCommand to behave uniformly...
URL: https://github.com/apache/geode/pull/1046#discussion_r150344376
##########
File path:
geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ShowMetricsInterceptor.java
##########
@@ -0,0 +1,111 @@
+/*
+ * 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.geode.management.internal.cli.commands;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import org.apache.commons.lang.StringUtils;
+
+import org.apache.geode.management.cli.Result;
+import org.apache.geode.management.internal.cli.AbstractCliAroundInterceptor;
+import org.apache.geode.management.internal.cli.GfshParseResult;
+import
org.apache.geode.management.internal.cli.commands.ShowMetricsCommand.Category;
+import org.apache.geode.management.internal.cli.i18n.CliStrings;
+import org.apache.geode.management.internal.cli.result.CommandResult;
+import org.apache.geode.management.internal.cli.result.ResultBuilder;
+
+public class ShowMetricsInterceptor extends AbstractCliAroundInterceptor {
+ @Override
+ public Result preExecution(GfshParseResult parseResult) {
+ String export_to_report_to =
parseResult.getParamValueAsString(CliStrings.SHOW_METRICS__FILE);
+ if (export_to_report_to != null && !export_to_report_to.endsWith(".csv")) {
+ return ResultBuilder
+
.createUserErrorResult(CliStrings.format(CliStrings.INVALID_FILE_EXTENSION,
".csv"));
+ }
+
+ String regionName =
parseResult.getParamValueAsString(CliStrings.SHOW_METRICS__REGION);
+ String port =
parseResult.getParamValueAsString(CliStrings.SHOW_METRICS__CACHESERVER__PORT);
+ String member = parseResult.getParamValueAsString(CliStrings.MEMBER);
+ String[] categoryArgs = (String[])
parseResult.getParamValue(CliStrings.SHOW_METRICS__CATEGORY);
+
+ if (StringUtils.isNotEmpty(port) && !StringUtils.isNumeric(port)) {
Review comment:
you can declare the port in the option as Integer, that way, the parser will
validate it to be an integer for you.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Show metrics disregards specified --categories for CacheServer (--port option
> related) metrics
> -----------------------------------------------------------------------------------------------
>
> Key: GEODE-3961
> URL: https://issues.apache.org/jira/browse/GEODE-3961
> Project: Geode
> Issue Type: Bug
> Reporter: Patrick Rhomberg
>
> Those CacheServer metric categories ({{query}}, {{notification}}, and
> {{cache-server}}) are not checked against those categories specified by the
> user and are only checked against the cache server bean being non-null
> (implicitly: that the port was provided and valid).
> For unification and consistency, these categories should not be displayed
> when the {{--categories}} option is specified and excludes them.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)