Пример #1
0
 public override void StartResourceLocalization(string user, ApplicationId appId,
                                                YarnProtos.LocalResourceProto proto, Path localPath)
 {
     lock (this)
     {
         NMMemoryStateStoreService.TrackerState ts = GetTrackerState(new NMMemoryStateStoreService.TrackerKey
                                                                         (user, appId));
         ts.inProgressMap[localPath] = proto;
     }
 }
Пример #2
0
 private NMMemoryStateStoreService.TrackerState GetTrackerState(NMMemoryStateStoreService.TrackerKey
                                                                key)
 {
     NMMemoryStateStoreService.TrackerState ts = trackerStates[key];
     if (ts == null)
     {
         ts = new NMMemoryStateStoreService.TrackerState();
         trackerStates[key] = ts;
     }
     return(ts);
 }
Пример #3
0
 public override void FinishResourceLocalization(string user, ApplicationId appId,
                                                 YarnServerNodemanagerRecoveryProtos.LocalizedResourceProto proto)
 {
     lock (this)
     {
         NMMemoryStateStoreService.TrackerState ts = GetTrackerState(new NMMemoryStateStoreService.TrackerKey
                                                                         (user, appId));
         Path localPath = new Path(proto.GetLocalPath());
         Sharpen.Collections.Remove(ts.inProgressMap, localPath);
         ts.localizedResources[localPath] = proto;
     }
 }
Пример #4
0
 private NMStateStoreService.LocalResourceTrackerState LoadTrackerState(NMMemoryStateStoreService.TrackerState
                                                                        ts)
 {
     NMStateStoreService.LocalResourceTrackerState result = new NMStateStoreService.LocalResourceTrackerState
                                                                ();
     Sharpen.Collections.AddAll(result.localizedResources, ts.localizedResources.Values
                                );
     foreach (KeyValuePair <Path, YarnProtos.LocalResourceProto> entry in ts.inProgressMap)
     {
         result.inProgressResources[entry.Value] = entry.Key;
     }
     return(result);
 }
Пример #5
0
 public override void RemoveLocalizedResource(string user, ApplicationId appId, Path
                                              localPath)
 {
     lock (this)
     {
         NMMemoryStateStoreService.TrackerState ts = trackerStates[new NMMemoryStateStoreService.TrackerKey
                                                                       (user, appId)];
         if (ts != null)
         {
             Sharpen.Collections.Remove(ts.inProgressMap, localPath);
             Sharpen.Collections.Remove(ts.localizedResources, localPath);
         }
     }
 }
Пример #6
0
 public override NMStateStoreService.RecoveredLocalizationState LoadLocalizationState
     ()
 {
     lock (this)
     {
         NMStateStoreService.RecoveredLocalizationState result = new NMStateStoreService.RecoveredLocalizationState
                                                                     ();
         foreach (KeyValuePair <NMMemoryStateStoreService.TrackerKey, NMMemoryStateStoreService.TrackerState
                                > e in trackerStates)
         {
             NMMemoryStateStoreService.TrackerKey   tk = e.Key;
             NMMemoryStateStoreService.TrackerState ts = e.Value;
             // check what kind of tracker state we have and recover appropriately
             // public trackers have user == null
             // private trackers have a valid user but appId == null
             // app-specific trackers have a valid user and valid appId
             if (tk.user == null)
             {
                 result.publicTrackerState = LoadTrackerState(ts);
             }
             else
             {
                 NMStateStoreService.RecoveredUserResources rur = result.userResources[tk.user];
                 if (rur == null)
                 {
                     rur = new NMStateStoreService.RecoveredUserResources();
                     result.userResources[tk.user] = rur;
                 }
                 if (tk.appId == null)
                 {
                     rur.privateTrackerState = LoadTrackerState(ts);
                 }
                 else
                 {
                     rur.appTrackerStates[tk.appId] = LoadTrackerState(ts);
                 }
             }
         }
         return(result);
     }
 }