MCPcopy Create free account
hub / github.com/apache/pig / copyFromClusterToLocal

Method copyFromClusterToLocal

test/org/apache/pig/test/Util.java:714–746  ·  view source on GitHub ↗
(MiniGenericCluster cluster,
            String fileNameOnCluster, String localFileName)

Source from the content-addressed store, hash-verified

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) {

Calls 9

toConfigurationMethod · 0.95
mkdirsMethod · 0.80
replaceMethod · 0.65
existsMethod · 0.65
getMethod · 0.65
openMethod · 0.65
closeMethod · 0.65
getPropertiesMethod · 0.45
readLineMethod · 0.45

Tested by

no test coverage detected