org.springframework.shell.core.annotation.CliAvailabilityIndicator Java Examples

The following examples show how to use org.springframework.shell.core.annotation.CliAvailabilityIndicator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RyaAdminCommands.java    From rya with Apache License 2.0 6 votes vote down vote up
/**
 * Enables commands that are available when the Shell is connected to a Rya Instance that supports PCJ Indexing.
 */
@CliAvailabilityIndicator({
    CREATE_PCJ_CMD,
    DELETE_PCJ_CMD})
public boolean arePCJCommandsAvailable() {
    // The PCJ commands are only available if the Shell is connected to an instance of Rya
    // that is new enough to use the RyaDetailsRepository and is configured to maintain PCJs.
    final ShellState shellState = state.getShellState();
    if(shellState.getConnectionState() == ConnectionState.CONNECTED_TO_INSTANCE) {
        final GetInstanceDetails getInstanceDetails = shellState.getConnectedCommands().get().getGetInstanceDetails();
        final String ryaInstanceName = state.getShellState().getRyaInstanceName().get();
        try {
            final Optional<RyaDetails> instanceDetails = getInstanceDetails.getDetails( ryaInstanceName );
            if(instanceDetails.isPresent()) {
                return instanceDetails.get().getPCJIndexDetails().isEnabled();
            }
        } catch (final RyaClientException e) {
            return false;
        }
    }
    return false;
}
 
Example #2
Source File: RyaAdminCommands.java    From rya with Apache License 2.0 6 votes vote down vote up
/**
 * Enables commands that are available when the Shell is connected to a Rya Instance that supports PCJ Indexing.
 */
@CliAvailabilityIndicator({
    CREATE_PERIODIC_PCJ_CMD,
    DELETE_PERIODIC_PCJ_CMD,
    LIST_INCREMENTAL_QUERIES})
public boolean arePeriodicPCJCommandsAvailable() {
    // The PCJ commands are only available if the Shell is connected to an instance of Rya
    // that is new enough to use the RyaDetailsRepository and is configured to maintain PCJs.
    final ShellState shellState = state.getShellState();
    if(shellState.getConnectionState() == ConnectionState.CONNECTED_TO_INSTANCE &&
            shellState.getStorageType().get() == StorageType.ACCUMULO) {
        final GetInstanceDetails getInstanceDetails = shellState.getConnectedCommands().get().getGetInstanceDetails();
        final String ryaInstanceName = state.getShellState().getRyaInstanceName().get();
        try {
            final Optional<RyaDetails> instanceDetails = getInstanceDetails.getDetails( ryaInstanceName );
            if(instanceDetails.isPresent()) {
                return instanceDetails.get().getPCJIndexDetails().isEnabled();
            }
        } catch (final RyaClientException e) {
            return false;
        }
    }
    return false;
}
 
Example #3
Source File: DiskStoreCommands.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
@CliAvailabilityIndicator({CliStrings.BACKUP_DISK_STORE, CliStrings.COMPACT_DISK_STORE,
  CliStrings.DESCRIBE_DISK_STORE, CliStrings.LIST_DISK_STORE, CliStrings.REVOKE_MISSING_DISK_STORE,
  CliStrings.SHOW_MISSING_DISK_STORE, CliStrings.CREATE_DISK_STORE, CliStrings.DESTROY_DISK_STORE})
public boolean diskStoreCommandsAvailable() {
  // these disk store commands are always available in GemFire
  return (!CliUtil.isGfshVM() || (getGfsh() != null && getGfsh().isConnectedAndReady()));
}
 
Example #4
Source File: FunctionCommands.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
@CliAvailabilityIndicator({CliStrings.EXECUTE_FUNCTION, CliStrings.DESTROY_FUNCTION, CliStrings.LIST_FUNCTION})  
public boolean functionCommandsAvailable() {
  boolean isAvailable = true; //always available on server
  if (CliUtil.isGfshVM()) { //in gfsh check if connected
    isAvailable = getGfsh() != null && getGfsh().isConnectedAndReady();
  }
  return isAvailable;  
}
 
Example #5
Source File: MiscellaneousCommands.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
@CliAvailabilityIndicator({ CliStrings.SHUTDOWN, CliStrings.GC,
  CliStrings.SHOW_DEADLOCK, CliStrings.SHOW_METRICS, CliStrings.SHOW_LOG,
  CliStrings.EXPORT_STACKTRACE, CliStrings.NETSTAT, CliStrings.EXPORT_LOGS })
