List of usage examples for java.lang Integer valueOf
@HotSpotIntrinsicCandidate public static Integer valueOf(int i)
From source file:com.sm.store.server.ClusterServer.java
public static void main(String[] args) { String[] opts = new String[] { "-host", "-configPath", "-dataPath", "-port", "replicaPort", "-start", "-freq" }; String[] defaults = new String[] { "", "", "", "0", "0", "true", "0" }; String[] paras = getOpts(args, opts, defaults); String configPath = paras[1]; if (configPath.length() == 0) { logger.error("missing config path"); throw new RuntimeException("missing -configPath"); }// ww w .ja v a 2 s. c o m //set configPath to system properties System.setProperty("configPath", configPath); NodeConfig nodeConfig = getNodeConfig(configPath + "/node.properties"); //int clusterNo = Integer.valueOf( paras[0]); String dataPath = paras[2]; if (dataPath.length() == 0) { dataPath = "./data"; } int port = Integer.valueOf(paras[3]); int replicaPort = Integer.valueOf(paras[4]); //get from command line, if not form nodeConfig if (port == 0) port = nodeConfig.getPort(); if (port == 0) { throw new RuntimeException("port is 0"); } else { if (replicaPort == 0) replicaPort = port + 1; } boolean start = Boolean.valueOf(paras[5]); String host = paras[0]; //get from command line, if not form nodeConfig or from getHost if (host.length() == 0) host = nodeConfig.getHost(); if (host.length() == 0) host = getLocalHost(); int freq = Integer.valueOf(paras[6]); logger.info("read clusterNode and storeConfig from " + configPath); BuildClusterNodes bcn = new BuildClusterNodes(configPath + "/clusters.xml"); //BuildStoreConfig bsc = new BuildStoreConfig(configPath+"/stores.xml"); BuildRemoteConfig brc = new BuildRemoteConfig(configPath + "/stores.xml"); List<ClusterNodes> clusterNodesList = bcn.build(); short clusterNo = findClusterNo(host + ":" + port, clusterNodesList); logger.info("create cluster server config for cluster " + clusterNo + " host " + host + " port " + port + " replica port " + replicaPort); ClusterServerConfig serverConfig = new ClusterServerConfig(clusterNodesList, brc.build().getConfigList(), clusterNo, dataPath, configPath, port, replicaPort, host); //over write config from command line if freq > 0 if (freq > 0) serverConfig.setFreq(freq); logger.info("create cluster server"); ClusterStoreServer cs = new ClusterStoreServer(serverConfig, new HessianSerializer()); // start replica server cs.startReplicaServer(); logger.info("hookup jvm shutdown process"); cs.hookShutdown(); if (start) { logger.info("server is starting " + cs.getServerConfig().toString()); cs.start(); } else logger.warn("server is staged and wait to be started"); List list = new ArrayList(); //add jmx metric List<String> stores = cs.getAllStoreNames(); for (String store : stores) { list.add(cs.getStore(store)); } list.add(cs); stores.add("ClusterServer"); JmxService jms = new JmxService(list, stores); }
From source file:com.sm.store.server.grizzly.GZClusterServer.java
public static void main(String[] args) { String[] opts = new String[] { "-host", "-configPath", "-dataPath", "-port", "replicaPort", "-start", "-freq" }; String[] defaults = new String[] { "", "", "", "0", "0", "true", "10" }; String[] paras = getOpts(args, opts, defaults); String configPath = paras[1]; if (configPath.length() == 0) { logger.error("missing config path"); throw new RuntimeException("missing -configPath"); }/* w ww . j a v a 2 s . c o m*/ System.setProperty("configPath", configPath); NodeConfig nodeConfig = getNodeConfig(configPath + "/node.properties"); //int clusterNo = Integer.valueOf( paras[0]); String dataPath = paras[2]; if (dataPath.length() == 0) { dataPath = "./data"; } int port = Integer.valueOf(paras[3]); int replicaPort = Integer.valueOf(paras[4]); //get from command line, if not form nodeConfig if (port == 0) port = nodeConfig.getPort(); if (port == 0) { throw new RuntimeException("port is 0"); } else { if (replicaPort == 0) replicaPort = port + 1; } boolean start = Boolean.valueOf(paras[5]); String host = paras[0]; //get from command line, if not form nodeConfig or from getHost if (host.length() == 0) host = nodeConfig.getHost(); if (host.length() == 0) host = getLocalHost(); int freq = Integer.valueOf(paras[6]); logger.info("read clusterNode and storeConfig from " + configPath); BuildClusterNodes bcn = new BuildClusterNodes(configPath + "/clusters.xml"); //BuildStoreConfig bsc = new BuildStoreConfig(configPath+"/stores.xml"); BuildRemoteConfig brc = new BuildRemoteConfig(configPath + "/stores.xml"); List<ClusterNodes> clusterNodesList = bcn.build(); short clusterNo = findClusterNo(host + ":" + port, clusterNodesList); logger.info("create cluster server config for cluster " + clusterNo + " host " + host + " port " + port + " replica port " + replicaPort); ClusterServerConfig serverConfig = new ClusterServerConfig(clusterNodesList, brc.build().getConfigList(), clusterNo, dataPath, configPath, port, replicaPort, host); serverConfig.setFreq(freq); logger.info("create cluster server"); GZClusterStoreServer cs = new GZClusterStoreServer(serverConfig, new HessianSerializer()); // start replica server cs.startReplicaServer(); logger.info("hookup jvm shutdown process"); cs.hookShutdown(); if (start) { logger.info("server is starting " + cs.getServerConfig().toString()); cs.start(); } else logger.warn("server is staged and wait to be started"); List list = new ArrayList(); //add jmx metric List<String> stores = cs.getAllStoreNames(); for (String store : stores) { list.add(cs.getStore(store)); } list.add(cs); stores.add("ClusterServer"); JmxService jms = new JmxService(list, stores); try { logger.info("Read from console and wait ...."); int c = System.in.read(); } catch (IOException e) { logger.warn("Error reading " + e.getMessage()); } logger.warn("Exiting from System.in.read()"); }
From source file:Main.java
public static void main(String[] args) throws Exception { DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); Document doc = dBuilder.parse(new InputSource(new StringReader(cfgXml))); doc.getDocumentElement().normalize(); System.out.println("Root element :" + doc.getDocumentElement().getNodeName()); NodeList nList = doc.getElementsByTagName("config"); for (int temp = 0; temp < nList.getLength(); temp++) { Node nNode = nList.item(temp); System.out.println("\nCurrent Element :" + nNode.getNodeName()); if (nNode.getNodeType() == Node.ELEMENT_NODE) { Element eElement = (Element) nNode; Config c = new Config(); c.name = eElement.getAttribute("name"); c.type = eElement.getAttribute("type"); c.format = eElement.getAttribute("format"); c.size = Integer.valueOf(eElement.getAttribute("size")); c.scale = Integer.valueOf(eElement.getAttribute("scale")); String attribute = eElement.getAttribute("required"); c.required = Boolean.valueOf("Yes".equalsIgnoreCase(attribute) ? true : false); System.out.println("Imported config : " + c); }//from ww w. j av a 2 s. c o m } }
From source file:de.tudarmstadt.ukp.experiments.dip.wp1.documents.Step2FillWithRetrievedResults.java
public static void main(String[] args) throws IOException { // input dir - list of xml query containers File inputDir = new File(args[0]); // retrieved results from Technion // ltr-50queries-100docs.txt File ltr = new File(args[1]); // output dir File outputDir = new File(args[2]); if (!outputDir.exists()) { outputDir.mkdirs();//from ww w .j av a2 s. co m } // load the query containers first (into map: id + container) Map<String, QueryResultContainer> queryResults = new HashMap<>(); for (File f : FileUtils.listFiles(inputDir, new String[] { "xml" }, false)) { System.out.println(f); QueryResultContainer queryResultContainer = QueryResultContainer .fromXML(FileUtils.readFileToString(f, "utf-8")); queryResults.put(queryResultContainer.qID, queryResultContainer); } // iterate over IR results for (String line : FileUtils.readLines(ltr)) { String[] split = line.split("\\s+"); Integer origQueryId = Integer.valueOf(split[0]); String clueWebID = split[2]; Integer rank = Integer.valueOf(split[3]); double score = Double.valueOf(split[4]); String additionalInfo = split[5]; // get the container for this result QueryResultContainer container = queryResults.get(origQueryId.toString()); if (container != null) { // add new result QueryResultContainer.SingleRankedResult result = new QueryResultContainer.SingleRankedResult(); result.clueWebID = clueWebID; result.rank = rank; result.score = score; result.additionalInfo = additionalInfo; if (container.rankedResults == null) { container.rankedResults = new ArrayList<>(); } container.rankedResults.add(result); } } // save all containers to the output dir for (QueryResultContainer queryResultContainer : queryResults.values()) { File outputFile = new File(outputDir, queryResultContainer.qID + ".xml"); FileUtils.writeStringToFile(outputFile, queryResultContainer.toXML(), "utf-8"); System.out.println("Finished " + outputFile); } }
From source file:uk.ac.kcl.Main.java
public static void main(String[] args) { File folder = new File(args[0]); File[] listOfFiles = folder.listFiles(); assert listOfFiles != null; for (File listOfFile : listOfFiles) { if (listOfFile.isFile()) { if (listOfFile.getName().endsWith(".properties")) { System.out.println("Properties sile found:" + listOfFile.getName() + ". Attempting to launch application context"); Properties properties = new Properties(); InputStream input; try { input = new FileInputStream(listOfFile); properties.load(input); if (properties.getProperty("globalSocketTimeout") != null) { TcpHelper.setSocketTimeout( Integer.valueOf(properties.getProperty("globalSocketTimeout"))); }/*from ww w . j av a 2 s. c om*/ Map<String, Object> map = new HashMap<>(); properties.forEach((k, v) -> { map.put(k.toString(), v); }); ConfigurableEnvironment environment = new StandardEnvironment(); MutablePropertySources propertySources = environment.getPropertySources(); propertySources.addFirst(new MapPropertySource(listOfFile.getName(), map)); @SuppressWarnings("resource") AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.registerShutdownHook(); ctx.setEnvironment(environment); String scheduling; try { scheduling = properties.getProperty("scheduler.useScheduling"); if (scheduling.equalsIgnoreCase("true")) { ctx.register(ScheduledJobLauncher.class); ctx.refresh(); } else if (scheduling.equalsIgnoreCase("false")) { ctx.register(SingleJobLauncher.class); ctx.refresh(); SingleJobLauncher launcher = ctx.getBean(SingleJobLauncher.class); launcher.launchJob(); } else if (scheduling.equalsIgnoreCase("slave")) { ctx.register(JobConfiguration.class); ctx.refresh(); } else { throw new RuntimeException( "useScheduling not configured. Must be true, false or slave"); } } catch (NullPointerException ex) { throw new RuntimeException( "useScheduling not configured. Must be true, false or slave"); } } catch (IOException e) { e.printStackTrace(); } } } } }
From source file:com.sm.store.TestMultiClient.java
public static void main(String[] args) throws Exception { String[] opts = new String[] { "-thread", "-times", "-host", "-port", "-store" }; String[] defaults = new String[] { "2", "10", "localhost", "7100", "keystore" }; String[] paras = getOpts(args, opts, defaults); int threads = Integer.valueOf(paras[0]); int times = Integer.valueOf(paras[1]); String host = paras[2];// w w w . j a v a 2 s .co m int port = Integer.valueOf(paras[3]); String store = paras[4]; for (int i = 0; i < threads; i++) { com.sm.store.client.RemoteClientImpl client = new GZRemoteClientImpl(host + ":" + port, null, store); logger.info("start thread =>" + i); new Thread(new RunnerThread(client, times, i), "thread-" + i).start(); } }
From source file:com.sm.replica.grizzly.DefaultReplicaServer.java
public static void main(String[] args) { String[] opts = new String[] { "-store", "-path", "-port", "-mode", "index" }; String[] defaults = new String[] { "replica", "./data", "7120", "0", "0" }; String[] paras = getOpts(args, opts, defaults); String store = paras[0];/*from ww w.java 2 s . c o m*/ int port = Integer.valueOf(paras[2]); String path = paras[1]; int mode = Integer.valueOf(paras[3]); int index = Integer.valueOf(paras[4]); CacheStore cacheStore = new CacheStore(path, null, mode); LogChannel logChannel = new LogChannel(store, index, path); DefaultReplicaServer defaultReplicaServer = new DefaultReplicaServer(logChannel, index, store, path); HashMap<String, CacheStore> storesMap = new HashMap<String, CacheStore>(); storesMap.put(store, cacheStore); UnisonFilter unisonServerFilter = new UnisonFilter(defaultReplicaServer); unisonServerFilter.setFreq(1); logger.info("start server at " + port); ReplicaServer server = new ReplicaServer(port, storesMap, unisonServerFilter); defaultReplicaServer.hookShutdown(); logger.info("set main thread to wait()"); try { //System.in.read(); Object obj = new Object(); synchronized (obj) { obj.wait(); } } catch (Exception io) { logger.error(io.getMessage(), io); } }
From source file:VoldemortStatusPage.java
public static void main(String[] args) throws Exception { if (args.length < 2) { System.out.println(/*www .j a v a 2 s.co m*/ "Usage: java -cp .:/path/to/voldemort-installation/lib/* VoldemortStatusPage <http-port-number> <cluster-details>.properties"); System.out .println(" Properties file should contain list of bootstrap URLs that needs to be monitored."); System.out.println(" Example enries:"); System.out.println(" cluster.1 = tcp://1.2.3.4:7001/"); System.out.println(" cluster.2 = tcp://1.2.3.5:7001/"); System.out.println(" cluster.3 = tcp://1.2.3.6:7001/"); return; } Properties p = lookupProperties(args[1]); startJettyServer(Integer.valueOf(args[0]), p); }
From source file:com.sm.test.TestFile.java
public static void main(String[] args) throws Exception { String[] opts = new String[] { "-filename", "-mapSize", "-range", "-listSize", "-times", "-url", "-store", }; String[] defaults = new String[] { "/Users/mhsieh/test/data/userCrm", "5", "4", "2", "100", "las1-crmp001:6172", "userCrm" }; String[] paras = getOpts(args, opts, defaults); String filename = paras[0];// w ww . ja va2 s.c o m short mapSize = Short.valueOf(paras[1]); int range = Integer.valueOf(paras[2]); int listSize = Integer.valueOf(paras[3]); int times = Integer.valueOf(paras[4]); String url = paras[5]; String store = paras[6]; TestFile testFile = new TestFile(mapSize, range, listSize); ClusterClientFactory ccf = ClusterClientFactory.connect(url, store); ClusterClient client = ccf.getDefaultStore(); StoreIterator storeIterator = new StoreIterator(filename); int i = 0; while (storeIterator.hasNext()) { // Pair<Key, byte[]> pair = storeIterator.next(); // short c1 = testFile.getPartitionIndex( pair.getFirst()).getFirst(); // short c2 = testFile.finePartition( pair.getFirst()); // if ( c1 != c2) { // logger.info( "mismatch i "+i + " c1 "+c1 + " c2 "+c2+ " "+ toStr( (byte[]) pair.getFirst().getKey() )+ " "+pair.getFirst().hashCode() ); // } List<Key> list = getKeyList(storeIterator, 1000); List<KeyValue> keyValues = client.multiGets(list); int ma = match(keyValues); if (ma != list.size()) { logger.info("expect " + list.size() + " get " + ma); } i++; if (i > times) break; } logger.info("close file " + filename); storeIterator.close(); }
From source file:io.rhiot.spec.IoTSpec.java
public static void main(String[] args) throws Exception { CommandLineParser parser = new DefaultParser(); Options options = new Options(); options.addOption(Option.builder("c").longOpt(CONFIG).desc( "Location of the test configuration file. A default value is 'src/main/resources/test.yaml' for easy IDE testing") .hasArg().build());/*from w w w . ja va 2s . c om*/ options.addOption(Option.builder("i").longOpt(INSTANCE).desc("Instance of the test; A default value is 1") .hasArg().build()); options.addOption(Option.builder("r").longOpt(REPORT) .desc("Location of the test report. A default value is 'target/report.csv'").hasArg().build()); CommandLine line = parser.parse(options, args); ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); TestProfile test = mapper.readValue(new File(line.getOptionValue(CONFIG, "src/main/resources/test.yaml")), TestProfile.class); int instance = Integer.valueOf(line.getOptionValue(INSTANCE, "1")); test.setInstance(instance); String report = line.getOptionValue(REPORT, "target/report.csv"); test.setReport(new CSVReport(report)); LOG.info("Test '" + test.getName() + "' instance " + instance + " started"); final List<Driver> drivers = test.getDrivers(); ExecutorService executorService = Executors.newFixedThreadPool(drivers.size()); List<Future<Void>> results = executorService.invokeAll(drivers, test.getDuration(), TimeUnit.MILLISECONDS); executorService.shutdownNow(); executorService.awaitTermination(5, TimeUnit.SECONDS); results.forEach(result -> { try { result.get(); } catch (ExecutionException execution) { LOG.warn("Exception running driver", execution); } catch (Exception interrupted) { } }); drivers.forEach(driver -> { driver.stop(); try { test.getReport().print(driver); } catch (Exception e) { LOG.warn("Failed to write reports for the driver " + driver); } LOG.debug("Driver " + driver); LOG.debug("\t " + driver.getResult()); }); test.getReport().close(); LOG.info("Test '" + test.getName() + "' instance " + instance + " finished"); }