/// <exception cref="System.IO.IOException"/> public override NMStateStoreService.RecoveredApplicationsState LoadApplicationsState () { NMStateStoreService.RecoveredApplicationsState state = new NMStateStoreService.RecoveredApplicationsState (); state.applications = new AList <YarnServerNodemanagerRecoveryProtos.ContainerManagerApplicationProto >(); string keyPrefix = ApplicationsKeyPrefix; LeveldbIterator iter = null; try { iter = new LeveldbIterator(db); iter.Seek(JniDBFactory.Bytes(keyPrefix)); while (iter.HasNext()) { KeyValuePair <byte[], byte[]> entry = iter.Next(); string key = JniDBFactory.AsString(entry.Key); if (!key.StartsWith(keyPrefix)) { break; } state.applications.AddItem(YarnServerNodemanagerRecoveryProtos.ContainerManagerApplicationProto .ParseFrom(entry.Value)); } state.finishedApplications = new AList <ApplicationId>(); keyPrefix = FinishedAppsKeyPrefix; iter.Seek(JniDBFactory.Bytes(keyPrefix)); while (iter.HasNext()) { KeyValuePair <byte[], byte[]> entry = iter.Next(); string key = JniDBFactory.AsString(entry.Key); if (!key.StartsWith(keyPrefix)) { break; } ApplicationId appId = ConverterUtils.ToApplicationId(Sharpen.Runtime.Substring(key , keyPrefix.Length)); state.finishedApplications.AddItem(appId); } } catch (DBException e) { throw new IOException(e); } finally { if (iter != null) { iter.Close(); } } return(state); }
/// <exception cref="System.IO.IOException"/> public override NMStateStoreService.RecoveredApplicationsState LoadApplicationsState () { lock (this) { NMStateStoreService.RecoveredApplicationsState state = new NMStateStoreService.RecoveredApplicationsState (); state.applications = new AList <YarnServerNodemanagerRecoveryProtos.ContainerManagerApplicationProto >(apps.Values); state.finishedApplications = new AList <ApplicationId>(finishedApps); return(state); } }