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:esg.common.QuickHash.java

public static void main(String[] args) {
    try {//  w  ww . j a  v  a  2s  .c o  m
        String val = null;
        String hash = null;
        QuickHash quickHash = new QuickHash(args[1]);
        for (int i = 0; i < 1; i++) {
            val = args[0] + (i % 1);
            System.out.print(val + " -> ");
            long start = System.currentTimeMillis();
            hash = quickHash.sum(val);
            System.out.println(hash + " -> t=" + (System.currentTimeMillis() - start));
        }
    } catch (Throwable t) {
        System.out.println(t.getMessage());
    }
}

From source file:FormatStorage2ColumnStorageMR.java

@SuppressWarnings("deprecation")
public static void main(String[] args) throws Exception {

    if (args.length != 2) {
        System.out.println("FormatStorage2ColumnStorageMR <input> <output>");
        System.exit(-1);/*from  www .j  a v  a  2s .co m*/
    }

    JobConf conf = new JobConf(FormatStorageMR.class);

    conf.setJobName("FormatStorage2ColumnStorageMR");

    conf.setNumMapTasks(1);
    conf.setNumReduceTasks(4);

    conf.setOutputKeyClass(LongWritable.class);
    conf.setOutputValueClass(Unit.Record.class);

    conf.setMapperClass(FormatStorageMapper.class);
    conf.setReducerClass(ColumnStorageReducer.class);

    conf.setInputFormat(FormatStorageInputFormat.class);
    conf.set("mapred.output.compress", "flase");

    Head head = new Head();
    initHead(head);

    head.toJobConf(conf);

    FileInputFormat.setInputPaths(conf, args[0]);
    Path outputPath = new Path(args[1]);
    FileOutputFormat.setOutputPath(conf, outputPath);

    FileSystem fs = outputPath.getFileSystem(conf);
    fs.delete(outputPath, true);

    JobClient jc = new JobClient(conf);
    RunningJob rj = null;
    rj = jc.submitJob(conf);

    String lastReport = "";
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss,SSS");
    long reportTime = System.currentTimeMillis();
    long maxReportInterval = 3 * 1000;
    while (!rj.isComplete()) {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
        }

        int mapProgress = Math.round(rj.mapProgress() * 100);
        int reduceProgress = Math.round(rj.reduceProgress() * 100);

        String report = " map = " + mapProgress + "%,  reduce = " + reduceProgress + "%";

        if (!report.equals(lastReport) || System.currentTimeMillis() >= reportTime + maxReportInterval) {

            String output = dateFormat.format(Calendar.getInstance().getTime()) + report;
            System.out.println(output);
            lastReport = report;
            reportTime = System.currentTimeMillis();
        }
    }

    System.exit(0);

}

From source file:edu.monash.merc.system.remote.HttpBarcodeFileGetter.java

public static void main(String[] args) {
    String fileLocation = "http://barcode.luhs.org/transcriptomes/abc.ntc.GPL96.csv";
    HttpBarcodeFileGetter fileGetter = new HttpBarcodeFileGetter();
    long startTime = System.currentTimeMillis();
    fileGetter.downloadBarcodeFile(fileLocation, "abc.ntc.GPL96.csv");
    long endTime = System.currentTimeMillis();
    System.out.println("===== total processing time : " + (endTime - startTime) / 1000 + " seconds.");
}

From source file:eu.scape_project.pc.hadoop.DroidIdentifyHadoopJob.java

/**
 * The main entry point.//from w  ww .  jav a  2  s  .co  m
 */
public static void main(String[] args) throws ParseException {
    Configuration conf = new Configuration();
    GenericOptionsParser gop = new GenericOptionsParser(conf, args);
    HadoopJobCliConfig pc = new HadoopJobCliConfig();
    CommandLineParser cmdParser = new PosixParser();
    CommandLine cmd = cmdParser.parse(HadoopJobOptions.OPTIONS, gop.getRemainingArgs());
    if ((args.length == 0) || (cmd.hasOption(HadoopJobOptions.HELP_OPT))) {
        HadoopJobOptions.exit("Usage", 0);
    } else {
        HadoopJobOptions.initOptions(cmd, pc);
    }
    String dir = pc.getDirStr();

    String name = pc.getHadoopJobName();
    if (name == null || name.equals("")) {
        name = "droid_identification";
    }

    try {
        Job job = new Job(conf, name);

        // local debugging
        //            job.getConfiguration().set("mapred.job.tracker", "local");
        //            job.getConfiguration().set("fs.default.name", "file:///");

        job.setJarByClass(DroidIdentifyHadoopJob.class);

        job.setMapperClass(DroidIdentifyMapper.class);
        //job.setCombinerClass(DroidIdentifyReducer.class);
        job.setReducerClass(DroidIdentifyReducer.class);

        job.setInputFormatClass(TextInputFormat.class);

        job.setOutputFormatClass(TextOutputFormat.class);
        //SequenceFileOutputFormat.setOutputCompressionType(job, SequenceFile.CompressionType.NONE);

        //conf.setMapOutputKeyClass(Text.class);
        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(LongWritable.class);

        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(LongWritable.class);

        SequenceFileInputFormat.addInputPath(job, new Path(dir));
        String outpath = "output/" + System.currentTimeMillis() + "dri";
        FileOutputFormat.setOutputPath(job, new Path(outpath));
        job.waitForCompletion(true);
        System.out.print(outpath);
        System.exit(0);
    } catch (Exception e) {
        logger.error("I/O error", e);
    }
}

From source file:edu.kit.dama.util.test.LocalAccessTest.java

