List of usage examples for java.util Vector elementAt
public synchronized E elementAt(int index)
From source file:gov.nih.nci.evs.browser.utils.SourceTreeUtils.java
public static void main(String[] args) { String outputfile = args[0];/*from ww w . j av a2s.co m*/ LexBIGService lbSvc = RemoteServerUtil.createLexBIGService(); SourceTreeUtils test = new SourceTreeUtils(lbSvc); //test.getRootConceptsBySource(outputfile); String source_hierarchy = test.getSourceHierarchies(); Vector u = gov.nih.nci.evs.browser.utils.StringUtils.parseData(source_hierarchy); System.out.println("u.size: " + u.size()); for (int i = 0; i < u.size(); i++) { String t = (String) u.elementAt(i); int j = i + 1; System.out.println("(" + j + ") " + t); ResolvedConceptReference rcr = test.getRandomResolvedConceptReference(t); if (rcr != null) { System.out.println(rcr.getEntityDescription().getContent() + " (" + rcr.getCode() + ")"); } else { System.out.println("rcr == null"); } } }
From source file:SimpleRecorder.java
public static void main(String[] args) { ////////////////////////////////////////////////////// // Object to handle the processing and sinking of the // data captured from the device. ////////////////////////////////////////////////////// Location2Location capture; ///////////////////////////////////// // Audio and video capture devices. //////////////////////////////////// CaptureDeviceInfo audioDevice = null; CaptureDeviceInfo videoDevice = null; ///////////////////////////////////////////////////////////// // Capture device's "location" plus the name and location of // the destination. ///////////////////////////////////////////////////////////// MediaLocator captureLocation = null; MediaLocator destinationLocation;// w w w.j a va 2 s .c o m String destinationName = null; //////////////////////////////////////////////////////////// // Formats the Processor (in Location2Location) must match. //////////////////////////////////////////////////////////// Format[] formats = new Format[1]; /////////////////////////////////////////////// // Content type for an audio or video capture. ////////////////////////////////////////////// ContentDescriptor audioContainer = new ContentDescriptor(FileTypeDescriptor.WAVE); ContentDescriptor videoContainer = new ContentDescriptor(FileTypeDescriptor.MSVIDEO); ContentDescriptor container = null; //////////////////////////////////////////////////////////////////// // Duration of recording (in seconds) and period to wait afterwards /////////////////////////////////////////////////////////////////// double duration = 10; int waitFor = 0; ////////////////////////// // Audio or video capture? ////////////////////////// String selected = AUDIO; //////////////////////////////////////////////////////// // All devices that support the format in question. // A means of "ensuring" the program works on different // machines with different capture devices. //////////////////////////////////////////////////////// Vector devices; ////////////////////////////////////////////////////////// // Whether to search for capture devices that support the // format or use the devices whos names are already // known to the application. ////////////////////////////////////////////////////////// boolean useKnownDevices = false; ///////////////////////////////////////////////////////// // Process the command-line options as to audio or video, // duration, and file to save to. ///////////////////////////////////////////////////////// for (int i = 0; i < args.length; i++) { if (args[i].equals("-d")) { try { duration = (new Double(args[++i])).doubleValue(); } catch (NumberFormatException e) { } } else if (args[i].equals("-w")) { try { waitFor = Integer.parseInt(args[++i]); } catch (NumberFormatException e) { } } else if (args[i].equals("-a")) { selected = AUDIO; } else if (args[i].equals("-v")) { selected = VIDEO; } else if (args[i].equals("-b")) { selected = BOTH; } else if (args[i].equals("-f")) { destinationName = args[++i]; } else if (args[i].equals("-k")) { useKnownDevices = true; } else if (args[i].equals("-h")) { System.out.println( "Call as java SimpleRecorder [-a | -v | -b] [-d duration] [-f file] [-k] [-w wait]"); System.out.println("\t-a\tAudio\n\t-v\tVideo\n\t-b\tBoth audio and video (system dependent)"); System.out.println("\t-d\trecording Duration (seconds)"); System.out .println("\t-f\tFile to save to\n\t-k\tuse Known device names (don't search for devices)"); System.out.println("\t-w\tWait the specified time (seconds) before abandoning capture"); System.out.println( "Defaults: 10 seconds, audio, and captured.wav or captured.avi, 4x recording duration wait"); System.exit(0); } } ///////////////////////////////////////////////////////////////// // Perform setup for audio capture. Includes finding a suitable // device, obatining its MediaLocator and setting the content // type. //////////////////////////////////////////////////////////////// if (selected.equals(AUDIO)) { devices = CaptureDeviceManager.getDeviceList(AUDIO_FORMAT); if (devices.size() > 0 && !useKnownDevices) { audioDevice = (CaptureDeviceInfo) devices.elementAt(0); } else audioDevice = CaptureDeviceManager.getDevice(AUDIO_DEVICE_NAME); if (audioDevice == null) { System.out.println("Can't find suitable audio device. Exiting"); System.exit(1); } captureLocation = audioDevice.getLocator(); formats[0] = AUDIO_FORMAT; if (destinationName == null) destinationName = DEFAULT_AUDIO_NAME; container = audioContainer; } ///////////////////////////////////////////////////////////////// // Perform setup for video capture. Includes finding a suitable // device, obatining its MediaLocator and setting the content // type. //////////////////////////////////////////////////////////////// else if (selected.equals(VIDEO)) { devices = CaptureDeviceManager.getDeviceList(VIDEO_FORMAT); if (devices.size() > 0 && !useKnownDevices) videoDevice = (CaptureDeviceInfo) devices.elementAt(0); else videoDevice = CaptureDeviceManager.getDevice(VIDEO_DEVICE_NAME); if (videoDevice == null) { System.out.println("Can't find suitable video device. Exiting"); System.exit(1); } captureLocation = videoDevice.getLocator(); formats[0] = VIDEO_FORMAT; if (destinationName == null) destinationName = DEFAULT_VIDEO_NAME; container = videoContainer; } else if (selected.equals(BOTH)) { captureLocation = null; formats = new Format[2]; formats[0] = AUDIO_FORMAT; formats[1] = VIDEO_FORMAT; container = videoContainer; if (destinationName == null) destinationName = DEFAULT_VIDEO_NAME; } //////////////////////////////////////////////////////////////////// // Perform all the necessary Processor and DataSink preparation via // the Location2Location class. //////////////////////////////////////////////////////////////////// destinationLocation = new MediaLocator(destinationName); System.out.println("Configuring for capture. Please wait."); capture = new Location2Location(captureLocation, destinationLocation, formats, container, 1.0); ///////////////////////////////////////////////////////////////////////////// // Start the recording and tell the user. Specify the length of the // recording. Then wait around for up to 4-times the duration of // recording // (can take longer to sink/write the data so should wait a bit incase). ///////////////////////////////////////////////////////////////////////////// System.out.println("Started recording " + duration + " seconds of " + selected + " ..."); capture.setStopTime(new Time(duration)); if (waitFor == 0) waitFor = (int) (4000 * duration); else waitFor *= 1000; int waited = capture.transfer(waitFor); ///////////////////////////////////////////////////////// // Report on the success (or otherwise) of the recording. ///////////////////////////////////////////////////////// int state = capture.getState(); if (state == Location2Location.FINISHED) System.out.println(selected + " capture successful in approximately " + ((int) ((waited + 500) / 1000)) + " seconds. Data written to " + destinationName); else if (state == Location2Location.FAILED) System.out.println(selected + " capture failed after approximately " + ((int) ((waited + 500) / 1000)) + " seconds"); else { System.out.println(selected + " capture still ongoing after approximately " + ((int) ((waited + 500) / 1000)) + " seconds"); System.out.println("Process likely to have failed"); } System.exit(0); }
From source file:it.infn.ct.GridEngine.Job.JSagaJobSubmission.java
public static void main(String[] args) { //JSagaJobSubmission tmpJSaga1 = new JSagaJobSubmission("jdbc:mysql://localhost/userstracking","tracking_user","usertracking"); //tmpJSaga1.removeNotAllowedCharacter("Job-1"); //tmpJSaga1.removeNotAllowedCharacter("Stre:ss:: te%st job n. 1"); int num_job = 1; //String bdiiCometa = "ldap://infn-bdii-01.ct.pi2s2.it:2170"; String bdiiCometa = "ldap://gridit-bdii-01.cnaf.infn.it:2170"; //String bdiiCometa = "ldap://bdii.eela.ufrj.br:2170"; String wmsList[] = { "wms://wms-4.dir.garr.it:7443/glite_wms_wmproxy_server"//, //"wms://wms005.cnaf.infn.it:7443/glite_wms_wmproxy_server"//, // "wms://gridit-wms-01.cnaf.infn.it:7443/glite_wms_wmproxy_server", // "wms://egee-rb-09.cnaf.infn.it:7443/glite_wms_wmproxy_server"};//, // "wms://egee-wms-01.cnaf.infn.it:7443/glite_wms_wmproxy_server", // /*"wms://wms013.cnaf.infn.it:7443/glite_wms_wmproxy_server",*/ // "wms://egee-wms-01.cnaf.infn.it:7443/glite_wms_wmproxy_server" };/* ww w . j a va2s. com*/ String EUMEDwmsList[] = { "wms://wms.ulakbim.gov.tr:7443/glite_wms_wmproxy_server" }; String bdiiEumed = "ldap://bdii.eumedgrid.eu:2170"; String sshList[] = { "ssh://api.ct.infn.it" }; //String CEs[] = {"grisuce.scope.unina.it", "ce-02.roma3.infn.it", "gridce3.pi.infn.it"}; String CEs[] = { //"ce-02.roma3.infn.it:8443/cream-pbs-grid" //"grisuce.scope.unina.it:8443/cream-pbs-grisu_short", //"cccreamceli09.in2p3.fr:8443/cream-sge-long" "ce-01.roma3.infn.it:8443/cream-pbs-grid" }; // String OCCI_ENDPOINT_HOST = "rocci://carach5.ics.muni.cz"; // String OCCI_ENDPOINT_PORT = "11443"; // String OCCI_AUTH = "x509"; // Possible RESOURCE values: 'os_tpl', 'resource_tpl', 'compute' // String OCCI_RESOURCE = "compute"; //String OCCI_RESOURCE_ID = "https://carach5.ics.muni.cz:11443/compute/a0ad539e-ad17-4309-bc9c-4f9f91aecbaa"; // String OCCI_VM_TITLE = "MyDebianROCCITest"; // Possible OCCI_OS values: 'debianvm', 'octave', 'r' and 'generic_www' // String OCCI_OS = "debianvm"; // String OCCI_FLAVOUR = "small"; // Possible ACTION values: 'list', 'describe', 'create' and 'delete' // String OCCI_ACTION = "create"; // String OCCI_PUBLIC_KEY = "/home/diego/.ssh/id_rsa.pub"; // String OCCI_PRIVATE_KEY = "/home/diego/.ssh/id_rsa"; // // String rOCCIURL = OCCI_ENDPOINT_HOST + ":" + // OCCI_ENDPOINT_PORT + // System.getProperty("file.separator") + "?" + // "action=" + OCCI_ACTION + // "&resource=" + OCCI_RESOURCE + // "&attributes_title=" + OCCI_VM_TITLE + // "&mixin_os_tpl=" + OCCI_OS + // "&mixin_resource_tpl=" + OCCI_FLAVOUR + // "&auth=" + OCCI_AUTH + // "&publickey_file=" + OCCI_PUBLIC_KEY + // "&privatekey_file=" + OCCI_PRIVATE_KEY; // // String rOCCIResourcesList[] = {rOCCIURL}; //String wmsList[] = {"wms://infn-wms-01.ct.pi2s2.it:7443/glite_wms_wmproxy_server"//, // "unicore://zam052v01.zam.kfa-juelich.de:8080/?Target=EMI-UNICOREX" //}; //JSagaJobSubmission tmpJSaga = new JSagaJobSubmission(); //JSagaJobSubmission tmpJSaga = new JSagaJobSubmission("jdbc:mysql://10.70.1.99/userstracking","tracking_user","usertracking"); //String bdiiGilda = "ldap://egee-bdii.cnaf.infn.it:2170"; //tmpJSaga.setBDII(bdiiGilda); //tmpJSaga.useRobotProxy("101", "gilda", "gilda", true); // tmpJSga.setJobOutput("myOutput.txt"); // tmpJSaga.setJobError("myError.txt"); System.out.println("#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#"); // JobId[] newJobsId = new JobId[num_job]; // /*SUBMISSION SPECIFYING JOB DESCRIPTION for (int i = 0; i < num_job; i++) { GEJobDescription description = new GEJobDescription(); description.setExecutable("/bin/sh"); description.setArguments("hostname.sh"); description.setInputFiles("/home/mario/Documenti/hostname.sh"); description.setOutputFiles("output.README"); description.setOutputPath("/tmp"); description.setOutput("Output.txt"); description.setError("Error.txt"); // String jdlRequirements = "JDLRequirements=(Member(\"MPI-START\",other.GlueHostApplicationSoftwareRunTimeEnvironment));JDLRequirements=(Member(\"MPICH\", other.GlueHostApplicationSoftwareRunTimeEnvironment))"; // description.setJDLRequirements(jdlRequirements); JSagaJobSubmission tmpJSaga = new JSagaJobSubmission("jdbc:mysql://localhost/userstracking", "tracking_user", "usertracking", description); tmpJSaga.setUserEmail("mario.torrisi@ct.infn.it"); tmpJSaga.setSenderEmail("mario.torrisi@ct.infn.it"); // tmpJSaga.setWMSList(rOCCIResourcesList); // tmpJSaga.useRobotProxy("etokenserver.ct.infn.it", "8082", "332576f78a4fe70a52048043e90cd11f", "fedcloud.egi.eu", "fedcloud.egi.eu", true); // tmpJSaga.setWMSList(sshList); // tmpJSaga.setWMSList(wmsList); tmpJSaga.setWMSList(EUMEDwmsList); // tmpJSaga.setCEList(CEs); // tmpJSaga.setRandomCE(true); // tmpJSaga.setSSHCredential("liferayadmin", "liferayadmin"); // tmpJSaga.setSSHCredential("root", "Passw0rd!"); tmpJSaga.useRobotProxy("etokenserver2.ct.infn.it", "8082", "bc779e33367eaad7882b9dfaa83a432c", "eumed", "eumed", true, true, "test"); // tmpJSaga.submitJobAsync("mtorrisi", "193.206.208.183:8162", 1, "ssh://gilda-liferay-vm-06.ct.infn.it:5000", "SSH - Stress test job - "+i); // tmpJSaga.submitJobAsync("mtorrisi", "193.206.208.183:8162", 1, "ssh://api.ct.infn.it", "SSH - Stress test job - "+i); // tmpJSaga.submitJobAsync("mtorrisi", "193.206.208.183:8162", 1, "wms://wms-4.dir.garr.it:7443/glite_wms_wmproxy_server", "WMS - Stress test job - "+i); tmpJSaga.submitJobAsync("test", "193.206.208.183:8162", 1, "test job n. " + i); } // /*SUBMISSION WITHOUT SPECIFYING JOB DESCRIPTION for (int i=0;i<num_job;i++) { JSagaJobSubmission tmpJSaga = new JSagaJobSubmission("jdbc:mysql://localhost/userstracking","tracking_user","usertracking"); tmpJSaga.setUserEmail("diego.scardaci@ct.infn.it"); //tmpJSaga.setSSHCredential("root", "Passw0rd!"); tmpJSaga.setExecutable("/bin/sh"); tmpJSaga.setArguments("hostname.sh"); tmpJSaga.setInputFiles("/home/mario/Documenti/hostname.sh"); tmpJSaga.setOutputFiles("output.README"); tmpJSaga.setOutputPath("/tmp"); tmpJSaga.setJobOutput("myOutput.txt"); tmpJSaga.setJobError("myError.txt"); tmpJSaga.setWMSList(wmsList); tmpJSaga.useRobotProxy("etokenserver.ct.infn.it", "8082", "332576f78a4fe70a52048043e90cd11f", "gridit", "gridit", true); tmpJSaga.setJDLRequirements(new String[] {"JDLRequirements=(Member(\"MPI-START\",other.GlueHostApplicationSoftwareRunTimeEnvironment))","JDLRequirements=(Member(\"MPICH\", other.GlueHostApplicationSoftwareRunTimeEnvironment))" }); tmpJSaga.submitJobAsync("test", "193.206.208.183:8162", 1, "test job n. "+i); // tmpJSaga.submitJobAsync("mtorrisi", "193.206.208.183:8162", 1, "ssh://api.ct.infn.it", "SSH - Stress test job - "+i); } // */ // tmpJSaga.setRandomCE(true); // //tmpJSaga.setUserEmail("mario.torrisi@ct.infn.it"); // //tmpJSaga.setJobQueue("infn-ce-01.ct.pi2s2.it:8443/cream-lsf-short"); // //tmpJSaga.setBDII(bdiiCometa); // //tmpJSaga.setWMSList(wmsList); // //tmpJSaga.setCEList(CEs); // //String selectedCE=tmpJSaga.getRandomCEFromCElist(); // //tmpJSaga.setUserProxy("/tmp/proxy"); // // //tmpJSaga.useRobotProxy("etokenserver.ct.infn.it", "8082", "332576f78a4fe70a52048043e90cd11f", "gridit", "gridit", true); // //tmpJSaga.setJKS("/home/diego/UnicoreOutput/robot2012.jks", "robot2012"); // //tmpJSaga.setGenesisJKS("/home/diego/genesisII/genesis-keys.jks", "srt5mInfn"); // //tmpJSaga.useRobotProxy("myproxy.ct.infn.it", "8082", "22002", "gridit", "gridit", true); // //tmpJSaga.useRobotProxy("myproxy.ct.infn.it", "8082", "21873", "prod.vo.eu-eela.eu", "prod.vo.eu-eela.eu", true); // //tmpJSaga.setOurGridCredential("diego", "scardaci"); //// tmpJSaga.setSPMDVariation("OpenMPI"); //// tmpJSaga.setTotalCPUCount("4"); //// tmpJSaga.setNumberOfProcesses("4"); //// tmpJSaga.setExecutable("diego_mpi_xn03"); //// tmpJSaga.setInputFiles("/home/diego/mpitest/diego_mpi_xn03"); // //// // tmpJSaga.setExecutable("lsf.sh"); // tmpJSaga.setArguments("hostname.job"); // tmpJSaga.setOutputPath("/tmp"); // //// tmpJSaga.setExecutable("/bin/hostname"); //// tmpJSaga.setArguments("-f"); //// tmpJSaga.setOutputPath("/tmp"); //// tmpJSaga.setJobOutput("myOutput-" + i + ".txt"); //// tmpJSaga.setJobError("myError-" + i + ".txt"); // tmpJSaga.setJobOutput("output.txt"); // tmpJSaga.setJobError("error.txt"); // tmpJSaga.setInputFiles("/home/mario/Documenti/ls.sh,/home/mario/Documenti/hostname.sh,/home/mario/Documenti/pwd.sh"); // //tmpJSaga.setOutputFiles("output.txt,error.txt");//,/home/diego/Enea/output/job.output<job.output,/home/diego/Enea/output/job.error<job.error,/home/diego/Enea/output/pwd.out<pwd.out"); //// tmpJSaga.setCheckJobsStatus(false); // //// String jdlRequirements[] = new String[1]; //// jdlRequirements[0] = "JDLRequirements=(Member(\"Rank\", other.GlueCEStateFreeCPUs))"; //// tmpJSaga.setJDLRequirements(jdlRequirements); // // //tmpJSaga.submitJobAsync("scardaci", "193.206.208.183:8162", 1, "wms://egee-wms-01.cnaf.infn.it:7443/glite_wms_wmproxy_server", "Job-"+i); // //tmpJSaga.submitJobAsync("scardaci", "193.206.208.183:8162", 1, "wms://prod-wms-01.pd.infn.it:7443/glite_wms_wmproxy_server", "Job-"+i); // //tmpJSaga.submitJobAsync("scardaci", "193.206.208.183:8162", 1, "wms://infn-wms-01.ct.pi2s2.it:7443/glite_wms_wmproxy_server", "Job-"+i); // //tmpJSaga.submitJobAsync("scardaci", "193.206.208.183:8162", 1, "wms://wms013.cnaf.infn.it:7443/glite_wms_wmproxy_server", "Job-"+i); // //tmpJSaga.submitJobAsync("scardaci", "193.206.208.183:8162", 1, "wms://wms.eela.ufrj.br:7443/glite_wms_wmproxy_server", "Job-"+i); //// String descr = "paperino"; //// if ((i==1) || (i==3) || (i==4)) //// descr = "pippo"; //// tmpJSaga.submitJobAsync("scardaci", "193.206.208.183:8162", 1, "unicore://zam052v01.zam.kfa-juelich.de:8080/?Target=EMI-UNICOREX", "UNICORE - Stress test job n. "+i); // //tmpJSaga.submitJobAsync("scardaci", "193.206.208.183:8162", 1, "bes-genesis2://xcg-server1.uvacse.virginia.edu:20443/axis/services/GeniiBESPortType?genii-container-id=93B641B7-9422-EA4C-A90B-CA6A9D98E344", "GenesisII - Stress test job n. "+i); // // //tmpJSaga.submitJob("scardaci", "193.206.208.183:8162", 1, "gLite - Stress test job n. "+i); //// if ((i%3)==0) // //tmpJSaga.submitJobAsync("mtorrisi", "193.206.208.183:8162", 1, "gLite - Stress test job n. "+i); //// else if ((i%3)==1) //// tmpJSaga.submitJobAsync("scardaci", "193.206.208.183:8162", 1, "wsgram://xn03.ctsf.cdacb.in:8443/PBS", "GARUDA - Stress test job n. "+i); //// else if ((i%3)==2) //// tmpJSaga.submitJobAsync("scardaci", "193.206.208.183:8162", 1, "ourgrid://api.ourgrid.org", "OurGrid - Stress test job n. "+i); // // // tmpJSaga.submitJobAsync("mtorrisi", "193.206.208.183:8162", 1, "ssh://cresco1-f1.portici.enea.it", "SSH - Stress test job n. "+i); // tmpJSaga.submitJobAsync("mtorrisi", "193.206.208.183:8162", 1, "ssh://gilda-liferay-vm-06.ct.infn.it:5000", "SSH - Stress test job n. "+i, null, null); // //// try { //// Thread.sleep(180000); //// } //// catch (Exception e) {} // //newJobsId[i] = tmpJSaga.submitJob("ricceri", "193.206.208.183:8162", 1, "Job-"+i); // //newJobsId[i] = tmpJSaga.submitJob("scardaci", "193.206.208.183:8162", 1, "Job-"+i); // //newJobsId[i] = tmpJSaga.submitJob("scardaci", "193.206.208.183:8162", 1, "wms://gilda-wms-02.ct.infn.it:7443/glite_wms_wmproxy_server", "Job-"+i); // //newJobsId[i] = tmpJSaga.submitJob("scardaci", "193.206.208.183:8162", 1, "wms://infn-wms-01.ct.pi2s2.it:7443/glite_wms_wmproxy_server", "Job-"+i); // //System.out.println("#2#2#2#2#2#2#2#2#2#2#2#2#2#2#2#2#2#2#2#2#"); // //System.out.println(newJobsId[i].getGridJobId()); // //System.out.println(newJobsId[i].getDbId()); //// try { //// Thread.sleep(10000); //// } //// catch (Exception e) {} //// // } System.out.println("Vado in sleep..."); try { Thread.sleep(60000); } catch (Exception e) { } System.out.println("Checking jobs..."); UsersTrackingDBInterface DBInterface = new UsersTrackingDBInterface("jdbc:mysql://localhost/userstracking", "tracking_user", "usertracking"); DBInterface.setJobsUpdatingInterval(30); String status = "RUNNING"; Vector<ActiveInteractions> jobList = null; // Vector<String[]> cesListwithCoord = null; // if (!DBInterface.isUpdateJobsStatusAsyncRunning("ViralGrid", "scardaci")) { // System.out.println("1- Running checking thread..."); // DBInterface.updateJobsStatusAsync2("ViralGrid","scardaci","/tmp"); // } // // if (!DBInterface.isUpdateJobsStatusAsyncRunning("ViralGrid", "scardaci")) { // System.out.println("2- Running checking thread..."); // DBInterface.updateJobsStatusAsync2("ViralGrid","scardaci","/tmp"); // } while (status.equals("RUNNING")) { //DBInterface.updateJobsStatus("ViralGrid","scardaci"); try { Thread.sleep(15000); } catch (Exception e) { } status = "DONE"; jobList = DBInterface.getActiveInteractionsByName("test"); if (jobList != null) { for (int i = 0; i < jobList.size(); i++) { if (jobList.get(i).getSubJobs() == null) { System.out.println("DBID = " + jobList.elementAt(i).getInteractionInfos()[0] + " Portal = " + jobList.elementAt(i).getInteractionInfos()[1] + " - Application = " + jobList.elementAt(i).getInteractionInfos()[2] + " - Description = " + jobList.elementAt(i).getInteractionInfos()[3] + " - Timestamp = " + jobList.elementAt(i).getInteractionInfos()[4] + " - Status = " + jobList.elementAt(i).getInteractionInfos()[5]); } else { System.out.println( "***COLLECTION INFOS*** DBID = " + jobList.elementAt(i).getInteractionInfos()[0] + " Portal = " + jobList.elementAt(i).getInteractionInfos()[1] + " - Application = " + jobList.elementAt(i).getInteractionInfos()[2] + " - Description = " + jobList.elementAt(i).getInteractionInfos()[3] + " - Timestamp = " + jobList.elementAt(i).getInteractionInfos()[4] + " - Status = " + jobList.elementAt(i).getInteractionInfos()[5]); Vector<String[]> subJobs = jobList.get(i).getSubJobs(); for (String[] subJobInfos : subJobs) System.out.println("\t|_***SUBJOB INFOS*** DBID = " + subJobInfos[0] + " Portal = " + subJobInfos[1] + " - Application = " + subJobInfos[2] + " - Description = " + subJobInfos[3] + " - Timestamp = " + subJobInfos[4] + " - Status = " + subJobInfos[5]); } if (!jobList.elementAt(i).getInteractionInfos()[5].equals("DONE")) status = "RUNNING"; } } // cesListwithCoord = DBInterface.getCEsGeographicDistribution("ViralGrid","scardaci"); // // if (cesListwithCoord!=null) { // for (int i=0;i<cesListwithCoord.size();i++) { // System.out.println("CE = " + cesListwithCoord.elementAt(i)[0] + " Num Jobs = " + cesListwithCoord.elementAt(i)[1] + " - Lat = " + cesListwithCoord.elementAt(i)[2] + " - Long = " + cesListwithCoord.elementAt(i)[3]); // } // } // if (!DBInterface.isUpdateJobsStatusAsyncRunning("ViralGrid", "scardaci")) { // System.out.println("3- Running checking thread..."); // DBInterface.updateJobsStatusAsync2("ViralGrid","scardaci","/tmp"); // } if (status.equals("RUNNING")) { try { Thread.sleep(15000); } catch (Exception e) { } } } String allTarPath = DBInterface.createAllJobsArchive("mtorrisi", "/tmp"); System.out.println("allTarPath=" + allTarPath); // String allTarPathForDesc = DBInterface.createAllJobsFromDescriptionArchive("scardaci","pippo","/tmp"); // System.out.println("allTarPathForDesc="+allTarPathForDesc); // for (int i=0;i<num_job;i++) { // String outputFile = ""; // outputFile = tmpJSaga.getJobOutput(newJobsId[i].getDbId()); // System.out.println("outputFile="+outputFile); // } Vector<ActiveInteractions> jobList1 = null; jobList1 = DBInterface.getActiveInteractionsByName("mtorrisi"); // for (int i=0;i<jobList1.size();i++) { // JSagaJobSubmission tmpJSaga = new JSagaJobSubmission("jdbc:mysql://localhost/userstracking","tracking_user","usertracking"); // //tmpJSaga.useRobotProxy("21174", "cometa", "cometa", true); // tmpJSaga.setOutputPath("/tmp/"); // String outputFile = ""; // outputFile = tmpJSaga.getJobOutput(new Integer(jobList.elementAt(i)[0]).intValue()); // System.out.println("outputFile="+outputFile); // } if (jobList1.size() == 0) System.out.println("No jobs for user mtorrisi"); // for (int i=0;i<jobList1.size();i++) { // System.out.println("Portal = " + jobList1.elementAt(i)[1] + " - Application = " + jobList1.elementAt(i)[2] + " - Description = " + jobList1.elementAt(i)[3] + " - Timestamp = " + jobList1.elementAt(i)[4] + " - Status = " + jobList1.elementAt(i)[5] ); // } // if (!DBInterface.isUpdateJobsStatusAsyncRunning("ViralGrid", "scardaci")) { // System.out.println("4- Running checking thread..."); // DBInterface.updateJobsStatusAsync2("ViralGrid","scardaci","/tmp"); // } // Vector<String[]> jobList2 = null; // jobList2 = DBInterface.getDoneJobsListByName("scardaci"); // for (int i=0;i<jobList2.size();i++) { // System.out.println("DONE JOB - Portal = " + jobList2.elementAt(i)[1] + " - Application = " + jobList2.elementAt(i)[2] + " - Description = " + jobList2.elementAt(i)[3] + " - Timestamp = " + jobList2.elementAt(i)[4]); // } System.exit(0); }
From source file:InlineSchemaValidator.java
/** Main program entry point. */ public static void main(String[] argv) { // is there anything to do? if (argv.length == 0) { printUsage();//from w w w . j ava 2s . c o m System.exit(1); } // variables Vector schemas = null; Vector instances = null; HashMap prefixMappings = null; HashMap uriMappings = null; String docURI = argv[argv.length - 1]; String schemaLanguage = DEFAULT_SCHEMA_LANGUAGE; int repetition = DEFAULT_REPETITION; boolean schemaFullChecking = DEFAULT_SCHEMA_FULL_CHECKING; boolean honourAllSchemaLocations = DEFAULT_HONOUR_ALL_SCHEMA_LOCATIONS; boolean validateAnnotations = DEFAULT_VALIDATE_ANNOTATIONS; boolean generateSyntheticAnnotations = DEFAULT_GENERATE_SYNTHETIC_ANNOTATIONS; boolean memoryUsage = DEFAULT_MEMORY_USAGE; // process arguments for (int i = 0; i < argv.length - 1; ++i) { String arg = argv[i]; if (arg.startsWith("-")) { String option = arg.substring(1); if (option.equals("l")) { // get schema language name if (++i == argv.length) { System.err.println("error: Missing argument to -l option."); } else { schemaLanguage = argv[i]; } continue; } if (option.equals("x")) { if (++i == argv.length) { System.err.println("error: Missing argument to -x option."); continue; } String number = argv[i]; try { int value = Integer.parseInt(number); if (value < 1) { System.err.println("error: Repetition must be at least 1."); continue; } repetition = value; } catch (NumberFormatException e) { System.err.println("error: invalid number (" + number + ")."); } continue; } if (arg.equals("-a")) { // process -a: xpath expressions for schemas if (schemas == null) { schemas = new Vector(); } while (i + 1 < argv.length - 1 && !(arg = argv[i + 1]).startsWith("-")) { schemas.add(arg); ++i; } continue; } if (arg.equals("-i")) { // process -i: xpath expressions for instance documents if (instances == null) { instances = new Vector(); } while (i + 1 < argv.length - 1 && !(arg = argv[i + 1]).startsWith("-")) { instances.add(arg); ++i; } continue; } if (arg.equals("-nm")) { String prefix; String uri; while (i + 2 < argv.length - 1 && !(prefix = argv[i + 1]).startsWith("-") && !(uri = argv[i + 2]).startsWith("-")) { if (prefixMappings == null) { prefixMappings = new HashMap(); uriMappings = new HashMap(); } prefixMappings.put(prefix, uri); HashSet prefixes = (HashSet) uriMappings.get(uri); if (prefixes == null) { prefixes = new HashSet(); uriMappings.put(uri, prefixes); } prefixes.add(prefix); i += 2; } continue; } if (option.equalsIgnoreCase("f")) { schemaFullChecking = option.equals("f"); continue; } if (option.equalsIgnoreCase("hs")) { honourAllSchemaLocations = option.equals("hs"); continue; } if (option.equalsIgnoreCase("va")) { validateAnnotations = option.equals("va"); continue; } if (option.equalsIgnoreCase("ga")) { generateSyntheticAnnotations = option.equals("ga"); continue; } if (option.equalsIgnoreCase("m")) { memoryUsage = option.equals("m"); continue; } if (option.equals("h")) { printUsage(); continue; } System.err.println("error: unknown option (" + option + ")."); continue; } } try { // Create new instance of inline schema validator. InlineSchemaValidator inlineSchemaValidator = new InlineSchemaValidator(prefixMappings, uriMappings); // Parse document containing schemas and validation roots DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); DocumentBuilder db = dbf.newDocumentBuilder(); db.setErrorHandler(inlineSchemaValidator); Document doc = db.parse(docURI); // Create XPath factory for selecting schema and validation roots XPathFactory xpf = XPathFactory.newInstance(); XPath xpath = xpf.newXPath(); xpath.setNamespaceContext(inlineSchemaValidator); // Select schema roots from the DOM NodeList[] schemaNodes = new NodeList[schemas != null ? schemas.size() : 0]; for (int i = 0; i < schemaNodes.length; ++i) { XPathExpression xpathSchema = xpath.compile((String) schemas.elementAt(i)); schemaNodes[i] = (NodeList) xpathSchema.evaluate(doc, XPathConstants.NODESET); } // Select validation roots from the DOM NodeList[] instanceNodes = new NodeList[instances != null ? instances.size() : 0]; for (int i = 0; i < instanceNodes.length; ++i) { XPathExpression xpathInstance = xpath.compile((String) instances.elementAt(i)); instanceNodes[i] = (NodeList) xpathInstance.evaluate(doc, XPathConstants.NODESET); } // Create SchemaFactory and configure SchemaFactory factory = SchemaFactory.newInstance(schemaLanguage); factory.setErrorHandler(inlineSchemaValidator); try { factory.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, schemaFullChecking); } catch (SAXNotRecognizedException e) { System.err.println("warning: SchemaFactory does not recognize feature (" + SCHEMA_FULL_CHECKING_FEATURE_ID + ")"); } catch (SAXNotSupportedException e) { System.err.println("warning: SchemaFactory does not support feature (" + SCHEMA_FULL_CHECKING_FEATURE_ID + ")"); } try { factory.setFeature(HONOUR_ALL_SCHEMA_LOCATIONS_ID, honourAllSchemaLocations); } catch (SAXNotRecognizedException e) { System.err.println("warning: SchemaFactory does not recognize feature (" + HONOUR_ALL_SCHEMA_LOCATIONS_ID + ")"); } catch (SAXNotSupportedException e) { System.err.println( "warning: SchemaFactory does not support feature (" + HONOUR_ALL_SCHEMA_LOCATIONS_ID + ")"); } try { factory.setFeature(VALIDATE_ANNOTATIONS_ID, validateAnnotations); } catch (SAXNotRecognizedException e) { System.err.println( "warning: SchemaFactory does not recognize feature (" + VALIDATE_ANNOTATIONS_ID + ")"); } catch (SAXNotSupportedException e) { System.err.println( "warning: SchemaFactory does not support feature (" + VALIDATE_ANNOTATIONS_ID + ")"); } try { factory.setFeature(GENERATE_SYNTHETIC_ANNOTATIONS_ID, generateSyntheticAnnotations); } catch (SAXNotRecognizedException e) { System.err.println("warning: SchemaFactory does not recognize feature (" + GENERATE_SYNTHETIC_ANNOTATIONS_ID + ")"); } catch (SAXNotSupportedException e) { System.err.println("warning: SchemaFactory does not support feature (" + GENERATE_SYNTHETIC_ANNOTATIONS_ID + ")"); } // Build Schema from sources Schema schema; { DOMSource[] sources; int size = 0; for (int i = 0; i < schemaNodes.length; ++i) { size += schemaNodes[i].getLength(); } sources = new DOMSource[size]; if (size == 0) { schema = factory.newSchema(); } else { int count = 0; for (int i = 0; i < schemaNodes.length; ++i) { NodeList nodeList = schemaNodes[i]; int nodeListLength = nodeList.getLength(); for (int j = 0; j < nodeListLength; ++j) { sources[count++] = new DOMSource(nodeList.item(j)); } } schema = factory.newSchema(sources); } } // Setup validator and input source. Validator validator = schema.newValidator(); validator.setErrorHandler(inlineSchemaValidator); try { validator.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, schemaFullChecking); } catch (SAXNotRecognizedException e) { System.err.println( "warning: Validator does not recognize feature (" + SCHEMA_FULL_CHECKING_FEATURE_ID + ")"); } catch (SAXNotSupportedException e) { System.err.println( "warning: Validator does not support feature (" + SCHEMA_FULL_CHECKING_FEATURE_ID + ")"); } try { validator.setFeature(HONOUR_ALL_SCHEMA_LOCATIONS_ID, honourAllSchemaLocations); } catch (SAXNotRecognizedException e) { System.err.println( "warning: Validator does not recognize feature (" + HONOUR_ALL_SCHEMA_LOCATIONS_ID + ")"); } catch (SAXNotSupportedException e) { System.err.println( "warning: Validator does not support feature (" + HONOUR_ALL_SCHEMA_LOCATIONS_ID + ")"); } try { validator.setFeature(VALIDATE_ANNOTATIONS_ID, validateAnnotations); } catch (SAXNotRecognizedException e) { System.err .println("warning: Validator does not recognize feature (" + VALIDATE_ANNOTATIONS_ID + ")"); } catch (SAXNotSupportedException e) { System.err.println("warning: Validator does not support feature (" + VALIDATE_ANNOTATIONS_ID + ")"); } try { validator.setFeature(GENERATE_SYNTHETIC_ANNOTATIONS_ID, generateSyntheticAnnotations); } catch (SAXNotRecognizedException e) { System.err.println("warning: Validator does not recognize feature (" + GENERATE_SYNTHETIC_ANNOTATIONS_ID + ")"); } catch (SAXNotSupportedException e) { System.err.println( "warning: Validator does not support feature (" + GENERATE_SYNTHETIC_ANNOTATIONS_ID + ")"); } // Validate instance documents for (int i = 0; i < instanceNodes.length; ++i) { NodeList nodeList = instanceNodes[i]; int nodeListLength = nodeList.getLength(); for (int j = 0; j < nodeListLength; ++j) { DOMSource source = new DOMSource(nodeList.item(j)); source.setSystemId(docURI); inlineSchemaValidator.validate(validator, source, docURI, repetition, memoryUsage); } } } catch (SAXParseException e) { // ignore } catch (Exception e) { System.err.println("error: Parse error occurred - " + e.getMessage()); if (e instanceof SAXException) { Exception nested = ((SAXException) e).getException(); if (nested != null) { e = nested; } } e.printStackTrace(System.err); } }
From source file:TypeInfoWriter.java
/** Main program entry point. */ public static void main(String[] argv) { // is there anything to do? if (argv.length == 0) { printUsage();//from w ww.j a v a 2 s. c o m System.exit(1); } // variables XMLReader parser = null; Vector schemas = null; Vector instances = null; String schemaLanguage = DEFAULT_SCHEMA_LANGUAGE; boolean schemaFullChecking = DEFAULT_SCHEMA_FULL_CHECKING; boolean honourAllSchemaLocations = DEFAULT_HONOUR_ALL_SCHEMA_LOCATIONS; boolean validateAnnotations = DEFAULT_VALIDATE_ANNOTATIONS; boolean generateSyntheticAnnotations = DEFAULT_GENERATE_SYNTHETIC_ANNOTATIONS; // process arguments for (int i = 0; i < argv.length; ++i) { String arg = argv[i]; if (arg.startsWith("-")) { String option = arg.substring(1); if (option.equals("l")) { // get schema language name if (++i == argv.length) { System.err.println("error: Missing argument to -l option."); } else { schemaLanguage = argv[i]; } continue; } if (option.equals("p")) { // get parser name if (++i == argv.length) { System.err.println("error: Missing argument to -p option."); continue; } String parserName = argv[i]; // create parser try { parser = XMLReaderFactory.createXMLReader(parserName); } catch (Exception e) { try { Parser sax1Parser = ParserFactory.makeParser(parserName); parser = new ParserAdapter(sax1Parser); System.err.println("warning: Features and properties not supported on SAX1 parsers."); } catch (Exception ex) { parser = null; System.err.println("error: Unable to instantiate parser (" + parserName + ")"); e.printStackTrace(System.err); System.exit(1); } } continue; } if (arg.equals("-a")) { // process -a: schema documents if (schemas == null) { schemas = new Vector(); } while (i + 1 < argv.length && !(arg = argv[i + 1]).startsWith("-")) { schemas.add(arg); ++i; } continue; } if (arg.equals("-i")) { // process -i: instance documents if (instances == null) { instances = new Vector(); } while (i + 1 < argv.length && !(arg = argv[i + 1]).startsWith("-")) { instances.add(arg); ++i; } continue; } if (option.equalsIgnoreCase("f")) { schemaFullChecking = option.equals("f"); continue; } if (option.equalsIgnoreCase("hs")) { honourAllSchemaLocations = option.equals("hs"); continue; } if (option.equalsIgnoreCase("va")) { validateAnnotations = option.equals("va"); continue; } if (option.equalsIgnoreCase("ga")) { generateSyntheticAnnotations = option.equals("ga"); continue; } if (option.equals("h")) { printUsage(); continue; } System.err.println("error: unknown option (" + option + ")."); continue; } } // use default parser? if (parser == null) { // create parser try { parser = XMLReaderFactory.createXMLReader(DEFAULT_PARSER_NAME); } catch (Exception e) { System.err.println("error: Unable to instantiate parser (" + DEFAULT_PARSER_NAME + ")"); e.printStackTrace(System.err); System.exit(1); } } try { // Create writer TypeInfoWriter writer = new TypeInfoWriter(); writer.setOutput(System.out, "UTF8"); // Create SchemaFactory and configure SchemaFactory factory = SchemaFactory.newInstance(schemaLanguage); factory.setErrorHandler(writer); try { factory.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, schemaFullChecking); } catch (SAXNotRecognizedException e) { System.err.println("warning: SchemaFactory does not recognize feature (" + SCHEMA_FULL_CHECKING_FEATURE_ID + ")"); } catch (SAXNotSupportedException e) { System.err.println("warning: SchemaFactory does not support feature (" + SCHEMA_FULL_CHECKING_FEATURE_ID + ")"); } try { factory.setFeature(HONOUR_ALL_SCHEMA_LOCATIONS_ID, honourAllSchemaLocations); } catch (SAXNotRecognizedException e) { System.err.println("warning: SchemaFactory does not recognize feature (" + HONOUR_ALL_SCHEMA_LOCATIONS_ID + ")"); } catch (SAXNotSupportedException e) { System.err.println( "warning: SchemaFactory does not support feature (" + HONOUR_ALL_SCHEMA_LOCATIONS_ID + ")"); } try { factory.setFeature(VALIDATE_ANNOTATIONS_ID, validateAnnotations); } catch (SAXNotRecognizedException e) { System.err.println( "warning: SchemaFactory does not recognize feature (" + VALIDATE_ANNOTATIONS_ID + ")"); } catch (SAXNotSupportedException e) { System.err.println( "warning: SchemaFactory does not support feature (" + VALIDATE_ANNOTATIONS_ID + ")"); } try { factory.setFeature(GENERATE_SYNTHETIC_ANNOTATIONS_ID, generateSyntheticAnnotations); } catch (SAXNotRecognizedException e) { System.err.println("warning: SchemaFactory does not recognize feature (" + GENERATE_SYNTHETIC_ANNOTATIONS_ID + ")"); } catch (SAXNotSupportedException e) { System.err.println("warning: SchemaFactory does not support feature (" + GENERATE_SYNTHETIC_ANNOTATIONS_ID + ")"); } // Build Schema from sources Schema schema; if (schemas != null && schemas.size() > 0) { final int length = schemas.size(); StreamSource[] sources = new StreamSource[length]; for (int j = 0; j < length; ++j) { sources[j] = new StreamSource((String) schemas.elementAt(j)); } schema = factory.newSchema(sources); } else { schema = factory.newSchema(); } // Setup validator and parser ValidatorHandler validator = schema.newValidatorHandler(); parser.setContentHandler(validator); if (validator instanceof DTDHandler) { parser.setDTDHandler((DTDHandler) validator); } parser.setErrorHandler(writer); validator.setContentHandler(writer); validator.setErrorHandler(writer); writer.setTypeInfoProvider(validator.getTypeInfoProvider()); try { validator.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, schemaFullChecking); } catch (SAXNotRecognizedException e) { System.err.println( "warning: Validator does not recognize feature (" + SCHEMA_FULL_CHECKING_FEATURE_ID + ")"); } catch (SAXNotSupportedException e) { System.err.println( "warning: Validator does not support feature (" + SCHEMA_FULL_CHECKING_FEATURE_ID + ")"); } try { validator.setFeature(HONOUR_ALL_SCHEMA_LOCATIONS_ID, honourAllSchemaLocations); } catch (SAXNotRecognizedException e) { System.err.println( "warning: Validator does not recognize feature (" + HONOUR_ALL_SCHEMA_LOCATIONS_ID + ")"); } catch (SAXNotSupportedException e) { System.err.println( "warning: Validator does not support feature (" + HONOUR_ALL_SCHEMA_LOCATIONS_ID + ")"); } try { validator.setFeature(VALIDATE_ANNOTATIONS_ID, validateAnnotations); } catch (SAXNotRecognizedException e) { System.err .println("warning: Validator does not recognize feature (" + VALIDATE_ANNOTATIONS_ID + ")"); } catch (SAXNotSupportedException e) { System.err.println("warning: Validator does not support feature (" + VALIDATE_ANNOTATIONS_ID + ")"); } try { validator.setFeature(GENERATE_SYNTHETIC_ANNOTATIONS_ID, generateSyntheticAnnotations); } catch (SAXNotRecognizedException e) { System.err.println("warning: Validator does not recognize feature (" + GENERATE_SYNTHETIC_ANNOTATIONS_ID + ")"); } catch (SAXNotSupportedException e) { System.err.println( "warning: Validator does not support feature (" + GENERATE_SYNTHETIC_ANNOTATIONS_ID + ")"); } // Validate instance documents and print type information if (instances != null && instances.size() > 0) { final int length = instances.size(); for (int j = 0; j < length; ++j) { parser.parse((String) instances.elementAt(j)); } } } catch (SAXParseException e) { // ignore } catch (Exception e) { System.err.println("error: Parse error occurred - " + e.getMessage()); if (e instanceof SAXException) { Exception nested = ((SAXException) e).getException(); if (nested != null) { e = nested; } } e.printStackTrace(System.err); } }
From source file:Main.java
public static void swap(Vector v, int i, int j) { Object o = v.elementAt(i); v.setElementAt(v.elementAt(j), i);/*from www .j a v a2 s.c o m*/ v.setElementAt(o, j); }
From source file:Main.java
public static <K1, K2, V> Map<K2, V> mapGetOrCreateVector(Vector<Map<K2, V>> vectorOfMaps, int index) { Map<K2, V> m = vectorOfMaps.elementAt(index); if (null == m) { m = newMap();/* w ww .ja v a 2 s . c o m*/ vectorOfMaps.add(index, m); } return m; }
From source file:Main.java
/** * Add all elements to the given vector. * @param vec//from www . j a va 2s . c o m * @param elems */ public static void addAll(final Vector vec, final Vector elems) { for (int i = 0; i < elems.size(); i++) { vec.addElement(elems.elementAt(i)); } }
From source file:Main.java
public static Hashtable contarElementos(Vector list) { Hashtable hash = new Hashtable(); for (int i = 0; i < list.size(); i++) { Object key = list.elementAt(i); if (hash.containsKey(key)) { Integer qtde = new Integer(((Integer) hash.get(key)).intValue() + 1); hash.put(key, qtde);/*from ww w .j a v a 2s. co m*/ } else { hash.put(key, new Integer(1)); } } return hash; }
From source file:Main.java
public static <K> K getElementAt(Vector<K> vec, int index) { if (vec.size() <= index) { vec.setSize(index + 10);//w w w. ja v a 2 s .co m return null; } return vec.elementAt(index); }