@Deprecated public void sync() throws IOException { hflush(); }
@Deprecated public void sync() throws IOException { hflush(); }
public void run() { while (running.get()) { try { out.write("test".getBytes()); out.hflush(); // Keep writing data every one second Thread.sleep(1000); } catch (IOException | InterruptedException e) { LOG.error("Exception during write", e); failed.set(true); break; } } running.set(false); } };
public void testBlocksScheduledCounter() throws IOException { MiniDFSCluster cluster = new MiniDFSCluster.Builder(new HdfsConfiguration()) .build(); cluster.waitActive(); FileSystem fs = cluster.getFileSystem(); //open a file an write a few bytes: FSDataOutputStream out = fs.create(new Path("/testBlockScheduledCounter")); for (int i=0; i<1024; i++) { out.write(i); } // flush to make sure a block is allocated. ((DFSOutputStream)(out.getWrappedStream())).hflush(); ArrayList<DatanodeDescriptor> dnList = new ArrayList<DatanodeDescriptor>(); cluster.getNamesystem().DFSNodesStatus(dnList, dnList); DatanodeDescriptor dn = dnList.get(0); assertEquals(1, dn.getBlocksScheduled()); // close the file and the counter should go to zero. out.close(); assertEquals(0, dn.getBlocksScheduled()); } }
((DFSOutputStream) ofs.getWrappedStream()).hflush();
((DFSOutputStream)stm.getWrappedStream()).hflush(); byte [] toRead = new byte[tenth]; byte [] expected = new byte[tenth];
((DFSOutputStream)out.getWrappedStream()).hflush();
getWrappedStream()); out.write(1); out.hflush(); FSDataInputStream in = null; try {
((DFSOutputStream)stm.getWrappedStream()).hsync(syncFlags); } else { ((DFSOutputStream)stm.getWrappedStream()).hflush();
((DFSOutputStream) ofs.getWrappedStream()).hflush();
((DFSOutputStream)out.getWrappedStream()).hflush();
getWrappedStream()); out.write(1); out.hflush();
getWrappedStream()); out.write(1); out.hflush(); FSDataInputStream in = null; try {
getWrappedStream()); out.write(1); out.hflush();
getWrappedStream()); out.write(1); out.hflush(); out.close(); FSDataInputStream in = null;
getWrappedStream()); out.write(1); out.hflush();