public static void main(String[] args) throws Exception {

    IFileTree tree = DataOrganizationUtils.createTreeFromFile("1q2345", new AbstractFile(new File(
            "/Users/jejkal/NetBeansProjects/KITDM/trunk/Docker/KITDM/share/log/cd37731e22d7df46722fa41efe2c5511ee83d3ee")),
            true);//from   w  w  w.j  a v  a 2  s  .  co m
    IDataOrganizationNode generatedNode = Util.getNodeByName(tree.getRootNode(),
            Constants.STAGING_GENERATED_FOLDER_NAME);

    //DataOrganizationUtils.printTree(tree.getRootNode(), true);
    DataOrganizationUtils.printTree((ICollectionNode) generatedNode, true);

    if (generatedNode == null || !(generatedNode instanceof ICollectionNode)
            || ((ICollectionNode) generatedNode).getChildren().isEmpty()) {
        System.out.println(
                "Node for 'generated' content not found or is empty. Skip registering view 'generated'.");
    } else {
        System.out.println("OK!");
    }
    if (true) {
        return;
    }

    //     DigitalObject c = DigitalObject.factoryNewDigitalObject();
    //System.out.println(c.getDigitalObjectIdentifier());
    /*   CustomDigitalObject c = new CustomDigitalObject();
    c.setDigitalObjectId(new DigitalObjectId(UUID.randomUUID().toString()));
    c.setLabel("TEst");
    c.setNote("ee123");
    System.out.println("EDS");
    mdm.save(c);
    System.out.println("ODN");*/
    // mdm.close();
    String accessKey = "admin";
    String accessSecret = "dama14";
    String restBaseUrl = "http://localhost:8080/KITDM";
    SimpleRESTContext context = new SimpleRESTContext(accessKey, accessSecret);
    /*  DigitalObject newDigitalObject= DigitalObject.factoryNewDigitalObject();
    newDigitalObject.setLabel("Sample DigitalObject");
    newDigitalObject.setNote("This is a sample");
    newDigitalObject.setStartDate(new Date());*/
    long s = System.currentTimeMillis();
    BaseMetaDataRestClient client;

    client = new BaseMetaDataRestClient(restBaseUrl + "/rest/basemetadata/", context);

    long t = 0;
    for (int i = 0; i < 100; i++) {

        DigitalObjectWrapper o = client.getDigitalObjectById(57l);
        t += (System.currentTimeMillis() - s);
        s = System.currentTimeMillis();
    }

    System.out.println("T " + (t / 100l));

    /*DigitalObject ob = o.getEntities().get(0);
    System.out.println(ob.getDigitalObjectIdentifier());
    System.out.println(ob.getDigitalObjectId().getStringRepresentation());*/
    /*Study newStudy =  Study.factoryNewStudy();
           newStudy.setTopic("Sample Study");
           newStudy.setNote("This is a sample");
           newStudy.setStartDate(new Date());
       Investigation newInvestigation= Investigation.factoryNewInvestigation();
           newInvestigation.setTopic("Sample Investigation");
           newInvestigation.setNote("This is a sample");
           newInvestigation.setStartDate(new Date());
            client = new BaseMetaDataRestClient(restBaseUrl + "/rest/basemetadata/", context);
            
           //Create a new study. The study will be assigned to the default group whose ID we've obtained above.
           StudyWrapper studyWrapper = client.addStudy(newStudy, Constants.USERS_GROUP_ID);
           //Assign returned study to 'newStudy' as the created entity now contains a valid studyId.
           newStudy = studyWrapper.getEntities().get(0);
            
           //Use the studyId to add a new investigation to the study we've just created.
           InvestigationWrapper investigationWrapper = client.addInvestigationToStudy(newStudy.getStudyId(), newInvestigation, Constants.USERS_GROUP_ID);
           //Assign returned investigation to 'newInvestigation' as the created entity now contains a valid investigationId.
           newInvestigation = investigationWrapper.getEntities().get(0);
            
           //Use the investigationId to add a new digital object to the investigation just created.
                   
           DigitalObjectWrapper digitalObjectWrapper = client.addDigitalObjectToInvestigation(newInvestigation.getInvestigationId(), newDigitalObject, Constants.USERS_GROUP_ID);
           //Assign returned digitalObject to 'newDigitalObject' as the created entity now contains a valid objectId.
           newDigitalObject = digitalObjectWrapper.getEntities().get(0);
           System.out.println("OK");
                   
            */
    /*StagingServiceRESTClient client = new StagingServiceRESTClient("http://localhost:8080/KITDM/rest/staging/", new SimpleRESTContext("admin", "dama14"));
            
           FileTreeImpl f = new FileTreeImpl();
           f.setDigitalObjectId(new DigitalObjectId("f735e33e-8821-460e-9d86-90281e6f91e1"));
           f.setViewName("default");
           CollectionNodeImpl col = new CollectionNodeImpl();
           col.setName("myImage");
           FileNodeImpl fi = new FileNodeImpl(new LFNImpl("file:/Users/jejkal/tmp/2016/5/16/admin/d83bdb349f073714cec972958ab5737e7fe28f27/data/images/StructureAdminMetadata.png"));
           fi.setNodeId(500l);
           col.addChild(fi);
           f.getRootNode().addChild(col);
            
           System.out.println(client.createDownload("f735e33e-8821-460e-9d86-90281e6f91e1", "273f477a-546c-41d7-9037-61723de4dd36", f, "USERS"));
            */

    /*String token = new String(Base64.getDecoder().decode("YWRtaW46ZGFtYTE0"));
    int splitIndex = token.indexOf(":");
    if (splitIndex < 1) {
        throw new UnauthorizedAccessAttemptException("Invalid basic authentication header.");
    }
            
    String user = token.substring(0, splitIndex);
    String secret = token.substring(splitIndex+1);
    System.out.println(user);
    System.out.println(secret);*/
    /* System.out.println(DigestUtils.md5Hex("admin:kitdm:dama14"));
        String md5a1 = DigestUtils.md5Hex("admin:kitdm:dama14");
            
                        String md5a2 = DigestUtils.md5Hex("GET:/KITDM/rest/basemetadata/investigations?groupId=USERS");
          Map<String, Object> custom = new HashMap<>();
           custom.put("repository.context", "empty");
           AdalapiProtocolConfiguration config = AdalapiProtocolConfiguration.factoryConfiguration(new URL("http://dreamatico.com/data_images/kitten/kitten-2.jpg"),SimpleHttp.class.getCanonicalName(), KITDMAuthenticator.class.getCanonicalName(), custom);
            
            
                   
                   
           String clientHash = "602ce28e72c44bf003556f4b0e5b678d";
           String serverDigest = DigestUtils.md5Hex(md5a1 + ":12345:" + md5a2);
                   
           System.out.println(md5a1);
        System.out.println(md5a2);
            
           System.out.println(serverDigest);
        System.out.println(clientHash);
            */
    /* String tokenKey = CryptUtil.stringToSHA1("test12345");
            System.out.println(tokenKey);
            IMetaDataManager mdm = MetaDataManagement.getMetaDataManagement().getMetaDataManager();
            mdm.setAuthorizationContext(AuthorizationContext.factorySystemContext());
    ServiceAccessToken accessToken = ServiceAccessUtil.getAccessToken(mdm, tokenKey, "simpleRestToken");
           System.out.println(accessToken);*/
    // AbstractFile fi = new AbstractFile(new URL("http://ipelsdf1.lsdf.kit.edu:8889/webdav/admin/1/data/screen.jpg"));
    //SimpleRESTContext context = new SimpleRESTContext("admin", "dama14");

    /* UserGroupWrapper groupWrapper = client1.getAllGroups(0, Integer.MAX_VALUE);
    System.out.println("The following groups were found:");
    for (UserGroup group : groupWrapper.getEntities()) {
    System.out.println(" Name: " + group.getGroupName());
    UserDataWrapper members = client1.getUsersOfGroup(group.getId(), 0, Integer.MAX_VALUE);
    System.out.println(" The group has the following members:");
    for (UserData user : members.getEntities()) {
        System.out.println("   - " + user.getFullname() + " (" + user.getDistinguishedName() + ")" + user.getUserId());
    }
    }
    //  client1.addGroup("uniqueId", "Another Custom Group", "A custom group created for testing purposes.");
            
    UserDataWrapper userWrapper = client1.getAllUsers(Constants.USERS_GROUP_ID, 0, Integer.MAX_VALUE);
    for (UserData user : userWrapper.getEntities()) {
    System.out.println(" - " + user.getFullname() + " (" + user.getDistinguishedName() + ")");
    }
            
    //distinguished name or id
    int modified = client1.addUserToGroup(3l, "tester").getCount();
            
    System.out.println(client1.removeUserFromGroup(3l, 421l).getCount());
     */
    /* UserDataWrapper newUser = client1.addUser(Constants.USERS_GROUP_ID, "Test", "User", "test@mail.org", newUserIdentifier);
           System.out.println(newUser.getEntities().get(0).getDistinguishedName());
           //distinguished name or id
           int modified = client1.addUserToGroup(3l, newUserIdentifier).getCount();
            */
    /*  UserGroupWrapper groupWrapper = client.getAllGroups(0, Integer.MAX_VALUE);
            
           for (UserGroup group : groupWrapper.getEntities()) {
    System.out.println("GName: " + group.getGroupName());
           }
            
           UserDataWrapper userWrapper = client.getAllUsers("eCod", 0, Integer.MAX_VALUE);
           for (UserData user : userWrapper.getEntities()) {
    System.out.println("UName: " + user.getDistinguishedName());
            
           }*/
    //        AbstractRandomDataProviderStrategy stra = new AbstractRandomDataProviderStrategy() {
    //            @Override
    //            public Long getLong(AttributeMetadata attributeMetadata) {
    //                if (attributeMetadata.getAttributeName().toLowerCase().contains("id")) {
    //                    return 0l;
    //                }
    //                return super.getLong(attributeMetadata); //To change body of generated methods, choose Tools | Templates.
    //            }
    //
    //            @Override
    //            public Object getMemoizedObject(AttributeMetadata attributeMetadata) {
    //                if (attributeMetadata != null && attributeMetadata.getAttributeName() != null) {
    //                    switch (attributeMetadata.getAttributeName()) {
    //                        case "validFrom":
    //                            return new Date(0);
    //                        case "startDate":
    //                            return new Date(0);
    //                        case "validUntil":
    //                            return new Date(System.currentTimeMillis());
    //                        case "endDate":
    //                            return new Date(System.currentTimeMillis());
    //                        case "uploadDate":
    //                            return new Date(System.currentTimeMillis());
    //                    }
    //                }
    //                return super.getMemoizedObject(attributeMetadata);
    //            }
    //
    //        };
    //        stra.setDefaultNumberOfCollectionElements(1);       
    //        PodamFactory factory = new PodamFactoryImpl(stra);
    //
    //        DigitalObject a2 = factory.manufacturePojo(DigitalObject.class);
    //
    //        IMetaDataManager mdm = MetaDataManagement.getMetaDataManagement().getMetaDataManager();
    //        mdm.setAuthorizationContext(AuthorizationContext.factorySystemContext());
    //        a2 = mdm.save(a2);
    //
    //        System.out.println(a2);
    if (true) {
        return;
    }

    /*String content = org.apache.commons.io.FileUtils.readFileToString(new File("/Users/jejkal/Software/GenericRestClient-1.2/bin/data/default_view.json"));
    JSONObject viewObject = new JSONObject(content);
    IFileTree tree1 = Util.jsonViewToFileTree(viewObject, true, false);
    DataOrganizationUtils.printTree(tree1.getRootNode(), true);*/
    /*AdalapiProtocolConfiguration config = AdalapiProtocolConfiguration.factoryConfiguration(new URL("http://localhost:8080"), "edu.kit.lsdf.adalapi.protocols.WebDav", "edu.kit.dama.staging.adalapi.authenticator.KITDMAuthenticator", null);
           IMetaDataManager mdm = MetaDataManagement.getMetaDataManagement().getMetaDataManager();
           mdm.setAuthorizationContext(AuthorizationContext.factorySystemContext());
           System.out.println("RESULT " + mdm.save(config));
            
           DatabaseProtocolConfigurator config1 = new DatabaseProtocolConfigurator();
           ProtocolSettings.getSingleton().setExternalProtocolConfigurator(config1);
            
           Configuration configuration = config1.getConfiguration(new URL("http://localhost:8080"));
           Iterator keys = configuration.getKeys();
           while (keys.hasNext()) {
    String key = (String) keys.next();
    System.out.println(key + " - " + configuration.getString(key));
           }*/
    //SardineImpl impl = new SardineImpl("webdav", "webdav");
    //impl.enablePreemptiveAuthentication(new URL("http://127.0.0.1:8080/webdav/admin/1/data/index.html"));
    //impl.setCredentials("webdav", "webdav");
    //System.out.println(impl.get("http://webdav@127.0.0.1:8080/webdav/admin/1/data/index.html"));
    //System.out.println(impl.exists("http://webdav@ipesuco1.ipe.kit.edu:10000/"));
    /*Configuration config = new DatabaseProtocolConfigurator().getConfiguration(new URL("http://localhost:8080/webdav/admin/1/data/index.html"));
    config.addProperty("username", "webdav");
    config.addProperty("password", "webdav");
            
    AbstractFile file = new AbstractFile(new URL("http://localhost:8080/webdav/admin/1/data/index.html"));
    System.out.println(file.exists());
            
    /* Configuration config1 = new DatabaseProtocolConfigurator().getConfiguration(new URL("http://localhost:8080/webdav/admin/1/data/index.html"));
    config1.addProperty("username", "webdav1");
    config1.addProperty("password", "webdav1");
     */
    /* AbstractFile file2 = new AbstractFile(new URL("http://localhost:8080/webdav/admin/1/data/index.html"));
           System.out.println(file2.exists());*/
    // createDestination("1", new AuthorizationContext(new UserId("admin"), new GroupId("USERS"), Role.ADMINISTRATOR));
    //  System.out.println(file.exists());
    ///////////
    //          long investigationId = -1l;
    //        int first = 0;
    //        int results = 10;
    //         List<DigitalObject> objects;
    //            if (investigationId <= 0) {
    //                //no investigationId provided...get all objects
    //                mdm.addProperty(MetaDataManagerJpa.JAVAX_PERSISTENCE_FETCHGRAPH, "DigitalObject.simple");
    //                objects = mdm.findResultList("SELECT o FROM DigitalObject o", DigitalObject.class, first, results);
    //            } else {
    //                //first, obtain investigation for id
    //                mdm.addProperty(MetaDataManagerJpa.JAVAX_PERSISTENCE_FETCHGRAPH, "Investigation.simple");
    //                Investigation investigation = mdm.find(Investigation.class, investigationId);
    //                if (investigation == null) {
    //                    LOGGER.error("Investigation for id {} not found.", investigationId);
    //                    throw new WebApplicationException(Response.Status.NOT_FOUND);
    //                }
    //                //try to get objects in investigation
    //                mdm.addProperty(MetaDataManagerJpa.JAVAX_PERSISTENCE_FETCHGRAPH, "DigitalObject.simple");
    //                objects = mdm.findResultList("SELECT o FROM DigitalObject o WHERE o.investigation.investigationId=" + investigationId, DigitalObject.class, first, results);
    //            }
    ////////
    /* BaseMetaDataRestClient cl = new BaseMetaDataRestClient("http://ipesuco1.ipe.kit.edu:8080/KITDM/rest/basemetadata/", new SimpleRESTContext("admin", "dama14"));
    DigitalObjectWrapper w = cl.getAllDigitalObjects(63l, 0, 100, "eCod");
            
    System.out.println("Time2: " + (System.currentTimeMillis() - s));
     */
    //DataOrganizationRestClient doClient = new DataOrganizationRestClient("http://localhost:8080/KITDM/rest/dataorganization/", new SimpleRESTContext("admin", "dama14"));
    /* DataOrganizer org = DataOrganizerFactory.getInstance().getDataOrganizer();
    IFileTree tree1 = org.loadFileTree(new DigitalObjectId("ef16c1e5-d9b3-44b5-ba77-b9877082d02c"), "default");
            
    IFileTree sub = org.loadSubTree(new NodeId(new DigitalObjectId("ef16c1e5-d9b3-44b5-ba77-b9877082d02c"), 400l,1), 0);
            
    DataOrganizationUtils.printTree(sub.getRootNode(), true);*/

    /* FileTreeImpl newTree = new FileTreeImpl();
           newTree.setDigitalObjectId(new DigitalObjectId("ef16c1e5-d9b3-44b5-ba77-b9877082d02c"));
           newTree.setViewName("custom");
           CollectionNodeImpl images = new CollectionNodeImpl();
           images.setNodeId(400l);
            
           CollectionNodeImpl documents = new CollectionNodeImpl();
           documents.setName("documents");
           FileNodeImpl fDocumentation = new FileNodeImpl(null);
           fDocumentation.setNodeId(200l);
           documents.addChild(fDocumentation);
           newTree.getRootNode().addChild(images);
           newTree.getRootNode().addChild(documents);
            
           doClient.postView("USERS", 31l, newTree, Boolean.TRUE, new SimpleRESTContext("admin", "dama14"));
            */
    /* DataOrganizer org = DataOrganizerFactory.getInstance().getDataOrganizer();
           IFileTree tree1 = org.loadFileTree(new DigitalObjectId("ef16c1e5-d9b3-44b5-ba77-b9877082d02c"), "custom");
            
           DataOrganizationUtils.printTree(tree1.getRootNode(), true);*/
    DataOrganizer dor = DataOrganizerFactory.getInstance().getDataOrganizer();
    //dor.configure("http://localhost:7474", "neo4j", "test");
    // edu.kit.dama.mdm.dataorganization.impl.jpa.DataOrganizerImpl dor = new edu.kit.dama.mdm.dataorganization.impl.jpa.DataOrganizerImpl();

    // IFileTree tree = DataOrganizationUtils.createTreeFromFile("Large4", new AbstractFile(new File("/Users/jejkal/NetBeansProjects/KITDM/trunk")), true);
    //edu.kit.dama.mdm.dataorganization.impl.jpa.DataOrganizerImpl dor = new edu.kit.dama.mdm.dataorganization.impl.jpa.DataOrganizerImpl();       
    // System.out.println("Create tree");
    //  dor.createFileTree(tree);
    System.out.println("DONE");
    s = System.currentTimeMillis();

    System.out.println(dor.getViews(new DigitalObjectId("Large4")));
    //dor.createFileTree(tree);
    System.out.println("R " + (System.currentTimeMillis() - s));

    if (true) {
        return;
    }

    //  IMetaDataManager mdm1 = MetaDataManagement.getMetaDataManagement().getMetaDataManager();
    // mdm1.addProperty(MetaDataManagerJpa.JAVAX_PERSISTENCE_FETCHGRAPH, "DigitalObject.simple");
    //   AuthorizationContext ctx1 = new AuthorizationContext(new UserId("admin"), new GroupId("eCod"), Role.ADMINISTRATOR);
    //   mdm1.setAuthorizationContext(ctx1);*/
    /* StringBuilder query = new StringBuilder();
    IMetaDataManager mdm1 = MetaDataManagement.getMetaDataManagement().getMetaDataManager();
    mdm1.setAuthorizationContext(ctx1);
    String domain = SecurableEntityHelper.getSecurableResourceDomain(DigitalObject.class);
    String uniqueField = SecurableEntityHelper.getDomainUniqueFieldName(DigitalObject.class);
            
    query.append("SELECT o FROM FilterHelper f, ").
        append("DigitalObject").append(" o WHERE ");
            
    query.append("f.userId='").append(ctx1.getUserId().getStringRepresentation());
    query.append("' AND ");
            
    query.append("f.groupId='").append(ctx1.getGroupId().getStringRepresentation()).append("' AND ")
        .append("f.domainId='").append(domain).
        append("' AND f.roleAllowed>=").append(Role.GUEST.ordinal()).
        append(" AND f.domainUniqueId=o.").append(uniqueField);
            
    long s1 = System.currentTimeMillis();
            
    List<DigitalObject> result2 = mdm1.findResultList(query.toString(), DigitalObject.class, 0, 100);
    System.out.println("D: " + (System.currentTimeMillis() - s1));*/
    /*for(int i=0;i<100;i++){
       if(result1.get(i).getDigitalObjectId().equals(result2.get(i).getDigitalObjectId())){
           System.out.println("ERROR ");
           System.out.println(result1.get(i));
           System.out.println("=====================");
           System.out.println(result2.get(i));
           System.out.println("===================");
           System.out.println(i);
       }
    }*/
    if (true) {
        return;
    }
    //        IMetaDataManager mdm = MetaDataManagement.getMetaDataManagement().getMetaDataManager();
    //        AuthorizationContext ctx = new AuthorizationContext(new UserId("admin"), new GroupId("eCod"), Role.ADMINISTRATOR);
    //        mdm.setAuthorizationContext(ctx);
    //        long s = System.currentTimeMillis();
    //        //System.out.println(new DigitalObjectSecureQueryHelper().getReadableResources(mdm, 0, 100, ctx).size());
    //        System.out.println("Time: " + (System.currentTimeMillis() - s));
    //        s = System.currentTimeMillis();
    //        mdm.addProperty(MetaDataManagerJpa.JAVAX_PERSISTENCE_FETCHGRAPH, "DigitalObject.default");
    //        System.out.println(mdm.findResultList("SELECT o FROM DigitalObject o", DigitalObject.class, 0, 100).size());
    //        System.out.println("Time2: " + (System.currentTimeMillis() - s));
    //        if (true) {
    //            return;
    //        }

    //        IMetaDataManager mdm = MetaDataManagement.getMetaDataManagement().getMetaDataManager();
    //        //mdm.setAuthorizationContext(new AuthorizationContext(new UserId("admin"), new GroupId("eCod"), Role.MANAGER));
    //        mdm.setAuthorizationContext(AuthorizationContext.factorySystemContext());
    //        mdm.addProperty(MetaDataManagerJpa.JAVAX_PERSISTENCE_FETCHGRAPH, "DigitalObject.default");
    //        long s = System.currentTimeMillis();
    //        DigitalObject result = mdm.find(DigitalObject.class, 1000l);
    //        System.out.println(result.getBaseId());
    //        System.out.println(result.getLabel());
    //        System.out.println(result.getInvestigation().getInvestigationId());
    //        System.out.println(result.getInvestigation().getTopic());
    //        /* System.out.println(result.getStudyId());
    //         System.out.println(result.getTopic());*/
    //        System.out.println("TIME: " + (System.currentTimeMillis() - s));
    //        // System.out.println(result.getInvestigations().size());

    /* System.out.println(result.getBaseId());
     System.out.println(result.getLabel());
     System.out.println(result.getNote());
     System.out.println("--------");
     mdm.addProperty(MetaDataManagerJpa.JAVAX_PERSISTENCE_FETCHGRAPH, "DigitalObject.default");
     result = mdm.save(result);
     System.out.println(result.getBaseId());
     System.out.println(result.getLabel());
     System.out.println(result.getNote());
     System.out.println("--------");
     result = mdm.find(DigitalObject.class).get(0);
     System.out.println(result.getBaseId());
     System.out.println(result.getLabel());
     System.out.println(result.getNote());*/

    /* System.out.println("TOPIC " + result.get(0).getTopic());
            System.out.println("NOT " + result.get(0).getNote());
            System.out.println("INV " + result.get(0).getInvestigations());
            System.out.println("DO " + ((Investigation) result.get(0).getInvestigations().toArray()[0]).getDataSets());*/
    if (true) {
        return;
    }

    //        long t = System.currentTimeMillis();
    //
    //        AbstractRandomDataProviderStrategy stra = new AbstractRandomDataProviderStrategy() {
    //        };
    //        stra.setDefaultNumberOfCollectionElements(1);
    //        PodamFactory factory = new PodamFactoryImpl(stra);
    //        DigitalObject a = factory.manufacturePojo(DigitalObject.class);
    //        DigitalObject a2 = factory.manufacturePojoWithFullData(DigitalObject.class);
    //
    //        //for (int i = 0; i < 10; i++) {
    //        //  long s = System.currentTimeMillis();
    //        Marshaller marshaller = org.eclipse.persistence.jaxb.JAXBContext.newInstance(DigitalObject.class).createMarshaller();
    //        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
    //        marshaller.setProperty("eclipselink.media-type", "application/json");
    //        marshaller.setProperty(MarshallerProperties.OBJECT_GRAPH, "default");
    //        marshaller.marshal(a, System.out);
    //        marshaller.marshal(a2, System.out);
    //        //  t += System.currentTimeMillis() - s;
    //        // }
    //        System.out.println("D " + (System.currentTimeMillis() - t));
    //        if (true) {
    //            return;
    //        }
    Document docDigitalObject = null;
    String completeXml = null;

    String baseXML = DigitalObject2Xml.getXmlString(DigitalObject.factoryNewDigitalObject());

    try {
        ByteArrayInputStream bin = new ByteArrayInputStream(baseXML.getBytes());
        docDigitalObject = JaxenUtil.getW3CDocument(bin);//XMLTools.parseDOM(baseXML);
    } catch (Exception exc) {
        throw new MetaDataExtractionException("Failed to transform DigitalObject XML.", exc);
    }

    Element digitalObjectElement = docDigitalObject.getDocumentElement();

    Document completeDocument = null;
    try {
        completeDocument = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
    } catch (ParserConfigurationException ex) {
        throw new MetaDataExtractionException("Failed to generate target document.", ex);
    }
    Element rootElement = completeDocument.createElement("test");

    Element root = completeDocument.createElementNS(BaseMetaDataHelper.DAMA_NAMESPACE_BASEMETADATA,
            BaseMetaDataHelper.DAMA_NAMESPACE_PREFIX);
    root.appendChild(completeDocument.importNode(digitalObjectElement, true));
    Node csmdRoot = root.appendChild(completeDocument.createElementNS(
            BaseMetaDataHelper.DAMA_NAMESPACE_METADATA, BaseMetaDataHelper.CSMD_NAMESPACE_PREFIX));
    csmdRoot.appendChild(completeDocument.importNode(rootElement, true));

    completeDocument.appendChild(root);
    root.setAttributeNS("http://www.w3.org/2001/XMLSchema-instance", "xsi:schemaLocation",
            BaseMetaDataHelper.DAMA_NAMESPACE_METADATA + " " + BaseMetaDataHelper.DAMA_NAMESPACE_BASEMETADATA
                    + "/MetaData.xsd");
    // convert tweaked DOM back to XML string
    try {
        completeXml = getStringFromDocument(completeDocument);//XMLTools.getXML(completeDocument);
    } catch (Exception exc) {
        throw new MetaDataExtractionException("Internal XML conversion error.", exc);
    }
    System.out.println(completeXml);

    //    IMetaDataManager mdm = MetaDataManagement.getMetaDataManagement().getMetaDataManager();
    //    IAuthorizationContext context = new AuthorizationContext(new UserId("admin"), new GroupId(Constants.USERS_GROUP_ID), Role.ADMINISTRATOR);//AuthorizationContext.factorySystemContext();
    //    mdm.setAuthorizationContext(context);
    //    try {
    //      //TransferClientProperties props = new TransferClientProperties();
    //      //props.setStagingAccessPointId("0000-0000-0000-0000");
    //      //IngestInformationServiceLocal.getSingleton().prepareIngest(new DigitalObjectId("c98408fc-36d0-4cc0-8197-340873d6698e"), props, context);
    //
    //      //System.out.println(StagingService.getSingleton().finalizeIngest(new DigitalObjectId("c98408fc-36d0-4cc0-8197-340873d6698e"), context));
    //      System.out.println(MetadataIndexingHelper.getSingleton().performIndexing("KITDataManager", "dc", new GroupId("USERS"), 10, context));
    //    } finally {
    //      mdm.close();
    //    }
}

