@SubCommands({@SubCommand(name = "GenerateData", impl = GenerateDataCommand.class), @SubCommand(name = "CreateSegment", impl = CreateSegmentCommand.class), @SubCommand(name = "StartZookeeper", impl = StartZookeeperCommand.class), @SubCommand(name = "StartKafka", impl = StartKafkaCommand.class), @SubCommand(name = "StreamAvroIntoKafka", impl = StreamAvroIntoKafkaCommand.class), @SubCommand(name = "StartController", impl = StartControllerCommand.class), @SubCommand(name = "StartBroker", impl = StartBrokerCommand.class), @SubCommand(name = "StartServer", impl = StartServerCommand.class), @SubCommand(name = "AddTable", impl = AddTableCommand.class), @SubCommand(name = "ChangeTableState", impl = ChangeTableState.class), @SubCommand(name = "AddTenant", impl = AddTenantCommand.class), @SubCommand(name = "AddSchema", impl = AddSchemaCommand.class), @SubCommand(name = "UploadSegment", impl = UploadSegmentCommand.class), @SubCommand(name = "PostQuery", impl = PostQueryCommand.class), @SubCommand(name = "StopProcess", impl = StopProcessCommand.class), @SubCommand(name = "DeleteCluster", impl = DeleteClusterCommand.class), @SubCommand(name = "ShowClusterInfo", impl = ShowClusterInfoCommand.class), @SubCommand(name = "AvroSchemaToPinotSchema", impl = AvroSchemaToPinotSchema.class), @SubCommand(name = "RebalanceTable", impl = RebalanceTableCommand.class), @SubCommand(name = "ChangeNumReplicas", impl = ChangeNumReplicasCommand.class), @SubCommand(name = "ValidateConfig", impl = ValidateConfigCommand.class), @SubCommand(name = "VerifySegmentState", impl = VerifySegmentState.class), @SubCommand(name = "ConvertPinotSegment", impl = PinotSegmentConvertCommand.class), @SubCommand(name = "MoveReplicaGroup", impl = MoveReplicaGroup.class), @SubCommand(name = "BackfillSegmentColumn", impl = BackfillDateTimeColumnCommand.class), @SubCommand(name = "VerifyClusterState", impl = VerifyClusterStateCommand.class), @SubCommand(name = "ApplyTableConfig", impl = ApplyTableConfigCommand.class), @SubCommand(name = "RealtimeProvisioningHelper", impl = RealtimeProvisioningHelperCommand.class), @SubCommand(name = "MergeSegments", impl = SegmentMergeCommand.class)}) Command _subCommand;
public void printUsage() { LOGGER.info("Usage: pinot-tools.sh <subCommand>"); LOGGER.info("Valid subCommands are:"); Class<PinotToolLauncher> obj = PinotToolLauncher.class; for (Field f : obj.getDeclaredFields()) { if (f.isAnnotationPresent(SubCommands.class)) { SubCommands subCommands = f.getAnnotation(SubCommands.class); for (SubCommand subCommand : subCommands.value()) { Class<?> subCommandClass = subCommand.impl(); Command command = null; try { command = (Command) subCommandClass.newInstance(); LOGGER.info("\t" + subCommand.name() + "\t<" + command.description() + ">"); } catch (Exception e) { LOGGER.info("Internal Error: Error instantiating class."); } } } } } }
@Override public String getDefaultMetaVariable() { StringBuffer rv = new StringBuffer(); rv.append("["); for (SubCommand sc : commands.value()) { rv.append(sc.name()).append(" | "); } rv.delete(rv.length()-3, rv.length()); rv.append("]"); return rv.toString(); }
protected Object instantiate(SubCommand c) { try { return c.impl().newInstance(); } catch (InstantiationException e) { throw new IllegalStateException("Failed to instantiate "+c,e); } catch (IllegalAccessException e) { throw new IllegalStateException("Failed to instantiate "+c,e); } }
@Override public String getDefaultMetaVariable() { StringBuffer rv = new StringBuffer(); rv.append("["); for (SubCommand sc : commands.value()) { rv.append(sc.name()).append(" | "); } rv.delete(rv.length()-3, rv.length()); rv.append("]"); return rv.toString(); }
protected Object instantiate(SubCommand c) { try { return c.impl().newInstance(); } catch (InstantiationException e) { throw new IllegalStateException("Failed to instantiate "+c,e); } catch (IllegalAccessException e) { throw new IllegalStateException("Failed to instantiate "+c,e); } }
@SubCommands({@SubCommand(name = "UpdateSegmentState", impl = UpdateSegmentState.class), @SubCommand(name = "AutoAddInvertedIndex", impl = AutoAddInvertedIndexTool.class), @SubCommand(name = "ValidateTableRetention", impl = ValidateTableRetention.class), @SubCommand(name = "PerfBenchmarkRunner", impl = PerfBenchmarkRunner.class), @SubCommand(name = "QueryRunner", impl = QueryRunner.class)}) Command _subCommand;
public void printUsage() { LOGGER.info("Usage: pinot-admin.sh <subCommand>"); LOGGER.info("Valid subCommands are:"); Class<PinotAdministrator> obj = PinotAdministrator.class; for (Field f : obj.getDeclaredFields()) { if (f.isAnnotationPresent(SubCommands.class)) { SubCommands subCommands = f.getAnnotation(SubCommands.class); for (SubCommand subCommand : subCommands.value()) { Class<?> subCommandClass = subCommand.impl(); Command command = null; try { command = (Command) subCommandClass.newInstance(); LOGGER.info("\t" + subCommand.name() + "\t<" + command.description() + ">"); } catch (Exception e) { LOGGER.info("Internal Error: Error instantiating class."); } } } } LOGGER.info("For other crud operations, please refer to ${ControllerAddress}/help."); } }
@Override public int parseArguments(Parameters params) throws CmdLineException { String subCmd = params.getParameter(0); for (SubCommand c : commands.value()) { if (c.name().equals(subCmd)) { setter.addValue(subCommand(c,params)); return params.size(); // consume all the remaining tokens } } return fallback(subCmd); }
protected Object instantiate(SubCommand c) { try { return c.impl().newInstance(); } catch (InstantiationException e) { throw new IllegalStateException("Failed to instantiate "+c,e); } catch (IllegalAccessException e) { throw new IllegalStateException("Failed to instantiate "+c,e); } }
usage = "The subcommand to run") @SubCommands({ @SubCommand(name = "createKeyRing", impl = CreateKeyRingCommand.class), @SubCommand(name = "createCryptoKey", impl = CreateCryptoKeyCommand.class), @SubCommand(name = "createCryptoKeyVersion", impl = CreateCryptoKeyVersionCommand.class), @SubCommand(name = "listKeyRings", impl = ListKeyRingsCommand.class), @SubCommand(name = "listCryptoKeys", impl = ListCryptoKeysCommand.class), @SubCommand(name = "listCryptoKeyVersions", impl = ListCryptoKeyVersionsCommand.class), @SubCommand(name = "disableCryptoKeyVersion", impl = DisableCryptoKeyVersionCommand.class), @SubCommand(name = "enableCryptoKeyVersion", impl = EnableCryptoKeyVersionCommand.class), @SubCommand(name = "destroyCryptoKeyVersion", impl = DestroyCryptoKeyVersionCommand.class), @SubCommand(name = "restoreCryptoKeyVersion", impl = RestoreCryptoKeyVersionCommand.class), @SubCommand(name = "getKeyRingPolicy", impl = GetKeyRingPolicyCommand.class), @SubCommand(name = "getCryptoKeyPolicy", impl = GetCryptoKeyPolicyCommand.class), @SubCommand(name = "setPrimaryVersion", impl = SetPrimaryVersionCommand.class), @SubCommand(name = "addMemberToKeyRingPolicy", impl = AddMemberToKeyRingPolicyCommand.class), @SubCommand(name = "addMemberToCryptoKeyPolicy", impl = AddMemberToCryptoKeyPolicyCommand.class), @SubCommand(name = "removeMemberFromKeyRingPolicy", impl = RemoveMemberFromKeyRingPolicyCommand.class), @SubCommand(name = "removeMemberFromCryptoKeyPolicy", impl = RemoveMemberFromCryptoKeyPolicyCommand.class) })
@SuppressWarnings("unchecked") public static Map<String, Command> all() { if (ALL == null) { try { ALL = new HashMap<String, Command>(); Field cmdField = Gaffer.class.getDeclaredField("cmd"); SubCommands subCommands = cmdField.getAnnotation(SubCommands.class); for (SubCommand sub : subCommands.value()) { if (Command.class.isAssignableFrom(sub.impl())) { Class<Command> clazz = (Class<Command>) sub.impl(); ALL.put(sub.name(), clazz.newInstance()); } } } catch (Exception e) { throw new RuntimeException(e); } } return ALL; }
@Override public int parseArguments(Parameters params) throws CmdLineException { String subCmd = params.getParameter(0); for (SubCommand c : commands.value()) { if (c.name().equals(subCmd)) { setter.addValue(subCommand(c,params)); return params.size(); // consume all the remaining tokens } } return fallback(subCmd); }
usage = "The subcommand to run") @SubCommands({ @SubCommand(name = "encrypt", impl = EncryptCommand.class), @SubCommand(name = "decrypt", impl = DecryptCommand.class) }) Command command;
@Override public String getDefaultMetaVariable() { StringBuffer rv = new StringBuffer(); rv.append("["); for (SubCommand sc : commands.value()) { rv.append(sc.name()).append(" | "); } rv.delete(rv.length()-3, rv.length()); rv.append("]"); return rv.toString(); }
public class ShellCommandWrapper { @Argument(handler = SubCommandHandler.class) @SubCommands({ @SubCommand(name = "get_config", impl = GetConfigCommand.class), @SubCommand(name = "press", impl = PressButtonCommand.class), @SubCommand(name = "start", impl = StartActivityCommand.class), @SubCommand(name = "list", impl = ListCommand.class), @SubCommand(name = "show", impl = ShowCommand.class), }) private ShellCommand command; public void execute(HarmonyClient harmonyClient) { command.execute(harmonyClient); } }
@Override public int parseArguments(Parameters params) throws CmdLineException { String subCmd = params.getParameter(0); for (SubCommand c : commands.value()) { if (c.name().equals(subCmd)) { setter.addValue(subCommand(c,params)); return params.size(); // consume all the remaining tokens } } return fallback(subCmd); }
public class ListCommand extends ShellCommand { @Argument(handler = SubCommandHandler.class) @SubCommands({ @SubCommand(name = "devices", impl = ListDevicesCommand.class), @SubCommand(name = "activities", impl = ListActivitiesCommand.class)}) private ShellCommand command; @Override public void execute(HarmonyClient harmonyClient) { command.execute(harmonyClient); } }
@SubCommand(name = "help", impl = HelpOptions.class), @SubCommand(name = "init", impl = InitOptionsImpl.class), @SubCommand(name = "list-remote", impl = ListRemoteOptionsImpl.class), @SubCommand(name = "pull", impl = PullOptionsImpl.class), @SubCommand(name = "push", impl = PushOptionsImpl.class), @SubCommand(name = "put-project", impl = PutProjectOptionsImpl.class), @SubCommand(name = "put-user", impl = PutUserOptionsImpl.class), @SubCommand(name = "put-version", impl = PutVersionOptionsImpl.class), @SubCommand(name = "stats", impl = GetStatisticsOptionsImpl.class), @SubCommand(name = "glossary-delete", impl = GlossaryDeleteOptionsImpl.class), @SubCommand(name = "glossary-push", impl = GlossaryPushOptionsImpl.class), @SubCommand(name = "glossary-pull", impl = GlossaryPullOptionsImpl.class)})
@SubCommand(name = "encrypt2", impl = Encrypt2Command.class), @SubCommand(name = "mux", impl = MuxMp4.class), @SubCommand(name = "cenc", impl = CencEncryptAndMux.class), @SubCommand(name = "dumpbox", impl = DumpBox.class), @SubCommand(name = "extractkid", impl = ExtractKeyId.class)