public boolean shutdownCommandAvailable() {
  boolean isAvailable = true; // always available on server
  if (CliUtil.isGfshVM()) { // in gfsh check if connected
    isAvailable = getGfsh() != null && getGfsh().isConnectedAndReady();
  }
  return isAvailable;
}
 
Example #6
Source File: RyaStreamsCommands.java    From rya with Apache License 2.0 5 votes vote down vote up
/**
 * Enables commands that become available when a Rya instance has a configured Rya Streams subsystem to use.
 */
@CliAvailabilityIndicator({
    STREAM_QUERIES_ADD_CMD,
    STREAM_QUERIES_DELETE_CMD,
    STREAM_QUERIES_START_CMD,
    STREAM_QUERIES_STOP_CMD,
    STREAM_QUERIES_LIST_CMD,
    STREAM_QUERIES_DETAILS_CMD})
public boolean areQueriesCommandsAvailable() {
    return state.getShellState().getRyaStreamsCommands().isPresent();
}
 
Example #7
Source File: DataCommands.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
@CliAvailabilityIndicator({ CliStrings.REBALANCE, CliStrings.GET,
    CliStrings.PUT, CliStrings.REMOVE, CliStrings.LOCATE_ENTRY,
    CliStrings.QUERY, CliStrings.IMPORT_DATA, CliStrings.EXPORT_DATA })
public boolean dataCommandsAvailable() {
  boolean isAvailable = true; // always available on server
  if (CliUtil.isGfshVM()) { // in gfsh check if connected
    isAvailable = getGfsh() != null && getGfsh().isConnectedAndReady();
  }
  return isAvailable;
}
 
Example #8
Source File: DeployCommands.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
@CliAvailabilityIndicator({ CliStrings.DEPLOY, CliStrings.UNDEPLOY, CliStrings.LIST_DEPLOYED })
public final boolean isConnected() {
  if (!CliUtil.isGfshVM()) {
    return true;
  }

  return (getGfsh() != null && getGfsh().isConnectedAndReady());
}
 
Example #9
Source File: MemberCommands.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
@CliAvailabilityIndicator({CliStrings.LIST_MEMBER, CliStrings.DESCRIBE_MEMBER})
public boolean isListMemberAvailable() {
  boolean isAvailable = true;
  if (CliUtil.isGfshVM()) {
    isAvailable = getGfsh() != null && getGfsh().isConnectedAndReady();
  }
  return isAvailable;
}
 
Example #10
Source File: RyaAdminCommands.java    From rya with Apache License 2.0 5 votes vote down vote up
/**
 * Enables commands that are always available once the Shell is connected to a Rya Instance.
 */
@CliAvailabilityIndicator({
    PRINT_INSTANCE_DETAILS_CMD,
    UNINSTALL_CMD})
public boolean areInstanceCommandsAvailable() {
    return state.getShellState().getConnectionState() == ConnectionState.CONNECTED_TO_INSTANCE;
}
 
Example #11
Source File: CreateAlterDestroyRegionCommands.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
@CliAvailabilityIndicator({ CliStrings.ALTER_REGION, CliStrings.CREATE_REGION, CliStrings.DESTROY_REGION })
public boolean isRegionCommandAvailable() {
  boolean isAvailable = true; // always available on server
  if (CliUtil.isGfshVM()) { // in gfsh check if connected //TODO - Abhishek: make this better
    isAvailable = getGfsh() != null && getGfsh().isConnectedAndReady();
  }
  return isAvailable;
}
 
Example #12
Source File: QueueCommands.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
@CliAvailabilityIndicator({ CliStrings.CREATE_ASYNC_EVENT_QUEUE, CliStrings.LIST_ASYNC_EVENT_QUEUES })
public boolean queueCommandsAvailable() {
  boolean isAvailable = true;
  if (CliUtil.isGfshVM()) {
    isAvailable = getGfsh() != null && getGfsh().isConnectedAndReady();
  }
  return isAvailable;
}
 
Example #13
Source File: RyaConnectionCommands.java    From rya with Apache License 2.0 5 votes vote down vote up
@CliAvailabilityIndicator({CONNECT_INSTANCE_CMD})
public boolean isConnectToInstanceAvailable() {
    switch(sharedState.getShellState().getConnectionState()) {
    case CONNECTED_TO_STORAGE:
    case CONNECTED_TO_INSTANCE:
        return true;
    default:
        return false;
    }
}
 
