Changeset 31088 for other-projects
- Timestamp:
- 2016-11-10T16:09:55+13:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
other-projects/hathitrust/wcsa/extracted-features-solr/trunk/solr-ingest/src/main/java/org/hathitrust/extractedfeatures/ClusterFileIO.java
r30996 r31088 24 24 public class ClusterFileIO { 25 25 26 private static FileSystem __fs = null; 27 28 /* 29 public static void initOLD(JavaSparkContext java_spark_context) 26 27 public static void memory_usage(String prefix) 30 28 { 31 try { 32 Configuration hadoop_conf = java_spark_context.hadoopConfiguration(); 33 _fs = FileSystem.get(hadoop_conf); 34 } 35 catch (IOException e) { 36 e.printStackTrace(); 37 } 29 Runtime runtime = Runtime.getRuntime(); 30 31 java.text.NumberFormat format = java.text.NumberFormat.getInstance(); 32 33 StringBuilder sb = new StringBuilder(); 34 long maxMemory = runtime.maxMemory(); 35 long allocatedMemory = runtime.totalMemory(); 36 long freeMemory = runtime.freeMemory(); 37 38 sb.append(prefix+" free memory: " + format.format(freeMemory / 1024) + "\n"); 39 sb.append(prefix+" allocated memory: " + format.format(allocatedMemory / 1024) + "\n"); 40 sb.append(prefix+" max memory: " + format.format(maxMemory / 1024) + "\n"); 41 sb.append(prefix+" total free memory: " + format.format((freeMemory + (maxMemory - allocatedMemory)) / 1024) + "\n"); 42 43 System.out.print(sb.toString()); 38 44 } 39 */ 40 41 /* 42 public static void init(String input_dir) 43 { 44 try { 45 Configuration conf = new Configuration(); 46 URI uri = new URI(input_dir); 47 _fs = FileSystem.get(uri, conf); 48 } 49 catch (URISyntaxException e) { 50 e.printStackTrace(); 51 } 52 catch (IOException e) { 53 e.printStackTrace(); 54 } 55 56 } 57 */ 45 58 46 59 47 protected static FileSystem getFileSystemInstance(String input_dir) 60 48 { 61 if (__fs == null) {49 FileSystem fs = null; 62 50 63 64 65 66 __fs = FileSystem.get(uri,conf);67 68 69 70 71 72 73 74 } 75 return __fs;51 try { 52 Configuration conf = new Configuration(); 53 URI uri = new URI(input_dir); 54 fs = FileSystem.newInstance(uri,conf); 55 } 56 catch (URISyntaxException e) { 57 e.printStackTrace(); 58 } 59 catch (IOException e) { 60 e.printStackTrace(); 61 } 62 63 return fs; 76 64 } 77 65
Note:
See TracChangeset
for help on using the changeset viewer.