List of usage examples for java.util Vector get
public synchronized E get(int index)
From source file:CreateNewType.java
public static void main(String[] args) { String url = "jdbc:mySubprotocol:myDataSource"; Connection con;// www. j a v a2 s . c o m Statement stmt; try { Class.forName("myDriver.ClassName"); } catch (java.lang.ClassNotFoundException e) { System.err.print("ClassNotFoundException: "); System.err.println(e.getMessage()); } try { con = DriverManager.getConnection(url, "myLogin", "myPassword"); stmt = con.createStatement(); String typeToCreate = null; String prompt = "Enter 's' to create a structured type " + "or 'd' to create a distinct type\n" + "and hit Return: "; do { typeToCreate = getInput(prompt) + " "; typeToCreate = typeToCreate.toLowerCase().substring(0, 1); } while (!(typeToCreate.equals("s") || typeToCreate.equals("d"))); Vector dataTypes = getDataTypes(con, typeToCreate); String typeName; String attributeName; String sqlType; prompt = "Enter the new type name and hit Return: "; typeName = getInput(prompt); String createTypeString = "create type " + typeName; if (typeToCreate.equals("d")) createTypeString += " as "; else createTypeString += " ("; String commaAndSpace = ", "; boolean firstTime = true; while (true) { System.out.println(""); prompt = "Enter an attribute name " + "(or nothing when finished) \nand hit Return: "; attributeName = getInput(prompt); if (firstTime) { if (attributeName.length() == 0) { System.out.print("Need at least one attribute;"); System.out.println(" please try again"); continue; } else { createTypeString += attributeName + " "; firstTime = false; } } else if (attributeName.length() == 0) { break; } else { createTypeString += commaAndSpace + attributeName + " "; } String localTypeName = null; String paramString = ""; while (true) { System.out.println(""); System.out.println("LIST OF TYPES YOU MAY USE: "); boolean firstPrinted = true; int length = 0; for (int i = 0; i < dataTypes.size(); i++) { DataType dataType = (DataType) dataTypes.get(i); if (!dataType.needsToBeSet()) { if (!firstPrinted) System.out.print(commaAndSpace); else firstPrinted = false; System.out.print(dataType.getSQLType()); length += dataType.getSQLType().length(); if (length > 50) { System.out.println(""); length = 0; firstPrinted = true; } } } System.out.println(""); int index; prompt = "Enter an attribute type " + "from the list and hit Return: "; sqlType = getInput(prompt); for (index = 0; index < dataTypes.size(); index++) { DataType dataType = (DataType) dataTypes.get(index); if (dataType.getSQLType().equalsIgnoreCase(sqlType) && !dataType.needsToBeSet()) { break; } } localTypeName = null; paramString = ""; if (index < dataTypes.size()) { // there was a match String params; DataType dataType = (DataType) dataTypes.get(index); params = dataType.getParams(); localTypeName = dataType.getLocalType(); if (params != null) { prompt = "Enter " + params + ": "; paramString = "(" + getInput(prompt) + ")"; } break; } else { // use the name as given prompt = "Are you sure? " + "Enter 'y' or 'n' and hit Return: "; String check = getInput(prompt) + " "; check = check.toLowerCase().substring(0, 1); if (check.equals("n")) continue; else { localTypeName = sqlType; break; } } } createTypeString += localTypeName + paramString; if (typeToCreate.equals("d")) break; } if (typeToCreate.equals("s")) createTypeString += ")"; System.out.println(""); System.out.print("Your CREATE TYPE statement as "); System.out.println("sent to your DBMS: "); System.out.println(createTypeString); System.out.println(""); stmt.executeUpdate(createTypeString); stmt.close(); con.close(); } catch (SQLException ex) { System.err.println("SQLException: " + ex.getMessage()); } }
From source file:net.java.sen.tools.MkSenDic.java
/** * Build sen dictionary.//from w w w . j a v a2s. com * * @param args * custom dictionary files. see dic/build.xml. */ public static void main(String args[]) { ResourceBundle rb = ResourceBundle.getBundle("dictionary"); DictionaryMaker dm1 = new DictionaryMaker(); DictionaryMaker dm2 = new DictionaryMaker(); DictionaryMaker dm3 = new DictionaryMaker(); // 1st field information of connect file. Vector rule1 = new Vector(); // 2nd field information of connect file. Vector rule2 = new Vector(); // 3rd field information of connect file. Vector rule3 = new Vector(); // 4th field information of connect file. // this field shows cost of morpheme connection // [size3*(x3*size2+x2)+x1] // [size3*(Attr1*size2+Attr2)+Attl] short score[] = new short[20131]; long start = System.currentTimeMillis(); // ///////////////////////////////////////// // // Step1. Loading connetion file. // log.info("(1/7): reading connection matrix ... "); try { log.info("connection file = " + rb.getString("text_connection_file")); log.info("charset = " + rb.getString("dic.charset")); CSVParser csvparser = new CSVParser(new FileInputStream(rb.getString("text_connection_file")), rb.getString("dic.charset")); String t[]; int line = 0; while ((t = csvparser.nextTokens()) != null) { if (t.length < 4) { log.warn("invalid line in " + rb.getString("text_connection_file") + ":" + line); log.warn(rb.getString("text_connection_file") + "may be broken."); break; } dm1.add(t[0]); rule1.add(t[0]); dm2.add(t[1]); rule2.add(t[1]); dm3.add(t[2]); rule3.add(t[2]); if (line == score.length) { score = resize(score); } score[line++] = (short) Integer.parseInt(t[3]); } // ///////////////////////////////////////// // // Step2. Building internal dictionary // log.info("(2/7): building type dictionary ... "); dm1.build(); dm2.build(); dm3.build(); // if you want check specified morpheme, you uncomment and modify // following line: /* * System.out.print("22="); dm3.getById(22); * System.out.print("368="); dm3.getById(368); * * System.out.println(dm3.getDicId("?????*,*,*,*,?")); * DictionaryMaker.debug = true; * System.out.println(dm3.getDicId("?????*,*,*,*,?")); * System.out.println(dm3.getDicIdNoCache("?????*,*,*,*,?")); */ } catch (IOException e) { e.printStackTrace(); System.exit(0); } // ------------------------------------------------- int size1 = dm1.size(); int size2 = dm2.size(); int size3 = dm3.size(); int ruleSize = rule1.size(); short matrix[] = new short[size1 * size2 * size3]; short default_cost = (short) Integer.parseInt(rb.getString("default_connection_cost")); // ///////////////////////////////////////// // // Step3. Writing Connection Matrix // log.info("(3/7): writing conection matrix (" + size1 + " x " + size2 + " x " + size3 + " = " + size1 * size2 * size3 + ") ..."); for (int i = 0; i < (int) (size1 * size2 * size3); i++) matrix[i] = default_cost; for (int i = 0; i < ruleSize; i++) { Vector r1 = dm1.getRuleIdList((String) rule1.get(i)); Vector r2 = dm2.getRuleIdList((String) rule2.get(i)); Vector r3 = dm3.getRuleIdList((String) rule3.get(i)); for (Iterator i1 = r1.iterator(); i1.hasNext();) { int ii1 = ((Integer) i1.next()).intValue(); for (Iterator i2 = r2.iterator(); i2.hasNext();) { int ii2 = ((Integer) i2.next()).intValue(); for (Iterator i3 = r3.iterator(); i3.hasNext();) { int ii3 = ((Integer) i3.next()).intValue(); int pos = size3 * (size2 * ii1 + ii2) + ii3; matrix[pos] = score[i]; } } } } try { DataOutputStream out = new DataOutputStream( new BufferedOutputStream(new FileOutputStream(rb.getString("matrix_file")))); out.writeShort(size1); out.writeShort(size2); out.writeShort(size3); for (int i1 = 0; i1 < size1; i1++) for (int i2 = 0; i2 < size2; i2++) for (int i3 = 0; i3 < size3; i3++) { out.writeShort(matrix[size3 * (size2 * i1 + i2) + i3]); // if (matrix[size3 * (size2 * i1 + i2) + i3] != // default_cost) { // } } out.close(); } catch (IOException e) { e.printStackTrace(); System.exit(0); } matrix = null; score = null; // ------------------------------------------------- int pos_start = Integer.parseInt(rb.getString("pos_start")); int pos_size = Integer.parseInt(rb.getString("pos_size")); int di = 0; int offset = 0; ArrayList dicList = new ArrayList(); // ///////////////////////////////////////// // // Step4. Reading Morpheme Information // log.info("(4/7): reading morpheme information ... "); String t = null; String[] csv = null; try { // writer for feature file. BufferedWriter bw = new BufferedWriter(new OutputStreamWriter( new FileOutputStream(rb.getString("pos_file")), rb.getString("sen.charset"))); log.info("load dic: " + rb.getString("text_dic_file")); BufferedReader dicStream = null; int custom_dic = -1; if (args.length == 0) { dicStream = new BufferedReader(new InputStreamReader( new FileInputStream(rb.getString("text_dic_file")), rb.getString("dic.charset"))); } else { custom_dic = 0; dicStream = new BufferedReader( new InputStreamReader(new FileInputStream(args[custom_dic]), rb.getString("dic.charset"))); } int line = 0; CSVData key_b = new CSVData(); CSVData pos_b = new CSVData(); while (true) { t = dicStream.readLine(); if (t == null) { dicStream.close(); custom_dic++; if (args.length == custom_dic) { break; } else { // read custum dictionary log.info("load dic: " + "args[custum_dic]"); dicStream = new BufferedReader(new InputStreamReader(new FileInputStream(args[custom_dic]), rb.getString("dic.charset"))); } continue; } CSVParser parser = new CSVParser(t); csv = parser.nextTokens(); if (csv.length < (pos_size + pos_start)) { throw new RuntimeException("format error:" + t); } key_b.clear(); pos_b.clear(); for (int i = pos_start; i < (pos_start + pos_size - 1); i++) { key_b.append(csv[i]); pos_b.append(csv[i]); } key_b.append(csv[pos_start + pos_size - 1]); pos_b.append(csv[pos_start + pos_size - 1]); for (int i = pos_start + pos_size; i < (csv.length - 1); i++) { pos_b.append(csv[i]); } pos_b.append(csv[csv.length - 1]); CToken token = new CToken(); token.rcAttr2 = (short) dm1.getDicId(key_b.toString()); token.rcAttr1 = (short) dm2.getDicId(key_b.toString()); token.lcAttr = (short) dm3.getDicId(key_b.toString()); token.posid = 0; token.posID = offset; token.length = (short) csv[0].length(); token.cost = (short) Integer.parseInt(csv[1]); dicList.add(new PairObject(csv[0], token)); byte b[] = pos_b.toString().getBytes(rb.getString("sen.charset")); offset += (b.length + 1); String pos_b_str = pos_b.toString(); bw.write(pos_b_str, 0, pos_b_str.length()); // bw.write(b, 0, b.length); bw.write(0); if (++di % 50000 == 0) log.info("" + di + "... "); } bw.close(); // ----end of writing feature.cha ---- } catch (Exception e) { log.error("Error: " + t); e.printStackTrace(); System.exit(1); } rule1 = null; rule2 = null; rule3 = null; // ///////////////////////////////////////// // // Step5. Sort lexs and write to file // log.info("(5/7): sorting lex... "); int value[] = new int[dicList.size()]; char key[][] = new char[dicList.size()][]; int spos = 0; int dsize = 0; int bsize = 0; String prev = ""; Collections.sort(dicList); // ///////////////////////////////////////// // // Step6. Writing Token Information // log.info("(6/7): writing token... "); try { // writer for token file. DataOutputStream out = new DataOutputStream( new BufferedOutputStream(new FileOutputStream(rb.getString("token_file")))); // writing 'bos' and 'eos' and 'unknown' token. CToken token = new CToken(); token.rcAttr2 = (short) dm1.getDicId(rb.getString("bos_pos")); token.rcAttr1 = (short) dm2.getDicId(rb.getString("bos_pos")); token.lcAttr = (short) dm3.getDicId(rb.getString("bos_pos")); token.write(out); token.rcAttr2 = (short) dm1.getDicId(rb.getString("eos_pos")); token.rcAttr1 = (short) dm2.getDicId(rb.getString("eos_pos")); token.lcAttr = (short) dm3.getDicId(rb.getString("eos_pos")); token.write(out); token.rcAttr2 = (short) dm1.getDicId(rb.getString("unknown_pos")); token.rcAttr1 = (short) dm2.getDicId(rb.getString("unknown_pos")); token.lcAttr = (short) dm3.getDicId(rb.getString("unknown_pos")); token.posID = -1; token.write(out); log.info("key size = " + key.length); for (int i = 0; i < key.length; i++) { String k = (String) ((PairObject) dicList.get(i)).key; if (!prev.equals(k) && i != 0) { key[dsize] = ((String) ((PairObject) dicList.get(spos)).key).toCharArray(); value[dsize] = bsize + (spos << 8); dsize++; bsize = 1; spos = i; } else { bsize++; } prev = (String) ((PairObject) dicList.get(i)).key; ((CToken) (((PairObject) dicList.get(i)).value)).write(out); } out.flush(); out.close(); } catch (Exception e) { e.printStackTrace(); System.exit(1); } key[dsize] = ((String) ((PairObject) dicList.get(spos)).key).toCharArray(); value[dsize] = bsize + (spos << 8); dsize++; dm1 = null; dm2 = null; dm3 = null; dicList = null; // ///////////////////////////////////////// // // Step7. Build Double Array // log.info("(7/7): building Double-Array (size = " + dsize + ") ..."); DoubleArrayTrie da = new DoubleArrayTrie(); da.build(key, null, value, dsize); try { da.save(rb.getString("double_array_file")); } catch (Exception e) { e.printStackTrace(); } log.info("total time = " + (System.currentTimeMillis() - start) / 1000 + "[ms]"); }
From source file:edu.umn.cs.spatialHadoop.operations.RangeQuery.java
public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException { final OperationsParams params = new OperationsParams(new GenericOptionsParser(args)); final Path[] paths = params.getPaths(); if (paths.length <= 1 && !params.checkInput()) { printUsage();//from w w w.ja va2s. co m System.exit(1); } if (paths.length >= 2 && !params.checkInputOutput()) { printUsage(); System.exit(1); } if (params.get("rect") == null) { System.err.println("You must provide a query range"); printUsage(); System.exit(1); } final Path inPath = params.getInputPath(); final Path outPath = params.getOutputPath(); final Rectangle[] queryRanges = params.getShapes("rect", new Rectangle()); // All running jobs final Vector<Long> resultsCounts = new Vector<Long>(); Vector<Job> jobs = new Vector<Job>(); Vector<Thread> threads = new Vector<Thread>(); long t1 = System.currentTimeMillis(); for (int i = 0; i < queryRanges.length; i++) { final OperationsParams queryParams = new OperationsParams(params); OperationsParams.setShape(queryParams, "rect", queryRanges[i]); if (OperationsParams.isLocal(new JobConf(queryParams), inPath)) { // Run in local mode final Rectangle queryRange = queryRanges[i]; final Shape shape = queryParams.getShape("shape"); final Path output = outPath == null ? null : (queryRanges.length == 1 ? outPath : new Path(outPath, String.format("%05d", i))); Thread thread = new Thread() { @Override public void run() { FSDataOutputStream outFile = null; final byte[] newLine = System.getProperty("line.separator", "\n").getBytes(); try { ResultCollector<Shape> collector = null; if (output != null) { FileSystem outFS = output.getFileSystem(queryParams); final FSDataOutputStream foutFile = outFile = outFS.create(output); collector = new ResultCollector<Shape>() { final Text tempText = new Text2(); @Override public synchronized void collect(Shape r) { try { tempText.clear(); r.toText(tempText); foutFile.write(tempText.getBytes(), 0, tempText.getLength()); foutFile.write(newLine); } catch (IOException e) { e.printStackTrace(); } } }; } else { outFile = null; } long resultCount = rangeQueryLocal(inPath, queryRange, shape, queryParams, collector); resultsCounts.add(resultCount); } catch (IOException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } finally { try { if (outFile != null) outFile.close(); } catch (IOException e) { e.printStackTrace(); } } } }; thread.start(); threads.add(thread); } else { // Run in MapReduce mode queryParams.setBoolean("background", true); Job job = rangeQueryMapReduce(inPath, outPath, queryParams); jobs.add(job); } } while (!jobs.isEmpty()) { Job firstJob = jobs.firstElement(); firstJob.waitForCompletion(false); if (!firstJob.isSuccessful()) { System.err.println("Error running job " + firstJob); System.err.println("Killing all remaining jobs"); for (int j = 1; j < jobs.size(); j++) jobs.get(j).killJob(); System.exit(1); } Counters counters = firstJob.getCounters(); Counter outputRecordCounter = counters.findCounter(Task.Counter.MAP_OUTPUT_RECORDS); resultsCounts.add(outputRecordCounter.getValue()); jobs.remove(0); } while (!threads.isEmpty()) { try { Thread thread = threads.firstElement(); thread.join(); threads.remove(0); } catch (InterruptedException e) { e.printStackTrace(); } } long t2 = System.currentTimeMillis(); System.out.println("Time for " + queryRanges.length + " jobs is " + (t2 - t1) + " millis"); System.out.println("Results counts: " + resultsCounts); }
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" };// w w w. j a v a 2 s . c o m 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:edu.umn.cs.sthadoop.trajectory.TrajectoryOverlap.java
public static void main(String[] args) throws Exception { // args = new String[8]; // args[0] = "/export/scratch/mntgData/geolifeGPS/geolife_Trajectories_1.3/HDFS/index_geolife"; // args[1] = "/export/scratch/mntgData/geolifeGPS/geolife_Trajectories_1.3/HDFS/knn-dis-result"; // args[2] = "shape:edu.umn.cs.sthadoop.trajectory.GeolifeTrajectory"; // args[3] = "interval:2008-05-01,2008-05-30"; // args[4] = "time:month"; // args[5] = "traj:39.9119983,116.606835;39.9119783,116.6065483;39.9119599,116.6062649;39.9119416,116.6059899;39.9119233,116.6057282;39.9118999,116.6054783;39.9118849,116.6052366;39.9118666,116.6050099;39.91185,116.604775;39.9118299,116.604525;39.9118049,116.6042649;39.91177,116.6040166;39.9117516,116.6037583;39.9117349,116.6035066;39.9117199,116.6032666;39.9117083,116.6030232;39.9117,116.6027566;39.91128,116.5969383;39.9112583,116.5966766;39.9112383,116.5964232;39.9112149,116.5961699;39.9111933,116.5959249;39.9111716,116.5956883"; // args[6] = "-overwrite"; // args[7] = "-local";//"-no-local"; final OperationsParams params = new OperationsParams(new GenericOptionsParser(args)); final Path[] paths = params.getPaths(); if (paths.length <= 1 && !params.checkInput()) { printUsage();//from w w w .j a va 2 s. co m System.exit(1); } if (paths.length >= 2 && !params.checkInputOutput()) { printUsage(); System.exit(1); } if (params.get("traj") == null) { System.err.println("Trajectory query is missing"); printUsage(); System.exit(1); } // Invoke method to compute the trajectory MBR. String rectangle = getTrajectoryRectangle(params.get("traj")); params.set("rect", rectangle); if (params.get("rect") == null) { System.err.println("You must provide a Trajectory Query"); printUsage(); System.exit(1); } if (params.get("interval") == null) { System.err.println("Temporal range missing"); printUsage(); System.exit(1); } TextSerializable inObj = params.getShape("shape"); if (!(inObj instanceof STPoint)) { LOG.error("Shape is not instance of STPoint"); printUsage(); System.exit(1); } // Get spatio-temporal slices. List<Path> STPaths = getIndexedSlices(params); final Path outPath = params.getOutputPath(); final Rectangle[] queryRanges = params.getShapes("rect", new Rectangle()); // All running jobs final Vector<Long> resultsCounts = new Vector<Long>(); Vector<Job> jobs = new Vector<Job>(); Vector<Thread> threads = new Vector<Thread>(); long t1 = System.currentTimeMillis(); for (Path stPath : STPaths) { final Path inPath = stPath; for (int i = 0; i < queryRanges.length; i++) { final OperationsParams queryParams = new OperationsParams(params); OperationsParams.setShape(queryParams, "rect", queryRanges[i]); if (OperationsParams.isLocal(new JobConf(queryParams), inPath)) { // Run in local mode final Rectangle queryRange = queryRanges[i]; final Shape shape = queryParams.getShape("shape"); final Path output = outPath == null ? null : (queryRanges.length == 1 ? outPath : new Path(outPath, String.format("%05d", i))); Thread thread = new Thread() { @Override public void run() { FSDataOutputStream outFile = null; final byte[] newLine = System.getProperty("line.separator", "\n").getBytes(); try { ResultCollector<Shape> collector = null; if (output != null) { FileSystem outFS = output.getFileSystem(queryParams); final FSDataOutputStream foutFile = outFile = outFS.create(output); collector = new ResultCollector<Shape>() { final Text tempText = new Text2(); @Override public synchronized void collect(Shape r) { try { tempText.clear(); r.toText(tempText); foutFile.write(tempText.getBytes(), 0, tempText.getLength()); foutFile.write(newLine); } catch (IOException e) { e.printStackTrace(); } } }; } else { outFile = null; } long resultCount = rangeQueryLocal(inPath, queryRange, shape, queryParams, collector); resultsCounts.add(resultCount); } catch (IOException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } finally { try { if (outFile != null) outFile.close(); } catch (IOException e) { e.printStackTrace(); } } } }; thread.start(); threads.add(thread); } else { // Run in MapReduce mode Path outTempPath = outPath == null ? null : new Path(outPath, String.format("%05d", i) + "-" + inPath.getName()); queryParams.setBoolean("background", true); Job job = rangeQueryMapReduce(inPath, outTempPath, queryParams); jobs.add(job); } } } while (!jobs.isEmpty()) { Job firstJob = jobs.firstElement(); firstJob.waitForCompletion(false); if (!firstJob.isSuccessful()) { System.err.println("Error running job " + firstJob); System.err.println("Killing all remaining jobs"); for (int j = 1; j < jobs.size(); j++) jobs.get(j).killJob(); System.exit(1); } Counters counters = firstJob.getCounters(); Counter outputRecordCounter = counters.findCounter(Task.Counter.MAP_OUTPUT_RECORDS); resultsCounts.add(outputRecordCounter.getValue()); jobs.remove(0); } while (!threads.isEmpty()) { try { Thread thread = threads.firstElement(); thread.join(); threads.remove(0); } catch (InterruptedException e) { e.printStackTrace(); } } long t2 = System.currentTimeMillis(); System.out.println("QueryPlan:"); for (Path stPath : STPaths) { System.out.println(stPath.getName()); } System.out.println("Time for " + queryRanges.length + " jobs is " + (t2 - t1) + " millis"); System.out.println("Results counts: " + resultsCounts); }
From source file:edu.umn.cs.sthadoop.operations.STRangeQuery.java
public static void main(String[] args) throws Exception { // args = new String[7]; // args[0] = "/home/louai/nyc-taxi/yellowIndex"; // args[1] = "/home/louai/nyc-taxi/resultSTRQ"; // args[2] = "shape:edu.umn.cs.sthadoop.core.STPoint"; // args[3] = "rect:-74.98451232910156,35.04014587402344,-73.97936248779295,41.49399566650391"; // args[4] = "interval:2015-01-01,2015-01-02"; // args[5] = "-overwrite"; // args[6] = "-no-local"; // Query for test with output // args = new String[6]; // args[0] = "/home/louai/nyc-taxi/yellowIndex"; // args[1] = "shape:edu.umn.cs.sthadoop.core.STPoint"; // args[2] = "rect:-74.98451232910156,35.04014587402344,-73.97936248779295,41.49399566650391"; // args[3] = "interval:2015-01-01,2015-01-03"; // args[4] = "-overwrite"; // args[5 ] = "-no-local"; final OperationsParams params = new OperationsParams(new GenericOptionsParser(args)); final Path[] paths = params.getPaths(); if (paths.length <= 1 && !params.checkInput()) { printUsage();/*from w w w . j a va 2s.c om*/ System.exit(1); } if (paths.length >= 2 && !params.checkInputOutput()) { printUsage(); System.exit(1); } if (params.get("rect") == null) { String x1 = "-" + Double.toString(Double.MAX_VALUE); String y1 = "-" + Double.toString(Double.MAX_VALUE); String x2 = Double.toString(Double.MAX_VALUE); String y2 = Double.toString(Double.MAX_VALUE); System.out.println(x1 + "," + y1 + "," + x2 + "," + y2); params.set("rect", x1 + "," + y1 + "," + x2 + "," + y2); // System.err.println("You must provide a query range"); // printUsage(); // System.exit(1); } if (params.get("interval") == null) { System.err.println("Temporal range missing"); printUsage(); System.exit(1); } TextSerializable inObj = params.getShape("shape"); if (!(inObj instanceof STPoint) && !(inObj instanceof STRectangle)) { LOG.error("Shape is not instance of STPoint or STRectangle"); printUsage(); System.exit(1); } // Get spatio-temporal slices. List<Path> STPaths = getIndexedSlices(params); final Path outPath = params.getOutputPath(); final Rectangle[] queryRanges = params.getShapes("rect", new Rectangle()); // All running jobs final Vector<Long> resultsCounts = new Vector<Long>(); Vector<Job> jobs = new Vector<Job>(); Vector<Thread> threads = new Vector<Thread>(); long t1 = System.currentTimeMillis(); for (Path stPath : STPaths) { final Path inPath = stPath; for (int i = 0; i < queryRanges.length; i++) { final OperationsParams queryParams = new OperationsParams(params); OperationsParams.setShape(queryParams, "rect", queryRanges[i]); if (OperationsParams.isLocal(new JobConf(queryParams), inPath)) { // Run in local mode final Rectangle queryRange = queryRanges[i]; final Shape shape = queryParams.getShape("shape"); final Path output = outPath == null ? null : (queryRanges.length == 1 ? outPath : new Path(outPath, String.format("%05d", i))); Thread thread = new Thread() { @Override public void run() { FSDataOutputStream outFile = null; final byte[] newLine = System.getProperty("line.separator", "\n").getBytes(); try { ResultCollector<Shape> collector = null; if (output != null) { FileSystem outFS = output.getFileSystem(queryParams); final FSDataOutputStream foutFile = outFile = outFS.create(output); collector = new ResultCollector<Shape>() { final Text tempText = new Text2(); @Override public synchronized void collect(Shape r) { try { tempText.clear(); r.toText(tempText); foutFile.write(tempText.getBytes(), 0, tempText.getLength()); foutFile.write(newLine); } catch (IOException e) { e.printStackTrace(); } } }; } else { outFile = null; } long resultCount = rangeQueryLocal(inPath, queryRange, shape, queryParams, collector); resultsCounts.add(resultCount); } catch (IOException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } finally { try { if (outFile != null) outFile.close(); } catch (IOException e) { e.printStackTrace(); } } } }; thread.start(); threads.add(thread); } else { // Run in MapReduce mode Path outTempPath = outPath == null ? null : new Path(outPath, String.format("%05d", i) + "-" + inPath.getName()); queryParams.setBoolean("background", true); Job job = rangeQueryMapReduce(inPath, outTempPath, queryParams); jobs.add(job); } } } while (!jobs.isEmpty()) { Job firstJob = jobs.firstElement(); firstJob.waitForCompletion(false); if (!firstJob.isSuccessful()) { System.err.println("Error running job " + firstJob); System.err.println("Killing all remaining jobs"); for (int j = 1; j < jobs.size(); j++) jobs.get(j).killJob(); System.exit(1); } Counters counters = firstJob.getCounters(); Counter outputRecordCounter = counters.findCounter(Task.Counter.MAP_OUTPUT_RECORDS); resultsCounts.add(outputRecordCounter.getValue()); jobs.remove(0); } while (!threads.isEmpty()) { try { Thread thread = threads.firstElement(); thread.join(); threads.remove(0); } catch (InterruptedException e) { e.printStackTrace(); } } long t2 = System.currentTimeMillis(); System.out.println("QueryPlan:"); for (Path stPath : STPaths) { System.out.println(stPath.getName()); } System.out.println("Time for " + queryRanges.length + " jobs is " + (t2 - t1) + " millis"); System.out.println("Results counts: " + resultsCounts); }
From source file:Main.java
public static void deleteAllFiles(Vector filesToDelete) { for (int i = 0; i < filesToDelete.size(); i++) { ((File) filesToDelete.get(i)).delete(); }//from w w w. j a v a2s . com }
From source file:com.tulskiy.musique.plugins.hotkeys.HotkeyConfiguration.java
public static void setHotkeys(Vector<Vector> values) { Configuration config = Application.getInstance().getConfiguration(); ArrayList<String> hotkeysRaw = new ArrayList<String>(); for (Vector value : values) { hotkeysRaw.add(value.get(0) + ": " + value.get(1)); }/* ww w . jav a2s . c om*/ config.setList(getHotkeyKey(), hotkeysRaw); }
From source file:Main.java
/** * @param el// www. java 2 s . c o m * @return the number of element and attribute nodes in an XML tree */ public static int nodeCount(Element el) { int count = 1 + el.getAttributes().getLength(); // this node and its attributes // contributions from child elements Vector<Element> childElements = childElements(el); for (int i = 0; i < childElements.size(); i++) count = count + nodeCount(childElements.get(i)); return count; }
From source file:Main.java
private static double[] vectorToDoubleArray(Vector<Double> vector) { int length = vector.size(); double[] retorno = new double[length]; for (int x = 0; x < length; x++) { retorno[x] = vector.get(x); }//w ww . j a v a 2 s .co m return retorno; }