Example #14
Source File: DurableClientCommands.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
@CliAvailabilityIndicator({ CliStrings.LIST_DURABLE_CQS, CliStrings.CLOSE_DURABLE_CLIENTS, CliStrings.CLOSE_DURABLE_CQS, CliStrings.COUNT_DURABLE_CQ_EVENTS })
public boolean durableCommandsAvailable() {
  boolean isAvailable = true;
  if (CliUtil.isGfshVM()) { 
    isAvailable = getGfsh() != null && getGfsh().isConnectedAndReady();
  }
  return isAvailable;
}
 
Example #15
Source File: CreateAlterDestroyRegionCommands.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
@CliAvailabilityIndicator({ CliStrings.ALTER_REGION, CliStrings.CREATE_REGION, CliStrings.DESTROY_REGION })
public boolean isRegionCommandAvailable() {
  boolean isAvailable = true; // always available on server
  if (CliUtil.isGfshVM()) { // in gfsh check if connected //TODO - Abhishek: make this better
    isAvailable = getGfsh() != null && getGfsh().isConnectedAndReady();
  }
  return isAvailable;
}
 
Example #16
Source File: RyaCommands.java    From rya with Apache License 2.0 5 votes vote down vote up
/**
 * Enables commands that are always available once the Shell is connected to a Rya Instance.
 */
@CliAvailabilityIndicator({ LOAD_DATA_CMD, SPARQL_QUERY_CMD })
public boolean areInstanceCommandsAvailable() {
    switch (state.getShellState().getConnectionState()) {
    case CONNECTED_TO_INSTANCE:
        return true;
    default:
        return false;
    }
}
 
Example #17
Source File: WanCommands.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
@CliAvailabilityIndicator( { CliStrings.CREATE_GATEWAYSENDER,
    CliStrings.START_GATEWAYSENDER, CliStrings.PAUSE_GATEWAYSENDER,
    CliStrings.RESUME_GATEWAYSENDER, CliStrings.STOP_GATEWAYSENDER,
    CliStrings.CREATE_GATEWAYRECEIVER, CliStrings.START_GATEWAYRECEIVER,
    CliStrings.STOP_GATEWAYRECEIVER, CliStrings.LIST_GATEWAY,
    CliStrings.STATUS_GATEWAYSENDER, CliStrings.STATUS_GATEWAYRECEIVER })
public boolean isWanCommandsAvailable() {
  boolean isAvailable = true; // always available on server
  if (CliUtil.isGfshVM()) {
    isAvailable = getGfsh() != null && getGfsh().isConnectedAndReady();
  }
  return isAvailable;
}
 
Example #18
Source File: MiscellaneousCommands.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
@CliAvailabilityIndicator({ CliStrings.SHUTDOWN, CliStrings.GC,
  CliStrings.SHOW_DEADLOCK, CliStrings.SHOW_METRICS, CliStrings.SHOW_LOG,
  CliStrings.EXPORT_STACKTRACE, CliStrings.NETSTAT, CliStrings.EXPORT_LOGS })
public boolean shutdownCommandAvailable() {
  boolean isAvailable = true; // always available on server
  if (CliUtil.isGfshVM()) { // in gfsh check if connected
    isAvailable = getGfsh() != null && getGfsh().isConnectedAndReady();
  }
  return isAvailable;
}
 
Example #19
Source File: FunctionCommands.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
@CliAvailabilityIndicator({CliStrings.EXECUTE_FUNCTION, CliStrings.DESTROY_FUNCTION, CliStrings.LIST_FUNCTION})  
public boolean functionCommandsAvailable() {
  boolean isAvailable = true; //always available on server
  if (CliUtil.isGfshVM()) { //in gfsh check if connected
    isAvailable = getGfsh() != null && getGfsh().isConnectedAndReady();
  }
  return isAvailable;  
}
 
Example #20
Source File: DataCommands.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
@CliAvailabilityIndicator({ CliStrings.REBALANCE, CliStrings.GET,
    CliStrings.PUT, CliStrings.REMOVE, CliStrings.LOCATE_ENTRY,
    CliStrings.QUERY, CliStrings.IMPORT_DATA, CliStrings.EXPORT_DATA })
