Example usage for java.lang System currentTimeMillis

List of usage examples for java.lang System currentTimeMillis

Introduction

In this page you can find the example usage for java.lang System currentTimeMillis.

Prototype

@HotSpotIntrinsicCandidate
public static native long currentTimeMillis();

Source Link

Document

Returns the current time in milliseconds.

Usage

From source file:com.vangent.hieos.empi.pixpdq.loader.PIDFeedLoader.java

/**
 *
 * @param args/*from  ww w  . j av  a 2  s.c  o m*/
 */
public static void main(String[] args) {
    PIDFeedLoader pfl = new PIDFeedLoader();
    long start = System.currentTimeMillis();
    for (int i = 0; i < DEMOGRAPHIC_FILES.length; i++) {
        String demographicFile = DEMOGRAPHIC_FILES[i];
        PIDFeedRunnable pidFeedRunnable = pfl.getPIDFeedRunnable(TEMPLATE, demographicFile, ENDPOINT);
        Thread thread = new Thread(pidFeedRunnable);
        thread.start();
    }
    System.out.println(" done ... TOTAL TIME - " + (System.currentTimeMillis() - start) + "ms.");
}

From source file:com.jrodeo.queue.messageset.provider.TestHttpClient4.java

public static void main(String[] args) throws Exception {
    if (args.length < 2) {
        System.out.println("Usage: <target URI> <no of requests> <concurrent connections>");
        System.exit(-1);/*from w  w  w. j a  v  a2 s  .com*/
    }
    URI targetURI = new URI(args[0]);
    int n = Integer.parseInt(args[1]);
    int c = 1;
    if (args.length > 2) {
        c = Integer.parseInt(args[2]);
    }

    TestHttpClient4 test = new TestHttpClient4();
    test.init();

    List<MessageSetRow> rows = new ArrayList<MessageSetRow>();
    for (int i = 0; i < 45; i++) {
        MessageSetRow msr = new MessageSetRow();
        msr.setI(i);
        msr.setData("this is a message row " + i);
        rows.add(msr);
    }
    MessageSet ms = new MessageSet();
    ms.setRows(rows);

    ObjectMapper mapper = new ObjectMapper();
    byte[] payload = mapper.writeValueAsBytes(ms);

    System.out.println("payload size to server: " + payload.length);

    try {
        long startTime = System.currentTimeMillis();
        // Stats stats = test.get(targetURI, n, c);
        Stats stats = test.post(targetURI, payload, n, c);
        long finishTime = System.currentTimeMillis();

        Stats.printStats(targetURI, startTime, finishTime, stats);
    } finally {
        test.shutdown();
    }
}

From source file:at.illecker.hama.rootbeer.examples.hellorootbeer.HelloRootbeerGpuBSP.java

public static void main(String[] args) throws InterruptedException, IOException, ClassNotFoundException {
    // BSP job configuration
    HamaConfiguration conf = new HamaConfiguration();

    BSPJob job = new BSPJob(conf);
    // Set the job name
    job.setJobName("HelloRootbeer GPU Example");
    // set the BSP class which shall be executed
    job.setBspClass(HelloRootbeerGpuBSP.class);
    // help Hama to locale the jar to be distributed
    job.setJarByClass(HelloRootbeerGpuBSP.class);

    job.setInputFormat(NullInputFormat.class);

    job.setOutputKeyClass(Text.class);
    job.setOutputValueClass(DoubleWritable.class);
    job.setOutputFormat(TextOutputFormat.class);
    FileOutputFormat.setOutputPath(job, TMP_OUTPUT);

    job.set("bsp.child.java.opts", "-Xmx4G");

    if (args.length > 0) {
        if (args.length == 3) {
            job.setNumBspTask(Integer.parseInt(args[0]));
            job.set("hellorootbeer.kernelCount", args[1]);
            job.set("hellorootbeer.iterations", args[2]);
        } else {/*from  ww w . j a v  a  2 s  . co m*/
            System.out.println("Wrong argument size!");
            System.out.println("    Argument1=numBspTask");
            System.out.println("    Argument2=kernelCount");
            System.out.println("    Argument3=iterations");
            return;
        }
    } else {
        job.setNumBspTask(1); // one GPU task only
        job.set("hellorootbeer.kernelCount", "" + HelloRootbeerGpuBSP.kernelCount);
        job.set("hellorootbeer.iterations", "" + HelloRootbeerGpuBSP.iterations);
    }
    LOG.info("NumBspTask: " + job.getNumBspTask());
    LOG.info("KernelCount: " + job.get("hellorootbeer.kernelCount"));
    LOG.info("Iterations: " + job.get("hellorootbeer.iterations"));

    long startTime = System.currentTimeMillis();
    if (job.waitForCompletion(true)) {
        printOutput(job);
        System.out.println("Job Finished in " + (System.currentTimeMillis() - startTime) / 1000.0 + " seconds");
    }
}

From source file:amie.keys.CSAKey.java

