/// <exception cref="System.IO.IOException"/> public override NMStateStoreService.RecoveredContainerTokensState LoadContainerTokensState () { NMStateStoreService.RecoveredContainerTokensState state = new NMStateStoreService.RecoveredContainerTokensState (); state.activeTokens = new Dictionary <ContainerId, long>(); LeveldbIterator iter = null; try { iter = new LeveldbIterator(db); iter.Seek(JniDBFactory.Bytes(ContainerTokensKeyPrefix)); int containerTokensKeyPrefixLength = ContainerTokensKeyPrefix.Length; while (iter.HasNext()) { KeyValuePair <byte[], byte[]> entry = iter.Next(); string fullKey = JniDBFactory.AsString(entry.Key); if (!fullKey.StartsWith(ContainerTokensKeyPrefix)) { break; } string key = Sharpen.Runtime.Substring(fullKey, containerTokensKeyPrefixLength); if (key.Equals(CurrentMasterKeySuffix)) { state.currentMasterKey = ParseMasterKey(entry.Value); } else { if (key.Equals(PrevMasterKeySuffix)) { state.previousMasterKey = ParseMasterKey(entry.Value); } else { if (key.StartsWith(ConverterUtils.ContainerPrefix)) { LoadContainerToken(state, fullKey, key, entry.Value); } } } } } catch (DBException e) { throw new IOException(e); } finally { if (iter != null) { iter.Close(); } } return(state); }
/// <exception cref="System.IO.IOException"/> public override NMStateStoreService.RecoveredContainerTokensState LoadContainerTokensState () { lock (this) { // return a copy so caller can't modify our state NMStateStoreService.RecoveredContainerTokensState result = new NMStateStoreService.RecoveredContainerTokensState (); result.currentMasterKey = containerTokenState.currentMasterKey; result.previousMasterKey = containerTokenState.previousMasterKey; result.activeTokens = new Dictionary <ContainerId, long>(containerTokenState.activeTokens ); return(result); } }
/// <exception cref="System.IO.IOException"/> private static void LoadContainerToken(NMStateStoreService.RecoveredContainerTokensState state, string key, string containerIdStr, byte[] value) { ContainerId containerId; long expTime; try { containerId = ConverterUtils.ToContainerId(containerIdStr); expTime = long.Parse(JniDBFactory.AsString(value)); } catch (ArgumentException e) { throw new IOException("Bad container token state for " + key, e); } state.activeTokens[containerId] = expTime; }
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 >(); }