This articles talks about steps involved in adding a gfsh command for a Geode feature that can be operated using Gfsh.
Its still under work...
Needs to be added.
Adding new parameter to existing command
Here we are using implementation of new api "ignoreEvictionAndExpiration()" with AsyncEventQueue as an example.
Changes to commands set
All Gfsh commands are listed in QueueCommands class file.
Open "geode-core/src/main/java/com/gemstone/gemfire/management/cli/commands/QueueCommands.java"
Look for @CliOption
Add the new parameter (copy/paste one of the existing command and change it to reflect new command)
E.g:
@CliOption(key = CliStrings.CREATE_ASYNC_EVENT_QUEUE__IGNORE_EVICTION_EXPIRATION,
unspecifiedDefaultValue = "true",
specifiedDefaultValue = "true",
help = CliStrings.CREATE_ASYNC_EVENT_QUEUE__IGNORE_EVICTION_EXPIRATION__HELP)
Boolean ignoreEvictionAndExpiration,
CliUtil.executeFunction() — Make changes to pass new argument.
ResultCollector<?, ?> rc = CliUtil.executeFunction(new CreateAsyncEventQueueFunction(),
new Object[] { id, parallel, enableBatchConflation, batchSize,batchTimeInterval,
persistent, diskStore, diskSynchronous, maxQueueMemory, dispatcherThreads, orderPolicy,
gatewayEventFilters, gatewaySubstitutionListener, listener, listenerProperties,
ignoreEvictionAndExpiration},
targetMembers);
geode-core/src/main/java/com/gemstone/gemfire/management/internal/web/controllers/commands/QueueCommands.java
@RequestParam(value = CliStrings.CREATE_ASYNC_EVENT_QUEUE__IGNORE_EVICTION_EXPIRATION, defaultValue = "true") final Boolean isIgnoreEvictionAndExpiration,
cli/i18n/CliStrings.java
Add the new option command and help content.
public static final String CREATE_ASYNC_EVENT_QUEUE__IGNORE_EVICTION_EXPIRATION = "ignore-eviction-expiration";
public static final String CREATE_ASYNC_EVENT_QUEUE__IGNORE_EVICTION_EXPIRATION__HELP = "Whether to ignore eviction and expiration events.";
Make changes to function call:
geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/functions/CreateAsyncEventQueueFunction.java
read the args and use it.
final boolean ignoreEvictionAndExpiration = (Boolean) args[15];
asyncEventQueueFactory.setIgnoreEvictionAndExpiration(ignoreEvictionAndExpiration);
geode-core/src/main/java/com/gemstone/gemfire/management/cli/commands/QueueCommandsDUnitTest.java
src/test/java/com/com/gemstone/gemfire/management/internal/configuration/SharedConfigurationEndToEndDUnitTest.java
public static ResultCollector<?, ?> executeFunction(final Function function, Object args , final Set<DistributedMember> targetMembers) {
Execution execution = null;
if (args != null) {
execution = FunctionService.onMembers(targetMembers).withArgs(args);
} else {
execution = FunctionService.onMembers(targetMembers);
}
((AbstractExecution) execution).setIgnoreDepartedMembers(true);
return execution.execute(function);
}
geode-core/src/main/java/com/gemstone/gemfire/management/internal/web/controllers/QueueCommandsController.java
command.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__IGNORE_EVICTION_EXPIRATION, String.valueOf(isIgnoreEvictionAndExpiration));