-
Notifications
You must be signed in to change notification settings - Fork 390
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement proper status reporting in nodemgr by events on Windows
Reporting by events was missing so I had to add some new code to windows_process_manager.py. Also I wanted to reuse some code from docker_process_manager.py so I moved it to common_process_manager.py Change-Id: If191e8cfd6ca18fd8b4899c7bcaa259d6950d628 Partial-Bug: #1783539
- Loading branch information
Michal Clapinski
committed
Aug 3, 2018
1 parent
9d26794
commit fae95d2
Showing
5 changed files
with
65 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# | ||
# Copyright (c) 2018 Juniper Networks, Inc. All rights reserved. | ||
# | ||
|
||
def dummy_process_info(name): | ||
info = dict() | ||
info['name'] = name | ||
info['group'] = name | ||
info['pid'] = 0 | ||
info['statename'] = 'PROCESS_STATE_EXITED' | ||
info['expected'] = -1 | ||
return info | ||
|
||
|
||
def convert_to_pi_event(info): | ||
pi_event = info.copy() | ||
pi_event['state'] = pi_event.pop('statename') | ||
if 'start' in pi_event: | ||
del pi_event['start'] | ||
return pi_event | ||
|
||
class ProcessInfoCache(object): | ||
def __init__(self): | ||
self._cached_process_infos = {} | ||
|
||
def update_cache(self, info): | ||
name = info['name'] | ||
cached_info = self._cached_process_infos.get(name) | ||
if cached_info is None: | ||
self._cached_process_infos[name] = info | ||
return True | ||
if info['name'] != cached_info['name'] or \ | ||
info['group'] != cached_info['group'] or \ | ||
info['pid'] != cached_info['pid'] or \ | ||
info['statename'] != cached_info['statename']: | ||
self._cached_process_infos[name] = info | ||
return True | ||
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters