1 31 package org.objectweb.proactive.examples.c3d; 32 33 class Hosts { 34 35 protected java.util.Vector allNodes = new java.util.Vector (); 36 protected int index = 0; 37 38 39 public Hosts(String filename) throws java.io.IOException { 40 java.io.File f = new java.io.File (filename); 42 if (f.canRead()) { 43 byte[] b = getBytesFromInputStream(new java.io.FileInputStream (f)); 44 java.util.StringTokenizer tokenizer = new java.util.StringTokenizer (new String (b)); 45 while (tokenizer.hasMoreTokens()) { 46 allNodes.addElement(tokenizer.nextToken()); 47 } 48 } 49 } 50 51 52 public String getNextNode() { 53 String result; 55 result = (String )allNodes.elementAt(index); 56 index = (index + 1) % allNodes.size(); 57 return result; 58 } 59 60 61 public int getMachines() { 62 return allNodes.size(); 63 } 64 65 66 73 private static byte[] getBytesFromInputStream(java.io.InputStream in) throws java.io.IOException { 74 java.io.DataInputStream din = new java.io.DataInputStream (in); 75 byte[] bytecodes = new byte[in.available()]; 76 try { 77 din.readFully(bytecodes); 78 } finally { 79 if (din != null) din.close(); 80 } 81 return bytecodes; 82 } 83 } 84 | Popular Tags |