@Test public void testExecute() throws IOException { String filePath = "/testWriteFile/file"; int size = 66560; writeFile(filePath, size); ReadFileAction readFileAction = new ReadFileAction(); readFileAction.setDfsClient(dfsClient); readFileAction.setContext(smartContext); Map<String, String> args = new HashMap(); args.put(ReadFileAction.FILE_PATH, filePath); readFileAction.init(args); readFileAction.run(); Assert.assertTrue(readFileAction.getExpectedAfterRun()); }
@Override protected void execute() throws Exception { if (filePath == null) { throw new IllegalArgumentException("File parameter is missing."); } appendLog( String.format("Action starts at %s : Read %s", Utils.getFormatedCurrentTime(), filePath)); if (!dfsClient.exists(filePath)) { throw new ActionException("ReadFile Action fails, file " + filePath + " doesn't exist!"); } DFSInputStream dfsInputStream = dfsClient.open(filePath); byte[] buffer = new byte[bufferSize]; while (dfsInputStream.read(buffer, 0, bufferSize) != -1) {} dfsInputStream.close(); }
ReadFileAction extends HdfsAction { @Override protected void execute() throws Exception { if (filePath == null) { throw new IllegalArgumentException("File parameter is missing."); } appendLog( String.format("Action starts at %s : Read %s", Utils.getFormatedCurrentTime(), filePath)); if (!dfsClient.exists(filePath)) { throw new ActionException("ReadFile Action fails, file " + filePath + " doesn't exist!"); } DFSInputStream dfsInputStream = dfsClient.open(filePath); byte[] buffer = new byte[bufferSize]; while (dfsInputStream.read(buffer, 0, bufferSize) != -1) {} dfsInputStream.close(); } }
ReadFileAction extends HdfsAction { @Override protected void execute() throws Exception { if (filePath == null) { throw new IllegalArgumentException("File parameter is missing."); } appendLog( String.format("Action starts at %s : Read %s", Utils.getFormatedCurrentTime(), filePath)); if (!dfsClient.exists(filePath)) { throw new ActionException("ReadFile Action fails, file " + filePath + " doesn't exist!"); } DFSInputStream dfsInputStream = dfsClient.open(filePath); byte[] buffer = new byte[bufferSize]; while (dfsInputStream.read(buffer, 0, bufferSize) != -1) {} dfsInputStream.close(); }  }
ReadFileAction extends HdfsAction { @Override protected void execute() throws Exception { if (filePath == null) { throw new IllegalArgumentException("File parameter is missing."); } appendLog( String.format("Action starts at %s : Read %s", Utils.getFormatedCurrentTime(), filePath)); if (!dfsClient.exists(filePath)) { throw new ActionException("ReadFile Action fails, file " + filePath + " doesn't exist!"); } DFSInputStream dfsInputStream = dfsClient.open(filePath); byte[] buffer = new byte[bufferSize]; while (dfsInputStream.read(buffer, 0, bufferSize) != -1) {} dfsInputStream.close(); }  @Override void init(Map<String, String> args); }
ReadFileAction extends HdfsAction { @Override protected void execute() throws Exception { if (filePath == null) { throw new IllegalArgumentException("File parameter is missing."); } appendLog( String.format("Action starts at %s : Read %s", Utils.getFormatedCurrentTime(), filePath)); if (!dfsClient.exists(filePath)) { throw new ActionException("ReadFile Action fails, file " + filePath + " doesn't exist!"); } DFSInputStream dfsInputStream = dfsClient.open(filePath); byte[] buffer = new byte[bufferSize]; while (dfsInputStream.read(buffer, 0, bufferSize) != -1) {} dfsInputStream.close(); }  @Override void init(Map<String, String> args); static final String BUF_SIZE; }