List of usage examples for java.util Set add
boolean add(E e);
From source file:org.apache.flink.benchmark.Runner.java
public static void main(String[] args) throws Exception { final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); env.getConfig().enableObjectReuse(); env.getConfig().disableSysoutLogging(); ParameterTool parameters = ParameterTool.fromArgs(args); if (!(parameters.has("p") && parameters.has("types") && parameters.has("algorithms"))) { printUsage();/*from w ww. j a v a 2s . c om*/ System.exit(-1); } int parallelism = parameters.getInt("p"); env.setParallelism(parallelism); Set<IdType> types = new HashSet<>(); if (parameters.get("types").equals("all")) { types.add(IdType.INT); types.add(IdType.LONG); types.add(IdType.STRING); } else { for (String type : parameters.get("types").split(",")) { if (type.toLowerCase().equals("int")) { types.add(IdType.INT); } else if (type.toLowerCase().equals("long")) { types.add(IdType.LONG); } else if (type.toLowerCase().equals("string")) { types.add(IdType.STRING); } else { printUsage(); throw new RuntimeException("Unknown type: " + type); } } } Queue<RunnerWithScore> queue = new PriorityQueue<>(); if (parameters.get("algorithms").equals("all")) { for (Map.Entry<String, Class> entry : AVAILABLE_ALGORITHMS.entrySet()) { for (IdType type : types) { AlgorithmRunner runner = (AlgorithmRunner) entry.getValue().newInstance(); runner.initialize(type, SAMPLES, parallelism); runner.warmup(env); queue.add(new RunnerWithScore(runner, 1.0)); } } } else { for (String algorithm : parameters.get("algorithms").split(",")) { double ratio = 1.0; if (algorithm.contains("=")) { String[] split = algorithm.split("="); algorithm = split[0]; ratio = Double.parseDouble(split[1]); } if (AVAILABLE_ALGORITHMS.containsKey(algorithm.toLowerCase())) { Class clazz = AVAILABLE_ALGORITHMS.get(algorithm.toLowerCase()); for (IdType type : types) { AlgorithmRunner runner = (AlgorithmRunner) clazz.newInstance(); runner.initialize(type, SAMPLES, parallelism); runner.warmup(env); queue.add(new RunnerWithScore(runner, ratio)); } } else { printUsage(); throw new RuntimeException("Unknown algorithm: " + algorithm); } } } JsonFactory factory = new JsonFactory(); while (queue.size() > 0) { RunnerWithScore current = queue.poll(); AlgorithmRunner runner = current.getRunner(); StringWriter writer = new StringWriter(); JsonGenerator gen = factory.createGenerator(writer); gen.writeStartObject(); gen.writeStringField("algorithm", runner.getClass().getSimpleName()); boolean running = true; while (running) { try { runner.run(env, gen); running = false; } catch (ProgramInvocationException e) { // only suppress job cancellations if (!(e.getCause() instanceof JobCancellationException)) { throw e; } } } JobExecutionResult result = env.getLastJobExecutionResult(); long runtime_ms = result.getNetRuntime(); gen.writeNumberField("runtime_ms", runtime_ms); current.credit(runtime_ms); if (!runner.finished()) { queue.add(current); } gen.writeObjectFieldStart("accumulators"); for (Map.Entry<String, Object> accumulatorResult : result.getAllAccumulatorResults().entrySet()) { gen.writeStringField(accumulatorResult.getKey(), accumulatorResult.getValue().toString()); } gen.writeEndObject(); gen.writeEndObject(); gen.close(); System.out.println(writer.toString()); } }
From source file:com.netflix.genie.client.sample.ApplicationServiceSampleClient.java
/** * Main for running client code.// w w w . jav a 2 s .c om * * @param args program arguments * @throws Exception On issue. */ public static void main(final String[] args) throws Exception { // //Initialize Eureka, if it is being used // LOG.info("Initializing Eureka"); // ApplicationServiceClient.initEureka("test"); LOG.info("Initializing list of Genie servers"); ConfigurationManager.getConfigInstance().setProperty("genie2Client.ribbon.listOfServers", "localhost:7001"); LOG.info("Initializing ApplicationServiceClient"); final ApplicationServiceClient appClient = ApplicationServiceClient.getInstance(); LOG.info("Creating new application config"); final Application app1 = appClient.createApplication(getSampleApplication(null)); LOG.info("Application configuration created with id: " + app1.getId()); LOG.info(app1.toString()); LOG.info("Getting Applications using specified filter criteria name = " + APP_NAME); final Multimap<String, String> params = ArrayListMultimap.create(); params.put("name", APP_NAME); final List<Application> appResponses = appClient.getApplications(params); if (appResponses.isEmpty()) { LOG.info("No applications found for specified criteria."); } else { LOG.info("Applications found:"); for (final Application appResponse : appResponses) { LOG.info(appResponse.toString()); } } LOG.info("Getting application config by id"); final Application app2 = appClient.getApplication(app1.getId()); LOG.info(app2.toString()); LOG.info("Updating existing application config"); app2.setStatus(ApplicationStatus.INACTIVE); final Application app3 = appClient.updateApplication(app1.getId(), app2); LOG.info(app3.toString()); LOG.info("Configurations for application with id " + app1.getId()); final Set<String> configs = appClient.getConfigsForApplication(app1.getId()); for (final String config : configs) { LOG.info("Config = " + config); } LOG.info("Adding configurations to application with id " + app1.getId()); final Set<String> newConfigs = new HashSet<>(); newConfigs.add("someNewConfigFile"); newConfigs.add("someOtherNewConfigFile"); final Set<String> configs2 = appClient.addConfigsToApplication(app1.getId(), newConfigs); for (final String config : configs2) { LOG.info("Config = " + config); } LOG.info("Updating set of configuration files associated with id " + app1.getId()); //This should remove the original config leaving only the two in this set final Set<String> configs3 = appClient.updateConfigsForApplication(app1.getId(), newConfigs); for (final String config : configs3) { LOG.info("Config = " + config); } LOG.info("Deleting all the configuration files from the application with id " + app1.getId()); //This should remove the original config leaving only the two in this set final Set<String> configs4 = appClient.removeAllConfigsForApplication(app1.getId()); for (final String config : configs4) { //Shouldn't print anything LOG.info("Config = " + config); } /**************** Begin tests for tag Api's *********************/ LOG.info("Get tags for application with id " + app1.getId()); final Set<String> tags = app1.getTags(); for (final String tag : tags) { LOG.info("Tag = " + tag); } LOG.info("Adding tags to application with id " + app1.getId()); final Set<String> newTags = new HashSet<>(); newTags.add("tag1"); newTags.add("tag2"); final Set<String> tags2 = appClient.addTagsToApplication(app1.getId(), newTags); for (final String tag : tags2) { LOG.info("Tag = " + tag); } LOG.info("Updating set of tags associated with id " + app1.getId()); //This should remove the original config leaving only the two in this set final Set<String> tags3 = appClient.updateTagsForApplication(app1.getId(), newTags); for (final String tag : tags3) { LOG.info("Tag = " + tag); } LOG.info("Deleting one tag from the application with id " + app1.getId()); //This should remove the "tag3" from the tags final Set<String> tags5 = appClient.removeTagForApplication(app1.getId(), "tag1"); for (final String tag : tags5) { //Shouldn't print anything LOG.info("Tag = " + tag); } LOG.info("Deleting all the tags from the application with id " + app1.getId()); //This should remove the original config leaving only the two in this set final Set<String> tags4 = appClient.removeAllConfigsForApplication(app1.getId()); for (final String tag : tags4) { //Shouldn't print anything LOG.info("Config = " + tag); } /********************** End tests for tag Api's **********************/ LOG.info("Jars for application with id " + app1.getId()); final Set<String> jars = appClient.getJarsForApplication(app1.getId()); for (final String jar : jars) { LOG.info("jar = " + jar); } LOG.info("Adding jars to application with id " + app1.getId()); final Set<String> newJars = new HashSet<>(); newJars.add("someNewJarFile.jar"); newJars.add("someOtherNewJarFile.jar"); final Set<String> jars2 = appClient.addJarsToApplication(app1.getId(), newJars); for (final String jar : jars2) { LOG.info("jar = " + jar); } LOG.info("Updating set of jars associated with id " + app1.getId()); //This should remove the original jar leaving only the two in this set final Set<String> jars3 = appClient.updateJarsForApplication(app1.getId(), newJars); for (final String jar : jars3) { LOG.info("jar = " + jar); } LOG.info("Deleting all the jars from the application with id " + app1.getId()); //This should remove the original jar leaving only the two in this set final Set<String> jars4 = appClient.removeAllJarsForApplication(app1.getId()); for (final String jar : jars4) { //Shouldn't print anything LOG.info("jar = " + jar); } LOG.info("Getting the commands associated with id " + app1.getId()); final Set<Command> commands = appClient.getCommandsForApplication(app1.getId()); for (final Command command : commands) { LOG.info("Command: " + command.toString()); } LOG.info("Deleting application using id"); final Application app4 = appClient.deleteApplication(app1.getId()); LOG.info("Deleted application with id: " + app4.getId()); LOG.info(app4.toString()); LOG.info("Done"); }
From source file:org.acme.insurance.policyquote.test.WorkServiceMain.java
public static void main(String... args) throws Exception { serverHostname = System.getProperty("serverHostname", serverHostname); Set<String> policies = new HashSet<String>(); for (String arg : args) { arg = Strings.trimToNull(arg);//from ww w . j a va 2s . co m if (arg != null) { if (arg.equals(CONFIDENTIALITY) || arg.equals(CLIENT_AUTHENTICATION) || arg.equals(HELP)) { policies.add(arg); } else { LOGGER.error(MAVEN_USAGE); throw new Exception(MAVEN_USAGE); } } } if (policies.contains(HELP)) { LOGGER.info(MAVEN_USAGE); } else { final String scheme; final int port; if (policies.contains(CONFIDENTIALITY)) { LOGGER.info("Invoking service via SSL..."); scheme = "https"; port = 443; SSLContext sslcontext = SSLContext.getInstance("TLS"); sslcontext.init(null, null, null); SSLSocketFactory sf = new SSLSocketFactory(sslcontext, SSLSocketFactory.STRICT_HOSTNAME_VERIFIER); Scheme https = new Scheme(scheme, port, sf); SchemeRegistry sr = new SchemeRegistry(); sr.register(https); } else { scheme = "http"; port = 8080; } Element assertion = policies.contains(CLIENT_AUTHENTICATION) ? getAssertion() : null; invokeWorkService(scheme, port, assertion); } }
From source file:cc.kune.kunecli.KuneCliMain.java
/** * The main method./*from w w w . j a v a2 s. com*/ * * @param args * the arguments * @throws InvalidSyntaxException * the invalid syntax exception * @throws ExecutionException * the execution exception * @throws MalformedURLException * the malformed url exception */ public static void main(final String[] args) throws InvalidSyntaxException, ExecutionException, MalformedURLException { final String serverPrefix = System.getenv("KUNE_SERVER_URL"); if (serverPrefix != null) { SERVER_PREFFIX = serverPrefix; SERVICE_PREFFIX = setServicePrefix(); LOG.debug("Using server URL: " + SERVER_PREFFIX); LOG.debug("Using service URL: " + SERVICE_PREFFIX); } initServices(); // TODO: integrate jline or similar? // http://jline.sourceforge.net/index.html // http://sourceforge.net/projects/javacurses/ // http://massapi.com/class/jcurses/widgets/Button.java.html // Create an empty command set final Set<Command> cs = new LinkedHashSet<Command>(); // Create the interpreter final NaturalCLI nc = new NaturalCLI(cs); // Add the commands that can be understood cs.add(new HelpCommand(cs)); // help cs.add(new HTMLHelpCommand(cs)); // htmlhelp // A script can be useful for kune cs.add(new ExecuteFileCommand(nc)); // execute file <filename:string> // cs.add(new HelloWorldCommand()); // kune specific commands cs.add(injector.getInstance(AuthCommand.class)); cs.add(injector.getInstance(SiteInviteCommand.class)); cs.add(injector.getInstance(SiteI18nStatsCommand.class)); cs.add(injector.getInstance(SiteReindexCommand.class)); cs.add(injector.getInstance(SiteReloadPropertiesCommand.class)); cs.add(injector.getInstance(GroupsCount.class)); cs.add(injector.getInstance(GroupsReindexCommand.class)); cs.add(injector.getInstance(UsersCount.class)); cs.add(injector.getInstance(UsersDailySignInsCommand.class)); cs.add(injector.getInstance(UsersLastSignInsCommand.class)); cs.add(injector.getInstance(UsersLangStatsCommand.class)); cs.add(injector.getInstance(UsersSignInsStatsCommand.class)); cs.add(injector.getInstance(UsersReindexCommand.class)); cs.add(injector.getInstance(WaveToDirCommand.class)); cs.add(injector.getInstance(DeltaMigrationToMongoCommand.class)); // As the return type of these commands are not java.io.Serializable (and // instead GWT's IsSerializable) the return part of this cmds fails // cs.add(injector.getInstance(GetInitDataCommand.class)); // cs.add(injector.getInstance(GetI18nLangCommand.class)); // Execute the command line nc.execute(args, 0); }
From source file:com.btoddb.fastpersitentqueue.speedtest.SpeedTest.java
public static void main(String[] args) throws Exception { if (0 == args.length) { System.out.println();//from w ww . j a va 2 s. co m System.out.println("ERROR: must specify the config file path/name"); System.out.println(); System.exit(1); } SpeedTestConfig config = SpeedTestConfig.create(args[0]); System.out.println(config.toString()); File theDir = new File(config.getDirectory(), "speed-" + UUID.randomUUID().toString()); FileUtils.forceMkdir(theDir); Fpq queue = config.getFpq(); queue.setJournalDirectory(new File(theDir, "journals")); queue.setPagingDirectory(new File(theDir, "pages")); try { queue.init(); // // start workers // AtomicLong counter = new AtomicLong(); AtomicLong pushSum = new AtomicLong(); AtomicLong popSum = new AtomicLong(); long startTime = System.currentTimeMillis(); Set<SpeedPushWorker> pushWorkers = new HashSet<SpeedPushWorker>(); for (int i = 0; i < config.getNumberOfPushers(); i++) { pushWorkers.add(new SpeedPushWorker(queue, config, counter, pushSum)); } Set<SpeedPopWorker> popWorkers = new HashSet<SpeedPopWorker>(); for (int i = 0; i < config.getNumberOfPoppers(); i++) { popWorkers.add(new SpeedPopWorker(queue, config, popSum)); } ExecutorService pusherExecSrvc = Executors.newFixedThreadPool( config.getNumberOfPushers() + config.getNumberOfPoppers(), new ThreadFactory() { @Override public Thread newThread(Runnable runnable) { Thread t = new Thread(runnable); t.setName("SpeedTest-Pusher"); return t; } }); ExecutorService popperExecSrvc = Executors.newFixedThreadPool( config.getNumberOfPushers() + config.getNumberOfPoppers(), new ThreadFactory() { @Override public Thread newThread(Runnable runnable) { Thread t = new Thread(runnable); t.setName("SpeedTest-Popper"); return t; } }); long startPushing = System.currentTimeMillis(); for (SpeedPushWorker sw : pushWorkers) { pusherExecSrvc.submit(sw); } long startPopping = System.currentTimeMillis(); for (SpeedPopWorker sw : popWorkers) { popperExecSrvc.submit(sw); } // // wait to finish // long endTime = startTime + config.getDurationOfTest() * 1000; long endPushing = 0; long displayTimer = 0; while (0 == endPushing || !queue.isEmpty()) { // display status every second if (1000 < (System.currentTimeMillis() - displayTimer)) { System.out.println(String.format("status (%ds) : journals = %d : memory segments = %d", (endTime - System.currentTimeMillis()) / 1000, queue.getJournalMgr().getJournalIdMap().size(), queue.getMemoryMgr().getSegments().size())); displayTimer = System.currentTimeMillis(); } pusherExecSrvc.shutdown(); if (pusherExecSrvc.awaitTermination(100, TimeUnit.MILLISECONDS)) { endPushing = System.currentTimeMillis(); // tell poppers, all pushers are finished for (SpeedPopWorker sw : popWorkers) { sw.stopWhenQueueEmpty(); } } } long endPopping = System.currentTimeMillis(); popperExecSrvc.shutdown(); popperExecSrvc.awaitTermination(10, TimeUnit.SECONDS); long numberOfPushes = 0; for (SpeedPushWorker sw : pushWorkers) { numberOfPushes += sw.getNumberOfEntries(); } long numberOfPops = 0; for (SpeedPopWorker sw : popWorkers) { numberOfPops += sw.getNumberOfEntries(); } long pushDuration = endPushing - startPushing; long popDuration = endPopping - startPopping; System.out.println("push - pop checksum = " + pushSum.get() + " - " + popSum.get() + " = " + (pushSum.get() - popSum.get())); System.out.println("push duration = " + pushDuration); System.out.println("pop duration = " + popDuration); System.out.println(); System.out.println("pushed = " + numberOfPushes); System.out.println("popped = " + numberOfPops); System.out.println(); System.out.println("push entries/sec = " + numberOfPushes / (pushDuration / 1000f)); System.out.println("pop entries/sec = " + numberOfPops / (popDuration / 1000f)); System.out.println(); System.out.println("journals created = " + queue.getJournalsCreated()); System.out.println("journals removed = " + queue.getJournalsRemoved()); } finally { if (null != queue) { queue.shutdown(); } // FileUtils.deleteDirectory(theDir); } }
From source file:edu.ucsb.cs.eager.sa.cerebro.ProfessorX.java
public static void main(String[] args) { Options options = new Options(); options.addOption("i", "input-file", true, "Path to input xml file"); options.addOption("r", "root-path", true, "Root path of all Git repositories"); CommandLine cmd;/*from w w w . j av a 2s.c o m*/ try { CommandLineParser parser = new BasicParser(); cmd = parser.parse(options, args); } catch (ParseException e) { System.err.println("Error: " + e.getMessage() + "\n"); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("Cerebro", options); return; } String inputFileName = cmd.getOptionValue("i"); if (inputFileName == null) { System.err.println("input file path is required"); return; } String rootPath = cmd.getOptionValue("r"); if (rootPath == null) { System.err.println("root path is required"); return; } File inputFile = new File(inputFileName); DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); Document doc; try { DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); doc = dBuilder.parse(inputFile); } catch (Exception e) { System.err.println(e.getMessage()); e.printStackTrace(); return; } NodeList repoList = doc.getElementsByTagName("repo"); for (int i = 0; i < repoList.getLength(); i++) { Element repo = (Element) repoList.item(i); String name = repo.getElementsByTagName("name").item(0).getTextContent(); String classPath = repo.getElementsByTagName("classpath").item(0).getTextContent(); Set<String> classes = new LinkedHashSet<String>(); NodeList classesList = repo.getElementsByTagName("classes").item(0).getChildNodes(); for (int j = 0; j < classesList.getLength(); j++) { if (!(classesList.item(j) instanceof Element)) { continue; } classes.add(classesList.item(j).getTextContent()); } analyzeRepo(rootPath, name, classPath, classes); } }
From source file:com.netflix.genie.client.sample.ClusterServiceSampleClient.java
/** * Main for running client code.//from w w w . jav a2s . c o m * * @param args program arguments * @throws Exception On issue. */ public static void main(final String[] args) throws Exception { // Initialize Eureka, if it is being used // LOG.info("Initializing Eureka"); // ClusterServiceClient.initEureka("test"); LOG.info("Initializing list of Genie servers"); ConfigurationManager.getConfigInstance().setProperty("genie2Client.ribbon.listOfServers", "localhost:7001"); LOG.info("Initializing ApplicationServiceClient"); final ApplicationServiceClient appClient = ApplicationServiceClient.getInstance(); final Application app1 = appClient.createApplication( ApplicationServiceSampleClient.getSampleApplication(ApplicationServiceSampleClient.ID)); LOG.info("Created application:"); LOG.info(app1.toString()); final Application app2 = appClient.createApplication( ApplicationServiceSampleClient.getSampleApplication(ApplicationServiceSampleClient.ID + "2")); LOG.info("Created application:"); LOG.info(app2.toString()); LOG.info("Initializing CommandServiceClient"); final CommandServiceClient commandClient = CommandServiceClient.getInstance(); LOG.info("Creating command pig13_mr2"); final Command command1 = commandClient .createCommand(CommandServiceSampleClient.createSampleCommand(CommandServiceSampleClient.ID)); commandClient.setApplicationForCommand(command1.getId(), app1); LOG.info("Created command:"); LOG.info(command1.toString()); final List<Command> commands = new ArrayList<>(); commands.add(command1); LOG.info("Initializing ClusterConfigServiceClient"); final ClusterServiceClient clusterClient = ClusterServiceClient.getInstance(); LOG.info("Creating new cluster configuration"); final Cluster cluster1 = clusterClient.createCluster(createSampleCluster(ID)); clusterClient.addCommandsToCluster(cluster1.getId(), commands); LOG.info("Cluster config created with id: " + cluster1.getId()); LOG.info(cluster1.toString()); LOG.info("Getting cluster config by id"); final Cluster cluster2 = clusterClient.getCluster(cluster1.getId()); LOG.info(cluster2.toString()); LOG.info("Getting clusterConfigs using specified filter criteria"); final Multimap<String, String> params = ArrayListMultimap.create(); params.put("name", NAME); params.put("adHoc", "false"); params.put("test", "true"); params.put("limit", "3"); final List<Cluster> clusters = clusterClient.getClusters(params); if (clusters != null && !clusters.isEmpty()) { for (final Cluster cluster : clusters) { LOG.info(cluster.toString()); } } else { LOG.info("No clusters found for parameters"); } LOG.info("Configurations for cluster with id " + cluster1.getId()); final Set<String> configs = clusterClient.getConfigsForCluster(cluster1.getId()); for (final String config : configs) { LOG.info("Config = " + config); } LOG.info("Adding configurations to cluster with id " + cluster1.getId()); final Set<String> newConfigs = new HashSet<>(); newConfigs.add("someNewConfigFile"); newConfigs.add("someOtherNewConfigFile"); final Set<String> configs2 = clusterClient.addConfigsToCluster(cluster1.getId(), newConfigs); for (final String config : configs2) { LOG.info("Config = " + config); } LOG.info("Updating set of configuration files associated with id " + cluster1.getId()); //This should remove the original config leaving only the two in this set final Set<String> configs3 = clusterClient.updateConfigsForCluster(cluster1.getId(), newConfigs); for (final String config : configs3) { LOG.info("Config = " + config); } /**************** Begin tests for tag Api's *********************/ LOG.info("Get tags for cluster with id " + cluster1.getId()); final Set<String> tags = cluster1.getTags(); for (final String tag : tags) { LOG.info("Tag = " + tag); } LOG.info("Adding tags to cluster with id " + cluster1.getId()); final Set<String> newTags = new HashSet<>(); newTags.add("tag1"); newTags.add("tag2"); final Set<String> tags2 = clusterClient.addTagsToCluster(cluster1.getId(), newTags); for (final String tag : tags2) { LOG.info("Tag = " + tag); } LOG.info("Updating set of tags associated with id " + cluster1.getId()); //This should remove the original config leaving only the two in this set final Set<String> tags3 = clusterClient.updateTagsForCluster(cluster1.getId(), newTags); for (final String tag : tags3) { LOG.info("Tag = " + tag); } LOG.info("Deleting one tag from the cluster with id " + cluster1.getId()); //This should remove the "tag3" from the tags final Set<String> tags5 = clusterClient.removeTagForCluster(cluster1.getId(), "tag1"); for (final String tag : tags5) { //Shouldn't print anything LOG.info("Tag = " + tag); } LOG.info("Deleting all the tags from the cluster with id " + cluster1.getId()); //This should remove the original config leaving only the two in this set final Set<String> tags4 = clusterClient.removeAllTagsForCluster(cluster1.getId()); for (final String tag : tags4) { //Shouldn't print anything LOG.info("Config = " + tag); } /********************** End tests for tag Api's **********************/ LOG.info("Commands for cluster with id " + cluster1.getId()); final List<Command> commands1 = clusterClient.getCommandsForCluster(cluster1.getId()); for (final Command command : commands1) { LOG.info("Command = " + command); } LOG.info("Adding commands to cluster with id " + cluster1.getId()); final List<Command> newCmds = new ArrayList<>(); newCmds.add(commandClient.createCommand(CommandServiceSampleClient.createSampleCommand(ID + "something"))); newCmds.add(commandClient.createCommand(CommandServiceSampleClient.createSampleCommand(null))); final List<Command> commands2 = clusterClient.addCommandsToCluster(cluster1.getId(), newCmds); for (final Command command : commands2) { LOG.info("Command = " + command); } LOG.info("Updating set of commands files associated with id " + cluster1.getId()); //This should remove the original config leaving only the two in this set final List<Command> commands3 = clusterClient.updateCommandsForCluster(cluster1.getId(), newCmds); for (final Command command : commands3) { LOG.info("Command = " + command); } LOG.info("Deleting the command from the cluster with id " + ID + "something"); final Set<Command> commands4 = clusterClient.removeCommandForCluster(cluster1.getId(), ID + "something"); for (final Command command : commands4) { LOG.info("Command = " + command); } LOG.info("Deleting all the commands from the command with id " + command1.getId()); final List<Command> commands5 = clusterClient.removeAllCommandsForCluster(cluster1.getId()); for (final Command command : commands5) { //Shouldn't print anything LOG.info("Command = " + command); } LOG.info("Updating existing cluster config"); cluster2.setStatus(ClusterStatus.TERMINATED); final Cluster cluster3 = clusterClient.updateCluster(cluster2.getId(), cluster2); LOG.info("Cluster updated:"); LOG.info(cluster3.toString()); LOG.info("Deleting cluster config using id"); final Cluster cluster4 = clusterClient.deleteCluster(cluster1.getId()); LOG.info("Deleted cluster config with id: " + cluster1.getId()); LOG.info(cluster4.toString()); LOG.info("Deleting command config using id"); final Command command5 = commandClient.deleteCommand(command1.getId()); LOG.info("Deleted command config with id: " + command1.getId()); LOG.info(command5.toString()); LOG.info("Deleting commands in newCmd"); for (final Command cmd : newCmds) { commandClient.deleteCommand(cmd.getId()); } LOG.info("Deleting application config using id"); final Application app3 = appClient.deleteApplication(app1.getId()); LOG.info("Deleted application config with id: " + app1.getId()); LOG.info(app3.toString()); LOG.info("Deleting application config using id"); final Application app4 = appClient.deleteApplication(app2.getId()); LOG.info("Deleted application config with id: " + app2.getId()); LOG.info(app4.toString()); LOG.info("Done"); }
From source file:Main.java
public static void main(String[] argv) throws Exception { Set result = new HashSet(); Provider[] providers = Security.getProviders(); for (int i = 0; i < providers.length; i++) { Set keys = providers[i].keySet(); for (Iterator it = keys.iterator(); it.hasNext();) { String key = (String) it.next(); key = key.split(" ")[0]; if (key.startsWith("Alg.Alias.")) { // Strip the alias key = key.substring(10);//from w ww .ja va 2 s . c om } int ix = key.indexOf('.'); result.add(key.substring(0, ix)); } } System.out.println(result); }
From source file:com.jivesoftware.os.routing.bird.deployable.config.extractor.ConfigExtractor.java
public static void main(String[] args) { String configHost = args[0];/*from w w w . j ava 2 s. c om*/ String configPort = args[1]; String instanceKey = args[2]; String instanceVersion = args[3]; String setPath = args[4]; String getPath = args[5]; HttpRequestHelper buildRequestHelper = buildRequestHelper(null, configHost, Integer.parseInt(configPort)); try { Set<URL> packages = new HashSet<>(); for (int i = 5; i < args.length; i++) { packages.addAll(ClasspathHelper.forPackage(args[i])); } Reflections reflections = new Reflections(new ConfigurationBuilder().setUrls(packages) .setScanners(new SubTypesScanner(), new TypesScanner())); Set<Class<? extends Config>> subTypesOf = reflections.getSubTypesOf(Config.class); File configDir = new File("./config"); configDir.mkdirs(); Set<Class<? extends Config>> serviceConfig = new HashSet<>(); Set<Class<? extends Config>> healthConfig = new HashSet<>(); for (Class<? extends Config> type : subTypesOf) { if (HealthCheckConfig.class.isAssignableFrom(type)) { healthConfig.add(type); } else { serviceConfig.add(type); } } Map<String, String> defaultServiceConfig = extractAndPublish(serviceConfig, new File(configDir, "default-service-config.properties"), "default", instanceKey, instanceVersion, buildRequestHelper, setPath); DeployableConfig getServiceOverrides = new DeployableConfig("override", instanceKey, instanceVersion, defaultServiceConfig); DeployableConfig gotSerivceConfig = buildRequestHelper.executeRequest(getServiceOverrides, getPath, DeployableConfig.class, null); if (gotSerivceConfig == null) { System.out.println("Failed to publish default service config for " + Arrays.deepToString(args)); } else { Properties override = createKeySortedProperties(); override.putAll(gotSerivceConfig.properties); override.store(new FileOutputStream("config/override-service-config.properties"), ""); } Map<String, String> defaultHealthConfig = extractAndPublish(healthConfig, new File(configDir, "default-health-config.properties"), "default-health", instanceKey, instanceVersion, buildRequestHelper, setPath); DeployableConfig getHealthOverrides = new DeployableConfig("override-health", instanceKey, instanceVersion, defaultHealthConfig); DeployableConfig gotHealthConfig = buildRequestHelper.executeRequest(getHealthOverrides, getPath, DeployableConfig.class, null); if (gotHealthConfig == null) { System.out.println("Failed to publish default health config for " + Arrays.deepToString(args)); } else { Properties override = createKeySortedProperties(); override.putAll(gotHealthConfig.properties); override.store(new FileOutputStream("config/override-health-config.properties"), ""); } Properties instanceProperties = createKeySortedProperties(); File configFile = new File("config/instance.properties"); if (configFile.exists()) { instanceProperties.load(new FileInputStream(configFile)); } Properties serviceOverrideProperties = createKeySortedProperties(); configFile = new File("config/override-service-config.properties"); if (configFile.exists()) { serviceOverrideProperties.load(new FileInputStream(configFile)); } Properties healthOverrideProperties = createKeySortedProperties(); configFile = new File("config/override-health-config.properties"); if (configFile.exists()) { healthOverrideProperties.load(new FileInputStream(configFile)); } Properties properties = createKeySortedProperties(); properties.putAll(defaultServiceConfig); properties.putAll(defaultHealthConfig); properties.putAll(serviceOverrideProperties); properties.putAll(healthOverrideProperties); properties.putAll(instanceProperties); properties.store(new FileOutputStream("config/config.properties"), ""); System.exit(0); } catch (Exception x) { x.printStackTrace(); System.exit(1); } }
From source file:Main.java
public static void main(String[] args) { Set<Object> result = new HashSet<Object>(); Provider[] providers = Security.getProviders(); for (Provider provider : providers) { Set<Object> keys = provider.keySet(); for (Object key : keys) { String data = (String) key; data = data.split(" ")[0]; if (data.startsWith("Alg.Alias")) { data = data.substring(10); }/*from ww w.j av a 2 s . c om*/ data = data.substring(0, data.indexOf('.')); result.add(data); } } for (Object o : result) { System.out.println("Service Type = " + o); } }