예제 #1
0
 /// <summary>Serialize the actual read result on the wire.</summary>
 /// <exception cref="System.IO.IOException"/>
 internal static void WriteReadResult(OutputStream @out, DataTransferProtos.Status
                                      statusCode)
 {
     ((DataTransferProtos.ClientReadStatusProto)DataTransferProtos.ClientReadStatusProto
      .NewBuilder().SetStatus(statusCode).Build()).WriteDelimitedTo(@out);
     @out.Flush();
 }
예제 #2
0
        public static int CombineHeader(PipelineAck.ECN ecn, DataTransferProtos.Status status
                                        )
        {
            int header = 0;

            header = PipelineAck.StatusFormat.SetStatus(header, status);
            header = PipelineAck.StatusFormat.SetECN(header, ecn);
            return(header);
        }
예제 #3
0
        /// <summary>Get the timeout to be used for transmitting the OOB type</summary>
        /// <returns>the timeout in milliseconds</returns>
        /// <exception cref="System.IO.IOException"/>
        public static long GetOOBTimeout(DataTransferProtos.Status status)
        {
            int index = status.GetNumber() - OobStart;

            if (index >= 0 && index < NumOobTypes)
            {
                return(OobTimeout[index]);
            }
            // Not an OOB.
            throw new IOException("Not an OOB status: " + status);
        }
예제 #4
0
 /// <exception cref="System.IO.IOException"/>
 private void SendResponse(DataTransferProtos.Status status, string firstBadLink,
                           string message, DataOutputStream @out)
 {
     DataTransferProtos.BlockOpResponseProto.Builder builder = DataTransferProtos.BlockOpResponseProto
                                                               .NewBuilder().SetStatus(status);
     if (firstBadLink != null)
     {
         builder.SetFirstBadLink(firstBadLink);
     }
     if (message != null)
     {
         builder.SetMessage(message);
     }
     ((DataTransferProtos.BlockOpResponseProto)builder.Build()).WriteDelimitedTo(@out);
 }
예제 #5
0
 // in will be closed when its Socket is closed.
 /// <summary>
 /// When the reader reaches end of the read, it sends a status response
 /// (e.g.
 /// </summary>
 /// <remarks>
 /// When the reader reaches end of the read, it sends a status response
 /// (e.g. CHECKSUM_OK) to the DN. Failure to do so could lead to the DN
 /// closing our connection (which we will re-open), but won't affect
 /// data correctness.
 /// </remarks>
 internal virtual void SendReadResult(DataTransferProtos.Status statusCode)
 {
     System.Diagnostics.Debug.Assert(!sentStatusCode, "already sent status code to " +
                                     peer);
     try
     {
         WriteReadResult(peer.GetOutputStream(), statusCode);
         sentStatusCode = true;
     }
     catch (IOException e)
     {
         // It's ok not to be able to send this. But something is probably wrong.
         Log.Info("Could not send read status (" + statusCode + ") to datanode " + peer.GetRemoteAddressString
                      () + ": " + e.Message);
     }
 }
예제 #6
0
 public static int SetStatus(int old, DataTransferProtos.Status status)
 {
     return((int)PipelineAck.StatusFormat.Status.Bits.Combine(status.GetNumber(), old));
 }
예제 #7
0
 public static int SetStatusForHeader(int old, DataTransferProtos.Status status)
 {
     return(PipelineAck.StatusFormat.SetStatus(old, status));
 }
예제 #8
0
 /// <summary>return true if it is the restart OOB status code</summary>
 public static bool IsRestartOOBStatus(DataTransferProtos.Status st)
 {
     return(st.Equals(DataTransferProtos.Status.OobRestart));
 }