/// <exception cref="System.IO.IOException"/> public override NMStateStoreService.RecoveredLogDeleterState LoadLogDeleterState( ) { lock (this) { NMStateStoreService.RecoveredLogDeleterState state = new NMStateStoreService.RecoveredLogDeleterState (); state.logDeleterMap = new Dictionary <ApplicationId, YarnServerNodemanagerRecoveryProtos.LogDeleterProto >(logDeleterState); return(state); } }
/// <exception cref="System.IO.IOException"/> public override NMStateStoreService.RecoveredLogDeleterState LoadLogDeleterState( ) { NMStateStoreService.RecoveredLogDeleterState state = new NMStateStoreService.RecoveredLogDeleterState (); state.logDeleterMap = new Dictionary <ApplicationId, YarnServerNodemanagerRecoveryProtos.LogDeleterProto >(); LeveldbIterator iter = null; try { iter = new LeveldbIterator(db); iter.Seek(JniDBFactory.Bytes(LogDeleterKeyPrefix)); int logDeleterKeyPrefixLength = LogDeleterKeyPrefix.Length; while (iter.HasNext()) { KeyValuePair <byte[], byte[]> entry = iter.Next(); string fullKey = JniDBFactory.AsString(entry.Key); if (!fullKey.StartsWith(LogDeleterKeyPrefix)) { break; } string appIdStr = Sharpen.Runtime.Substring(fullKey, logDeleterKeyPrefixLength); ApplicationId appId = null; try { appId = ConverterUtils.ToApplicationId(appIdStr); } catch (ArgumentException) { Log.Warn("Skipping unknown log deleter key " + fullKey); continue; } YarnServerNodemanagerRecoveryProtos.LogDeleterProto proto = YarnServerNodemanagerRecoveryProtos.LogDeleterProto .ParseFrom(entry.Value); state.logDeleterMap[appId] = proto; } } catch (DBException e) { throw new IOException(e); } finally { if (iter != null) { iter.Close(); } } return(state); }