public static void main(String[] args) throws IOException, InterruptedException {
    final Triple<MiningAssistant, Float, String> parsedArgs = parseArguments(args);
    final Set<Rule> output = new LinkedHashSet<>();

    // Helper object that contains the implementation for the calculation
    // of confidence and support
    // The file with the non-keys, one per line
    long timea = System.currentTimeMillis();
    List<List<String>> inputNonKeys = Utilities.parseNonKeysFile(parsedArgs.third);
    System.out.println(inputNonKeys.size() + " input non-keys");
    final List<List<String>> nonKeys = pruneBySupport(inputNonKeys, parsedArgs.second,
            parsedArgs.first.getKb());// w ww  .  j a  va 2s  .  c  om
    Collections.sort(nonKeys, new Comparator<List<String>>() {

        @Override
        public int compare(List<String> o1, List<String> o2) {
            int r = Integer.compare(o2.size(), o1.size());
            if (r == 0) {
                return Integer.compare(o2.hashCode(), o1.hashCode());
            }

            return r;
        }

    });
    System.out.println(nonKeys.size() + " non-keys after pruning");
    int totalLoad = computeLoad(nonKeys);
    System.out.println(totalLoad + " is the total load");
    int nThreads = Runtime.getRuntime().availableProcessors();
    //int batchSize = Math.max(Math.min(maxBatchSize, totalLoad / nThreads), minBatchSize);
    int batchSize = Math.max(Math.min(maxLoad, totalLoad / nThreads), minLoad);

    final Queue<int[]> chunks = new PriorityQueue(50, new Comparator<int[]>() {
        @Override
        public int compare(int[] o1, int[] o2) {
            return Integer.compare(o2[2], o1[2]);
        }

    });

    final HashSet<HashSet<Integer>> nonKeysInt = new HashSet<>();
    final HashMap<String, Integer> property2Id = new HashMap<>();
    final HashMap<Integer, String> id2Property = new HashMap<>();
    final List<Integer> propertiesList = new ArrayList<>();
    int support = (int) parsedArgs.second.floatValue();
    KB kb = parsedArgs.first.getKb();
    buildDictionaries(nonKeys, nonKeysInt, property2Id, id2Property, propertiesList, support, kb);
    final List<HashSet<Integer>> nonKeysIntList = new ArrayList<>(nonKeysInt);
    int start = 0;
    int[] nextIdx = nextIndex(nonKeysIntList, 0, batchSize);
    int end = nextIdx[0];
    int load = nextIdx[1];
    while (start < nonKeysIntList.size()) {
        int[] chunk = new int[] { start, end, load };
        chunks.add(chunk);
        start = end;
        nextIdx = nextIndex(nonKeysIntList, end, batchSize);
        end = nextIdx[0];
        load = nextIdx[1];
    }

    Thread[] threads = new Thread[Math.min(Runtime.getRuntime().availableProcessors(), chunks.size())];
    for (int i = 0; i < threads.length; ++i) {
        threads[i] = new Thread(new Runnable() {

            @Override
            public void run() {
                while (true) {
                    int[] chunk = null;
                    synchronized (chunks) {
                        if (!chunks.isEmpty()) {
                            chunk = chunks.poll();
                        } else {
                            break;
                        }
                    }
                    System.out.println("Processing chunk " + Arrays.toString(chunk));
                    mine(parsedArgs, nonKeysIntList, property2Id, id2Property, propertiesList, chunk[0],
                            chunk[1], output);
                }

            }
        });
        threads[i].start();
    }

    for (int i = 0; i < threads.length; ++i) {
        threads[i].join();
    }
    long timeb = System.currentTimeMillis();
    System.out.println("==== Unique C-keys =====");
    for (Rule r : output) {
        System.out.println(Utilities.formatKey(r));
    }
    System.out.println(
            "VICKEY found " + output.size() + " unique conditional keys in " + (timeb - timea) + " ms");
}

From source file:com.grantingersoll.intell.index.Indexer.java

public static void main(String[] args) throws Exception {
    DefaultOptionBuilder obuilder = new DefaultOptionBuilder();
    ArgumentBuilder abuilder = new ArgumentBuilder();
    GroupBuilder gbuilder = new GroupBuilder();

    Option wikipediaFileOpt = obuilder.withLongName("wikiFile").withRequired(true)
            .withArgument(abuilder.withName("wikiFile").withMinimum(1).withMaximum(1).create())
            .withDescription(/*from w ww .j a  v  a  2 s . c  om*/
                    "The path to the wikipedia dump file.  Maybe a directory containing wikipedia dump files."
                            + "  If a directory is specified, only .xml files are used.")
            .withShortName("w").create();

    Option numDocsOpt = obuilder.withLongName("numDocs").withRequired(false)
            .withArgument(abuilder.withName("numDocs").withMinimum(1).withMaximum(1).create())
            .withDescription("The number of docs to index").withShortName("n").create();

    Option solrURLOpt = obuilder.withLongName("solrURL").withRequired(false)
            .withArgument(abuilder.withName("solrURL").withMinimum(1).withMaximum(1).create())
            .withDescription("The URL where Solr lives").withShortName("s").create();

    Option solrBatchOpt = obuilder.withLongName("batch").withRequired(false)
            .withArgument(abuilder.withName("batch").withMinimum(1).withMaximum(1).create())
            .withDescription("The number of docs to include in each indexing batch").withShortName("b")
            .create();

    Group group = gbuilder.withName("Options").withOption(wikipediaFileOpt).withOption(numDocsOpt)
            .withOption(solrURLOpt).withOption(solrBatchOpt).create();

    Parser parser = new Parser();
    parser.setGroup(group);
    CommandLine cmdLine = parser.parse(args);

    File file;
    file = new File(cmdLine.getValue(wikipediaFileOpt).toString());
    File[] dumpFiles;
    if (file.isDirectory()) {
        dumpFiles = file.listFiles(new FilenameFilter() {
            public boolean accept(File file, String s) {
                return s.endsWith(".xml");
            }
        });
    } else {
        dumpFiles = new File[] { file };
    }

    int numDocs = Integer.MAX_VALUE;
    if (cmdLine.hasOption(numDocsOpt)) {
        numDocs = Integer.parseInt(cmdLine.getValue(numDocsOpt).toString());
    }
    String url = DEFAULT_SOLR_URL;
    if (cmdLine.hasOption(solrURLOpt)) {
        url = cmdLine.getValue(solrURLOpt).toString();
    }
    int batch = 100;
    if (cmdLine.hasOption(solrBatchOpt)) {
        batch = Integer.parseInt(cmdLine.getValue(solrBatchOpt).toString());
    }
    Indexer indexer = new Indexer(new CommonsHttpSolrServer(url));
    int total = 0;
    for (int i = 0; i < dumpFiles.length && total < numDocs; i++) {
        File dumpFile = dumpFiles[i];
        log.info("Indexing: " + file + " Num files to index: " + (numDocs - total));
        long start = System.currentTimeMillis();
        int totalFile = indexer.index(dumpFile, numDocs - total, batch);
        long finish = System.currentTimeMillis();
        if (log.isInfoEnabled()) {
            log.info("Indexing " + dumpFile + " took " + (finish - start) + " ms");
        }
        total += totalFile;
        log.info("Done Indexing: " + file + ". Indexed " + totalFile + " docs for that file and " + total
                + " overall.");

    }
    log.info("Indexed " + total + " docs overall.");
}

From source file:com.app.server.Main.java

/**
 * This is the start of the all the services in web server
 * @param args//ww  w  . j a v a2  s.co m
 * @throws IOException 
 * @throws SAXException 
 */
