RyaAdminCommands implements CommandMarker { @CliCommand(value = INSTALL_CMD, help = "Create a new instance of Rya interactively.") public String install() { final RyaClient commands = state.getShellState().getConnectedCommands().get(); String instanceName = null; InstallConfiguration installConfig = null; try { boolean verified = false; while(!verified) { instanceName = installPrompt.promptInstanceName(); installConfig = installPrompt.promptInstallConfiguration(instanceName); verified = installPrompt.promptVerified(instanceName, installConfig); } commands.getInstall().install(instanceName, installConfig); return String.format("The Rya instance named '%s' has been installed.", instanceName); } catch(final DuplicateInstanceNameException e) { throw new RuntimeException(String.format("A Rya instance named '%s' already exists. Try again with a different name.", instanceName), e); } catch (final IOException | RyaClientException e) { throw new RuntimeException("Could not install a new instance of Rya. Reason: " + e.getMessage(), e); } } @Autowired  RyaAdminCommands(
            final SharedShellState state,
            final InstallPrompt installPrompt,
            final SparqlPrompt sparqlPrompt,
            final UninstallPrompt uninstallPrompt); @CliAvailabilityIndicator({ LIST_INSTANCES_CMD, INSTALL_CMD}) boolean areStorageCommandsAvailable(); @CliAvailabilityIndicator({ INSTALL_ACCUMULO_PARAMETERS_CMD}) boolean areAccumuloStorageCommandsAvailable(); @CliAvailabilityIndicator({ INSTALL_MONGO_PARAMETERS_CMD}) boolean areMongoStorageCommandsAvailable(); @CliAvailabilityIndicator({ PRINT_INSTANCE_DETAILS_CMD, UNINSTALL_CMD}) boolean areInstanceCommandsAvailable(); @CliAvailabilityIndicator({ ADD_USER_CMD, REMOVE_USER_CMD}) boolean areUserCommandAvailable(); @CliAvailabilityIndicator({ CREATE_PCJ_CMD, DELETE_PCJ_CMD}) boolean arePCJCommandsAvailable(); @CliAvailabilityIndicator({ CREATE_PERIODIC_PCJ_CMD, DELETE_PERIODIC_PCJ_CMD, LIST_INCREMENTAL_QUERIES}) boolean arePeriodicPCJCommandsAvailable(); @CliCommand(value = LIST_INSTANCES_CMD, help = "List the names of the installed Rya instances.") String listInstances(); @CliCommand(value = INSTALL_CMD, help = "Create a new instance of Rya interactively.") String install(); @CliCommand(value = INSTALL_ACCUMULO_PARAMETERS_CMD, help = "Create a new Accumulo instance of Rya with command line parameters.") String installWithAccumuloParameters(
            @CliOption(key = {"instanceName"}, mandatory = true, help = "The name of the Rya instance to create.")
            final String instanceName,

            @CliOption(key = {"enableTableHashPrefix"}, mandatory = false, help = "Use Shard Balancing (improves streamed input write speeds).", unspecifiedDefaultValue = "false", specifiedDefaultValue = "true")
            final boolean enableTableHashPrefix,

            @CliOption(key = {"enableEntityCentricIndex"}, mandatory = false, help = "Use Entity Centric Indexing.", unspecifiedDefaultValue = "false", specifiedDefaultValue = "true")
            final boolean enableEntityCentricIndex,

            @CliOption(key = {"enableFreeTextIndex"}, mandatory = false, help = "Use Free Text Indexing.", unspecifiedDefaultValue = "false", specifiedDefaultValue = "true")
            final boolean enableFreeTextIndex,

            // TODO RYA-215
            //            @CliOption(key = {"enableGeospatialIndex"}, mandatory = false, help = "Use Geospatial Indexing.", unspecifiedDefaultValue = "false", specifiedDefaultValue = "true")
            //            final boolean enableGeospatialIndex,

            @CliOption(key = {"enableTemporalIndex"}, mandatory = false, help = "Use Temporal Indexing.", unspecifiedDefaultValue = "false", specifiedDefaultValue = "true")
            final boolean enableTemporalIndex,

            @CliOption(key = {"enablePcjIndex"}, mandatory = false, help = "Use Precomputed Join (PCJ) Indexing.", unspecifiedDefaultValue = "false", specifiedDefaultValue = "true")
            final boolean enablePcjIndex,

            @CliOption(key = {"fluoPcjAppName"}, mandatory = false, help = "Fluo Application Name for PCJ Index Updater (fluo app must be initialized and enablePcjIndex=true).")
            final String fluoPcjAppName
            ); @CliCommand(value = INSTALL_MONGO_PARAMETERS_CMD, help = "Create a new MongoDB instance of Rya with command line parameters.") String installWithMongoParameters(
            @CliOption(key = {"instanceName"}, mandatory = true, help = "The name of the Rya instance to create.")
            final String instanceName,

            @CliOption(key = {"enableFreeTextIndex"}, mandatory = false, help = "Use Free Text Indexing.", unspecifiedDefaultValue = "false", specifiedDefaultValue = "true")
            final boolean enableFreeTextIndex,

            // TODO RYA-215
            //            @CliOption(key = {"enableGeospatialIndex"}, mandatory = false, help = "Use Geospatial Indexing.", unspecifiedDefaultValue = "false", specifiedDefaultValue = "true")
            //            final boolean enableGeospatialIndex,

            @CliOption(key = {"enableTemporalIndex"}, mandatory = false, help = "Use Temporal Indexing.", unspecifiedDefaultValue = "false", specifiedDefaultValue = "true")
            final boolean enableTemporalIndex,

            @CliOption(key = {"enablePcjIndex"}, mandatory = false, help = "Use Precomputed Join (PCJ) Indexing.", unspecifiedDefaultValue = "false", specifiedDefaultValue = "true")
            final boolean enablePcjIndex); @CliCommand(value = PRINT_INSTANCE_DETAILS_CMD, help = "Print information about how the Rya instance is configured.") String printInstanceDetails(); @CliCommand(value = CREATE_PCJ_CMD, help = "Creates and starts the maintenance of a new PCJ using a Fluo application.") String createPcj(
            @CliOption(key = {"exportToRya"}, mandatory = false, help = "Indicates that results for the query should be exported to a Rya PCJ table.", unspecifiedDefaultValue = "false", specifiedDefaultValue = "true") final
            boolean exportToRya,
            @CliOption(key = {"exportToKafka"}, mandatory = false, help = "Indicates that results for the query should be exported to a Kafka Topic.", unspecifiedDefaultValue = "false", specifiedDefaultValue = "true") final
            boolean exportToKafka); @CliCommand(value = DELETE_PCJ_CMD, help = "Deletes and halts maintenance of a PCJ.") String deletePcj(
            @CliOption(key = {"pcjId"}, mandatory = true, help = "The ID of the PCJ that will be deleted.")
            final String pcjId); @CliCommand(value = CREATE_PERIODIC_PCJ_CMD, help = "Creates and starts the maintenance of a new Periodic PCJ and registers the associated Periodic Notification with Kafka.") String createPeriodicPcj(
            @CliOption(key = {"topic"}, mandatory = true, help = "Kafka topic for registering new PeriodicNotifications.  This topic is monitored by the Periodic Notification Service.") final
            String topic,
            @CliOption(key = {"brokers"}, mandatory = true, help = "Comma delimited list of host/port pairs to establish the initial connection to the Kafka cluster.") final
            String brokers); @CliCommand(value = DELETE_PERIODIC_PCJ_CMD, help = "Deletes and halts maintenance of a Periodic PCJ.") String deletePeriodicPcj(
            @CliOption(key = {"pcjId"}, mandatory = true, help = "The ID of the PCJ that will be deleted.")
            final String pcjId,
            @CliOption(key = {"topic"}, mandatory = true, help = "Kafka topic for registering a delete notice to remove a PeriodicNotification from the Periodic Notification Service.")
            final String topic,
            @CliOption(key = {"brokers"}, mandatory = true, help = "Comma delimited list of host/port pairs to establish the initial connection to the Kafka cluster.")
            final String brokers
            ); @CliCommand(value = LIST_INCREMENTAL_QUERIES, help = "Lists relevant information about all SPARQL queries maintained by the Fluo application.") String listFluoQueries(); @CliCommand(value = ADD_USER_CMD, help = "Adds an authorized user to the Rya instance.") void addUser(
            @CliOption(key = {"username"}, mandatory = true, help = "The username of the user that will be granted access.")
            final String username); @CliCommand(value = REMOVE_USER_CMD, help = "Removes an authorized user from the Rya instance.") void removeUser(
            @CliOption(key = {"username"}, mandatory = true, help = "The username of the user whose access will be revoked.")
            final String username); @CliCommand(value = UNINSTALL_CMD, help = "Uninstall an instance of Rya.") String uninstall(); static final String CREATE_PCJ_CMD; static final String CREATE_PERIODIC_PCJ_CMD; static final String DELETE_PCJ_CMD; static final String DELETE_PERIODIC_PCJ_CMD; static final String LIST_INCREMENTAL_QUERIES; static final String PRINT_INSTANCE_DETAILS_CMD; static final String INSTALL_CMD; static final String INSTALL_ACCUMULO_PARAMETERS_CMD; static final String INSTALL_MONGO_PARAMETERS_CMD; static final String LIST_INSTANCES_CMD; static final String UNINSTALL_CMD; static final String ADD_USER_CMD; static final String REMOVE_USER_CMD; }
