Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This articles talks about changes required to add a new gfsh command or parameter for a Geode feature (operated using Gfsh).

这份文档介绍如何在geode中增加一个gfsh命令。

1. Adding a new Gfsh command

...

IndexCommands.java contains all the similar index commandscommands for OQL index. For example:

  • list index
  • create index
  • destroy index

...

final Set<DistributedMember> targetMembers = CliUtil.findAllMatchingMembers(groups, null);
return CliUtil.executeFunction(createIndexFunction, indexInfo, targetMembers);


1.3  Example of adding Lucene List Index and create index command

In above step, we have added a text file "org.springframework.shell.core.CommandMarker" under geode-lucene/src/main/resources/META-INF/services/ directory. The text file's content is:

...

public class LuceneCreateIndexFunction extends FunctionAdapter implements InternalEntity {

...

}

 

/* Only show these commands as available when gfsh is online */

@CliAvailabilityIndicator({LuceneCliStrings.LUCENE_SEARCH_INDEX, LuceneCliStrings.LUCENE_CREATE_INDEX,

 LuceneCliStrings.LUCENE_DESCRIBE_INDEX, LuceneCliStrings.LUCENE_LIST_INDEX})

 public boolean indexCommandsAvailable() {

  return (!CliUtil.isGfshVM() || (getGfsh() != null && getGfsh().isConnectedAndReady()))

 }

1.4  Tests

For each command, need at least dunit test and junit tests. 

LuceneIndexCommandsDUnitTest.java

LuceneIndexCommandsJUnitTest.java

LuceneListIndexFunctionJUnitTest.java

LuceneCreateIndexFunctionJUnitTest.java

 

2. Adding new parameter to existing command

...

src/test/java/com/com/gemstone/gemfire/management/internal/configuration/SharedConfigurationEndToEndDUnitTest.java


 

@CliAvailabilityIndicator({LuceneCliStrings.LUCENE_SEARCH_INDEX, LuceneCliStrings.LUCENE_CREATE_INDEX,
  + LuceneCliStrings.LUCENE_DESCRIBE_INDEX, LuceneCliStrings.LUCENE_LIST_INDEX})
  + public boolean indexCommandsAvailable() {
  + return (!CliUtil.isGfshVM() || (getGfsh() != null && getGfsh().isConnectedAndReady()));
  + }