/// <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());
        }
Example #2
0
        /// <summary>Signal the current rolling upgrade status as indicated by the NN.</summary>
        /// <param name="rollingUpgradeStatus">rolling upgrade status</param>
        /// <exception cref="System.IO.IOException"/>
        internal virtual void SignalRollingUpgrade(RollingUpgradeStatus rollingUpgradeStatus
                                                   )
        {
            if (rollingUpgradeStatus == null)
            {
                return;
            }
            string bpid = GetBlockPoolId();

            if (!rollingUpgradeStatus.IsFinalized())
            {
                dn.GetFSDataset().EnableTrash(bpid);
                dn.GetFSDataset().SetRollingUpgradeMarker(bpid);
            }
            else
            {
                dn.GetFSDataset().ClearTrash(bpid);
                dn.GetFSDataset().ClearRollingUpgradeMarker(bpid);
            }
        }