public static void main(String[] args) throws IOException, SAXException {

    long startTime = System.currentTimeMillis();
    Hashtable urlClassLoaderMap = new Hashtable();
    Hashtable executorServicesMap = new Hashtable();
    Hashtable ataMap = new Hashtable<String, ATAConfig>();
    Hashtable messagingClassMap = new Hashtable();
    ConcurrentHashMap servletMapping = new ConcurrentHashMap();
    Vector deployerList = new Vector(), serviceList = new Vector();
    DigesterLoader serverdigesterLoader = DigesterLoader.newLoader(new FromXmlRulesModule() {
        protected void loadRules() {
            // TODO Auto-generated method stub
            try {
                loadXMLRules(new InputSource(new FileInputStream("./config/serverconfig-rules.xml")));
            } catch (FileNotFoundException e) {
                log.error("Error in loading the xml rules ./config/serverconfig-rules.xml", e);
                // TODO Auto-generated catch block
                //e.printStackTrace();
            }

        }
    });
    Digester serverdigester = serverdigesterLoader.newDigester();
    final ServerConfig serverconfig = (ServerConfig) serverdigester
            .parse(new InputSource(new FileInputStream("./config/serverconfig.xml")));

    //log.info(messagingconfig);
    ////log.info(serverconfig.getDeploydirectory());
    PropertyConfigurator.configure("log4j.properties");
    /*MemcachedClient cache=new MemcachedClient(
        new InetSocketAddress("localhost", 1000));*/

    // Store a value (async) for one hour
    //c.set("someKey", 36, new String("arun"));
    // Retrieve a value.        
    System.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.naming.java.javaURLContextFactory");
    System.setProperty(Context.URL_PKG_PREFIXES, "org.apache.naming");
    ExecutorService executor = java.util.concurrent.Executors.newCachedThreadPool();

    MBeanServer mbs = MBeanServerFactory.createMBeanServer("singham");
    ObjectName name = null;
    try {
        mbs.registerMBean(serverconfig, new ObjectName("com.app.server:type=serverinfo"));
    } catch (Exception e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
    /*try {
       name = new ObjectName("com.app.server:type=WarDeployer");
    } catch (MalformedObjectNameException e1) {
       // TODO Auto-generated catch block
       e1.printStackTrace();
    } 
            
    WarDeployer warDeployer=new WarDeployer(serverconfig.getDeploydirectory(),serverconfig.getFarmWarDir(),serverconfig.getClustergroup(),urlClassLoaderMap,executorServicesMap,messagingClassMap,servletMapping,messagingconfig,sessionObjects);
    warDeployer.setPriority(MIN_PRIORITY);
    try {
       mbs.registerMBean(warDeployer, name);
    } catch (InstanceAlreadyExistsException | MBeanRegistrationException
    | NotCompliantMBeanException e1) {
       // TODO Auto-generated catch block
       e1.printStackTrace();
    } 
            
    //warDeployer.start();
    executor.execute(warDeployer);*/

    final byte[] shutdownBt = new byte[50];
    /*WebServerRequestProcessor webserverRequestProcessor=new WebServer().new WebServerRequestProcessor(servletMapping,urlClassLoaderMap,serverSocketChannel,serverconfig.getDeploydirectory(),Integer.parseInt(serverconfig.getShutdownport()),1);
      webserverRequestProcessor.setPriority(MIN_PRIORITY);
    try {
       name = new ObjectName("com.app.server:type=WebServerRequestProcessor");
    } catch (MalformedObjectNameException e1) {
       // TODO Auto-generated catch block
       e1.printStackTrace();
    } 
            
    try {
       mbs.registerMBean(webserverRequestProcessor, name);
    } catch (InstanceAlreadyExistsException | MBeanRegistrationException
    | NotCompliantMBeanException e1) {
       // TODO Auto-generated catch block
       e1.printStackTrace();
    }
            
    //webserverRequestProcessor.start();
      executor.execute(webserverRequestProcessor);
            
            
      for(int i=0;i<10;i++){
       WebServerRequestProcessor webserverRequestProcessor1=new WebServer().new WebServerRequestProcessor(servletMapping,urlClassLoaderMap,serverSocketChannel,serverconfig.getDeploydirectory(),Integer.parseInt(serverconfig.getShutdownport()),2);
    webserverRequestProcessor1.setPriority(MIN_PRIORITY);
       try {
    name = new ObjectName("com.app.server:type=WebServerRequestProcessor"+(i+1));
       } catch (MalformedObjectNameException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
       } 
               
       try {
    mbs.registerMBean(webserverRequestProcessor1, name);
       } catch (InstanceAlreadyExistsException | MBeanRegistrationException
       | NotCompliantMBeanException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
       }
               
         executor.execute(webserverRequestProcessor1);
      }*/

    /*ExecutorServiceThread executorService=new ExecutorServiceThread(serverSocketChannelServices,executorServicesMap,Integer.parseInt(serverconfig.getShutdownport()),ataMap,urlClassLoaderMap,serverconfig.getDeploydirectory(),serverconfig.getServicesdirectory(),serverconfig.getEarservicesdirectory(),serverconfig.getNodesport());
            
    try {
       name = new ObjectName("com.app.services:type=ExecutorServiceThread");
    } catch (MalformedObjectNameException e1) {
       // TODO Auto-generated catch block
       e1.printStackTrace();
    } 
            
    try {
       mbs.registerMBean(executorService, name);
    } catch (InstanceAlreadyExistsException | MBeanRegistrationException
    | NotCompliantMBeanException e1) {
       // TODO Auto-generated catch block
       e1.printStackTrace();
    }
            
    //executorService.start();
    executor.execute(executorService);
            
            
    for(int i=0;i<10;i++){
       ExecutorServiceThread executorService1=new ExecutorServiceThread(serverSocketChannelServices,executorServicesMap,Integer.parseInt(serverconfig.getShutdownport()),ataMap,urlClassLoaderMap,serverconfig.getDeploydirectory(),serverconfig.getServicesdirectory(),serverconfig.getEarservicesdirectory(),serverconfig.getNodesport());
               
       try {
    name = new ObjectName("com.app.services:type=ExecutorServiceThread"+(i+1));
       } catch (MalformedObjectNameException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
       } 
               
       try {
    mbs.registerMBean(executorService1, name);
       } catch (InstanceAlreadyExistsException | MBeanRegistrationException
       | NotCompliantMBeanException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
       }
               
       executor.execute(executorService1);
    }*/

    /*WebServerHttpsRequestProcessor webserverHttpsRequestProcessor=new WebServer().new WebServerHttpsRequestProcessor(servletMapping,urlClassLoaderMap,Integer.parseInt(serverconfig.getHttpsport()),serverconfig.getDeploydirectory(),Integer.parseInt(serverconfig.getShutdownport()),serverconfig.getHttpscertificatepath(),serverconfig.getHttpscertificatepasscode(),1);
    try {
       name = new ObjectName("com.app.server:type=WebServerHttpsRequestProcessor");
    } catch (MalformedObjectNameException e1) {
       // TODO Auto-generated catch block
       e1.printStackTrace();
    } 
            
    try {
       mbs.registerMBean(webserverHttpsRequestProcessor, name);
    } catch (InstanceAlreadyExistsException | MBeanRegistrationException
    | NotCompliantMBeanException e1) {
       // TODO Auto-generated catch block
       e1.printStackTrace();
    }
    webserverHttpsRequestProcessor.setPriority(MAX_PRIORITY);
    //webserverRequestProcessor.start();
      executor.execute(webserverHttpsRequestProcessor);*/

    /* for(int i=0;i<2;i++){
        webserverHttpsRequestProcessor=new WebServer().new WebServerHttpsRequestProcessor(urlClassLoaderMap,Integer.parseInt(serverconfig.getHttpsport())+(i+1),serverconfig.getDeploydirectory(),Integer.parseInt(serverconfig.getShutdownport()),serverconfig.getHttpscertificatepath(),serverconfig.getHttpscertificatepasscode(),1);
              
      try {
    name = new ObjectName("com.app.server:type=WebServerHttpsRequestProcessor"+(i+1));
      } catch (MalformedObjectNameException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
      } 
              
      try {
    mbs.registerMBean(webserverHttpsRequestProcessor, name);
      } catch (InstanceAlreadyExistsException | MBeanRegistrationException
       | NotCompliantMBeanException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
      }
              
      executor.execute(webserverHttpsRequestProcessor);
    }*/

    /*ATAServer ataServer=new ATAServer(serverconfig.getAtaaddress(),serverconfig.getAtaport(),ataMap);
            
    try {
       name = new ObjectName("com.app.services:type=ATAServer");
    } catch (MalformedObjectNameException e1) {
       // TODO Auto-generated catch block
       e1.printStackTrace();
    } 
            
    try {
       mbs.registerMBean(ataServer, name);
    } catch (InstanceAlreadyExistsException | MBeanRegistrationException
    | NotCompliantMBeanException e1) {
       // TODO Auto-generated catch block
       e1.printStackTrace();
    }
            
            
    ataServer.start();*/

    /*ATAConfigClient ataClient=new ATAConfigClient(serverconfig.getAtaaddress(),serverconfig.getAtaport(),serverconfig.getServicesport(),executorServicesMap);
            
    try {
       name = new ObjectName("com.app.services:type=ATAConfigClient");
    } catch (MalformedObjectNameException e1) {
       // TODO Auto-generated catch block
       e1.printStackTrace();
    } 
            
    try {
       mbs.registerMBean(ataClient, name);
    } catch (InstanceAlreadyExistsException | MBeanRegistrationException
    | NotCompliantMBeanException e1) {
       // TODO Auto-generated catch block
       e1.printStackTrace();
    }
    ataClient.start();*/

    /*MessagingServer messageServer=new MessagingServer(serverconfig.getMessageport(),messagingClassMap);
            
    try {
       name = new ObjectName("com.app.messaging:type=MessagingServer");
    } catch (MalformedObjectNameException e1) {
       // TODO Auto-generated catch block
       e1.printStackTrace();
    } 
            
    try {
       mbs.registerMBean(messageServer, name);
    } catch (InstanceAlreadyExistsException | MBeanRegistrationException
    | NotCompliantMBeanException e1) {
       // TODO Auto-generated catch block
       e1.printStackTrace();
    }
    //messageServer.start();
    executor.execute(messageServer);*/

    /*RandomQueueMessagePicker randomqueuemessagepicker=new RandomQueueMessagePicker(messagingClassMap);
            
    try {
       name = new ObjectName("com.app.messaging:type=RandomQueueMessagePicker");
    } catch (MalformedObjectNameException e1) {
       // TODO Auto-generated catch block
       e1.printStackTrace();
    } 
            
    try {
       mbs.registerMBean(randomqueuemessagepicker, name);
    } catch (InstanceAlreadyExistsException | MBeanRegistrationException
    | NotCompliantMBeanException e1) {
       // TODO Auto-generated catch block
       e1.printStackTrace();
    }
            
    //randomqueuemessagepicker.start();
    executor.execute(randomqueuemessagepicker);*/

    /*RoundRobinQueueMessagePicker roundrobinqueuemessagepicker=new RoundRobinQueueMessagePicker(messagingClassMap);
            
    try {
       name = new ObjectName("com.app.messaging:type=RoundRobinQueueMessagePicker");
    } catch (MalformedObjectNameException e1) {
       // TODO Auto-generated catch block
       e1.printStackTrace();
    } 
            
    try {
       mbs.registerMBean(roundrobinqueuemessagepicker, name);
    } catch (InstanceAlreadyExistsException | MBeanRegistrationException
    | NotCompliantMBeanException e1) {
       // TODO Auto-generated catch block
       e1.printStackTrace();
    }
            
    //roundrobinqueuemessagepicker.start();
    executor.execute(roundrobinqueuemessagepicker);*/

    /*TopicMessagePicker topicpicker= new TopicMessagePicker(messagingClassMap);
            
    try {
       name = new ObjectName("com.app.messaging:type=TopicMessagePicker");
    } catch (MalformedObjectNameException e1) {
       // TODO Auto-generated catch block
       e1.printStackTrace();
    } 
            
    try {
       mbs.registerMBean(topicpicker, name);
    } catch (InstanceAlreadyExistsException | MBeanRegistrationException
    | NotCompliantMBeanException e1) {
       // TODO Auto-generated catch block
       e1.printStackTrace();
    }
    //topicpicker.start();
    executor.execute(topicpicker);*/

    try {
        name = new ObjectName(SARDeployer.OBJECT_NAME);
    } catch (Exception e) {
        log.error("Error in creating the object name " + SARDeployer.OBJECT_NAME, e);
        // TODO Auto-generated catch block
        //e1.printStackTrace();
    }
    log.info(System.getProperty("user.dir"));
    try {
        mbs.createMBean("com.app.server.SARDeployer", name);
        mbs.invoke(name, "init", new Object[] { deployerList }, new String[] { Vector.class.getName() });
        mbs.invoke(name, "init", new Object[] { serviceList, serverconfig, mbs }, new String[] {
                Vector.class.getName(), ServerConfig.class.getName(), MBeanServer.class.getName() });
        mbs.invoke(name, "start", null, null);
        mbs.invoke(name, "deploy",
                new Object[] {
                        new URL("file:///" + new File("").getAbsolutePath() + "/config/mbean-service.xml") },
                new String[] { URL.class.getName() });
        /*name=new ObjectName("com.app.server:type=deployer,service=WARDeployer");
        mbs.invoke(name, "deploy", new Object[]{new URL("file:///"+serverconfig.getDeploydirectory()+"/TestDollar2.war")}, new String[]{URL.class.getName()});
        mbs.invoke(name, "deploy", new Object[]{new URL("file:///"+serverconfig.getDeploydirectory()+"/StrutsProj.war")}, new String[]{URL.class.getName()});*/
        //mbs.registerMBean("", name);
    } catch (Exception ex) {
        log.error("Error in SAR DEPLOYER ", ex);
        // TODO Auto-generated catch block
        //e1.printStackTrace();
    }

    //scanner.deployPackages(new File[]{new File(serverconfig.getDeploydirectory()+"/AppServer.war")});

    try {
        new NodeResourceReceiver(mbs).start();
    } catch (Exception ex) {
        log.error("Node Receiver start", ex);
        //e2.printStackTrace();
    }
    long endTime = System.currentTimeMillis();
    log.info("Server started in " + ((endTime - startTime) / 1000) + " seconds");
    /*try {
       mbs.invoke(name, "startDeployer", null, null);
    } catch (InstanceNotFoundException e1) {
       // TODO Auto-generated catch block
       e1.printStackTrace();
    } catch (ReflectionException e1) {
       // TODO Auto-generated catch block
       e1.printStackTrace();
    } catch (MBeanException e1) {
       // TODO Auto-generated catch block
       e1.printStackTrace();
    }
    */
    /*JarDeployer jarDeployer=new JarDeployer(registry,serverconfig.getServicesdirectory(), serverconfig.getServiceslibdirectory(),serverconfig.getCachedir(),executorServicesMap, urlClassLoaderMap);
    try {
       name = new ObjectName("com.app.server:type=JarDeployer");
    } catch (MalformedObjectNameException e1) {
       // TODO Auto-generated catch block
       e1.printStackTrace();
    } 
            
    try {
       mbs.registerMBean(jarDeployer, name);
    } catch (InstanceAlreadyExistsException | MBeanRegistrationException
    | NotCompliantMBeanException e1) {
       // TODO Auto-generated catch block
       e1.printStackTrace();
    }
            
    //jarDeployer.start();
    executor.execute(jarDeployer);*/

    /*EARDeployer earDeployer=new EARDeployer(registry,serverconfig.getEarservicesdirectory(),serverconfig.getDeploydirectory(),executorServicesMap, urlClassLoaderMap,serverconfig.getCachedir(),warDeployer);
    try {
       name = new ObjectName("com.app.server:type=EARDeployer");
    } catch (MalformedObjectNameException e1) {
       // TODO Auto-generated catch block
       e1.printStackTrace();
    } 
            
    try {
       mbs.registerMBean(earDeployer, name);
    } catch (InstanceAlreadyExistsException | MBeanRegistrationException
    | NotCompliantMBeanException e1) {
       // TODO Auto-generated catch block
       e1.printStackTrace();
    }
            
    //earDeployer.start();
    executor.execute(earDeployer);*/

    /*JVMConsole jvmConsole=new JVMConsole(Integer.parseInt(serverconfig.getJvmConsolePort()));
            
    try {
       name = new ObjectName("com.app.server:type=JVMConsole");
    } catch (MalformedObjectNameException e1) {
       // TODO Auto-generated catch block
       e1.printStackTrace();
    } 
            
    try {
       mbs.registerMBean(jvmConsole, name);
    } catch (InstanceAlreadyExistsException | MBeanRegistrationException
    | NotCompliantMBeanException e1) {
       // TODO Auto-generated catch block
       e1.printStackTrace();
    }
    executor.execute(jvmConsole);*/

    /*ScheduledExecutorService exec = Executors.newSingleThreadScheduledExecutor();
     XMLDeploymentScanner xmlDeploymentScanner =new XMLDeploymentScanner(serverconfig.getDeploydirectory(),serverconfig.getServiceslibdirectory());
    exec.scheduleAtFixedRate(xmlDeploymentScanner, 0, 1000, TimeUnit.MILLISECONDS);*/

    /*EmbeddedJMS embeddedJMS=null;
    try {
       embeddedJMS=new EmbeddedJMS();
       embeddedJMS.start();
    } catch (Exception ex) {
       // TODO Auto-generated catch block
       ex.printStackTrace();
    }   
             
     EJBDeployer ejbDeployer=new EJBDeployer(serverconfig.getServicesdirectory(),registry,Integer.parseInt(serverconfig.getServicesregistryport()),embeddedJMS);
    try {
       name = new ObjectName("com.app.server:type=EJBDeployer");
    } catch (MalformedObjectNameException e1) {
       // TODO Auto-generated catch block
       e1.printStackTrace();
    } 
            
    try {
       mbs.registerMBean(ejbDeployer, name);
    } catch (InstanceAlreadyExistsException | MBeanRegistrationException
    | NotCompliantMBeanException e1) {
       // TODO Auto-generated catch block
       e1.printStackTrace();
    }
            
    //jarDeployer.start();
    executor.execute(ejbDeployer);*/

    new Thread() {
        public void run() {
            try {
                ServerSocket serverSocket = new ServerSocket(Integer.parseInt(serverconfig.getShutdownport()));
                while (true) {
                    Socket sock = serverSocket.accept();
                    InputStream istream = sock.getInputStream();
                    istream.read(shutdownBt);
                    String shutdownStr = new String(shutdownBt);
                    String[] shutdownToken = shutdownStr.split("\r\n\r\n");
                    //log.info(shutdownStr);
                    if (shutdownToken[0].startsWith("shutdown WebServer")) {
                        synchronized (shutDownObject) {
                            shutDownObject.notifyAll();
                        }
                    }
                }
            } catch (Exception e) {
                log.error("Shutdown error", e);
                // TODO Auto-generated catch block
                //e.printStackTrace();
            }
        }
    }.start();

    Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
        public void run() {
            log.info("IN shutdown Hook");
            synchronized (shutDownObject) {
                shutDownObject.notifyAll();
            }
        }
    }));
    try {
        synchronized (shutDownObject) {
            shutDownObject.wait();
        }
        //executor.shutdownNow();
        //serverSocketChannelServices.close();
        //embeddedJMS.stop();

    } catch (Exception e) {
        log.error("Error in object wait ", e);
        // TODO Auto-generated catch block
        //e1.printStackTrace();
    }
    try {
        mbs.invoke(name, "stop", null, null);
        mbs.invoke(name, "destroy", null, null);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    log.info("Halting JVM");
    log.info("Exiting JVM");
    /*try{
       Thread.sleep(10000);
    }
    catch(Exception ex){
               
    }*/

    //webserverRequestProcessor.stop();
    //webserverRequestProcessor1.stop();

    /*warDeployer.stop();
    executorService.stop();
    //ataServer.stop();
    //ataClient.stop();
    messageServer.stop();
    randomqueuemessagepicker.stop();
    roundrobinqueuemessagepicker.stop();
    topicpicker.stop();*/
    /*try {
       mbs.invoke(new ObjectName("com.app.server:type=SARDeployer"), "destroyDeployer", null, null);
    } catch (InstanceNotFoundException | MalformedObjectNameException
    | ReflectionException | MBeanException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
    }*/
    //earDeployer.stop();
    System.exit(0);
}

