Exemplo n.º 1
0
# stdlib
import logging
from datetime import datetime, timedelta
from time import sleep

# Bunch
from bunch import Bunch

# Zato
from zato.common import ENSURE_SINGLETON_JOB
from zato.common.broker_message import MESSAGE_TYPE, SCHEDULER, SINGLETON
from zato.server.base import BrokerMessageReceiver
from zato.server.scheduler import Scheduler

_accepted_messages = SCHEDULER.values() + SINGLETON.values()


class SingletonServer(BrokerMessageReceiver):
    """ A server of which one instance only may be running in a Zato container.
    Holds and processes data which can't be made parallel, such as scheduler,
    hot-deployment or on-disk configuration management.
    """
    def __init__(self,
                 parallel_server=None,
                 server_id=None,
                 scheduler=None,
                 broker_client=None,
                 initial_sleep_time=None,
                 is_cluster_wide=False):
        self.parallel_server = parallel_server
Exemplo n.º 2
0
# stdlib
import logging
from datetime import datetime, timedelta
from time import sleep

# Bunch
from zato.bunch import Bunch

# Zato
from zato.common import ENSURE_SINGLETON_JOB
from zato.common.broker_message import MESSAGE_TYPE, SCHEDULER, SINGLETON
from zato.common.util import add_scheduler_jobs, invoke_startup_services
from zato.server.base import BrokerMessageReceiver
from zato.server.scheduler import Scheduler

_accepted_messages = SCHEDULER.values() + SINGLETON.values()

class SingletonServer(BrokerMessageReceiver):
    """ A server of which one instance only may be running in a Zato container.
    Holds and processes data which can't be made parallel, such as scheduler,
    hot-deployment or on-disk configuration management.
    """
    def __init__(self, parallel_server=None, server_id=None, scheduler=None,
                 broker_client=None, initial_sleep_time=None, is_cluster_wide=False):
        self.parallel_server = parallel_server
        self.server_id = server_id
        self.scheduler = scheduler or Scheduler(self)
        self.broker_client = broker_client
        self.initial_sleep_time = initial_sleep_time
        self.is_cluster_wide = is_cluster_wide
        self.logger = logging.getLogger('zato_singleton')