Class GfshCommand

java.lang.Object
org.apache.geode.management.cli.GfshCommand
All Implemented Interfaces:
org.apache.geode.management.internal.cli.CommandMarker
Direct Known Subclasses:
SingleGfshCommand

@Experimental @ShellComponent public abstract class GfshCommand extends Object implements org.apache.geode.management.internal.cli.CommandMarker
  • Field Details

  • Constructor Details

    • GfshCommand

      public GfshCommand()
  • Method Details

    • isOnlineCommandAvailable

      public boolean isOnlineCommandAvailable()
    • affectsClusterConfiguration

      public boolean affectsClusterConfiguration()
      For those commands that could possibly change the cluster configuration, they need to override this method to return true.
      Returns:
      whether the command may change the cluster configuration
    • authorize

      public void authorize(ResourcePermission.Resource resource, ResourcePermission.Operation operation, ResourcePermission.Target target)
    • authorize

      public void authorize(ResourcePermission.Resource resource, ResourcePermission.Operation operation, String target)
    • authorize

      public void authorize(ResourcePermission.Resource resource, ResourcePermission.Operation operation, String target, String key)
    • getCache

      public Cache getCache()
    • getManagementService

      public <T extends ManagementService> T getManagementService()
    • getConfigurationPersistenceService

      public <T extends ConfigurationPersistenceService> T getConfigurationPersistenceService()
    • getClusterManagementService

      public ClusterManagementService getClusterManagementService()
    • setCache

      public void setCache(Cache cache)
    • hasCacheSet

      public boolean hasCacheSet()
      Check if this command has a cache instance set (used for test mocking)
    • isSharedConfigurationRunning

      public boolean isSharedConfigurationRunning()
    • getSubject

      public org.apache.shiro.subject.Subject getSubject()
    • getMember

      public DistributedMember getMember(String memberName)
      this either returns a non-null member or throw an exception if member is not found.
      Parameters:
      memberName - the member name of the member to find
      Returns:
      the member
    • findMember

      public DistributedMember findMember(String memberName)
      this will return the member found or null if no member with that name
      Parameters:
      memberName - the member name of the member to find
      Returns:
      the member found or null if no member with that name exists
    • getAllMembers

      public Set<DistributedMember> getAllMembers()
      Gets all members in the GemFire distributed system/cache, including locators
      Returns:
      a set of all members
    • getAllNormalMembers

      public Set<DistributedMember> getAllNormalMembers()
      Get All members, excluding locators
      Returns:
      a set of all non-locator members
    • getNormalMembersWithSameOrNewerVersion

      public Set<DistributedMember> getNormalMembersWithSameOrNewerVersion(org.apache.geode.internal.serialization.KnownVersion version)
      Get All members >= a specific version, excluding locators
      Parameters:
      version - a KnownVersion to compare with the version of members
      Returns:
      a set of non-locator members with version equal to or newer than the given version
    • getMembersFunctionExecutor

      public Execution getMembersFunctionExecutor(Set<DistributedMember> members)
    • findMembers

      public Set<DistributedMember> findMembers(String[] groups, String[] members)
      if no members matches these names, an empty set would return, this does not include locators
      Parameters:
      groups - names of groups to which returned members belong
      members - member names or IDs which returned members match
      Returns:
      a set of matching members
    • findAllOtherLocators

      public Set<DistributedMember> findAllOtherLocators()
    • findAllLocators

      public Set<DistributedMember> findAllLocators()
    • getMembers

      public Set<DistributedMember> getMembers(String[] groups, String[] members)
      if no members matches these names, a UserErrorException will be thrown
      Parameters:
      groups - names of groups to which returned members belong
      members - member names or IDs which returned members match
      Returns:
      a set of matching members
    • findMembersIncludingLocators

      public Set<DistributedMember> findMembersIncludingLocators(String[] groups, String[] members)
      if no members matches these names, an empty set would return
      Parameters:
      groups - names of groups to which returned members belong
      members - member names or IDs which returned members match
      Returns:
      a set of matching members
    • getMembersIncludingLocators

      public Set<DistributedMember> getMembersIncludingLocators(String[] groups, String[] members)
      if no members matches these names, a UserErrorException will be thrown
      Parameters:
      groups - names of groups to which returned members belong
      members - member names or IDs which returned members match
      Returns:
      a set of matching members
    • findMembersForRegion

      public Set<DistributedMember> findMembersForRegion(String regionPath)
    • findAnyMembersForRegion

      public Set<DistributedMember> findAnyMembersForRegion(String regionPath)
    • executeFunction

      public ResultCollector<?,?> executeFunction(Function<?> function, Object args, Set<DistributedMember> targetMembers)
    • executeFunction

      public ResultCollector<?,?> executeFunction(Function<?> function, Object args, DistributedMember targetMember)
    • executeFunctionAndGetFunctionResult

      public org.apache.geode.management.internal.functions.CliFunctionResult executeFunctionAndGetFunctionResult(Function<?> function, Object args, DistributedMember targetMember)
    • executeAndGetFunctionResult

      public List<org.apache.geode.management.internal.functions.CliFunctionResult> executeAndGetFunctionResult(Function<?> function, Object args, Set<DistributedMember> targetMembers)
    • poll

      public boolean poll(long timeout, TimeUnit unit, Supplier<Boolean> function)
      Very basic polling functionality that executes a function until it returns true or the timeout is reached. The polling call is performed on the calling thread. Do not use it with a function that may have an unbounded runtime. The timeout is very coarse and will not account for the function overrunning the given time.
      Parameters:
      timeout - the maximum amount of time to wait for the function to return
      unit - the TimeUnit for the timeout
      function - a Supplier<Boolean> function that will poll for the condition
      Returns:
      true if the function returns true within the timeout period; false otherwise