@Test public void install() throws DuplicateInstanceNameException, RyaClientException, IOException { final Install mockInstall = mock(Install.class); final RyaClient mockCommands = mock(RyaClient.class); when(mockCommands.getInstall()).thenReturn( mockInstall ); final SharedShellState state = new SharedShellState(); state.connectedToAccumulo(mock(AccumuloConnectionDetails.class), mockCommands); final String instanceName = "unitTests"; final InstallConfiguration installConfig = InstallConfiguration.builder() .setEnableGeoIndex(true) .setEnablePcjIndex(true) .build(); final InstallPrompt mockInstallPrompt = mock(InstallPrompt.class); when(mockInstallPrompt.promptInstanceName()).thenReturn( instanceName ); when(mockInstallPrompt.promptInstallConfiguration(instanceName)).thenReturn( installConfig ); when(mockInstallPrompt.promptVerified(eq(instanceName), eq(installConfig))).thenReturn(true); final RyaAdminCommands commands = new RyaAdminCommands(state, mockInstallPrompt, mock(SparqlPrompt.class), mock(UninstallPrompt.class)); final String message = commands.install(); verify(mockInstall).install(eq(instanceName), eq(installConfig)); final String expected = "The Rya instance named 'unitTests' has been installed."; assertEquals(expected, message); }