Пример #1
0
        /// <summary>Receive OP_WRITE_BLOCK</summary>
        /// <exception cref="System.IO.IOException"/>
        private void OpWriteBlock(DataInputStream @in)
        {
            DataTransferProtos.OpWriteBlockProto proto = DataTransferProtos.OpWriteBlockProto
                                                         .ParseFrom(PBHelper.VintPrefixed(@in));
            DatanodeInfo[] targets    = PBHelper.Convert(proto.GetTargetsList());
            TraceScope     traceScope = DataTransferProtoUtil.ContinueTraceSpan(proto.GetHeader()
                                                                                , proto.GetType().Name);

            try
            {
                WriteBlock(PBHelper.Convert(proto.GetHeader().GetBaseHeader().GetBlock()), PBHelper
                           .ConvertStorageType(proto.GetStorageType()), PBHelper.Convert(proto.GetHeader().
                                                                                         GetBaseHeader().GetToken()), proto.GetHeader().GetClientName(), targets, PBHelper
                           .ConvertStorageTypes(proto.GetTargetStorageTypesList(), targets.Length), PBHelper
                           .Convert(proto.GetSource()), DataTransferProtoUtil.FromProto(proto.GetStage()),
                           proto.GetPipelineSize(), proto.GetMinBytesRcvd(), proto.GetMaxBytesRcvd(), proto
                           .GetLatestGenerationStamp(), DataTransferProtoUtil.FromProto(proto.GetRequestedChecksum
                                                                                            ()), (proto.HasCachingStrategy() ? GetCachingStrategy(proto.GetCachingStrategy()
                                                                                                                                                  ) : CachingStrategy.NewDefaultStrategy()), (proto.HasAllowLazyPersist() ? proto.
                                                                                                                                                                                              GetAllowLazyPersist() : false), (proto.HasPinning() ? proto.GetPinning() : false
                                                                                                                                                                                                                               ), (PBHelper.ConvertBooleanList(proto.GetTargetPinningsList())));
            }
            finally
            {
                if (traceScope != null)
                {
                    traceScope.Close();
                }
            }
        }
Пример #2
0
 /// <exception cref="System.IO.IOException"/>
 public override void WriteBlock(ExtendedBlock blk, StorageType storageType, Org.Apache.Hadoop.Security.Token.Token
                                 <BlockTokenIdentifier> blockToken, string clientName, DatanodeInfo[] targets, StorageType
                                 [] targetStorageTypes, DatanodeInfo source, BlockConstructionStage stage, int pipelineSize
                                 , long minBytesRcvd, long maxBytesRcvd, long latestGenerationStamp, DataChecksum
                                 requestedChecksum, CachingStrategy cachingStrategy, bool allowLazyPersist, bool
                                 pinning, bool[] targetPinnings)
 {
     DataTransferProtos.ClientOperationHeaderProto header = DataTransferProtoUtil.BuildClientHeader
                                                                (blk, clientName, blockToken);
     DataTransferProtos.ChecksumProto checksumProto = DataTransferProtoUtil.ToProto(requestedChecksum
                                                                                    );
     DataTransferProtos.OpWriteBlockProto.Builder proto = DataTransferProtos.OpWriteBlockProto
                                                          .NewBuilder().SetHeader(header).SetStorageType(PBHelper.ConvertStorageType(storageType
                                                                                                                                     )).AddAllTargets(PBHelper.Convert(targets, 1)).AddAllTargetStorageTypes(PBHelper
                                                                                                                                                                                                             .ConvertStorageTypes(targetStorageTypes, 1)).SetStage(DataTransferProtoUtil.ToProto
                                                                                                                                                                                                                                                                       (stage)).SetPipelineSize(pipelineSize).SetMinBytesRcvd(minBytesRcvd).SetMaxBytesRcvd
                                                              (maxBytesRcvd).SetLatestGenerationStamp(latestGenerationStamp).SetRequestedChecksum
                                                              (checksumProto).SetCachingStrategy(GetCachingStrategy(cachingStrategy)).SetAllowLazyPersist
                                                              (allowLazyPersist).SetPinning(pinning).AddAllTargetPinnings(PBHelper.Convert(targetPinnings
                                                                                                                                           , 1));
     if (source != null)
     {
         proto.SetSource(PBHelper.ConvertDatanodeInfo(source));
     }
     Send(@out, OP.WriteBlock, ((DataTransferProtos.OpWriteBlockProto)proto.Build()));
 }
Пример #3
0
        /// <summary>
        /// Receive
        /// <see cref="OP.RequestShortCircuitShm"/>
        ///
        /// </summary>
        /// <exception cref="System.IO.IOException"/>
        private void OpRequestShortCircuitShm(DataInputStream @in)
        {
            DataTransferProtos.ShortCircuitShmRequestProto proto = DataTransferProtos.ShortCircuitShmRequestProto
                                                                   .ParseFrom(PBHelper.VintPrefixed(@in));
            TraceScope traceScope = DataTransferProtoUtil.ContinueTraceSpan(proto.GetTraceInfo
                                                                                (), proto.GetType().Name);

            try
            {
                RequestShortCircuitShm(proto.GetClientName());
            }
            finally
            {
                if (traceScope != null)
                {
                    traceScope.Close();
                }
            }
        }
