Beispiel #1
0
        /// <exception cref="System.IO.IOException"/>
        public virtual HeartbeatResponse SendHeartbeat(DatanodeRegistration registration,
                                                       StorageReport[] reports, long cacheCapacity, long cacheUsed, int xmitsInProgress
                                                       , int xceiverCount, int failedVolumes, VolumeFailureSummary volumeFailureSummary
                                                       )
        {
            DatanodeProtocolProtos.HeartbeatRequestProto.Builder builder = DatanodeProtocolProtos.HeartbeatRequestProto
                                                                           .NewBuilder().SetRegistration(PBHelper.Convert(registration)).SetXmitsInProgress
                                                                               (xmitsInProgress).SetXceiverCount(xceiverCount).SetFailedVolumes(failedVolumes);
            builder.AddAllReports(PBHelper.ConvertStorageReports(reports));
            if (cacheCapacity != 0)
            {
                builder.SetCacheCapacity(cacheCapacity);
            }
            if (cacheUsed != 0)
            {
                builder.SetCacheUsed(cacheUsed);
            }
            if (volumeFailureSummary != null)
            {
                builder.SetVolumeFailureSummary(PBHelper.ConvertVolumeFailureSummary(volumeFailureSummary
                                                                                     ));
            }
            DatanodeProtocolProtos.HeartbeatResponseProto resp;
            try
            {
                resp = rpcProxy.SendHeartbeat(NullController, ((DatanodeProtocolProtos.HeartbeatRequestProto
                                                                )builder.Build()));
            }
            catch (ServiceException se)
            {
                throw ProtobufHelper.GetRemoteException(se);
            }
            DatanodeCommand[] cmds = new DatanodeCommand[resp.GetCmdsList().Count];
            int index = 0;

            foreach (DatanodeProtocolProtos.DatanodeCommandProto p in resp.GetCmdsList())
            {
                cmds[index] = PBHelper.Convert(p);
                index++;
            }
            RollingUpgradeStatus rollingUpdateStatus = null;

            // Use v2 semantics if available.
            if (resp.HasRollingUpgradeStatusV2())
            {
                rollingUpdateStatus = PBHelper.Convert(resp.GetRollingUpgradeStatusV2());
            }
            else
            {
                if (resp.HasRollingUpgradeStatus())
                {
                    rollingUpdateStatus = PBHelper.Convert(resp.GetRollingUpgradeStatus());
                }
            }
            return(new HeartbeatResponse(cmds, PBHelper.Convert(resp.GetHaStatus()), rollingUpdateStatus
                                         ));
        }
        /// <exception cref="Com.Google.Protobuf.ServiceException"/>
        public virtual DatanodeProtocolProtos.HeartbeatResponseProto SendHeartbeat(RpcController
                                                                                   controller, DatanodeProtocolProtos.HeartbeatRequestProto request)
        {
            HeartbeatResponse response;

            try
            {
                StorageReport[]      report = PBHelper.ConvertStorageReports(request.GetReportsList());
                VolumeFailureSummary volumeFailureSummary = request.HasVolumeFailureSummary() ? PBHelper
                                                            .ConvertVolumeFailureSummary(request.GetVolumeFailureSummary()) : null;
                response = impl.SendHeartbeat(PBHelper.Convert(request.GetRegistration()), report
                                              , request.GetCacheCapacity(), request.GetCacheUsed(), request.GetXmitsInProgress
                                                  (), request.GetXceiverCount(), request.GetFailedVolumes(), volumeFailureSummary);
            }
            catch (IOException e)
            {
                throw new ServiceException(e);
            }
            DatanodeProtocolProtos.HeartbeatResponseProto.Builder builder = DatanodeProtocolProtos.HeartbeatResponseProto
                                                                            .NewBuilder();
            DatanodeCommand[] cmds = response.GetCommands();
            if (cmds != null)
            {
                for (int i = 0; i < cmds.Length; i++)
                {
                    if (cmds[i] != null)
                    {
                        builder.AddCmds(PBHelper.Convert(cmds[i]));
                    }
                }
            }
            builder.SetHaStatus(PBHelper.Convert(response.GetNameNodeHaState()));
            RollingUpgradeStatus rollingUpdateStatus = response.GetRollingUpdateStatus();

            if (rollingUpdateStatus != null)
            {
                // V2 is always set for newer datanodes.
                // To be compatible with older datanodes, V1 is set to null
                //  if the RU was finalized.
                HdfsProtos.RollingUpgradeStatusProto rus = PBHelper.ConvertRollingUpgradeStatus(rollingUpdateStatus
                                                                                                );
                builder.SetRollingUpgradeStatusV2(rus);
                if (!rollingUpdateStatus.IsFinalized())
                {
                    builder.SetRollingUpgradeStatus(rus);
                }
            }
            return((DatanodeProtocolProtos.HeartbeatResponseProto)builder.Build());
        }