CalvalusShFileSystem extends LocalFileSystem { @Override public FSDataInputStream open(Path path) throws IOException { if (isLoginUser) { return unixFileSystem.open(path); } return open(path, 4096); } CalvalusShFileSystem();  CalvalusShFileSystem(String username, FileSystem fs);  CalvalusShFileSystem(String username, JobClientsMap.CacheEntry cacheEntry); @Override void initialize(URI name, Configuration conf); static synchronized void createOrRegister(String username,
                                                     JobClientsMap.CacheEntry cacheEntry,
                                                     Map<String,FileSystem> fileSystemMap); static synchronized FileSystem getCreate(URI uri, Configuration conf); JobClientsMap.CacheEntry getCacheEntry(); @Override FileStatus[] listStatus(Path path); @Override FileStatus[] listStatus(Path path, PathFilter filter); @Override RemoteIterator<LocatedFileStatus> listLocatedStatus(Path f); @Override FileStatus getFileStatus(Path path); @Override FileStatus[] globStatus(Path path); @Override FileStatus[] globStatus(Path path, PathFilter filter); @Override FSDataInputStream open(Path path); @Override FSDataInputStream open(Path path, int bufferSize); @Override FSDataOutputStream create(Path path, FsPermission permission, boolean overwrite, int bufferSize, short replication, long blockSize, Progressable progress); @Override FSDataOutputStream append(Path path, int bufferSize, Progressable progress); @Override boolean mkdirs(Path path, FsPermission permission); @Override void setPermission(Path path, FsPermission permission); @Override boolean rename(Path src, Path dst); @Override boolean delete(Path path, boolean recursive); @Override void setWorkingDirectory(Path new_dir); @Override Path getWorkingDirectory(); @Override URI getUri(); @Override Path makeQualified(Path path); @Override Configuration getConf(); static final String CALVALUS_SH_COMMAND; }
@Test @Ignore public void testCat() throws Exception { System.setProperty("calvalus.accesscontrol.external", "true"); String user = "vboxadd"; JobClientsMap jobClientsMap = new JobClientsMap(new JobConf()); JobClient jobClient = jobClientsMap.getJobClient(user); FileSystem fileSystem = jobClientsMap.getFileSystem(user); try (BufferedReader in = new BufferedReader(new InputStreamReader(fileSystem.open(new Path("/calvalus/testdir/testfile"))))) { String line; while ((line = in.readLine()) != null) { System.out.println("|" + line + "|"); } }; }
@Test @Ignore public void testCatGeoIndex() throws Exception { System.setProperty("calvalus.accesscontrol.external", "true"); String user = "vboxadd"; JobClientsMap jobClientsMap = new JobClientsMap(new JobConf()); JobClient jobClient = jobClientsMap.getJobClient(user); FileSystem fileSystem = jobClientsMap.getFileSystem(user); try (BufferedInputStream in = new BufferedInputStream(fileSystem.open(new Path("/home/boe/tmp/geo_index.b")))) { try (BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream("/home/boe/tmp/geo_index.b.copy"))) { byte[] buf = new byte[8192]; int n; while ((n = in.read(buf)) > 0) { out.write(buf, 0, n); } } }; }