Пример #4
0
        /// <summary>
        /// Receive
        /// <see cref="OP.ReleaseShortCircuitFds"/>
        ///
        /// </summary>
        /// <exception cref="System.IO.IOException"/>
        private void OpReleaseShortCircuitFds(DataInputStream @in)
        {
            DataTransferProtos.ReleaseShortCircuitAccessRequestProto proto = DataTransferProtos.ReleaseShortCircuitAccessRequestProto
                                                                             .ParseFrom(PBHelper.VintPrefixed(@in));
            TraceScope traceScope = DataTransferProtoUtil.ContinueTraceSpan(proto.GetTraceInfo
                                                                                (), proto.GetType().Name);

            try
            {
                ReleaseShortCircuitFds(PBHelper.Convert(proto.GetSlotId()));
            }
            finally
            {
                if (traceScope != null)
                {
                    traceScope.Close();
                }
            }
        }
Пример #5
0
        /// <summary>Receive OP_BLOCK_CHECKSUM</summary>
        /// <exception cref="System.IO.IOException"/>
        private void OpBlockChecksum(DataInputStream @in)
        {
            DataTransferProtos.OpBlockChecksumProto proto = DataTransferProtos.OpBlockChecksumProto
                                                            .ParseFrom(PBHelper.VintPrefixed(@in));
            TraceScope traceScope = DataTransferProtoUtil.ContinueTraceSpan(proto.GetHeader()
                                                                            , proto.GetType().Name);

            try
            {
                BlockChecksum(PBHelper.Convert(proto.GetHeader().GetBlock()), PBHelper.Convert(proto
                                                                                               .GetHeader().GetToken()));
            }
            finally
            {
                if (traceScope != null)
                {
                    traceScope.Close();
                }
            }
        }
Пример #6
0
        /// <summary>
        /// Receive
        /// <see cref="OP.RequestShortCircuitFds"/>
        ///
        /// </summary>
        /// <exception cref="System.IO.IOException"/>
        private void OpRequestShortCircuitFds(DataInputStream @in)
        {
            DataTransferProtos.OpRequestShortCircuitAccessProto proto = DataTransferProtos.OpRequestShortCircuitAccessProto
                                                                        .ParseFrom(PBHelper.VintPrefixed(@in));
            ShortCircuitShm.SlotId slotId = (proto.HasSlotId()) ? PBHelper.Convert(proto.GetSlotId
                                                                                       ()) : null;
            TraceScope traceScope = DataTransferProtoUtil.ContinueTraceSpan(proto.GetHeader()
                                                                            , proto.GetType().Name);

            try
            {
                RequestShortCircuitFds(PBHelper.Convert(proto.GetHeader().GetBlock()), PBHelper.Convert
                                           (proto.GetHeader().GetToken()), slotId, proto.GetMaxVersion(), proto.GetSupportsReceiptVerification
                                           ());
            }
            finally
            {
                if (traceScope != null)
                {
                    traceScope.Close();
                }
            }
        }
Пример #7
0
        /// <summary>
        /// Receive
        /// <see cref="OP.TransferBlock"/>
        ///
        /// </summary>
        /// <exception cref="System.IO.IOException"/>
        private void OpTransferBlock(DataInputStream @in)
        {
            DataTransferProtos.OpTransferBlockProto proto = DataTransferProtos.OpTransferBlockProto
                                                            .ParseFrom(PBHelper.VintPrefixed(@in));
            DatanodeInfo[] targets    = PBHelper.Convert(proto.GetTargetsList());
            TraceScope     traceScope = DataTransferProtoUtil.ContinueTraceSpan(proto.GetHeader()
                                                                                , proto.GetType().Name);

            try
            {
                TransferBlock(PBHelper.Convert(proto.GetHeader().GetBaseHeader().GetBlock()), PBHelper
                              .Convert(proto.GetHeader().GetBaseHeader().GetToken()), proto.GetHeader().GetClientName
                                  (), targets, PBHelper.ConvertStorageTypes(proto.GetTargetStorageTypesList(), targets
                                                                            .Length));
            }
            finally
            {
                if (traceScope != null)
                {
                    traceScope.Close();
                }
            }
        }
Пример #8
0
        /// <summary>Receive OP_READ_BLOCK</summary>
        /// <exception cref="System.IO.IOException"/>
        private void OpReadBlock()
        {
            DataTransferProtos.OpReadBlockProto proto = DataTransferProtos.OpReadBlockProto.ParseFrom
                                                            (PBHelper.VintPrefixed(@in));
            TraceScope traceScope = DataTransferProtoUtil.ContinueTraceSpan(proto.GetHeader()
                                                                            , proto.GetType().Name);

            try
            {
                ReadBlock(PBHelper.Convert(proto.GetHeader().GetBaseHeader().GetBlock()), PBHelper
                          .Convert(proto.GetHeader().GetBaseHeader().GetToken()), proto.GetHeader().GetClientName
                              (), proto.GetOffset(), proto.GetLen(), proto.GetSendChecksums(), (proto.HasCachingStrategy
                                                                                                    () ? GetCachingStrategy(proto.GetCachingStrategy()) : CachingStrategy.NewDefaultStrategy
                                                                                                    ()));
            }
            finally
            {
                if (traceScope != null)
                {
                    traceScope.Close();
                }
            }
        }
