Exemplo n.º 1
0
 internal WriteCtx(FileHandle handle, long offset, int count, int originalCount, Nfs3Constant.WriteStableHow
                   stableHow, ByteBuffer data, Org.Jboss.Netty.Channel.Channel channel, int xid, bool
                   replied, WriteCtx.DataState dataState)
 {
     this.handle        = handle;
     this.offset        = offset;
     this.count         = count;
     this.originalCount = originalCount;
     this.stableHow     = stableHow;
     this.data          = data;
     this.channel       = channel;
     this.xid           = xid;
     this.replied       = replied;
     this.dataState     = dataState;
     raf            = null;
     this.startTime = Runtime.NanoTime();
 }
Exemplo n.º 2
0
 /// <summary>Writing the data into a local file.</summary>
 /// <remarks>
 /// Writing the data into a local file. After the writing, if
 /// <see cref="dataState"/>
 /// is still ALLOW_DUMP, set
 /// <see cref="data"/>
 /// to null and set
 /// <see cref="dataState"/>
 /// to DUMPED.
 /// </remarks>
 /// <exception cref="System.IO.IOException"/>
 internal virtual long DumpData(FileOutputStream dumpOut, RandomAccessFile raf)
 {
     if (dataState != WriteCtx.DataState.AllowDump)
     {
         if (Log.IsTraceEnabled())
         {
             Log.Trace("No need to dump with status(replied,dataState):" + "(" + replied + ","
                       + dataState + ")");
         }
         return(0);
     }
     // Resized write should not allow dump
     Preconditions.CheckState(originalCount == InvalidOriginalCount);
     this.raf       = raf;
     dumpFileOffset = dumpOut.GetChannel().Position();
     dumpOut.Write(((byte[])data.Array()), 0, count);
     if (Log.IsDebugEnabled())
     {
         Log.Debug("After dump, new dumpFileOffset:" + dumpFileOffset);
     }
     // it is possible that while we dump the data, the data is also being
     // written back to HDFS. After dump, if the writing back has not finished
     // yet, we change its flag to DUMPED and set the data to null. Otherwise
     // this WriteCtx instance should have been removed from the buffer.
     if (dataState == WriteCtx.DataState.AllowDump)
     {
         lock (this)
         {
             if (dataState == WriteCtx.DataState.AllowDump)
             {
                 data      = null;
                 dataState = WriteCtx.DataState.Dumped;
                 return(count);
             }
         }
     }
     return(0);
 }
Exemplo n.º 3
0
 public virtual void SetDataState(WriteCtx.DataState dataState)
 {
     this.dataState = dataState;
 }