Example #1
0
 public void Run()
 {
     try
     {
         while (!openerDone.Get())
         {
             @out.Write(DFSTestUtil.GenerateSequentialBytes(0, writeSize));
             @out.Hflush();
         }
     }
     catch (IOException e)
     {
         TestFileConcurrentReader.Log.Warn("error in writer", e);
     }
     finally
     {
         try
         {
             @out.Close();
         }
         catch (IOException)
         {
             TestFileConcurrentReader.Log.Error("unable to close file");
         }
     }
 }
Example #2
0
 public void Run()
 {
     try
     {
         FSDataOutputStream outputStream = this._enclosing.fileSystem.Create(file);
         if (syncType == TestFileConcurrentReader.SyncType.Append)
         {
             outputStream.Close();
             outputStream = this._enclosing.fileSystem.Append(file);
         }
         try
         {
             for (int i = 0; !error.Get() && i < numWrites; i++)
             {
                 byte[] writeBuf = DFSTestUtil.GenerateSequentialBytes(i * writeSize, writeSize);
                 outputStream.Write(writeBuf);
                 if (syncType == TestFileConcurrentReader.SyncType.Sync)
                 {
                     outputStream.Hflush();
                 }
                 writerStarted.Set(true);
             }
         }
         catch (IOException e)
         {
             error.Set(true);
             TestFileConcurrentReader.Log.Error("error writing to file", e);
         }
         finally
         {
             outputStream.Close();
         }
         writerDone.Set(true);
     }
     catch (Exception e)
     {
         TestFileConcurrentReader.Log.Error("error in writer", e);
         throw new RuntimeException(e);
     }
 }
Example #3
0
 /// <exception cref="System.IO.IOException"/>
 private void WriteFileAndSync(FSDataOutputStream stm, int size)
 {
     byte[] buffer = DFSTestUtil.GenerateSequentialBytes(0, size);
     stm.Write(buffer, 0, size);
     stm.Hflush();
 }