Removed usage of update time concept
Fixes bug 1201445 Change-Id: Ie9eff190cc680873eaaf64474e0382910257b66c
This commit is contained in:
parent
90d6e1cd43
commit
e6b0ef52af
@ -13,15 +13,11 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import time
|
|
||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
import psutil
|
import psutil
|
||||||
from psutil import _error
|
from psutil import _error
|
||||||
import sh
|
|
||||||
|
|
||||||
from stackalytics.openstack.common import log as logging
|
from stackalytics.openstack.common import log as logging
|
||||||
from stackalytics.openstack.common import timeutils
|
|
||||||
from stackalytics.processor import commit_processor
|
from stackalytics.processor import commit_processor
|
||||||
from stackalytics.processor import persistent_storage
|
from stackalytics.processor import persistent_storage
|
||||||
from stackalytics.processor import runtime_storage
|
from stackalytics.processor import runtime_storage
|
||||||
@ -37,11 +33,6 @@ OPTS = [
|
|||||||
help='The folder that holds all project sources to analyze'),
|
help='The folder that holds all project sources to analyze'),
|
||||||
cfg.StrOpt('runtime-storage-uri', default='memcached://127.0.0.1:11211',
|
cfg.StrOpt('runtime-storage-uri', default='memcached://127.0.0.1:11211',
|
||||||
help='Storage URI'),
|
help='Storage URI'),
|
||||||
cfg.StrOpt('frontend-update-address',
|
|
||||||
default='http://user:user@localhost/update/%s',
|
|
||||||
help='Address of update handler'),
|
|
||||||
cfg.StrOpt('repo-poll-period', default='300',
|
|
||||||
help='Repo poll period in seconds'),
|
|
||||||
cfg.StrOpt('persistent-storage-uri', default='mongodb://localhost',
|
cfg.StrOpt('persistent-storage-uri', default='mongodb://localhost',
|
||||||
help='URI of persistent storage'),
|
help='URI of persistent storage'),
|
||||||
cfg.BoolOpt('sync-default-data', default=False,
|
cfg.BoolOpt('sync-default-data', default=False,
|
||||||
@ -76,21 +67,11 @@ def get_pids():
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def update_pid(pid):
|
|
||||||
url = cfg.CONF.frontend_update_address % pid
|
|
||||||
sh.curl(url)
|
|
||||||
|
|
||||||
|
|
||||||
def update_pids(runtime_storage):
|
def update_pids(runtime_storage):
|
||||||
pids = get_pids()
|
pids = get_pids()
|
||||||
if not pids:
|
if not pids:
|
||||||
return
|
return
|
||||||
runtime_storage.active_pids(pids)
|
runtime_storage.active_pids(pids)
|
||||||
current_time = time.time()
|
|
||||||
for pid in pids:
|
|
||||||
if current_time > runtime_storage.get_pid_update_time(pid):
|
|
||||||
update_pid(pid)
|
|
||||||
return current_time
|
|
||||||
|
|
||||||
|
|
||||||
def process_repo(repo, runtime_storage, processor):
|
def process_repo(repo, runtime_storage, processor):
|
||||||
@ -114,14 +95,6 @@ def process_repo(repo, runtime_storage, processor):
|
|||||||
|
|
||||||
|
|
||||||
def update_repos(runtime_storage, persistent_storage):
|
def update_repos(runtime_storage, persistent_storage):
|
||||||
current_time = time.time()
|
|
||||||
repo_update_time = runtime_storage.get_repo_update_time()
|
|
||||||
|
|
||||||
if current_time < repo_update_time:
|
|
||||||
LOG.info('The next update is scheduled at %s. Skipping' %
|
|
||||||
timeutils.iso8601_from_timestamp(repo_update_time))
|
|
||||||
return
|
|
||||||
|
|
||||||
repos = persistent_storage.get_repos()
|
repos = persistent_storage.get_repos()
|
||||||
processor = commit_processor.CommitProcessorFactory.get_processor(
|
processor = commit_processor.CommitProcessorFactory.get_processor(
|
||||||
commit_processor.COMMIT_PROCESSOR_CACHED,
|
commit_processor.COMMIT_PROCESSOR_CACHED,
|
||||||
@ -130,9 +103,6 @@ def update_repos(runtime_storage, persistent_storage):
|
|||||||
for repo in repos:
|
for repo in repos:
|
||||||
process_repo(repo, runtime_storage, processor)
|
process_repo(repo, runtime_storage, processor)
|
||||||
|
|
||||||
runtime_storage.set_repo_update_time(time.time() +
|
|
||||||
int(cfg.CONF.repo_poll_period))
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
# init conf and logging
|
# init conf and logging
|
||||||
|
@ -47,18 +47,6 @@ class RuntimeStorage(object):
|
|||||||
def active_pids(self, pids):
|
def active_pids(self, pids):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def get_pid_update_time(self, pid):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def set_pid_update_time(self, pid, time):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def get_repo_update_time(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def set_repo_update_time(self, time):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class MemcachedStorage(RuntimeStorage):
|
class MemcachedStorage(RuntimeStorage):
|
||||||
|
|
||||||
@ -126,7 +114,6 @@ class MemcachedStorage(RuntimeStorage):
|
|||||||
for pid in stored_pids:
|
for pid in stored_pids:
|
||||||
if pid not in pids:
|
if pid not in pids:
|
||||||
self.memcached.delete('pid:%s' % pid)
|
self.memcached.delete('pid:%s' % pid)
|
||||||
self.memcached.delete('pid_update_time:%s' % pid)
|
|
||||||
|
|
||||||
self.memcached.set('pids', pids)
|
self.memcached.set('pids', pids)
|
||||||
|
|
||||||
@ -147,18 +134,6 @@ class MemcachedStorage(RuntimeStorage):
|
|||||||
|
|
||||||
self.memcached.set('first_valid_update_id', min_update)
|
self.memcached.set('first_valid_update_id', min_update)
|
||||||
|
|
||||||
def get_pid_update_time(self, pid):
|
|
||||||
return self.memcached.get('pid_update_time:%s' % pid) or 0
|
|
||||||
|
|
||||||
def set_pid_update_time(self, pid, time):
|
|
||||||
self.memcached.set('pid_update_time:%s' % pid, time)
|
|
||||||
|
|
||||||
def get_repo_update_time(self):
|
|
||||||
return self.memcached.get('repo_update_time') or 0
|
|
||||||
|
|
||||||
def set_repo_update_time(self, time):
|
|
||||||
self.memcached.set('repo_update_time', time)
|
|
||||||
|
|
||||||
def _get_update_count(self):
|
def _get_update_count(self):
|
||||||
return self.memcached.get('update:count') or 0
|
return self.memcached.get('update:count') or 0
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user