(MiniGenericCluster cluster,
String fileNameOnCluster, String localFileName)
| 712 | } |
| 713 | |
| 714 | static public void copyFromClusterToLocal(MiniGenericCluster cluster, |
| 715 | String fileNameOnCluster, String localFileName) throws IOException { |
| 716 | if(Util.WINDOWS){ |
| 717 | fileNameOnCluster = fileNameOnCluster.replace('\\','/'); |
| 718 | localFileName = localFileName.replace('\\','/'); |
| 719 | } |
| 720 | File parent = new File(localFileName).getParentFile(); |
| 721 | if (!parent.exists()) { |
| 722 | parent.mkdirs(); |
| 723 | } |
| 724 | PrintWriter writer = new PrintWriter(new FileWriter(localFileName)); |
| 725 | |
| 726 | FileSystem fs = FileSystem.get(ConfigurationUtil.toConfiguration( |
| 727 | cluster.getProperties())); |
| 728 | if(!fs.exists(new Path(fileNameOnCluster))) { |
| 729 | throw new IOException("File " + fileNameOnCluster + " does not exists on the minicluster"); |
| 730 | } |
| 731 | |
| 732 | String line = null; |
| 733 | FileStatus fst = fs.getFileStatus(new Path(fileNameOnCluster)); |
| 734 | if(fst.isDir()) { |
| 735 | throw new IOException("Only files from cluster can be copied locally," + |
| 736 | " " + fileNameOnCluster + " is a directory"); |
| 737 | } |
| 738 | FSDataInputStream stream = fs.open(new Path(fileNameOnCluster)); |
| 739 | BufferedReader reader = new BufferedReader(new InputStreamReader(stream)); |
| 740 | while( (line = reader.readLine()) != null) { |
| 741 | writer.println(line); |
| 742 | } |
| 743 | |
| 744 | reader.close(); |
| 745 | writer.close(); |
| 746 | } |
| 747 | |
| 748 | static public void printQueryOutput(Iterator<Tuple> actualResults, |
| 749 | Tuple[] expectedResults) { |
no test coverage detected