From source file:IndexService.IndexServer.java

public static void main(String[] args) {
    File stop = new File("/tmp/.indexstop");
    File running = new File("/tmp/.indexrunning");
    if (args != null && args.length > 0 && args[0].equals("stop")) {
        try {/* w w w.j a  v a  2s .  c  o m*/
            stop.createNewFile();
            running.delete();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return;
    }

    if (running.exists() && (System.currentTimeMillis() - running.lastModified() < 15000)) {
        long time = running.lastModified();
        try {
            Thread.sleep(10000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        if (running.lastModified() == time) {
            running.delete();
        } else {
            return;
        }
    }

    if (stop.exists()) {
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        if (stop.exists())
            stop.delete();
    }

    Configuration conf = new Configuration();
    IndexServer server = new IndexServer(conf);
    if (args != null && args.length > 0 && args[0].equals("test")) {
        server.testmode = true;
    }
    server.start();
    try {
        running.createNewFile();
    } catch (IOException e) {
        e.printStackTrace();
    }
    new UserCmdProc(server).start();

    while (true) {
        stop = new File("/tmp/.indexstop");
        if (stop.exists()) {
            server.close();
            running.delete();
            stop.delete();
            break;
        }
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e1) {
            e1.printStackTrace();
        }

        running.setLastModified(System.currentTimeMillis());

    }
}

From source file:biomine.nodeimportancecompression.ImportanceCompressionReport.java

public static void main(String[] args) throws IOException, java.text.ParseException {
    opts.addOption("algorithm", true,
            "Used algorithm for compression. Possible values are 'brute-force', "
                    + "'brute-force-edges','brute-force-merges','randomized','randomized-merges',"
                    + "'randomized-edges'," + "'fast-brute-force',"
                    + "'fast-brute-force-merges','fast-brute-force-merge-edges'. Default is 'brute-force'.");
    opts.addOption("query", true, "Query nodes ids, separated by comma.");
    opts.addOption("queryfile", true, "Read query nodes from file.");
    opts.addOption("ratio", true, "Goal ratio");
    opts.addOption("importancefile", true, "Read importances straight from file");
    opts.addOption("keepedges", false, "Don't remove edges during merges");
    opts.addOption("connectivity", false, "Compute and output connectivities in edge oriented case");
    opts.addOption("paths", false, "Do path oriented compression");
    opts.addOption("edges", false, "Do edge oriented compression");
    // opts.addOption( "a",

    double sigma = 1.0;
    CommandLineParser parser = new PosixParser();
    CommandLine cmd = null;// www .j  av  a 2s .  co  m

    try {
        cmd = parser.parse(opts, args);
    } catch (ParseException e) {
        e.printStackTrace();
        System.exit(0);
    }

    String queryStr = cmd.getOptionValue("query");
    String[] queryNodeIDs = {};
    double[] queryNodeIMP = {};
    if (queryStr != null) {
        queryNodeIDs = queryStr.split(",");
        queryNodeIMP = new double[queryNodeIDs.length];
        for (int i = 0; i < queryNodeIDs.length; i++) {
            String s = queryNodeIDs[i];
            String[] es = s.split("=");
            queryNodeIMP[i] = 1;
            if (es.length == 2) {
                queryNodeIDs[i] = es[0];
                queryNodeIMP[i] = Double.parseDouble(es[1]);
            } else if (es.length > 2) {
                System.out.println("Too many '=' in querynode specification: " + s);
            }
        }
    }

    String queryFile = cmd.getOptionValue("queryfile");
    Map<String, Double> queryNodes = Collections.EMPTY_MAP;
    if (queryFile != null) {
        File in = new File(queryFile);
        BufferedReader read = new BufferedReader(new FileReader(in));

        queryNodes = readMap(read);
        read.close();
    }

    String impfile = cmd.getOptionValue("importancefile");
    Map<String, Double> importances = null;
    if (impfile != null) {
        File in = new File(impfile);
        BufferedReader read = new BufferedReader(new FileReader(in));

        importances = readMap(read);
        read.close();
    }

    String algoStr = cmd.getOptionValue("algorithm");
    CompressionAlgorithm algo = null;

    if (algoStr == null || algoStr.equals("brute-force")) {
        algo = new BruteForceCompression();
    } else if (algoStr.equals("brute-force-edges")) {
        algo = new BruteForceCompressionOnlyEdges();
    } else if (algoStr.equals("brute-force-merges")) {
        algo = new BruteForceCompressionOnlyMerges();
    } else if (algoStr.equals("fast-brute-force-merges")) {
        //algo = new FastBruteForceCompressionOnlyMerges();
        algo = new FastBruteForceCompression(true, false);
    } else if (algoStr.equals("fast-brute-force-edges")) {
        algo = new FastBruteForceCompression(false, true);
        //algo = new FastBruteForceCompressionOnlyEdges();
    } else if (algoStr.equals("fast-brute-force")) {
        algo = new FastBruteForceCompression(true, true);
    } else if (algoStr.equals("randomized-edges")) {
        algo = new RandomizedCompressionOnlyEdges(); //modified
    } else if (algoStr.equals("randomized")) {
        algo = new RandomizedCompression();
    } else if (algoStr.equals("randomized-merges")) {
        algo = new RandomizedCompressionOnlyMerges();
    } else {
        System.out.println("Unsupported algorithm: " + algoStr);
        printHelp();
    }

    String ratioStr = cmd.getOptionValue("ratio");
    double ratio = 0;
    if (ratioStr != null) {
        ratio = Double.parseDouble(ratioStr);
    } else {
        System.out.println("Goal ratio not specified");
        printHelp();
    }

    String infile = null;
    if (cmd.getArgs().length != 0) {
        infile = cmd.getArgs()[0];
    } else {
        printHelp();
    }

    BMGraph bmg = BMGraphUtils.readBMGraph(new File(infile));
    HashMap<BMNode, Double> queryBMNodes = new HashMap<BMNode, Double>();
    for (String id : queryNodes.keySet()) {
        queryBMNodes.put(bmg.getNode(id), queryNodes.get(id));
    }

    long startMillis = System.currentTimeMillis();
    ImportanceGraphWrapper wrap = QueryImportance.queryImportanceGraph(bmg, queryBMNodes);

    if (importances != null) {
        for (String id : importances.keySet()) {
            wrap.setImportance(bmg.getNode(id), importances.get(id));
        }
    }

    ImportanceMerger merger = null;
    if (cmd.hasOption("edges")) {
        merger = new ImportanceMergerEdges(wrap.getImportanceGraph());
    } else if (cmd.hasOption("paths")) {
        merger = new ImportanceMergerPaths(wrap.getImportanceGraph());
    } else {
        System.out.println("Specify either 'paths' or 'edges'.");
        System.exit(1);
    }

    if (cmd.hasOption("keepedges")) {
        merger.setKeepEdges(true);
    }

    algo.compress(merger, ratio);
    long endMillis = System.currentTimeMillis();

    // write importance

    {
        BufferedWriter wr = new BufferedWriter(new FileWriter("importance.txt", false));
        for (BMNode nod : bmg.getNodes()) {
            wr.write(nod + " " + wrap.getImportance(nod) + "\n");
        }
        wr.close();
    }

    // write sum of all pairs of node importance    added by Fang
    /*   {
    BufferedWriter wr = new BufferedWriter(new FileWriter("sum_of_all_pairs_importance.txt", true));
    ImportanceGraph orig = wrap.getImportanceGraph();
    double sum = 0;
            
    for (int i = 0; i <= orig.getMaxNodeId(); i++) {
        for (int j = i+1; j <= orig.getMaxNodeId(); j++) {
            sum = sum+ wrap.getImportance(i)* wrap.getImportance(j);
        }
    }
            
    wr.write(""+sum);
    wr.write("\n");
    wr.close();
       }
            
    */

    // write uncompressed edges
    {
        BufferedWriter wr = new BufferedWriter(new FileWriter("edges.txt", false));
        ImportanceGraph orig = wrap.getImportanceGraph();
        ImportanceGraph ucom = merger.getUncompressedGraph();
        for (int i = 0; i <= orig.getMaxNodeId(); i++) {
            String iname = wrap.intToNode(i).toString();
            HashSet<Integer> ne = new HashSet<Integer>();
            ne.addAll(orig.getNeighbors(i));
            ne.addAll(ucom.getNeighbors(i));
            for (int j : ne) {
                if (i < j)
                    continue;
                String jname = wrap.intToNode(j).toString();
                double a = orig.getEdgeWeight(i, j);
                double b = ucom.getEdgeWeight(i, j);
                wr.write(iname + " " + jname + " " + a + " " + b + " " + Math.abs(a - b));
                wr.write("\n");
            }
        }
        wr.close();
    }
    // write distance
    {
        // BufferedWriter wr = new BufferedWriter(new
        // FileWriter("distance.txt",false));
        BufferedWriter wr = new BufferedWriter(new FileWriter("distance.txt", true)); //modified by Fang

        ImportanceGraph orig = wrap.getImportanceGraph();
        ImportanceGraph ucom = merger.getUncompressedGraph();
        double error = 0;
        for (int i = 0; i <= orig.getMaxNodeId(); i++) {
            HashSet<Integer> ne = new HashSet<Integer>();
            ne.addAll(orig.getNeighbors(i));
            ne.addAll(ucom.getNeighbors(i));
            for (int j : ne) {
                if (i <= j)
                    continue;
                double a = orig.getEdgeWeight(i, j);
                double b = ucom.getEdgeWeight(i, j);
                error += (a - b) * (a - b) * wrap.getImportance(i) * wrap.getImportance(j);
                // modify by Fang: multiply imp(u)imp(v)

            }
        }
        error = Math.sqrt(error);
        //////////error = Math.sqrt(error / 2); // modified by Fang: the error of each
        // edge is counted twice
        wr.write("" + error);
        wr.write("\n");
        wr.close();
    }
    // write sizes
    {
        ImportanceGraph orig = wrap.getImportanceGraph();
        ImportanceGraph comp = merger.getCurrentGraph();
        // BufferedWriter wr = new BufferedWriter(new
        // FileWriter("sizes.txt",false));
        BufferedWriter wr = new BufferedWriter(new FileWriter("sizes.txt", true)); //modified by Fang

        wr.write(orig.getNodeCount() + " " + orig.getEdgeCount() + " " + comp.getNodeCount() + " "
                + comp.getEdgeCount());
        wr.write("\n");
        wr.close();
    }
    //write time
    {
        System.out.println("writing time");
        BufferedWriter wr = new BufferedWriter(new FileWriter("time.txt", true)); //modified by Fang
        double secs = (endMillis - startMillis) * 0.001;
        wr.write("" + secs + "\n");
        wr.close();
    }

    //write change of connectivity for edge-oriented case       // added by Fang
    {
        if (cmd.hasOption("connectivity")) {

            BufferedWriter wr = new BufferedWriter(new FileWriter("connectivity.txt", true));
            ImportanceGraph orig = wrap.getImportanceGraph();
            ImportanceGraph ucom = merger.getUncompressedGraph();

            double diff = 0;

            for (int i = 0; i <= orig.getMaxNodeId(); i++) {
                ProbDijkstra pdori = new ProbDijkstra(orig, i);
                ProbDijkstra pducom = new ProbDijkstra(ucom, i);

                for (int j = i + 1; j <= orig.getMaxNodeId(); j++) {
                    double oriconn = pdori.getProbTo(j);
                    double ucomconn = pducom.getProbTo(j);

                    diff = diff + (oriconn - ucomconn) * (oriconn - ucomconn) * wrap.getImportance(i)
                            * wrap.getImportance(j);

                }
            }

            diff = Math.sqrt(diff);
            wr.write("" + diff);
            wr.write("\n");
            wr.close();

        }
    }

    //write output graph
    {
        BMGraph output = bmg;//new BMGraph(bmg);

        int no = 0;
        BMNode[] nodes = new BMNode[merger.getGroups().size()];
        for (ArrayList<Integer> gr : merger.getGroups()) {
            BMNode bmgroup = new BMNode("Group", "" + (no + 1));
            bmgroup.setAttributes(new HashMap<String, String>());
            bmgroup.put("autoedges", "0");
            nodes[no] = bmgroup;
            no++;
            if (gr.size() == 0)
                continue;
            for (int x : gr) {
                BMNode nod = output.getNode(wrap.intToNode(x).toString());
                BMEdge belongs = new BMEdge(nod, bmgroup, "belongs_to");
                output.ensureHasEdge(belongs);
            }
            output.ensureHasNode(bmgroup);
        }
        for (int i = 0; i < nodes.length; i++) {
            for (int x : merger.getCurrentGraph().getNeighbors(i)) {
                if (x == i) {
                    nodes[x].put("selfedge", "" + merger.getCurrentGraph().getEdgeWeight(i, x));
                    //ge.put("goodness", ""+merger.getCurrentGraph().getEdgeWeight(i, x));
                    continue;
                }
                BMEdge ge = new BMEdge(nodes[x], nodes[i], "groupedge");
                ge.setAttributes(new HashMap<String, String>());
                ge.put("goodness", "" + merger.getCurrentGraph().getEdgeWeight(i, x));
                output.ensureHasEdge(ge);
            }
        }
        System.out.println(output.getGroupNodes());

        BMGraphUtils.writeBMGraph(output, "output.bmg");
    }
}

From source file:com.tamingtext.qa.WikipediaIndexer.java

public static void main(String[] args) throws Exception {
    DefaultOptionBuilder obuilder = new DefaultOptionBuilder();
    ArgumentBuilder abuilder = new ArgumentBuilder();
    GroupBuilder gbuilder = new GroupBuilder();

    Option wikipediaFileOpt = obuilder.withLongName("wikiFile").withRequired(true)
            .withArgument(abuilder.withName("wikiFile").withMinimum(1).withMaximum(1).create())
            .withDescription(//from   w w  w  .  ja  va  2s  .c  o  m
                    "The path to the wikipedia dump file.  Maybe a directory containing wikipedia dump files."
                            + "  If a directory is specified, only .xml files are used.")
            .withShortName("w").create();

    Option numDocsOpt = obuilder.withLongName("numDocs").withRequired(false)
            .withArgument(abuilder.withName("numDocs").withMinimum(1).withMaximum(1).create())
            .withDescription("The number of docs to index").withShortName("n").create();

    Option solrURLOpt = obuilder.withLongName("solrURL").withRequired(false)
            .withArgument(abuilder.withName("solrURL").withMinimum(1).withMaximum(1).create())
            .withDescription("The URL where Solr lives").withShortName("s").create();

    Option solrBatchOpt = obuilder.withLongName("batch").withRequired(false)
            .withArgument(abuilder.withName("batch").withMinimum(1).withMaximum(1).create())
            .withDescription("The number of docs to include in each indexing batch").withShortName("b")
            .create();

    Group group = gbuilder.withName("Options").withOption(wikipediaFileOpt).withOption(numDocsOpt)
            .withOption(solrURLOpt).withOption(solrBatchOpt).create();

    Parser parser = new Parser();
    parser.setGroup(group);
    CommandLine cmdLine = parser.parse(args);

    File file;
    file = new File(cmdLine.getValue(wikipediaFileOpt).toString());
    File[] dumpFiles;
    if (file.isDirectory()) {
        dumpFiles = file.listFiles(new FilenameFilter() {
            public boolean accept(File file, String s) {
                return s.endsWith(".xml");
            }
        });
    } else {
        dumpFiles = new File[] { file };
    }

    int numDocs = Integer.MAX_VALUE;
    if (cmdLine.hasOption(numDocsOpt)) {
        numDocs = Integer.parseInt(cmdLine.getValue(numDocsOpt).toString());
    }
    String url = DEFAULT_SOLR_URL;
    if (cmdLine.hasOption(solrURLOpt)) {
        url = cmdLine.getValue(solrURLOpt).toString();
    }
    int batch = 100;
    if (cmdLine.hasOption(solrBatchOpt)) {
        batch = Integer.parseInt(cmdLine.getValue(solrBatchOpt).toString());
    }
    WikipediaIndexer indexer = new WikipediaIndexer(new CommonsHttpSolrServer(url));
    int total = 0;
    for (int i = 0; i < dumpFiles.length && total < numDocs; i++) {
        File dumpFile = dumpFiles[i];
        log.info("Indexing: " + file + " Num files to index: " + (numDocs - total));
        long start = System.currentTimeMillis();
        int totalFile = indexer.index(dumpFile, numDocs - total, batch);
        long finish = System.currentTimeMillis();
        if (log.isInfoEnabled()) {
            log.info("Indexing " + dumpFile + " took " + (finish - start) + " ms");
        }
        total += totalFile;
        log.info("Done Indexing: " + file + ". Indexed " + totalFile + " docs for that file and " + total
                + " overall.");

    }
    log.info("Indexed " + total + " docs overall.");
}

From source file:gws.PageRank.java

public static void main(String[] args)
        throws IOException, InterruptedException, ClassNotFoundException, ParseException {
    Options opts = new Options();
    opts.addOption("i", "input_path", true, "The Location of output path.");
    opts.addOption("o", "output_path", true, "The Location of input path.");
    opts.addOption("h", "help", false, "Print usage");
    opts.addOption("t", "task_num", true, "The number of tasks.");
    opts.addOption("f", "file_type", true, "The file type of input data. Input"
            + "file format which is \"text\" tab delimiter separated or \"json\"." + "Default value - Text");

    if (args.length < 2) {
        new HelpFormatter()
                .printHelp("pagerank -i INPUT_PATH -o OUTPUT_PATH " + "[-t NUM_TASKS] [-f FILE_TYPE]", opts);
        System.exit(-1);/* w  w w.  j  a  va  2s  . com*/
    }

    HamaConfiguration conf = new HamaConfiguration();
    GraphJob pageJob = createJob(args, conf, opts);

    long startTime = System.currentTimeMillis();
    if (pageJob.waitForCompletion(true)) {
        System.out.println("Job Finished in " + (System.currentTimeMillis() - startTime) / 1000.0 + " seconds");
    }
}