Example #1
0
 GetReconfigurationStatus(RpcController unused, ClientDatanodeProtocolProtos.GetReconfigurationStatusRequestProto
                          request)
 {
     ClientDatanodeProtocolProtos.GetReconfigurationStatusResponseProto.Builder builder
         = ClientDatanodeProtocolProtos.GetReconfigurationStatusResponseProto.NewBuilder
               ();
     try
     {
         ReconfigurationTaskStatus status = impl.GetReconfigurationStatus();
         builder.SetStartTime(status.GetStartTime());
         if (status.Stopped())
         {
             builder.SetEndTime(status.GetEndTime());
             System.Diagnostics.Debug.Assert(status.GetStatus() != null);
             foreach (KeyValuePair <ReconfigurationUtil.PropertyChange, Optional <string> > result
                      in status.GetStatus())
             {
                 ClientDatanodeProtocolProtos.GetReconfigurationStatusConfigChangeProto.Builder changeBuilder
                     = ClientDatanodeProtocolProtos.GetReconfigurationStatusConfigChangeProto.NewBuilder
                           ();
                 ReconfigurationUtil.PropertyChange change = result.Key;
                 changeBuilder.SetName(change.prop);
                 changeBuilder.SetOldValue(change.oldVal != null ? change.oldVal : string.Empty);
                 if (change.newVal != null)
                 {
                     changeBuilder.SetNewValue(change.newVal);
                 }
                 if (result.Value.IsPresent())
                 {
                     // Get full stack trace.
                     changeBuilder.SetErrorMessage(result.Value.Get());
                 }
                 builder.AddChanges(changeBuilder);
             }
         }
     }
     catch (IOException e)
     {
         throw new ServiceException(e);
     }
     return((ClientDatanodeProtocolProtos.GetReconfigurationStatusResponseProto)builder
            .Build());
 }
Example #2
0
        /// <exception cref="System.IO.IOException"/>
        public virtual ReconfigurationTaskStatus GetReconfigurationStatus()
        {
            ClientDatanodeProtocolProtos.GetReconfigurationStatusResponseProto   response;
            IDictionary <ReconfigurationUtil.PropertyChange, Optional <string> > statusMap = null;
            long startTime;
            long endTime = 0;

            try
            {
                response = rpcProxy.GetReconfigurationStatus(NullController, VoidGetReconfigStatus
                                                             );
                startTime = response.GetStartTime();
                if (response.HasEndTime())
                {
                    endTime = response.GetEndTime();
                }
                if (response.GetChangesCount() > 0)
                {
                    statusMap = Maps.NewHashMap();
                    foreach (ClientDatanodeProtocolProtos.GetReconfigurationStatusConfigChangeProto change
                             in response.GetChangesList())
                    {
                        ReconfigurationUtil.PropertyChange pc = new ReconfigurationUtil.PropertyChange(change
                                                                                                       .GetName(), change.GetNewValue(), change.GetOldValue());
                        string errorMessage = null;
                        if (change.HasErrorMessage())
                        {
                            errorMessage = change.GetErrorMessage();
                        }
                        statusMap[pc] = Optional.FromNullable(errorMessage);
                    }
                }
            }
            catch (ServiceException e)
            {
                throw ProtobufHelper.GetRemoteException(e);
            }
            return(new ReconfigurationTaskStatus(startTime, endTime, statusMap));
        }