jinmeiliao commented on a change in pull request #5348:
URL: https://github.com/apache/geode/pull/5348#discussion_r466542979
##########
File path:
geode-core/src/main/java/org/apache/geode/management/internal/beans/GatewaySenderMBeanBridge.java
##########
@@ -334,4 +334,8 @@ public boolean isConnected() {
public int getEventsExceedingAlertThreshold() {
return
getStatistic(StatsKey.GATEWAYSENDER_EVENTS_EXCEEDING_ALERT_THRESHOLD).intValue();
}
+
Review comment:
no need
##########
File path:
geode-core/src/main/java/org/apache/geode/management/GatewaySenderMXBean.java
##########
@@ -273,6 +273,8 @@
*/
int getEventsExceedingAlertThreshold();
-
-
+ /**
Review comment:
you don't need these methods in the mbeans anymore
##########
File path:
geode-core/src/main/java/org/apache/geode/management/internal/beans/GatewaySenderMBean.java
##########
@@ -241,4 +241,9 @@ public boolean isConnected() {
public int getEventsExceedingAlertThreshold() {
return bridge.getEventsExceedingAlertThreshold();
}
+
Review comment:
no need for this
##########
File path:
geode-core/src/main/java/org/apache/geode/management/internal/configuration/functions/GatewaySenderManageFunction.java
##########
@@ -0,0 +1,148 @@
+/*
+ * 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.configuration.functions;
+
+import org.apache.logging.log4j.Logger;
+
+import org.apache.geode.annotations.Immutable;
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.execute.FunctionContext;
+import org.apache.geode.cache.wan.GatewaySender;
+import org.apache.geode.internal.cache.execute.InternalFunction;
+import org.apache.geode.internal.cache.xmlcache.CacheXml;
+import org.apache.geode.logging.internal.log4j.api.LogService;
+import org.apache.geode.management.internal.configuration.domain.XmlEntity;
+import org.apache.geode.management.internal.functions.CliFunctionResult;
+
+public class GatewaySenderManageFunction implements InternalFunction {
+ private static final Logger logger = LogService.getLogger();
+ private static final long serialVersionUID = -6022504778575202026L;
+
+ @Immutable
+ public static final GatewaySenderManageFunction INSTANCE = new
GatewaySenderManageFunction();
+
+ private static final String ID = GatewaySenderManageFunction.class.getName();
+
+ @Override
+ public boolean hasResult() {
+ return true;
+ }
+
+
+ /**
+ * This function is used to report all the gateway sender instances for a
given sender
+ * if all intances are stopped. In order to do so, it invokes the
setMustQueueDroppedEvents()
+ * method
+ * on every gateway sender instance for the gateway sender passed as a
parameter.
+ * The function requires an Object[] as context.getArguments() in which
+ * - the first parameter must be a Boolean stating of all gateway sender
instances are stopped
+ * - the second parameter must be a String containing the name of the sender.
+ */
+ @Override
+ public void execute(FunctionContext context) {
+ String memberName = context.getMemberName();
+ try {
+ Object[] arguments;
+
+ Boolean stop = getStopFromArguments(context.getArguments());
+ if (stop == null) {
+ context.getResultSender().lastResult(new CliFunctionResult("", false,
+ "Wrong arguments passed"));
+ return;
+ }
+ String senderId = getSenderIdFromArguments(context.getArguments());
+ if (senderId == null) {
+ context.getResultSender().lastResult(new CliFunctionResult("", false,
+ "Wrong arguments passed"));
+ return;
+ }
+
+ Cache cache = context.getCache();
+ GatewaySender sender = cache.getGatewaySender(senderId);
+
+ if (sender == null) {
+ context.getResultSender().lastResult(new CliFunctionResult(memberName,
false,
+ String.format("Sender '%s' does not exist", senderId)));
+ return;
+ }
+
+ sender.setMustQueueDroppedEvents(!stop);
+ XmlEntity xmlEntity = new XmlEntity(CacheXml.GATEWAY_SENDER, "name",
senderId);
Review comment:
a good example to use is `CreateDiskStoreFunction`, that one extends
CliFunction which handles the exceptions for you.
##########
File path:
geode-core/src/main/java/org/apache/geode/management/internal/configuration/functions/GatewaySenderManageFunction.java
##########
@@ -0,0 +1,148 @@
+/*
+ * 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.configuration.functions;
+
+import org.apache.logging.log4j.Logger;
+
+import org.apache.geode.annotations.Immutable;
+import org.apache.geode.cache.Cache;
+import org.apache.geode.cache.execute.FunctionContext;
+import org.apache.geode.cache.wan.GatewaySender;
+import org.apache.geode.internal.cache.execute.InternalFunction;
+import org.apache.geode.internal.cache.xmlcache.CacheXml;
+import org.apache.geode.logging.internal.log4j.api.LogService;
+import org.apache.geode.management.internal.configuration.domain.XmlEntity;
+import org.apache.geode.management.internal.functions.CliFunctionResult;
+
+public class GatewaySenderManageFunction implements InternalFunction {
+ private static final Logger logger = LogService.getLogger();
+ private static final long serialVersionUID = -6022504778575202026L;
+
+ @Immutable
+ public static final GatewaySenderManageFunction INSTANCE = new
GatewaySenderManageFunction();
+
+ private static final String ID = GatewaySenderManageFunction.class.getName();
+
+ @Override
+ public boolean hasResult() {
+ return true;
+ }
+
+
+ /**
+ * This function is used to report all the gateway sender instances for a
given sender
+ * if all intances are stopped. In order to do so, it invokes the
setMustQueueDroppedEvents()
+ * method
+ * on every gateway sender instance for the gateway sender passed as a
parameter.
+ * The function requires an Object[] as context.getArguments() in which
+ * - the first parameter must be a Boolean stating of all gateway sender
instances are stopped
+ * - the second parameter must be a String containing the name of the sender.
+ */
+ @Override
+ public void execute(FunctionContext context) {
+ String memberName = context.getMemberName();
+ try {
+ Object[] arguments;
+
+ Boolean stop = getStopFromArguments(context.getArguments());
+ if (stop == null) {
+ context.getResultSender().lastResult(new CliFunctionResult("", false,
+ "Wrong arguments passed"));
+ return;
+ }
+ String senderId = getSenderIdFromArguments(context.getArguments());
+ if (senderId == null) {
+ context.getResultSender().lastResult(new CliFunctionResult("", false,
+ "Wrong arguments passed"));
+ return;
+ }
+
+ Cache cache = context.getCache();
+ GatewaySender sender = cache.getGatewaySender(senderId);
+
+ if (sender == null) {
+ context.getResultSender().lastResult(new CliFunctionResult(memberName,
false,
+ String.format("Sender '%s' does not exist", senderId)));
+ return;
+ }
+
+ sender.setMustQueueDroppedEvents(!stop);
+ XmlEntity xmlEntity = new XmlEntity(CacheXml.GATEWAY_SENDER, "name",
senderId);
Review comment:
I don't think you need to modify the cache xml for this flag, there is
no need to send this back to the command. All this function does is to turn
on/off this flag and report the sucess/failure back to the command.
----------------------------------------------------------------
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]