Exemplo n.º 1
0
 /// <exception cref="System.IO.IOException"/>
 public override NMStateStoreService.RecoveredNMTokensState LoadNMTokensState()
 {
     lock (this)
     {
         // return a copy so caller can't modify our state
         NMStateStoreService.RecoveredNMTokensState result = new NMStateStoreService.RecoveredNMTokensState
                                                                 ();
         result.currentMasterKey      = nmTokenState.currentMasterKey;
         result.previousMasterKey     = nmTokenState.previousMasterKey;
         result.applicationMasterKeys = new Dictionary <ApplicationAttemptId, MasterKey>(nmTokenState
                                                                                         .applicationMasterKeys);
         return(result);
     }
 }
Exemplo n.º 2
0
 protected internal override void InitStorage(Configuration conf)
 {
     apps = new Dictionary <ApplicationId, YarnServerNodemanagerRecoveryProtos.ContainerManagerApplicationProto
                            >();
     finishedApps    = new HashSet <ApplicationId>();
     containerStates = new Dictionary <ContainerId, NMStateStoreService.RecoveredContainerState
                                       >();
     nmTokenState = new NMStateStoreService.RecoveredNMTokensState();
     nmTokenState.applicationMasterKeys = new Dictionary <ApplicationAttemptId, MasterKey
                                                          >();
     containerTokenState = new NMStateStoreService.RecoveredContainerTokensState();
     containerTokenState.activeTokens = new Dictionary <ContainerId, long>();
     trackerStates = new Dictionary <NMMemoryStateStoreService.TrackerKey, NMMemoryStateStoreService.TrackerState
                                     >();
     deleteTasks = new Dictionary <int, YarnServerNodemanagerRecoveryProtos.DeletionServiceDeleteTaskProto
                                   >();
     logDeleterState = new Dictionary <ApplicationId, YarnServerNodemanagerRecoveryProtos.LogDeleterProto
                                       >();
 }
Exemplo n.º 3
0
        /// <exception cref="System.IO.IOException"/>
        public override NMStateStoreService.RecoveredNMTokensState LoadNMTokensState()
        {
            NMStateStoreService.RecoveredNMTokensState state = new NMStateStoreService.RecoveredNMTokensState
                                                                   ();
            state.applicationMasterKeys = new Dictionary <ApplicationAttemptId, MasterKey>();
            LeveldbIterator iter = null;

            try
            {
                iter = new LeveldbIterator(db);
                iter.Seek(JniDBFactory.Bytes(NmTokensKeyPrefix));
                while (iter.HasNext())
                {
                    KeyValuePair <byte[], byte[]> entry = iter.Next();
                    string fullKey = JniDBFactory.AsString(entry.Key);
                    if (!fullKey.StartsWith(NmTokensKeyPrefix))
                    {
                        break;
                    }
                    string key = Sharpen.Runtime.Substring(fullKey, NmTokensKeyPrefix.Length);
                    if (key.Equals(CurrentMasterKeySuffix))
                    {
                        state.currentMasterKey = ParseMasterKey(entry.Value);
                    }
                    else
                    {
                        if (key.Equals(PrevMasterKeySuffix))
                        {
                            state.previousMasterKey = ParseMasterKey(entry.Value);
                        }
                        else
                        {
                            if (key.StartsWith(ApplicationAttemptId.appAttemptIdStrPrefix))
                            {
                                ApplicationAttemptId attempt;
                                try
                                {
                                    attempt = ConverterUtils.ToApplicationAttemptId(key);
                                }
                                catch (ArgumentException e)
                                {
                                    throw new IOException("Bad application master key state for " + fullKey, e);
                                }
                                state.applicationMasterKeys[attempt] = ParseMasterKey(entry.Value);
                            }
                        }
                    }
                }
            }
            catch (DBException e)
            {
                throw new IOException(e);
            }
            finally
            {
                if (iter != null)
                {
                    iter.Close();
                }
            }
            return(state);
        }