Пример #9
0
 /// <exception cref="System.IO.IOException"/>
 public override void ReadBlock(ExtendedBlock blk, Org.Apache.Hadoop.Security.Token.Token
                                <BlockTokenIdentifier> blockToken, string clientName, long blockOffset, long length
                                , bool sendChecksum, CachingStrategy cachingStrategy)
 {
     DataTransferProtos.OpReadBlockProto proto = ((DataTransferProtos.OpReadBlockProto
                                                   )DataTransferProtos.OpReadBlockProto.NewBuilder().SetHeader(DataTransferProtoUtil
                                                                                                               .BuildClientHeader(blk, clientName, blockToken)).SetOffset(blockOffset).SetLen(length
                                                                                                                                                                                              ).SetSendChecksums(sendChecksum).SetCachingStrategy(GetCachingStrategy(cachingStrategy
                                                                                                                                                                                                                                                                     )).Build());
     Send(@out, OP.ReadBlock, proto);
 }
Пример #10
0
 /// <exception cref="System.IO.IOException"/>
 public override void BlockChecksum(ExtendedBlock blk, Org.Apache.Hadoop.Security.Token.Token
                                    <BlockTokenIdentifier> blockToken)
 {
     DataTransferProtos.OpBlockChecksumProto proto = ((DataTransferProtos.OpBlockChecksumProto
                                                       )DataTransferProtos.OpBlockChecksumProto.NewBuilder().SetHeader(DataTransferProtoUtil
                                                                                                                       .BuildBaseHeader(blk, blockToken)).Build());
     Send(@out, OP.BlockChecksum, proto);
 }
Пример #11
0
 /// <exception cref="System.IO.IOException"/>
 public override void ReplaceBlock(ExtendedBlock blk, StorageType storageType, Org.Apache.Hadoop.Security.Token.Token
                                   <BlockTokenIdentifier> blockToken, string delHint, DatanodeInfo source)
 {
     DataTransferProtos.OpReplaceBlockProto proto = ((DataTransferProtos.OpReplaceBlockProto
                                                      )DataTransferProtos.OpReplaceBlockProto.NewBuilder().SetHeader(DataTransferProtoUtil
                                                                                                                     .BuildBaseHeader(blk, blockToken)).SetStorageType(PBHelper.ConvertStorageType(storageType
                                                                                                                                                                                                   )).SetDelHint(delHint).SetSource(PBHelper.ConvertDatanodeInfo(source)).Build());
     Send(@out, OP.ReplaceBlock, proto);
 }
Пример #12
0
 /// <exception cref="System.IO.IOException"/>
 public override void RequestShortCircuitFds(ExtendedBlock blk, Org.Apache.Hadoop.Security.Token.Token
                                             <BlockTokenIdentifier> blockToken, ShortCircuitShm.SlotId slotId, int maxVersion
                                             , bool supportsReceiptVerification)
 {
     DataTransferProtos.OpRequestShortCircuitAccessProto.Builder builder = DataTransferProtos.OpRequestShortCircuitAccessProto
                                                                           .NewBuilder().SetHeader(DataTransferProtoUtil.BuildBaseHeader(blk, blockToken)).
                                                                           SetMaxVersion(maxVersion);
     if (slotId != null)
     {
         builder.SetSlotId(PBHelper.Convert(slotId));
     }
     builder.SetSupportsReceiptVerification(supportsReceiptVerification);
     DataTransferProtos.OpRequestShortCircuitAccessProto proto = ((DataTransferProtos.OpRequestShortCircuitAccessProto
                                                                   )builder.Build());
     Send(@out, OP.RequestShortCircuitFds, proto);
 }
Пример #13
0
 /// <exception cref="System.IO.IOException"/>
 public override void TransferBlock(ExtendedBlock blk, Org.Apache.Hadoop.Security.Token.Token
                                    <BlockTokenIdentifier> blockToken, string clientName, DatanodeInfo[] targets, StorageType
                                    [] targetStorageTypes)
 {
     DataTransferProtos.OpTransferBlockProto proto = ((DataTransferProtos.OpTransferBlockProto
                                                       )DataTransferProtos.OpTransferBlockProto.NewBuilder().SetHeader(DataTransferProtoUtil
                                                                                                                       .BuildClientHeader(blk, clientName, blockToken)).AddAllTargets(PBHelper.Convert(
                                                                                                                                                                                          targets)).AddAllTargetStorageTypes(PBHelper.ConvertStorageTypes(targetStorageTypes
                                                                                                                                                                                                                                                          )).Build());
     Send(@out, OP.TransferBlock, proto);
 }