List of usage examples for java.util Properties Properties
public Properties()
From source file:com.marklogic.client.tutorial.util.Bootstrapper.java
/** * Command-line invocation./*from ww w. j av a2 s. c om*/ * @param args command-line arguments specifying the configuration and REST server */ public static void main(String[] args) throws ClientProtocolException, IOException, XMLStreamException, FactoryConfigurationError { Properties properties = new Properties(); for (int i = 0; i < args.length; i++) { String name = args[i]; if (name.startsWith("-") && name.length() > 1 && ++i < args.length) { name = name.substring(1); if ("properties".equals(name)) { InputStream propsStream = Bootstrapper.class.getClassLoader().getResourceAsStream(name); if (propsStream == null) throw new IOException("Could not read bootstrapper properties"); Properties props = new Properties(); props.load(propsStream); props.putAll(properties); properties = props; } else { properties.put(name, args[i]); } } else { System.err.println("invalid argument: " + name); System.err.println(getUsage()); System.exit(1); } } String invalid = joinList(listInvalidKeys(properties)); if (invalid != null && invalid.length() > 0) { System.err.println("invalid arguments: " + invalid); System.err.println(getUsage()); System.exit(1); } new Bootstrapper().makeServer(properties); System.out.println("Created " + properties.getProperty("restserver") + " server on " + properties.getProperty("restport") + " port for " + properties.getProperty("restdb") + " database"); }
From source file:net.recommenders.plista.client.Client.java
/** * This method starts the server// ww w. j a va2s .c o m * * @param args * @throws Exception */ public static void main(String[] args) throws Exception { final Properties properties = new Properties(); String fileName = ""; String recommenderClass = null; String handlerClass = null; if (args.length < 3) { fileName = System.getProperty("propertyFile"); } else { fileName = args[0]; recommenderClass = args[1]; handlerClass = args[2]; } // load the team properties try { properties.load(new FileInputStream(fileName)); } catch (IOException e) { logger.error(e.getMessage()); } catch (Exception e) { logger.error(e.getMessage()); } Recommender recommender = null; recommenderClass = (recommenderClass != null ? recommenderClass : properties.getProperty("plista.recommender")); System.out.println(recommenderClass); lognum = Integer.parseInt(properties.getProperty("plista.lognum")); try { final Class<?> transformClass = Class.forName(recommenderClass); recommender = (Recommender) transformClass.newInstance(); } catch (Exception e) { logger.error(e.getMessage()); throw new IllegalArgumentException("No recommender specified or recommender not available."); } // configure log4j /*if (args.length >= 4 && args[3] != null) { PropertyConfigurator.configure(args[0]); } else { PropertyConfigurator.configure("log4j.properties"); }*/ // set up and start server AbstractHandler handler = null; handlerClass = (handlerClass != null ? handlerClass : properties.getProperty("plista.handler")); System.out.println(handlerClass); try { final Class<?> transformClass = Class.forName(handlerClass); handler = (AbstractHandler) transformClass.getConstructor(Properties.class, Recommender.class) .newInstance(properties, recommender); } catch (Exception e) { logger.error(e.getMessage()); e.printStackTrace(); throw new IllegalArgumentException("No handler specified or handler not available."); } final Server server = new Server(Integer.parseInt(properties.getProperty("plista.port", "8080"))); server.setHandler(handler); logger.debug("Serverport " + server.getConnectors()[0].getPort()); server.start(); server.join(); }
From source file:edu.indiana.d2i.sloan.internal.DeleteVMSimulator.java
public static void main(String[] args) { DeleteVMSimulator simulator = new DeleteVMSimulator(); CommandLineParser parser = new PosixParser(); try {//from w w w . j a va 2 s . c om CommandLine line = simulator.parseCommandLine(parser, args); String wdir = line.getOptionValue(CMD_FLAG_VALUE.get(CMD_FLAG_KEY.WORKING_DIR)); if (!HypervisorCmdSimulator.resourceExist(wdir)) { logger.error(String.format("Cannot find VM working dir: %s", wdir)); System.exit(ERROR_CODE.get(ERROR_STATE.VM_NOT_EXIST)); } Properties prop = new Properties(); String filename = HypervisorCmdSimulator.cleanPath(wdir) + HypervisorCmdSimulator.VM_INFO_FILE_NAME; prop.load(new FileInputStream(new File(filename))); // cannot delete VM when it is not shutdown VMState currentState = VMState.valueOf(prop.getProperty(CMD_FLAG_VALUE.get(CMD_FLAG_KEY.VM_STATE))); if (!currentState.equals(VMState.SHUTDOWN)) { logger.error("Cannot perform delete when VM is not shutdown"); System.exit(ERROR_CODE.get(ERROR_STATE.VM_NOT_SHUTDOWN)); } // delete working directory FileUtils.deleteDirectory(new File(wdir)); // success System.exit(0); } catch (ParseException e) { logger.error(String.format("Cannot parse input arguments: %s%n, expected:%n%s", StringUtils.join(args, " "), simulator.getUsage(100, "", 5, 5, ""))); System.exit(ERROR_CODE.get(ERROR_STATE.INVALID_INPUT_ARGS)); } catch (IOException e) { logger.error(e.getMessage(), e); System.exit(ERROR_CODE.get(ERROR_STATE.IO_ERR)); } }
From source file:edu.indiana.d2i.sloan.internal.StopVMSimulator.java
public static void main(String[] args) { StopVMSimulator simulator = new StopVMSimulator(); CommandLineParser parser = new PosixParser(); try {//from w w w . ja v a 2 s. com CommandLine line = simulator.parseCommandLine(parser, args); String wdir = line.getOptionValue(CMD_FLAG_VALUE.get(CMD_FLAG_KEY.WORKING_DIR)); if (!HypervisorCmdSimulator.resourceExist(wdir)) { logger.error(String.format("Cannot find VM working dir: %s", wdir)); System.exit(ERROR_CODE.get(ERROR_STATE.VM_NOT_EXIST)); } Properties prop = new Properties(); String filename = HypervisorCmdSimulator.cleanPath(wdir) + HypervisorCmdSimulator.VM_INFO_FILE_NAME; prop.load(new FileInputStream(new File(filename))); // cannot stop VM when it is not running VMState currentState = VMState.valueOf(prop.getProperty(CMD_FLAG_VALUE.get(CMD_FLAG_KEY.VM_STATE))); if (!currentState.equals(VMState.RUNNING)) { logger.error("Cannot perform stop when VM is not running"); System.exit(ERROR_CODE.get(ERROR_STATE.VM_NOT_RUNNING)); } // stop VM try { Thread.sleep(1000); } catch (InterruptedException e) { logger.error(e.getMessage()); } // update VM status file, i.e. set state to shutdown prop.put(CMD_FLAG_VALUE.get(CMD_FLAG_KEY.VM_STATE), VMState.SHUTDOWN.toString()); // save VM state file back prop.store(new FileOutputStream(new File(filename)), ""); // success System.exit(0); } catch (ParseException e) { logger.error(String.format("Cannot parse input arguments: %s%n, expected:%n%s", StringUtils.join(args, " "), simulator.getUsage(100, "", 5, 5, ""))); System.exit(ERROR_CODE.get(ERROR_STATE.INVALID_INPUT_ARGS)); } catch (IOException e) { logger.error(e.getMessage(), e); System.exit(ERROR_CODE.get(ERROR_STATE.IO_ERR)); } }
From source file:TypeMapDemo.java
public static void main(String[] args) throws IOException, ClassNotFoundException, SQLException { Properties p = new Properties(); p.load(new FileInputStream("db.properties")); Class c = Class.forName(p.getProperty("db.driver")); System.out.println("Loaded driverClass " + c.getName()); Connection con = DriverManager.getConnection(p.getProperty("db.url"), "student", "student"); System.out.println("Got Connection " + con); Statement s = con.createStatement(); int ret;/*from w ww.j a va 2s. co m*/ try { s.executeUpdate("drop table MR"); s.executeUpdate("drop type MUSICRECORDING"); } catch (SQLException andDoNothingWithIt) { // Should use "if defined" but not sure it works for UDTs... } ret = s.executeUpdate("create type MUSICRECORDING as object (" + " id integer," + " title varchar(20), " + " artist varchar(20) " + ")"); System.out.println("Created TYPE! Ret=" + ret); ret = s.executeUpdate("create table MR of MUSICRECORDING"); System.out.println("Created TABLE! Ret=" + ret); int nRows = s.executeUpdate("insert into MR values(123, 'Greatest Hits', 'Ian')"); System.out.println("inserted " + nRows + " rows"); // Put the data class into the connection's Type Map // If the data class were not an inner class, // this would likely be done with Class.forName(...); Map map = con.getTypeMap(); map.put("MUSICRECORDING", MusicRecording.class); con.setTypeMap(map); ResultSet rs = s.executeQuery("select * from MR where id = 123"); //"select musicrecording(id,artist,title) from mr"); rs.next(); for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) { Object o = rs.getObject(i); System.out.print(o + "(Type " + o.getClass().getName() + ")\t"); } System.out.println(); }
From source file:com.joliciel.talismane.terminology.Main.java
public static void main(String[] args) throws Exception { String termFilePath = null;// w w w . j a va 2 s . co m String outFilePath = null; Command command = Command.extract; int depth = -1; String databasePropertiesPath = null; String projectCode = null; Map<String, String> argMap = TalismaneConfig.convertArgs(args); String logConfigPath = argMap.get("logConfigFile"); if (logConfigPath != null) { argMap.remove("logConfigFile"); Properties props = new Properties(); props.load(new FileInputStream(logConfigPath)); PropertyConfigurator.configure(props); } Map<String, String> innerArgs = new HashMap<String, String>(); for (Entry<String, String> argEntry : argMap.entrySet()) { String argName = argEntry.getKey(); String argValue = argEntry.getValue(); if (argName.equals("command")) command = Command.valueOf(argValue); else if (argName.equals("termFile")) termFilePath = argValue; else if (argName.equals("outFile")) outFilePath = argValue; else if (argName.equals("depth")) depth = Integer.parseInt(argValue); else if (argName.equals("databaseProperties")) databasePropertiesPath = argValue; else if (argName.equals("projectCode")) projectCode = argValue; else innerArgs.put(argName, argValue); } if (termFilePath == null && databasePropertiesPath == null) throw new TalismaneException("Required argument: termFile or databasePropertiesPath"); if (termFilePath != null) { String currentDirPath = System.getProperty("user.dir"); File termFileDir = new File(currentDirPath); if (termFilePath.lastIndexOf("/") >= 0) { String termFileDirPath = termFilePath.substring(0, termFilePath.lastIndexOf("/")); termFileDir = new File(termFileDirPath); termFileDir.mkdirs(); } } long startTime = new Date().getTime(); try { TerminologyServiceLocator terminologyServiceLocator = TerminologyServiceLocator.getInstance(); TerminologyService terminologyService = terminologyServiceLocator.getTerminologyService(); TerminologyBase terminologyBase = null; if (projectCode == null) throw new TalismaneException("Required argument: projectCode"); File file = new File(databasePropertiesPath); FileInputStream fis = new FileInputStream(file); Properties dataSourceProperties = new Properties(); dataSourceProperties.load(fis); terminologyBase = terminologyService.getPostGresTerminologyBase(projectCode, dataSourceProperties); if (command.equals(Command.analyse) || command.equals(Command.extract)) { if (depth < 0) throw new TalismaneException("Required argument: depth"); if (command.equals(Command.analyse)) { innerArgs.put("command", "analyse"); } else { innerArgs.put("command", "process"); } TalismaneFrench talismaneFrench = new TalismaneFrench(); TalismaneConfig config = new TalismaneConfig(innerArgs, talismaneFrench); PosTagSet tagSet = TalismaneSession.getPosTagSet(); Charset outputCharset = config.getOutputCharset(); TermExtractor termExtractor = terminologyService.getTermExtractor(terminologyBase); termExtractor.setMaxDepth(depth); termExtractor.setOutFilePath(termFilePath); termExtractor.getIncludeChildren().add(tagSet.getPosTag("P")); termExtractor.getIncludeChildren().add(tagSet.getPosTag("P+D")); termExtractor.getIncludeChildren().add(tagSet.getPosTag("CC")); termExtractor.getIncludeWithParent().add(tagSet.getPosTag("DET")); if (outFilePath != null) { if (outFilePath.lastIndexOf("/") >= 0) { String outFileDirPath = outFilePath.substring(0, outFilePath.lastIndexOf("/")); File outFileDir = new File(outFileDirPath); outFileDir.mkdirs(); } File outFile = new File(outFilePath); outFile.delete(); outFile.createNewFile(); Writer writer = new BufferedWriter( new OutputStreamWriter(new FileOutputStream(outFilePath), outputCharset)); TermAnalysisWriter termAnalysisWriter = new TermAnalysisWriter(writer); termExtractor.addTermObserver(termAnalysisWriter); } Talismane talismane = config.getTalismane(); talismane.setParseConfigurationProcessor(termExtractor); talismane.process(); } else if (command.equals(Command.list)) { List<Term> terms = terminologyBase.getTermsByFrequency(2); for (Term term : terms) { LOG.debug("Term: " + term.getText()); LOG.debug("Frequency: " + term.getFrequency()); LOG.debug("Heads: " + term.getHeads()); LOG.debug("Expansions: " + term.getExpansions()); LOG.debug("Contexts: " + term.getContexts()); } } } finally { long endTime = new Date().getTime(); long totalTime = endTime - startTime; LOG.info("Total time: " + totalTime); } }
From source file:com.mijecu25.sqlplus.SQLPlus.java
public static void main(String[] args) throws IOException { // Create and load the properties from the application properties file Properties properties = new Properties(); properties.load(SQLPlus.class.getClassLoader().getResourceAsStream(SQLPlus.APPLICATION_PROPERTIES_FILE)); SQLPlus.logger.info("Initializing " + SQLPlus.PROGRAM_NAME + " version " + properties.getProperty(SQLPlus.APPLICATION_PROPERTIES_FILE_VERSION)); // Check if the user is using a valid console (i.e. not from Eclipse) if (System.console() == null) { // The Console object for the JVM could not be found. Alert the user SQLPlus.logger.fatal(Messages.FATAL + "A JVM Console object was not found. Try running " + SQLPlus.PROGRAM_NAME + "from the command line"); System.out.println(/* w w w. jav a2s . c o m*/ Messages.FATAL + SQLPlus.PROGRAM_NAME + " was not able to find your JVM's Console object. " + "Try running " + SQLPlus.PROGRAM_NAME + " from the command line."); SQLPlus.exitSQLPlus(); SQLPlus.logger.fatal(Messages.FATAL + Messages.QUIT_PROGRAM_ERROR(PROGRAM_NAME)); return; } // UI intro System.out.println("Welcome to " + SQLPlus.PROGRAM_NAME + "! This program has a DSL to add alerts to various SQL DML events."); System.out.println("Be sure to use " + SQLPlus.PROGRAM_NAME + " from the command line."); System.out.println(); // Get the version System.out.println("Version: " + properties.getProperty(SQLPlus.APPLICATION_PROPERTIES_FILE_VERSION)); System.out.println(); // Read the license file BufferedReader bufferedReader; bufferedReader = new BufferedReader(new FileReader(SQLPlus.LICENSE_FILE)); // Read a line String line = bufferedReader.readLine(); // While the line is not null while (line != null) { System.out.println(line); // Read a new lines line = bufferedReader.readLine(); } // Close the buffer bufferedReader.close(); System.out.println(); // Create the jline console that allows us to remember commands, use arrow keys, and catch interruptions // from the user SQLPlus.console = new ConsoleReader(); SQLPlus.console.setHandleUserInterrupt(true); try { // Get credentials from the user SQLPlus.logger.info("Create SQLPlusConnection"); SQLPlus.createSQLPlusConnection(); } catch (NullPointerException | SQLException | IllegalArgumentException e) { // NPE: This exception can occur if the user is running the program where the JVM Console // object cannot be found. // SQLE: TODO should I add here the error code? // This exception can occur when trying to establish a connection // IAE: This exception can occur when trying to establish a connection SQLPlus.logger .fatal(Messages.FATAL + Messages.FATAL_EXIT(SQLPlus.PROGRAM_NAME, e.getClass().getName())); System.out.println(Messages.FATAL + Messages.FATAL_EXCEPTION_ACTION(e.getClass().getSimpleName()) + " " + Messages.CHECK_LOG_FILES); SQLPlus.exitSQLPlus(); SQLPlus.logger.fatal(Messages.FATAL + Messages.QUIT_PROGRAM_ERROR(SQLPlus.PROGRAM_NAME)); return; } catch (UserInterruptException uie) { SQLPlus.logger.warn(Messages.WARNING + "The user typed an interrupt instruction."); SQLPlus.exitSQLPlus(); return; } System.out.println("Connection established! Commands end with " + SQLPlus.END_OF_COMMAND); System.out.println("Type " + SQLPlus.EXIT + " or " + SQLPlus.QUIT + " to exit the application "); try { // Execute the input scanner while (true) { // Get a line from the user until the hit enter (carriage return, line feed/ new line). System.out.print(SQLPlus.PROMPT); try { line = SQLPlus.console.readLine().trim(); } catch (NullPointerException npe) { // TODO test this behavior // If this exception is catch, it is very likely that the user entered the end of line command. // This means that the program should quit. SQLPlus.logger.warn(Messages.WARNING + "The input from the user is null. It is very likely that" + "the user entered the end of line command and they want to quit."); SQLPlus.exitSQLPlus(); return; } // If the user did not enter anything if (line.isEmpty()) { // Continue to the next iteration continue; } if (line.equals(".")) { line = "use courses;"; } if (line.equals("-")) { line = "select created_at from classes;"; } if (line.equals("--")) { line = "select name, year from classes;"; } if (line.equals("*")) { line = "select * from classes;"; } if (line.equals("x")) { line = "select name from classes, classes;"; } if (line.equals("e")) { line = "select * feom classes;"; } // Logic to quit if (line.equals(SQLPlus.QUIT) || line.equals(SQLPlus.EXIT)) { SQLPlus.logger.info("The user wants to quit " + SQLPlus.PROGRAM_NAME); SQLPlus.exitSQLPlus(); break; } // Use a StringBuilder since jline works weird when it has read a line. The issue we were having was with the // end of command logic. jline does not keep the input from the user in the variable that was stored in. Each // time jline reads a new line, the variable is empty StringBuilder query = new StringBuilder(); query.append(line); // While the user does not finish the command with the SQLPlus.END_OF_COMMAND while (query.charAt(query.length() - 1) != SQLPlus.END_OF_COMMAND) { // Print the wait for command prompt and get the next line for the user System.out.print(SQLPlus.WAIT_FOR_END_OF_COMMAND); query.append(" "); line = StringUtils.stripEnd(SQLPlus.console.readLine(), null); query.append(line); } SQLPlus.logger.info("Raw input from the user: " + query); try { Statement statement; try { // Execute the antlr code to parse the user input SQLPlus.logger.info("Will parse the user input to determine what to execute"); ANTLRStringStream input = new ANTLRStringStream(query.toString()); SQLPlusLex lexer = new SQLPlusLex(input); CommonTokenStream tokens = new CommonTokenStream(lexer); SQLPlusParser parser = new SQLPlusParser(tokens); statement = parser.sqlplus(); } catch (RecognitionException re) { // TODO move this to somehwere else // String message = Messages.WARNING + "You have an error in your SQL syntax. Check the manual" // + " that corresponds to your " + SQLPlus.sqlPlusConnection.getCurrentDatabase() // + " server or " + SQLPlus.PROGRAM_NAME + " for the correct syntax"; // SQLPlus.logger.warn(message); // System.out.println(message); statement = new StatementDefault(); } statement.setStatement(query.toString()); SQLPlus.sqlPlusConnection.execute(statement); } catch (UnsupportedOperationException uoe) { // This exception can occur when the user entered a command allowed by the parsers, but not currently // supported by SQLPlus. This can occur because the parser is written in such a way that supports // the addition of features. SQLPlus.logger.warn(Messages.WARNING + uoe); System.out.println( Messages.WARNING + Messages.FATAL_EXCEPTION_ACTION(uoe.getClass().getSimpleName()) + " " + Messages.CHECK_LOG_FILES); SQLPlus.logger.warn(Messages.WARNING + "The previous command is not currently supported."); } } } catch (IllegalArgumentException iae) { // This exception can occur when a command is executed but it had illegal arguments. Most likely // it is a programmer's error and should be addressed by the developer. SQLPlus.logger .fatal(Messages.FATAL + Messages.FATAL_EXIT(SQLPlus.PROGRAM_NAME, iae.getClass().getName())); SQLPlus.exitSQLPlus(); SQLPlus.logger.fatal(Messages.FATAL + Messages.QUIT_PROGRAM_ERROR(SQLPlus.PROGRAM_NAME)); } catch (UserInterruptException uie) { SQLPlus.logger.warn(Messages.WARNING + "The user typed an interrupt instruction."); SQLPlus.exitSQLPlus(); } }
From source file:gobblin.scheduler.SchedulerDaemon.java
public static void main(String[] args) throws Exception { if (args.length < 1 || args.length > 2) { System.err.println(/*ww w . ja v a 2 s. c om*/ "Usage: SchedulerDaemon <default configuration properties file> [custom configuration properties file]"); System.exit(1); } // Load default framework configuration properties Properties defaultProperties = ConfigurationConverter.getProperties(new PropertiesConfiguration(args[0])); // Load custom framework configuration properties (if any) Properties customProperties = new Properties(); if (args.length == 2) { customProperties.putAll(ConfigurationConverter.getProperties(new PropertiesConfiguration(args[1]))); } log.debug("Scheduler Daemon::main starting with defaultProperties: {}, customProperties: {}", defaultProperties, customProperties); // Start the scheduler daemon new SchedulerDaemon(defaultProperties, customProperties).start(); }
From source file:com.dtolabs.rundeck.ec2.NodeGenerator.java
public static void main(final String[] args) throws IOException, GeneratorException { File outfile = null;//from w ww. j a v a 2s.c o m //load generator mapping if (args.length < 2) { System.err.println( "usage: <credentials.properties> <endpoint> [mapping.properties] [outfile] [query parameters, \"a=b\" ...]"); System.err.println( "\t optional arguments can be replaced by \"-\" to use the default, and then query parameters appended"); System.exit(2); } final InputStream stream = new FileInputStream(args[0]); final String endPoint = args[1]; final AWSCredentials credentials = new PropertiesCredentials(stream); Properties mapping = new Properties(); if (args.length > 2 && !"-".equals(args[2])) { mapping.load(new FileInputStream(args[2])); } else { mapping.load(NodeGenerator.class.getClassLoader().getResourceAsStream("simplemapping.properties")); } final ResourceXMLGenerator gen; if (args.length > 3 && !"-".equals(args[3])) { outfile = new File(args[3]); gen = new ResourceXMLGenerator(outfile); } else { //use stdout gen = new ResourceXMLGenerator(System.out); } ArrayList<String> params = new ArrayList<String>(); if (args.length > 4) { for (int i = 4; i < args.length; i++) { params.add(args[i]); } } Set<Instance> instances = performQuery(credentials, endPoint, params); for (final Instance inst : instances) { final INodeEntry iNodeEntry = instanceToNode(inst, mapping); if (null != iNodeEntry) { gen.addNode(iNodeEntry); } } gen.generate(); // if (null != outfile) { System.out.println("XML Stored: " + outfile.getAbsolutePath()); } }
From source file:eu.cognitum.readandwrite.App.java
public static void main(String[] args) { try {/*from w w w.j ava2 s .co m*/ String configFile = 0 == args.length ? "example.properties" : args[0]; CONFIGURATION = new Properties(); File f = new File(configFile); if (!f.exists()) { LOGGER.warning("configuration not found at " + configFile); return; } LOGGER.info("loading configuration file " + f.getAbsoluteFile()); CONFIGURATION.load(new FileInputStream(f)); String ip = CONFIGURATION.getProperty(PROP_STORAGE_HOSTNAME); String keyspace = CONFIGURATION.getProperty(PROP_STORAGE_KEYSPACE); String directory = CONFIGURATION.getProperty(PROP_STORAGE_DIRECTORY); // N of articles to be generated. int Narticles = 100000; // size of the buffer to commit each time int commitBufferSize = 100; // N of articles to commit before trying reads int readStep = 100; String currentNamespace = "http://mynamespace#"; LOGGER.log(Level.INFO, "Generating the rdf..."); GenerateRdf rdfGenerator = new GenerateRdf(currentNamespace, "tmp.rdf"); rdfGenerator.generateAndSaveRdf(Narticles); LOGGER.log(Level.INFO, "Generated the rdf!"); ArrayList<SimulateReadAndWrite> simulateAll = new ArrayList<SimulateReadAndWrite>(); int Ndbs = 0; DBS[] chosenDbs = { DBS.NATIVE }; //DBS[] chosenDbs = DBS.values(); for (DBS dbs : chosenDbs) { SailRepository sr; switch (dbs) { case NATIVE: sr = createNativeStoreConnection(directory); break; case TITAN: sr = createTitanConnection(ip, keyspace); break; case NEO4J: sr = createNeo4jConnection(keyspace); break; case ORIENT: sr = createOrientConnection(keyspace); break; default: sr = null; break; } if (sr == null) { throw new Exception("Something wrong while connecting to " + dbs.toString()); } simulateAll.add(new SimulateReadAndWrite(sr, "test" + dbs.toString(), Narticles, readStep, commitBufferSize, dbs.toString(), keyspace, currentNamespace, rdfGenerator)); simulateAll.get(Ndbs).start(); Ndbs++; } int Nfinished = 0; int k; while (Nfinished != Ndbs) { Nfinished = 0; k = 0; for (DBS dbs : chosenDbs) { if (simulateAll.get(k).IsProcessCompleted()) { Nfinished++; } else { System.out.println(String.format("Process for db %s is at %.2f", dbs.toString(), simulateAll.get(k).GetProgress())); } k++; } Thread.sleep(10000); } } catch (Exception ex) { LOGGER.log(Level.SEVERE, null, ex); } }