Merge "Introduce engine states"

This commit is contained in:
Jenkins 2014-06-18 22:30:16 +00:00 committed by Gerrit Code Review
commit 991550b1f6
2 changed files with 30 additions and 0 deletions

View File

@ -31,6 +31,7 @@ import six
from stevedore import driver from stevedore import driver
from entropy import exceptions from entropy import exceptions
from entropy import states
from entropy import utils from entropy import utils
import imp import imp
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -80,6 +81,9 @@ class Engine(object):
# Serializer related variables # Serializer related variables
self._serializer = None self._serializer = None
# State related variables
self._state = states.ENABLED
LOG.info('Created engine obj %s', self.name) LOG.info('Created engine obj %s', self.name)
# TODO(praneshp): Move to utils? # TODO(praneshp): Move to utils?
@ -196,6 +200,7 @@ class Engine(object):
new_additions.append({'time': next_call, 'name': key}) new_additions.append({'time': next_call, 'name': key})
new_additions.sort(key=operator.itemgetter('time')) new_additions.sort(key=operator.itemgetter('time'))
self.run_queue.extend(new_additions) self.run_queue.extend(new_additions)
LOG.info("Run queue till %s is %s", next_iteration, self.run_queue) LOG.info("Run queue till %s is %s", next_iteration, self.run_queue)
LOG.info("Repair scripts at %s: %s", next_iteration, self._repairs) LOG.info("Repair scripts at %s: %s", next_iteration, self._repairs)
@ -209,7 +214,12 @@ class Engine(object):
self.stop_engine() self.stop_engine()
def stop_engine(self): def stop_engine(self):
LOG.info("Stopping engine %s", self.name)
# Set state to stop, which will stop serializers
LOG.info("Setting %s to state: %s", self.name, states.DISABLED)
self._state = states.DISABLED
# Stop watchdog monitoring # Stop watchdog monitoring
LOG.info("Stopping watchdog for %s", self.name)
self._watchdog_thread.stop() self._watchdog_thread.stop()
def repair_modified(self): def repair_modified(self):

20
entropy/states.py Normal file
View File

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2012-2013 Yahoo! Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# Job states.
ENABLED = 'CLAIMED'
DISABLED = 'COMPLETE'