From source file:com.betfair.cougar.test.socket.app.SocketCompatibilityTestingApp.java

public static void main(String[] args) throws Exception {

    Parser parser = new PosixParser();
    Options options = new Options();
    options.addOption("r", "repo", true, "Repository type to search: local|central");
    options.addOption("c", "client-concurrency", true,
            "Max threads to allow each client tester to run tests, defaults to 10");
    options.addOption("t", "test-concurrency", true, "Max client testers to run concurrently, defaults to 5");
    options.addOption("m", "max-time", true,
            "Max time (in minutes) to allow tests to complete, defaults to 10");
    options.addOption("v", "version", false, "Print version and exit");
    options.addOption("h", "help", false, "This help text");
    CommandLine commandLine = parser.parse(options, args);
    if (commandLine.hasOption("h")) {
        System.out.println(options);
        System.exit(0);/* w  w  w . j a  v  a2s.  c o  m*/
    }
    if (commandLine.hasOption("v")) {
        System.out.println("How the hell should I know?");
        System.exit(0);
    }
    // 1. Find all testers in given repos
    List<RepoSearcher> repoSearchers = new ArrayList<>();
    for (String repo : commandLine.getOptionValues("r")) {
        if ("local".equals(repo.toLowerCase())) {
            repoSearchers.add(new LocalRepoSearcher());
        } else if ("central".equals(repo.toLowerCase())) {
            repoSearchers.add(new CentralRepoSearcher());
        } else {
            System.err.println("Unrecognized repo: " + repo);
            System.err.println(options);
            System.exit(1);
        }
    }
    int clientConcurrency = 10;
    if (commandLine.hasOption("c")) {
        try {
            clientConcurrency = Integer.parseInt(commandLine.getOptionValue("c"));
        } catch (NumberFormatException nfe) {
            System.err.println(
                    "client-concurrency is not a valid integer: '" + commandLine.getOptionValue("c") + "'");
            System.exit(1);
        }
    }
    int testConcurrency = 5;
    if (commandLine.hasOption("t")) {
        try {
            testConcurrency = Integer.parseInt(commandLine.getOptionValue("t"));
        } catch (NumberFormatException nfe) {
            System.err.println(
                    "test-concurrency is not a valid integer: '" + commandLine.getOptionValue("t") + "'");
            System.exit(1);
        }
    }
    int maxMinutes = 10;
    if (commandLine.hasOption("m")) {
        try {
            maxMinutes = Integer.parseInt(commandLine.getOptionValue("m"));
        } catch (NumberFormatException nfe) {
            System.err.println("max-time is not a valid integer: '" + commandLine.getOptionValue("m") + "'");
            System.exit(1);
        }
    }

    Properties clientProps = new Properties();
    clientProps.setProperty("client.concurrency", String.valueOf(clientConcurrency));

    File baseRunDir = new File(System.getProperty("user.dir") + "/run");
    baseRunDir.mkdirs();

    File tmpDir = new File(baseRunDir, "jars");
    tmpDir.mkdirs();

    List<ServerRunner> serverRunners = new ArrayList<>();
    List<ClientRunner> clientRunners = new ArrayList<>();
    for (RepoSearcher searcher : repoSearchers) {
        List<File> jars = searcher.findAndCache(tmpDir);
        for (File f : jars) {
            ServerRunner serverRunner = new ServerRunner(f, baseRunDir);
            System.out.println("Found tester: " + serverRunner.getVersion());
            serverRunners.add(serverRunner);
            clientRunners.add(new ClientRunner(f, baseRunDir, clientProps));
        }
    }

    // 2. Start servers and collect ports
    System.out.println();
    System.out.println("Starting " + serverRunners.size() + " servers...");
    for (ServerRunner server : serverRunners) {
        server.startServer();
    }
    System.out.println();

    List<TestCombo> tests = new ArrayList<>(serverRunners.size() * clientRunners.size());
    for (ServerRunner server : serverRunners) {
        for (ClientRunner client : clientRunners) {
            tests.add(new TestCombo(server, client));
        }
    }

    System.out.println("Enqueued " + tests.size() + " test combos to run...");

    long startTime = System.currentTimeMillis();
    // 3. Run every client against every server, collecting results
    BlockingQueue<Runnable> workQueue = new ArrayBlockingQueue(serverRunners.size() * clientRunners.size());
    ThreadPoolExecutor service = new ThreadPoolExecutor(testConcurrency, testConcurrency, 5000,
            TimeUnit.MILLISECONDS, workQueue);
    service.prestartAllCoreThreads();
    workQueue.addAll(tests);
    while (!workQueue.isEmpty()) {
        Thread.sleep(1000);
    }
    service.shutdown();
    service.awaitTermination(maxMinutes, TimeUnit.MINUTES);
    long endTime = System.currentTimeMillis();
    long totalTimeSecs = Math.round((endTime - startTime) / 1000.0);
    for (ServerRunner server : serverRunners) {
        server.shutdownServer();
    }

    System.out.println();
    System.out.println("=======");
    System.out.println("Results");
    System.out.println("-------");
    // print a summary
    int totalTests = 0;
    int totalSuccess = 0;
    for (TestCombo combo : tests) {
        String clientVer = combo.getClientVersion();
        String serverVer = combo.getServerVersion();
        String results = combo.getClientResults();
        ObjectMapper mapper = new ObjectMapper(new JsonFactory());
        JsonNode node = mapper.reader().readTree(results);
        JsonNode resultsArray = node.get("results");
        int numTests = resultsArray.size();
        int numSuccess = 0;
        for (int i = 0; i < numTests; i++) {
            if ("success".equals(resultsArray.get(i).get("result").asText())) {
                numSuccess++;
            }
        }
        totalSuccess += numSuccess;
        totalTests += numTests;
        System.out.println(clientVer + "/" + serverVer + ": " + numSuccess + "/" + numTests
                + " succeeded - took " + String.format("%2f", combo.getRunningTime()) + " seconds");
    }
    System.out.println("-------");
    System.out.println(
            "Overall: " + totalSuccess + "/" + totalTests + " succeeded - took " + totalTimeSecs + " seconds");

    FileWriter out = new FileWriter("results.json");
    PrintWriter pw = new PrintWriter(out);

    // 4. Output full results
    pw.println("{\n  \"results\": [");
    for (TestCombo combo : tests) {
        combo.emitResults(pw, "    ");
    }
    pw.println("  ],");
    pw.println("  \"servers\": [");
    for (ServerRunner server : serverRunners) {
        server.emitInfo(pw, "    ");
    }
    pw.println("  ],");
    pw.close();
}

