List of usage examples for java.lang System currentTimeMillis
@HotSpotIntrinsicCandidate public static native long currentTimeMillis();
From source file:deck36.storm.plan9.php.KittenRobbersTopology.java
public static void main(String[] args) throws Exception { String env = null;//from www . j a v a 2s . c o m if (args != null && args.length > 0) { env = args[0]; } if (!"dev".equals(env)) if (!"prod".equals(env)) { System.out.println("Usage: $0 (dev|prod)\n"); System.exit(1); } // Topology config Config conf = new Config(); // Load parameters and add them to the Config Map configMap = YamlLoader.loadYamlFromResource("config_" + env + ".yml"); conf.putAll(configMap); log.info(JSONValue.toJSONString((conf))); // Set topology loglevel to DEBUG conf.put(Config.TOPOLOGY_DEBUG, JsonPath.read(conf, "$.deck36_storm.debug")); // Create Topology builder TopologyBuilder builder = new TopologyBuilder(); // if there are not special reasons, start with parallelism hint of 1 // and multiple tasks. By that, you can scale dynamically later on. int parallelism_hint = JsonPath.read(conf, "$.deck36_storm.default_parallelism_hint"); int num_tasks = JsonPath.read(conf, "$.deck36_storm.default_num_tasks"); String badgeName = KittenRobbersTopology.class.getSimpleName(); // construct command to invoke the external bolt implementation ArrayList<String> command = new ArrayList(15); // Add main execution program (php, hhvm, zend, ..) and parameters command.add((String) JsonPath.read(conf, "$.deck36_storm.php.executor")); command.addAll((List<String>) JsonPath.read(conf, "$.deck36_storm.php.executor_params")); // Add main command to be executed (app/console, the phar file, etc.) and global context parameters (environment etc.) command.add((String) JsonPath.read(conf, "$.deck36_storm.php.main")); command.addAll((List<String>) JsonPath.read(conf, "$.deck36_storm.php.main_params")); // Add main route to be invoked and its parameters command.add((String) JsonPath.read(conf, "$.deck36_storm.KittenRobbersFromOuterSpaceBolt.main")); List boltParams = (List<String>) JsonPath.read(conf, "$.deck36_storm.KittenRobbersFromOuterSpaceBolt.params"); if (boltParams != null) command.addAll(boltParams); // Log the final command log.info("Command to start bolt for KittenRobbersFromOuterSpace: " + Arrays.toString(command.toArray())); // Add constructed external bolt command to topology using MultilangAdapterBolt builder.setBolt("badge", new MultilangAdapterTickTupleBolt(command, (Integer) JsonPath.read(conf, "$.deck36_storm.KittenRobbersFromOuterSpaceBolt.robber_frequency"), "badge"), parallelism_hint).setNumTasks(num_tasks); builder.setBolt("rabbitmq_router", new Plan9RabbitMQRouterBolt( (String) JsonPath.read(conf, "$.deck36_storm.KittenRobbersFromOuterSpaceBolt.rabbitmq.target_exchange"), "KittenRobbers" // RabbitMQ routing key ), parallelism_hint).setNumTasks(num_tasks).shuffleGrouping("badge"); builder.setBolt("rabbitmq_producer", new Plan9RabbitMQPushBolt(), parallelism_hint).setNumTasks(num_tasks) .shuffleGrouping("rabbitmq_router"); if ("dev".equals(env)) { LocalCluster cluster = new LocalCluster(); cluster.submitTopology(badgeName + System.currentTimeMillis(), conf, builder.createTopology()); Thread.sleep(2000000); } if ("prod".equals(env)) { StormSubmitter.submitTopology(badgeName + "-" + System.currentTimeMillis(), conf, builder.createTopology()); } }
From source file:fr.inria.atlanmod.kyanos.benchmarks.KyanosGraphQueryList.java
public static void main(String[] args) { Options options = new Options(); Option inputOpt = OptionBuilder.create(IN); inputOpt.setArgName("INPUT"); inputOpt.setDescription("Input Kyanos resource directory"); inputOpt.setArgs(1);/*from w w w.j av a2 s. c o m*/ inputOpt.setRequired(true); Option inClassOpt = OptionBuilder.create(EPACKAGE_CLASS); inClassOpt.setArgName("CLASS"); inClassOpt.setDescription("FQN of EPackage implementation class"); inClassOpt.setArgs(1); inClassOpt.setRequired(true); Option optFileOpt = OptionBuilder.create(OPTIONS_FILE); optFileOpt.setArgName("FILE"); optFileOpt.setDescription("Properties file holding the options to be used in the Kyanos Resource"); optFileOpt.setArgs(1); options.addOption(inputOpt); options.addOption(inClassOpt); options.addOption(optFileOpt); CommandLineParser parser = new PosixParser(); try { PersistenceBackendFactoryRegistry.getFactories().put(NeoBlueprintsURI.NEO_GRAPH_SCHEME, new BlueprintsPersistenceBackendFactory()); CommandLine commandLine = parser.parse(options, args); URI uri = NeoBlueprintsURI.createNeoGraphURI(new File(commandLine.getOptionValue(IN))); Class<?> inClazz = KyanosGraphQueryList.class.getClassLoader() .loadClass(commandLine.getOptionValue(EPACKAGE_CLASS)); inClazz.getMethod("init").invoke(null); ResourceSet resourceSet = new ResourceSetImpl(); resourceSet.getResourceFactoryRegistry().getProtocolToFactoryMap() .put(NeoBlueprintsURI.NEO_GRAPH_SCHEME, PersistentResourceFactory.eINSTANCE); Resource resource = resourceSet.createResource(uri); Map<String, Object> loadOpts = new HashMap<String, Object>(); if (commandLine.hasOption(OPTIONS_FILE)) { Properties properties = new Properties(); properties.load(new FileInputStream(new File(commandLine.getOptionValue(OPTIONS_FILE)))); for (final Entry<Object, Object> entry : properties.entrySet()) { loadOpts.put((String) entry.getKey(), (String) entry.getValue()); } } resource.load(loadOpts); { LOG.log(Level.INFO, "Start query"); long begin = System.currentTimeMillis(); EList<MethodDeclaration> list = JavaQueries.getUnusedMethodsList(resource); long end = System.currentTimeMillis(); LOG.log(Level.INFO, "End query"); LOG.log(Level.INFO, MessageFormat.format("Query result (list) contains {0} elements", list.size())); LOG.log(Level.INFO, MessageFormat.format("Time spent: {0}", MessageUtil.formatMillis(end - begin))); } if (resource instanceof PersistentResourceImpl) { PersistentResourceImpl.shutdownWithoutUnload((PersistentResourceImpl) resource); } else { resource.unload(); } } catch (ParseException e) { MessageUtil.showError(e.toString()); MessageUtil.showError("Current arguments: " + Arrays.toString(args)); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("java -jar <this-file.jar>", options, true); } catch (Throwable e) { MessageUtil.showError(e.toString()); } }
From source file:fr.inria.atlanmod.kyanos.benchmarks.KyanosGraphQueryLoop.java
public static void main(String[] args) { Options options = new Options(); Option inputOpt = OptionBuilder.create(IN); inputOpt.setArgName("INPUT"); inputOpt.setDescription("Input Kyanos resource directory"); inputOpt.setArgs(1);//w w w . j a v a 2s.c o m inputOpt.setRequired(true); Option inClassOpt = OptionBuilder.create(EPACKAGE_CLASS); inClassOpt.setArgName("CLASS"); inClassOpt.setDescription("FQN of EPackage implementation class"); inClassOpt.setArgs(1); inClassOpt.setRequired(true); Option optFileOpt = OptionBuilder.create(OPTIONS_FILE); optFileOpt.setArgName("FILE"); optFileOpt.setDescription("Properties file holding the options to be used in the Kyanos Resource"); optFileOpt.setArgs(1); options.addOption(inputOpt); options.addOption(inClassOpt); options.addOption(optFileOpt); CommandLineParser parser = new PosixParser(); try { PersistenceBackendFactoryRegistry.getFactories().put(NeoBlueprintsURI.NEO_GRAPH_SCHEME, new BlueprintsPersistenceBackendFactory()); CommandLine commandLine = parser.parse(options, args); URI uri = NeoBlueprintsURI.createNeoGraphURI(new File(commandLine.getOptionValue(IN))); Class<?> inClazz = KyanosGraphQueryLoop.class.getClassLoader() .loadClass(commandLine.getOptionValue(EPACKAGE_CLASS)); inClazz.getMethod("init").invoke(null); ResourceSet resourceSet = new ResourceSetImpl(); resourceSet.getResourceFactoryRegistry().getProtocolToFactoryMap() .put(NeoBlueprintsURI.NEO_GRAPH_SCHEME, PersistentResourceFactory.eINSTANCE); Resource resource = resourceSet.createResource(uri); Map<String, Object> loadOpts = new HashMap<String, Object>(); if (commandLine.hasOption(OPTIONS_FILE)) { Properties properties = new Properties(); properties.load(new FileInputStream(new File(commandLine.getOptionValue(OPTIONS_FILE)))); for (final Entry<Object, Object> entry : properties.entrySet()) { loadOpts.put((String) entry.getKey(), (String) entry.getValue()); } } resource.load(loadOpts); { LOG.log(Level.INFO, "Start query"); long begin = System.currentTimeMillis(); EList<MethodDeclaration> list = JavaQueries.getUnusedMethodsLoop(resource); long end = System.currentTimeMillis(); LOG.log(Level.INFO, "End query"); LOG.log(Level.INFO, MessageFormat.format("Query result (loops) contains {0} elements", list.size())); LOG.log(Level.INFO, MessageFormat.format("Time spent: {0}", MessageUtil.formatMillis(end - begin))); } if (resource instanceof PersistentResourceImpl) { PersistentResourceImpl.shutdownWithoutUnload((PersistentResourceImpl) resource); } else { resource.unload(); } } catch (ParseException e) { MessageUtil.showError(e.toString()); MessageUtil.showError("Current arguments: " + Arrays.toString(args)); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("java -jar <this-file.jar>", options, true); } catch (Throwable e) { MessageUtil.showError(e.toString()); } }
From source file:fr.inria.atlanmod.kyanos.benchmarks.KyanosGraphQueryGrabats.java
public static void main(String[] args) { Options options = new Options(); Option inputOpt = OptionBuilder.create(IN); inputOpt.setArgName("INPUT"); inputOpt.setDescription("Input Kyanos resource directory"); inputOpt.setArgs(1);/*from ww w . j a v a2s . co m*/ inputOpt.setRequired(true); Option inClassOpt = OptionBuilder.create(EPACKAGE_CLASS); inClassOpt.setArgName("CLASS"); inClassOpt.setDescription("FQN of EPackage implementation class"); inClassOpt.setArgs(1); inClassOpt.setRequired(true); Option optFileOpt = OptionBuilder.create(OPTIONS_FILE); optFileOpt.setArgName("FILE"); optFileOpt.setDescription("Properties file holding the options to be used in the Kyanos Resource"); optFileOpt.setArgs(1); options.addOption(inputOpt); options.addOption(inClassOpt); options.addOption(optFileOpt); CommandLineParser parser = new PosixParser(); try { PersistenceBackendFactoryRegistry.getFactories().put(NeoBlueprintsURI.NEO_GRAPH_SCHEME, new BlueprintsPersistenceBackendFactory()); CommandLine commandLine = parser.parse(options, args); URI uri = NeoBlueprintsURI.createNeoGraphURI(new File(commandLine.getOptionValue(IN))); Class<?> inClazz = KyanosGraphQueryGrabats.class.getClassLoader() .loadClass(commandLine.getOptionValue(EPACKAGE_CLASS)); inClazz.getMethod("init").invoke(null); ResourceSet resourceSet = new ResourceSetImpl(); resourceSet.getResourceFactoryRegistry().getProtocolToFactoryMap() .put(NeoBlueprintsURI.NEO_GRAPH_SCHEME, PersistentResourceFactory.eINSTANCE); Resource resource = resourceSet.createResource(uri); Map<String, Object> loadOpts = new HashMap<String, Object>(); if (commandLine.hasOption(OPTIONS_FILE)) { Properties properties = new Properties(); properties.load(new FileInputStream(new File(commandLine.getOptionValue(OPTIONS_FILE)))); for (final Entry<Object, Object> entry : properties.entrySet()) { loadOpts.put((String) entry.getKey(), (String) entry.getValue()); } } resource.load(loadOpts); { LOG.log(Level.INFO, "Start query"); long begin = System.currentTimeMillis(); EList<ClassDeclaration> list = JavaQueries.grabats09(resource); long end = System.currentTimeMillis(); LOG.log(Level.INFO, "End query"); LOG.log(Level.INFO, MessageFormat.format("Query result contains {0} elements", list.size())); LOG.log(Level.INFO, MessageFormat.format("Time spent: {0}", MessageUtil.formatMillis(end - begin))); } if (resource instanceof PersistentResourceImpl) { PersistentResourceImpl.shutdownWithoutUnload((PersistentResourceImpl) resource); } else { resource.unload(); } } catch (ParseException e) { MessageUtil.showError(e.toString()); MessageUtil.showError("Current arguments: " + Arrays.toString(args)); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("java -jar <this-file.jar>", options, true); } catch (Throwable e) { MessageUtil.showError(e.toString()); } }
From source file:fr.inria.atlanmod.kyanos.benchmarks.KyanosGraphQuery.java
public static void main(String[] args) { Options options = new Options(); Option inputOpt = OptionBuilder.create(IN); inputOpt.setArgName("INPUT"); inputOpt.setDescription("Input Kyanos resource directory"); inputOpt.setArgs(1);/*from w w w .jav a 2s .c o m*/ inputOpt.setRequired(true); Option inClassOpt = OptionBuilder.create(EPACKAGE_CLASS); inClassOpt.setArgName("CLASS"); inClassOpt.setDescription("FQN of EPackage implementation class"); inClassOpt.setArgs(1); inClassOpt.setRequired(true); Option optFileOpt = OptionBuilder.create(OPTIONS_FILE); optFileOpt.setArgName("FILE"); optFileOpt.setDescription("Properties file holding the options to be used in the Kyanos Resource"); optFileOpt.setArgs(1); options.addOption(inputOpt); options.addOption(inClassOpt); options.addOption(optFileOpt); CommandLineParser parser = new PosixParser(); try { PersistenceBackendFactoryRegistry.getFactories().put(NeoBlueprintsURI.NEO_GRAPH_SCHEME, new BlueprintsPersistenceBackendFactory()); CommandLine commandLine = parser.parse(options, args); URI uri = NeoBlueprintsURI.createNeoGraphURI(new File(commandLine.getOptionValue(IN))); Class<?> inClazz = KyanosGraphQuery.class.getClassLoader() .loadClass(commandLine.getOptionValue(EPACKAGE_CLASS)); inClazz.getMethod("init").invoke(null); ResourceSet resourceSet = new ResourceSetImpl(); resourceSet.getResourceFactoryRegistry().getProtocolToFactoryMap() .put(NeoBlueprintsURI.NEO_GRAPH_SCHEME, PersistentResourceFactory.eINSTANCE); Resource resource = resourceSet.createResource(uri); Map<String, Object> loadOpts = new HashMap<String, Object>(); if (commandLine.hasOption(OPTIONS_FILE)) { Properties properties = new Properties(); properties.load(new FileInputStream(new File(commandLine.getOptionValue(OPTIONS_FILE)))); for (final Entry<Object, Object> entry : properties.entrySet()) { loadOpts.put((String) entry.getKey(), (String) entry.getValue()); } } resource.load(loadOpts); { LOG.log(Level.INFO, "Start query"); long begin = System.currentTimeMillis(); EList<MethodDeclaration> list = JavaQueries.getUnusedMethodsList(resource); long end = System.currentTimeMillis(); LOG.log(Level.INFO, "End query"); LOG.log(Level.INFO, MessageFormat.format("Query result (list) contains {0} elements", list.size())); LOG.log(Level.INFO, MessageFormat.format("Time spent: {0}", MessageUtil.formatMillis(end - begin))); } { LOG.log(Level.INFO, "Start query"); long begin = System.currentTimeMillis(); EList<MethodDeclaration> list = JavaQueries.getUnusedMethodsLoop(resource); long end = System.currentTimeMillis(); LOG.log(Level.INFO, "End query"); LOG.log(Level.INFO, MessageFormat.format("Query result (loops) contains {0} elements", list.size())); LOG.log(Level.INFO, MessageFormat.format("Time spent: {0}", MessageUtil.formatMillis(end - begin))); } if (resource instanceof PersistentResourceImpl) { PersistentResourceImpl.shutdownWithoutUnload((PersistentResourceImpl) resource); } else { resource.unload(); } } catch (ParseException e) { MessageUtil.showError(e.toString()); MessageUtil.showError("Current arguments: " + Arrays.toString(args)); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("java -jar <this-file.jar>", options, true); } catch (Throwable e) { MessageUtil.showError(e.toString()); } }
From source file:bogdanrechi.xmlo.Xmlo.java
/** * Main method./*w w w . j av a 2 s. c o m*/ * * @param args * Program arguments. */ @SuppressWarnings("static-access") public static void main(String[] args) { long timeStart = System.currentTimeMillis(); _log = Logger.getLogger(Xmlo.class); Options argOptions = new Options(); OptionGroup operationTypes = new OptionGroup(); operationTypes.addOption( OptionBuilder.withDescription("XPath query").hasArg().withArgName("file").create("xpath")); operationTypes.addOption( OptionBuilder.withDescription("XSLT transformation").hasArg().withArgName("file").create("xslt")); operationTypes.addOption( OptionBuilder.withDescription("XQuery (with $sourceFilePath, see XmlOperations for details)") .hasArg().withArgName("file").create("xquery")); operationTypes .addOption(OptionBuilder.withDescription("XSD verify").hasArgs().withArgName("file").create("xsd")); operationTypes .addOption(OptionBuilder.withDescription("DTD verify").hasArgs().withArgName("file").create("dtd")); argOptions.addOptionGroup(operationTypes); argOptions.addOption(OptionBuilder.withDescription("on screen information while performing") .withLongOpt("verbose").create("v")); argOptions.addOption(OptionBuilder.withDescription("output non-void or invalid-type results only") .withLongOpt("results-only").create("o")); argOptions.addOption(OptionBuilder.withDescription("replicate input structure on the destination side") .withLongOpt("keep-structure").create("k")); argOptions.addOption(OptionBuilder.withDescription("recursive browsing of the target structure") .withLongOpt("resursive").create("r")); argOptions.addOption(OptionBuilder.withDescription("XPath and XQuery results not numbered") .withLongOpt("not-numbered").create("nn")); argOptions.addOption(OptionBuilder.withDescription("destination files extension").hasArg() .withArgName("ext").withLongOpt("extension").create("x")); argOptions.addOption(OptionBuilder.withDescription("target files mask").hasArg().withArgName("files mask") .withLongOpt("target").create("t")); OptionGroup destinationGroup = new OptionGroup(); destinationGroup.addOption(OptionBuilder.withDescription("destination file").hasArg().withArgName("file") .withLongOpt("destination-file").create("df")); destinationGroup.addOption(OptionBuilder.withDescription("destination folder").hasArg() .withArgName("folder").withLongOpt("destination-directory").create("dd")); destinationGroup.addOption(OptionBuilder.withDescription("destination terminal (and verbose)") .withLongOpt("destination-terminal").create("dt")); argOptions.addOptionGroup(destinationGroup); argOptions.addOption(OptionBuilder.withDescription("file containing namespaces aliases").hasArg() .withArgName("file").withLongOpt("namespaces").create("n")); argOptions.addOption(OptionBuilder.withDescription("usage information").withLongOpt("help").create("h")); argOptions.addOption(OptionBuilder.withDescription("show examples").withLongOpt("examples").create("e")); argOptions.addOption(OptionBuilder.withDescription("keep blank nodes while printing") .withLongOpt("keep-blanks").create("b")); argOptions.addOption( OptionBuilder.withDescription("show duration for each file when the verbose option is activated") .withLongOpt("show-duration").create("d")); CommandLineParser parser = new BasicParser(); try { CommandLine cmd = parser.parse(argOptions, args); if (cmd.hasOption('h') || cmd.hasOption('e') || cmd.getOptions().length == 0) { Format.println("\n" + General.getAboutInformation("resources/xmlo/metadata.properties")); if (cmd.hasOption('h') || cmd.getOptions().length == 0) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("xmlo", "where:", argOptions, null, true); Format.println(); } if (cmd.hasOption("e")) { String examples = Files.readTextFileFromResources("resources/xmlo/examples.txt", _errorMessage); if (examples != null) Format.println(examples); else { Format.println("Internal error! Please see the log file for detalis."); _log.error(_errorMessage.get()); System.exit(1); } } System.exit(0); return; } Format.println(); // options if (cmd.hasOption('r')) _recursive = true; if (cmd.hasOption('k')) _keepStructure = true; if (cmd.hasOption('o')) _resultsOnly = true; if (cmd.hasOption('v')) _verbose = true; if (cmd.hasOption('b')) _keepBlanks = true; if (cmd.hasOption('d')) _showDuration = true; if (cmd.hasOption('x')) _extension = "." + cmd.getOptionValue('x'); if (cmd.hasOption("nn")) _notNumbered = true; if (cmd.hasOption("df")) { _destination = cmd.getOptionValue("df"); if (Files.isFolder(_destination)) printErrorAndExit("The destination is a folder!"); _destinationIsFile = true; } if (cmd.hasOption("dd")) { _destination = cmd.getOptionValue("dd"); if (!Files.exists(_destination)) printErrorAndExit("The destination folder does not exist!"); if (!Files.isFolder(_destination)) printErrorAndExit("The destination is not a folder!"); } if (cmd.hasOption("dt")) _destinationIsTerminal = _verbose = true; if (cmd.hasOption('t')) _target = cmd.getOptionValue('t'); if (cmd.hasOption('n')) { _namespaces = cmd.getOptionValue('n'); extractNamespacesAliases(); } // operations if (cmd.hasOption("xpath")) { if (_target == null) _target = Files.CURRENT_DIRECTORY + Files.FILE_SEPARATOR + "*" + EXTENSION_XPATH; doXPath(cmd.getOptionValue("xpath")); } if (cmd.hasOption("xslt")) { if (_target == null) _target = Files.CURRENT_DIRECTORY + Files.FILE_SEPARATOR + "*" + EXTENSION_XSLT; doXslt(cmd.getOptionValue("xslt")); } if (cmd.hasOption("xquery")) { if (_target == null) _target = Files.CURRENT_DIRECTORY + Files.FILE_SEPARATOR + "*" + EXTENSION_XQUERY; doXQuery(cmd.getOptionValue("xquery")); } if (cmd.hasOption("xsd")) { if (_target == null) _target = Files.CURRENT_DIRECTORY + Files.FILE_SEPARATOR + "*" + EXTENSION_XSD; doXsd(cmd.getOptionValues("xsd")); } if (cmd.hasOption("dtd")) { if (_target == null) _target = Files.CURRENT_DIRECTORY + Files.FILE_SEPARATOR + "*" + EXTENSION_DTD; doDtd(cmd.getOptionValues("dtd")); } } catch (ParseException e) { printErrorAndExit(e.getMessage()); } Format.println("Finished%s.", _showDuration ? " in " + TimeMeasure.printDuration(timeStart) : ""); if (Platform.SYSTEM_IS_LINUX) Format.println(); System.exit(0); }
From source file:j8583.example.Client.java
public static void main(String[] args) throws Exception { Random rng = new Random(System.currentTimeMillis()); log.debug("Reading config"); mfact = ConfigParser.createFromClasspathConfig("j8583/example/config.xml"); mfact.setAssignDate(true);/*from www . j a v a2 s . c o m*/ mfact.setTraceNumberGenerator(new SimpleTraceGenerator((int) (System.currentTimeMillis() % 10000))); System.err.println("Connecting to server"); Socket sock = new Socket("localhost", 9999); // Send 10 messages, then wait for the responses Client client = new Client(sock); Thread reader = new Thread(client, "j8583-client"); reader.start(); for (int i = 0; i < 10; i++) { IsoMessage req = mfact.newMessage(0x200); req.setValue(4, amounts[rng.nextInt(amounts.length)], IsoType.AMOUNT, 0); req.setValue(12, req.getObjectValue(7), IsoType.TIME, 0); req.setValue(13, req.getObjectValue(7), IsoType.DATE4, 0); req.setValue(15, req.getObjectValue(7), IsoType.DATE4, 0); req.setValue(17, req.getObjectValue(7), IsoType.DATE4, 0); req.setValue(37, System.currentTimeMillis() % 1000000, IsoType.NUMERIC, 12); req.setValue(41, data[rng.nextInt(data.length)], IsoType.ALPHA, 16); req.setValue(48, data[rng.nextInt(data.length)], IsoType.LLLVAR, 0); pending.put(req.getField(11).toString(), req); System.err.println(String.format("Sending request %s", req.getField(11))); req.write(sock.getOutputStream(), 2); } log.debug("Waiting for responses"); while (pending.size() > 0 && sock.isConnected()) { Thread.sleep(500); } client.stop(); reader.interrupt(); log.debug("DONE."); }
From source file:com.strider.datadefender.DataDefender.java
@SuppressWarnings("unchecked") public static void main(final String[] args) throws ParseException, DatabaseDiscoveryException, IOException, SAXException, TikaException, java.text.ParseException, FileDiscoveryException { final long startTime = System.currentTimeMillis(); // Ensure we are not trying to run second instance of the same program final ApplicationLock al = new ApplicationLock("DataDefender"); if (al.isAppActive()) { LOG.error("Another instance of this program is already active"); displayExecutionTime(startTime); System.exit(1);//from w w w. ja va 2 s. com } LOG.info("Command-line arguments: " + Arrays.toString(args)); final Options options = createOptions(); final CommandLine line = getCommandLine(options, args); @SuppressWarnings("unchecked") List<String> unparsedArgs = line.getArgList(); if (line.hasOption("help") || (args.length == 0) || (unparsedArgs.size() < 1)) { help(options); displayExecutionTime(startTime); return; } if (line.hasOption("debug")) { LogManager.getRootLogger().setLevel(Level.DEBUG); } else { LogManager.getRootLogger().setLevel(Level.INFO); } final String cmd = unparsedArgs.get(0); // get & remove command arg unparsedArgs = unparsedArgs.subList(1, unparsedArgs.size()); List<String> errors = new ArrayList(); if ("file-discovery".equals(cmd)) { errors = PropertyCheck.check(cmd, ' '); if (errors.size() > 0) { displayErrors(errors); displayExecutionTime(startTime); return; } final String fileDiscoveryPropertyFile = line.getOptionValue('F', "filediscovery.properties"); final Properties fileDiscoveryProperties = loadPropertiesFromClassPath(fileDiscoveryPropertyFile); final FileDiscoverer discoverer = new FileDiscoverer(); discoverer.discover(fileDiscoveryProperties); displayExecutionTime(startTime); return; } // Get db properties file from command line argument or use default db.properties final String dbPropertiesFile = line.getOptionValue('P', "db.properties"); errors = PropertyCheck.checkDtabaseProperties(dbPropertiesFile); if (errors.size() > 0) { displayErrors(errors); displayExecutionTime(startTime); return; } final Properties props = loadProperties(dbPropertiesFile); try (final IDBFactory dbFactory = IDBFactory.get(props);) { switch (cmd) { case "anonymize": errors = PropertyCheck.check(cmd, ' '); if (errors.size() > 0) { displayErrors(errors); displayExecutionTime(startTime); return; } final String anonymizerPropertyFile = line.getOptionValue('A', "anonymizer.properties"); final Properties anonymizerProperties = loadProperties(anonymizerPropertyFile); final IAnonymizer anonymizer = new DatabaseAnonymizer(); anonymizer.anonymize(dbFactory, anonymizerProperties); break; case "generate": errors = PropertyCheck.check(cmd, ' '); if (errors.size() > 0) { displayErrors(errors); displayExecutionTime(startTime); return; } final IGenerator generator = new DataGenerator(); final String generatorPropertyFile = line.getOptionValue('A', "anonymizer.properties"); final Properties generatorProperties = loadProperties(generatorPropertyFile); generator.generate(dbFactory, generatorProperties); break; case "database-discovery": if (line.hasOption('c')) { errors = PropertyCheck.check(cmd, 'c'); if (errors.size() > 0) { displayErrors(errors); displayExecutionTime(startTime); return; } final String columnPropertyFile = line.getOptionValue('C', "columndiscovery.properties"); final Properties columnProperties = loadProperties(columnPropertyFile); final ColumnDiscoverer discoverer = new ColumnDiscoverer(); discoverer.discover(dbFactory, columnProperties, props.getProperty("vendor")); if (line.hasOption('r')) { discoverer.createRequirement("Sample-Requirement.xml"); } } else if (line.hasOption('d')) { errors = PropertyCheck.check(cmd, 'd'); if (errors.size() > 0) { displayErrors(errors); displayExecutionTime(startTime); return; } final String datadiscoveryPropertyFile = line.getOptionValue('D', "datadiscovery.properties"); final Properties dataDiscoveryProperties = loadProperties(datadiscoveryPropertyFile); final DatabaseDiscoverer discoverer = new DatabaseDiscoverer(); discoverer.discover(dbFactory, dataDiscoveryProperties, props.getProperty("vendor")); if (line.hasOption('r')) { discoverer.createRequirement("Sample-Requirement.xml"); } } break; default: help(options); break; } } displayExecutionTime(startTime); }
From source file:fr.inria.atlanmod.kyanos.benchmarks.KyanosGraphQueryUnusedMethodsList.java
public static void main(String[] args) { Options options = new Options(); Option inputOpt = OptionBuilder.create(IN); inputOpt.setArgName("INPUT"); inputOpt.setDescription("Input Kyanos resource directory"); inputOpt.setArgs(1);/*ww w. j a v a 2 s . c om*/ inputOpt.setRequired(true); Option inClassOpt = OptionBuilder.create(EPACKAGE_CLASS); inClassOpt.setArgName("CLASS"); inClassOpt.setDescription("FQN of EPackage implementation class"); inClassOpt.setArgs(1); inClassOpt.setRequired(true); Option optFileOpt = OptionBuilder.create(OPTIONS_FILE); optFileOpt.setArgName("FILE"); optFileOpt.setDescription("Properties file holding the options to be used in the Kyanos Resource"); optFileOpt.setArgs(1); options.addOption(inputOpt); options.addOption(inClassOpt); options.addOption(optFileOpt); CommandLineParser parser = new PosixParser(); try { PersistenceBackendFactoryRegistry.getFactories().put(NeoBlueprintsURI.NEO_GRAPH_SCHEME, new BlueprintsPersistenceBackendFactory()); CommandLine commandLine = parser.parse(options, args); URI uri = NeoBlueprintsURI.createNeoGraphURI(new File(commandLine.getOptionValue(IN))); Class<?> inClazz = KyanosGraphQueryUnusedMethodsList.class.getClassLoader() .loadClass(commandLine.getOptionValue(EPACKAGE_CLASS)); inClazz.getMethod("init").invoke(null); ResourceSet resourceSet = new ResourceSetImpl(); resourceSet.getResourceFactoryRegistry().getProtocolToFactoryMap() .put(NeoBlueprintsURI.NEO_GRAPH_SCHEME, PersistentResourceFactory.eINSTANCE); Resource resource = resourceSet.createResource(uri); Map<String, Object> loadOpts = new HashMap<String, Object>(); if (commandLine.hasOption(OPTIONS_FILE)) { Properties properties = new Properties(); properties.load(new FileInputStream(new File(commandLine.getOptionValue(OPTIONS_FILE)))); for (final Entry<Object, Object> entry : properties.entrySet()) { loadOpts.put((String) entry.getKey(), (String) entry.getValue()); } } resource.load(loadOpts); { LOG.log(Level.INFO, "Start query"); long begin = System.currentTimeMillis(); EList<MethodDeclaration> list = JavaQueries.getUnusedMethodsList(resource); long end = System.currentTimeMillis(); LOG.log(Level.INFO, "End query"); LOG.log(Level.INFO, MessageFormat.format("Query result contains {0} elements", list.size())); LOG.log(Level.INFO, MessageFormat.format("Time spent: {0}", MessageUtil.formatMillis(end - begin))); } if (resource instanceof PersistentResourceImpl) { PersistentResourceImpl.shutdownWithoutUnload((PersistentResourceImpl) resource); } else { resource.unload(); } } catch (ParseException e) { MessageUtil.showError(e.toString()); MessageUtil.showError("Current arguments: " + Arrays.toString(args)); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("java -jar <this-file.jar>", options, true); } catch (Throwable e) { MessageUtil.showError(e.toString()); } }
From source file:fr.inria.atlanmod.kyanos.benchmarks.KyanosGraphQueryOrphanNonPrimitiveTypes.java
public static void main(String[] args) { Options options = new Options(); Option inputOpt = OptionBuilder.create(IN); inputOpt.setArgName("INPUT"); inputOpt.setDescription("Input Kyanos resource directory"); inputOpt.setArgs(1);/* www .j a v a2s.c o m*/ inputOpt.setRequired(true); Option inClassOpt = OptionBuilder.create(EPACKAGE_CLASS); inClassOpt.setArgName("CLASS"); inClassOpt.setDescription("FQN of EPackage implementation class"); inClassOpt.setArgs(1); inClassOpt.setRequired(true); Option optFileOpt = OptionBuilder.create(OPTIONS_FILE); optFileOpt.setArgName("FILE"); optFileOpt.setDescription("Properties file holding the options to be used in the Kyanos Resource"); optFileOpt.setArgs(1); options.addOption(inputOpt); options.addOption(inClassOpt); options.addOption(optFileOpt); CommandLineParser parser = new PosixParser(); try { PersistenceBackendFactoryRegistry.getFactories().put(NeoBlueprintsURI.NEO_GRAPH_SCHEME, new BlueprintsPersistenceBackendFactory()); CommandLine commandLine = parser.parse(options, args); URI uri = NeoBlueprintsURI.createNeoGraphURI(new File(commandLine.getOptionValue(IN))); Class<?> inClazz = KyanosGraphQueryOrphanNonPrimitiveTypes.class.getClassLoader() .loadClass(commandLine.getOptionValue(EPACKAGE_CLASS)); inClazz.getMethod("init").invoke(null); ResourceSet resourceSet = new ResourceSetImpl(); resourceSet.getResourceFactoryRegistry().getProtocolToFactoryMap() .put(NeoBlueprintsURI.NEO_GRAPH_SCHEME, PersistentResourceFactory.eINSTANCE); Resource resource = resourceSet.createResource(uri); Map<String, Object> loadOpts = new HashMap<String, Object>(); if (commandLine.hasOption(OPTIONS_FILE)) { Properties properties = new Properties(); properties.load(new FileInputStream(new File(commandLine.getOptionValue(OPTIONS_FILE)))); for (final Entry<Object, Object> entry : properties.entrySet()) { loadOpts.put((String) entry.getKey(), (String) entry.getValue()); } } resource.load(loadOpts); { LOG.log(Level.INFO, "Start query"); long begin = System.currentTimeMillis(); EList<Type> list = JavaQueries.getOrphanNonPrimitivesTypes(resource); long end = System.currentTimeMillis(); LOG.log(Level.INFO, "End query"); LOG.log(Level.INFO, MessageFormat.format("Query result contains {0} elements", list.size())); LOG.log(Level.INFO, MessageFormat.format("Time spent: {0}", MessageUtil.formatMillis(end - begin))); } if (resource instanceof PersistentResourceImpl) { PersistentResourceImpl.shutdownWithoutUnload((PersistentResourceImpl) resource); } else { resource.unload(); } } catch (ParseException e) { MessageUtil.showError(e.toString()); MessageUtil.showError("Current arguments: " + Arrays.toString(args)); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("java -jar <this-file.jar>", options, true); } catch (Throwable e) { MessageUtil.showError(e.toString()); } }