public boolean dataCommandsAvailable() {
  boolean isAvailable = true; // always available on server
  if (CliUtil.isGfshVM()) { // in gfsh check if connected
    isAvailable = getGfsh() != null && getGfsh().isConnectedAndReady();
  }
  return isAvailable;
}
 
Example #21
Source File: RyaStreamsCommands.java    From rya with Apache License 2.0 5 votes vote down vote up
/**
 * Enables commands that become available when connected to a Rya instance.
 */
@CliAvailabilityIndicator({
    STREAMS_CONFIGURE_CMD,
    STREAMS_DETAILS_CMD})
public boolean areConfigCommandsAvailable() {
    return state.getShellState().getConnectionState() == ConnectionState.CONNECTED_TO_INSTANCE;
}
 
Example #22
Source File: MemberCommands.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
@CliAvailabilityIndicator({CliStrings.LIST_MEMBER, CliStrings.DESCRIBE_MEMBER})
public boolean isListMemberAvailable() {
  boolean isAvailable = true;
  if (CliUtil.isGfshVM()) {
    isAvailable = getGfsh() != null && getGfsh().isConnectedAndReady();
  }
  return isAvailable;
}
 
Example #23
Source File: DeployCommands.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
@CliAvailabilityIndicator({ CliStrings.DEPLOY, CliStrings.UNDEPLOY, CliStrings.LIST_DEPLOYED })
public final boolean isConnected() {
  if (!CliUtil.isGfshVM()) {
    return true;
  }

  return (getGfsh() != null && getGfsh().isConnectedAndReady());
}
 
Example #24
Source File: RyaAdminCommands.java    From rya with Apache License 2.0 5 votes vote down vote up
/**
 * Enables commands that are available when connected to a Rya Instance that supports user management.
 */
@CliAvailabilityIndicator({
    ADD_USER_CMD,
    REMOVE_USER_CMD})
public boolean areUserCommandAvailable() {
    return areInstanceCommandsAvailable() && state.getShellState().getStorageType().get() == StorageType.ACCUMULO;
}
 
Example #25
Source File: CommandManagerJUnitTest.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
@CliAvailabilityIndicator({ COMMAND1_NAME })
public boolean isAvailable() {
  return true; // always available on server

}
 
Example #26
Source File: RyaAdminCommands.java    From rya with Apache License 2.0 4 votes vote down vote up
/**
 * Enables commands that only become available once the Shell has been connected to an Accumulo Rya Storage.
 */
@CliAvailabilityIndicator({
    INSTALL_ACCUMULO_PARAMETERS_CMD})
public boolean areAccumuloStorageCommandsAvailable() {
    return isConnectedToStorageType(StorageType.ACCUMULO);
}
 
Example #27
Source File: TaskSchedulerCommands.java    From spring-cloud-dataflow with Apache License 2.0 4 votes vote down vote up
@CliAvailabilityIndicator({ SCHEDULER_UNSCHEDULE })
public boolean availableWithUnscheduleRole() {
	return dataFlowShell.hasAccess(RoleType.DESTROY, OpsType.TASK);
}
 
Example #28
Source File: TaskSchedulerCommands.java    From spring-cloud-dataflow with Apache License 2.0 4 votes vote down vote up
@CliAvailabilityIndicator({ SCHEDULER_CREATE })
public boolean availableWithCreateRole() {
	return dataFlowShell.hasAccess(RoleType.CREATE, OpsType.TASK);
}
 
Example #29
Source File: JobCommands.java    From spring-cloud-dataflow with Apache License 2.0 4 votes vote down vote up
@CliAvailabilityIndicator({ EXECUTION_DISPLAY, EXECUTION_LIST, EXECUTION_RESTART, STEP_EXECUTION_LIST,
		INSTANCE_DISPLAY, STEP_EXECUTION_PROGRESS, STEP_EXECUTION_DISPLAY })
public boolean availableWithViewRole() {
	return dataFlowShell.hasAccess(RoleType.VIEW, OpsType.JOB);
}
 
Example #30
Source File: StreamCommands.java    From spring-cloud-dataflow with Apache License 2.0 4 votes vote down vote up
@CliAvailabilityIndicator({ STREAM_ROLLBACK, STREAM_UPDATE, STREAM_SCALE })
public boolean availableWithModifyRole() {
	return dataFlowShell.hasAccess(RoleType.MODIFY, OpsType.STREAM);
}