From source file:com.norconex.collector.http.HttpCollector.java

/**
 * Invokes the HTTP Collector from the command line.  
 * @param args Invoke it once without any arguments to get a 
 *    list of command-line options.//from   w  ww  . j a  v a2 s . c  om
 */
public static void main(String[] args) {
    CommandLine cmd = parseCommandLineArguments(args);
    String action = cmd.getOptionValue(ARG_ACTION);
    File configFile = new File(cmd.getOptionValue(ARG_CONFIG));
    File varFile = null;
    if (cmd.hasOption(ARG_VARIABLES)) {
        varFile = new File(cmd.getOptionValue(ARG_VARIABLES));
    }

    try {
        HttpCollector conn = new HttpCollector(configFile, varFile);
        if (ARG_ACTION_START.equalsIgnoreCase(action)) {
            conn.crawl(false);
        } else if (ARG_ACTION_RESUME.equalsIgnoreCase(action)) {
            conn.crawl(true);
        } else if (ARG_ACTION_STOP.equalsIgnoreCase(action)) {
            conn.stop();
        }
    } catch (Exception e) {
        File errorFile = new File("./error-" + System.currentTimeMillis() + ".log");
        System.err.println("\n\nAn ERROR occured:\n\n" + e.getLocalizedMessage());
        System.err.println(
                "\n\nDetails of the error has been stored at: " + errorFile.getAbsolutePath() + "\n\n");
        try {
            PrintWriter w = new PrintWriter(errorFile);
            e.printStackTrace(w);
            w.flush();
            w.close();
        } catch (FileNotFoundException e1) {
            throw new HttpCollectorException("Cannot write error file.", e1);
        }
    }
}

