Utility method to copy a file form local filesystem to the dfs on the minicluster for testing in mapreduce mode @param cluster a reference to the minicluster @param localFileName the pathname of local file @param fileNameOnCluster the name with which the file should be created on the minicluster @th
(MiniGenericCluster cluster,
String localFileName, String fileNameOnCluster)
| 686 | * @throws IOException |
| 687 | */ |
| 688 | static public void copyFromLocalToCluster(MiniGenericCluster cluster, |
| 689 | String localFileName, String fileNameOnCluster) throws IOException { |
| 690 | if(Util.WINDOWS){ |
| 691 | if (!localFileName.contains(":")) { |
| 692 | localFileName = localFileName.replace('\\','/'); |
| 693 | } else { |
| 694 | localFileName = localFileName.replace('/','\\'); |
| 695 | } |
| 696 | fileNameOnCluster = fileNameOnCluster.replace('\\','/'); |
| 697 | } |
| 698 | PigServer ps = new PigServer(cluster.getExecType(), cluster.getProperties()); |
| 699 | String script = getFSMkDirCommand(fileNameOnCluster) + "fs -put " + localFileName + " " + fileNameOnCluster; |
| 700 | GruntParser parser = new GruntParser(new StringReader(script), ps); |
| 701 | parser.setInteractive(false); |
| 702 | try { |
| 703 | parser.parseStopOnError(); |
| 704 | } catch (org.apache.pig.tools.pigscript.parser.ParseException e) { |
| 705 | throw new IOException(e); |
| 706 | } |
| 707 | } |
| 708 | |
| 709 | static public void copyFromLocalToLocal(String fromLocalFileName, |
| 710 | String toLocalFileName) throws IOException { |
no test coverage detected