From source file:gov.lanl.adore.djatoka.DjatokaCompress.java

/**
 * Uses apache commons cli to parse input args. Passes parsed
 * parameters to ICompress implementation.
 * @param args command line parameters to defined input,output,etc.
 *///from w w w .  j  a  v  a  2s.  c o m
public static void main(String[] args) {
    // create the command line parser
    CommandLineParser parser = new PosixParser();

    // create the Options
    Options options = new Options();
    options.addOption("i", "input", true, "Filepath of the input file or dir.");
    options.addOption("o", "output", true, "Filepath of the output file or dir.");
    options.addOption("r", "rate", true, "Absolute Compression Ratio");
    options.addOption("s", "slope", true,
            "Used to generate relative compression ratio based on content characteristics.");
    options.addOption("y", "Clayers", true, "Number of quality levels.");
    options.addOption("l", "Clevels", true, "Number of DWT levels (reolution levels).");
    options.addOption("v", "Creversible", true, "Use Reversible Wavelet");
    options.addOption("c", "Cprecincts", true, "Precinct dimensions");
    options.addOption("p", "props", true, "Compression Properties File");
    options.addOption("d", "Corder", true, "Progression order");
    options.addOption("g", "ORGgen_plt", true, "Enables insertion of packet length information in the header");
    options.addOption("t", "ORGtparts", true, "Division of each tile's packets into tile-parts");
    options.addOption("b", "Cblk", true, "Codeblock Size");
    options.addOption("a", "AltImpl", true, "Alternate ICompress Implemenation");

    try {
        if (args.length == 0) {
            HelpFormatter formatter = new HelpFormatter();
            formatter.printHelp("gov.lanl.adore.djatoka.DjatokaCompress", options);
            System.exit(0);
        }

        // parse the command line arguments
        CommandLine line = parser.parse(options, args);
        String input = line.getOptionValue("i");
        String output = line.getOptionValue("o");

        String propsFile = line.getOptionValue("p");
        DjatokaEncodeParam p;
        if (propsFile != null) {
            Properties props = IOUtils.loadConfigByPath(propsFile);
            p = new DjatokaEncodeParam(props);
        } else
            p = new DjatokaEncodeParam();
        String rate = line.getOptionValue("r");
        if (rate != null)
            p.setRate(rate);
        String slope = line.getOptionValue("s");
        if (slope != null)
            p.setSlope(slope);
        String Clayers = line.getOptionValue("y");
        if (Clayers != null)
            p.setLayers(Integer.parseInt(Clayers));
        String Clevels = line.getOptionValue("l");
        if (Clevels != null)
            p.setLevels(Integer.parseInt(Clevels));
        String Creversible = line.getOptionValue("v");
        if (Creversible != null)
            p.setUseReversible(Boolean.parseBoolean(Creversible));
        String Cprecincts = line.getOptionValue("c");
        if (Cprecincts != null)
            p.setPrecincts(Cprecincts);
        String Corder = line.getOptionValue("d");
        if (Corder != null)
            p.setProgressionOrder(Corder);
        String ORGgen_plt = line.getOptionValue("g");
        if (ORGgen_plt != null)
            p.setInsertPLT(Boolean.parseBoolean(ORGgen_plt));
        String Cblk = line.getOptionValue("b");
        if (Cblk != null)
            p.setCodeBlockSize(Cblk);
        String alt = line.getOptionValue("a");

        ICompress jp2 = new KduCompressExe();
        if (alt != null)
            jp2 = (ICompress) Class.forName(alt).newInstance();
        if (new File(input).isDirectory() && new File(output).isDirectory()) {
            ArrayList<File> files = IOUtils.getFileList(input, new SourceImageFileFilter(), false);
            for (File f : files) {
                long x = System.currentTimeMillis();
                File outFile = new File(output, f.getName().substring(0, f.getName().indexOf(".")) + ".jp2");
                compress(jp2, f.getAbsolutePath(), outFile.getAbsolutePath(), p);
                report(f.getAbsolutePath(), x);
            }
        } else {
            long x = System.currentTimeMillis();
            File f = new File(input);
            if (output == null)
                output = f.getName().substring(0, f.getName().indexOf(".")) + ".jp2";
            if (new File(output).isDirectory())
                output = output + f.getName().substring(0, f.getName().indexOf(".")) + ".jp2";
            compress(jp2, input, output, p);
            report(input, x);
        }
    } catch (ParseException e) {
        logger.error("Parse exception:" + e.getMessage(), e);
    } catch (DjatokaException e) {
        logger.error("djatoka Compression exception:" + e.getMessage(), e);
    } catch (InstantiationException e) {
        logger.error("Unable to initialize alternate implemenation:" + e.getMessage(), e);
    } catch (Exception e) {
        logger.error("An exception occured:" + e.getMessage(), e);
    }
}

From source file:edu.usc.leqa.Main.java

/**
 * The main method for LEQA.//from  w w  w .jav  a2s .  c om
 *
 * @param args the command line arguments
 * @throws IOException 
 */
public static void main(String[] args) throws IOException {
    long start, actual = 0, estimated = 0;

    //      args = "-f ../sample_inputs/fabric.xml-t ../sample_inputs/tech.xml -i ../sample_inputs/tfc/8bitadder.tfc".split("\\s");
    parseInputs(args);
    // -s 0.001 

    /*
     * Parsing inputs: fabric, tech & qasm files
     * LEQA uses parsers of QSPR
     */
    System.out.println("Parsing technology and fabric files...");
    start = System.currentTimeMillis();
    layout = LayoutParser.parse(techFileAddr, fabricFileAddr);

    /* Converting TFC to QASM if TFC is provided. */
    String inputExtension = inputFileAddr.substring(inputFileAddr.lastIndexOf('.') + 1);
    if (inputExtension.compareToIgnoreCase("TFC") == 0) {
        System.out.println("TFC file is provided. Converting to QASM...");
        String qasmFileAddr = inputFileAddr.substring(0, inputFileAddr.lastIndexOf('.')) + ".qasm";

        if (TFCParser.parse(inputFileAddr, qasmFileAddr) == false) {
            System.err.println("Failed to convert " + inputFileAddr + " to QASM format.");
            System.exit(-1);
        }

        inputFileAddr = qasmFileAddr;
    } else if (inputExtension.compareToIgnoreCase("QASM") != 0) {
        System.err
                .println("Extension " + inputExtension + " is not supported! Only qasm and tfc are supported.");
        System.exit(-1);
    }

    /* Parsing the QASM file */
    System.out.println("Parsing QASM file...");
    qasm = QASMParser.QASMParser(inputFileAddr, layout);

    if (qasm == null || layout == null)
        System.exit(-1);
    parseRuntime = (System.currentTimeMillis() - start) / 1000.0;

    /*
     * Invoking LEQA for estimating the latency
     */
    System.out.println("Invoking LEQA...");
    start = System.currentTimeMillis();
    estimated = LEQA.leqa(qasm, layout, speed);
    leqaRuntime = (System.currentTimeMillis() - start) / 1000.0;

    /*
     * Invoking HL-QSPR for calculating the actual latency 
     * This is for comparison only. It can be commented out
     */
    if (!RuntimeConfig.SKIP) {
        System.out.println("Invoking QSPR...");
        start = System.currentTimeMillis();
        actual = QSPR.center(eds, layout, qasm);
        QSPRRuntime = (System.currentTimeMillis() - start) / 1000.0;
    }

    /*
     * Printing the results
     */
    int separatorLength = 30;
    System.out.println();
    System.out.println(StringUtils.center("Results", separatorLength));
    System.out.println(StringUtils.repeat('-', separatorLength));

    System.out.println("Estimated value:\t" + estimated);
    if (!RuntimeConfig.SKIP) {
        System.out.println("Actual value:\t\t" + actual);
        System.out.printf("Error:\t\t\t%.2f%%" + lineSeparator,
                (Math.abs(estimated - actual) * 100.0 / actual));
    }
    System.out.println(StringUtils.repeat('-', separatorLength));

    System.out.println("Parsing overhead:\t" + parseRuntime + "s");
    System.out.println("LEQA runtime:\t\t" + leqaRuntime + "s");
    if (!RuntimeConfig.SKIP) {
        System.out.println("QSPR time:\t\t" + QSPRRuntime + "s");
        System.out.printf("Speed up:\t\t%.2f" + lineSeparator, QSPRRuntime / leqaRuntime);
    }
}

From source file:com.appeligo.epg.EpgIndexer.java

public static void main(String[] args) throws Exception {
    HessianProxyFactory factory = new HessianProxyFactory();
    EPGProvider epg = (EPGProvider) factory.create(EPGProvider.class, "http://localhost/epg/channel.epg");
    Calendar cal = Calendar.getInstance();
    cal.add(Calendar.HOUR, -5);/*from www  .  j av  a 2  s.  c  o  m*/
    cal.set(Calendar.DATE, 1);
    String[] lineups = new String[] { "SDTW-C", "P-C", "P-DC", "P-S", "M-C", "M-DC", "M-S", "E-C", "E-DC",
            "E-S", "H-C", "H-DC", "H-S" };
    List<String> ids = epg.getModifiedProgramIds(cal.getTime());
    int count = 0;
    long average = 0;
    int counter = 0;
    int added = 0;
    while (count < ids.size()) {
        System.err.println("in loop: " + counter + ", " + count + "," + ids.size());
        int subsetSize = (ids.size() < 100 ? ids.size() : 100);
        counter++;
        if (count % 1000 == 0) {
            log.debug("Index programs into the Lucene Index. Current have processed " + count
                    + " programs out of " + ids.size());
        }
        int endIndex = (count + subsetSize > ids.size() ? ids.size() : count + subsetSize);
        List<String> subset = ids.subList(count, endIndex);
        count += subsetSize;

        long time = System.currentTimeMillis();
        HashMap<String, List<ScheduledProgram>> schedules = new HashMap<String, List<ScheduledProgram>>();
        for (String lineup : lineups) {
            ScheduledProgram[] programs = epg.getNextShowingList(lineup, subset);
            for (ScheduledProgram program : programs) {
                if (program != null) {
                    List<ScheduledProgram> schedule = schedules.get(program.getProgramId());
                    if (schedule == null) {
                        schedule = new ArrayList<ScheduledProgram>();
                        schedules.put(program.getProgramId(), schedule);
                    }
                    schedule.add(program);
                    added++;
                }
            }
        }
        long after = System.currentTimeMillis();
        long diff = after - time;
        average += diff;
        System.err.println(diff + " - " + (average / counter) + " added: " + added);
    }
    //      EpgIndexer indexer = new EpgIndexer(programIndex, epg, lineup);
    //      Calendar cal = Calendar.getInstance();
    //      cal.set(Calendar.DAY_OF_MONTH, 24);
    //      cal.set(Calendar.HOUR_OF_DAY, 0);
    //      indexer.updateEpgIndex(cal.getTime());
}