예제 #1
0
def main(args):
    """
    Command line journal
    """
    primary_journal = None
    kwargs = dict()
    if args.cfg:
        with open(args.cfg) as config:
            jconf = yaml.load(config)
            if 'primary' in jconf:
                primary_journal = jconf['primary']
                jconf.pop('primary')
            kwargs = jconf
    if args.primary:
        primary_journal = args.primary
    if primary_journal is None:
        sys.exit("Missing primary journal")
    (jmodule, jval) = primary_journal.split('://')
    str(jmodule).lower()
    if 'zookeeper' not in jmodule:
        sys.exit("Wrong zookeeper information")
    zkj = zkjournal.ZookeeperJournal(primary_journal, kwargs, args.adminuser)
    zkj.journal_zk_start()
    if zkj.zk.connected:
        zkj.upload_batch(args.batchsize, args.interval)
    sys.exit()
예제 #2
0
def main(args):
    """
    Command line journal
    """
    primary_journal = None
    kwargs = dict()
    if args.cfg:
        with open(args.cfg) as config:
            jconf = yaml.load(config)
            if 'primary' in jconf:
                primary_journal = jconf['primary']
                jconf.pop('primary')
            kwargs = jconf
    if args.primary:
        primary_journal = args.primary
    if primary_journal is None:
        sys.exit("Missing primary journal")
    (jmodule, jval) = primary_journal.split('://')
    str(jmodule).lower()
    if 'zookeeper' not in jmodule:
        sys.exit("Wrong zookeeper information")
    nfsregex_compiled = re.compile(args.nfsregex)
    zkj = zkjournal.ZookeeperJournal(primary_journal, kwargs)
    zkj.journal_zk_start()
    if zkj.zk.connected:
        zkj.dump(args.nfspath, args.interval, args.outfile, nfsregex_compiled)
    sys.exit()
예제 #3
0
 def create_journal(self,
                    jconf,
                    kwargs=None,
                    cachesize=None,
                    adminuser=None):
     """get the name and create obj"""
     (jmodule, jval) = jconf.split('://')
     str(jmodule).lower()
     if jmodule == 'nfs':
         return nfsjournal.NFSJournal(jval)
     if 'zookeeper' in jmodule:
         return zkjournal.ZookeeperJournal(jconf, kwargs, adminuser,
                                           cachesize)
     sys.exit("Unsupported journal type")
예제 #4
0
def start_resync(zkurl, kwargs, journal_nfspath, adminuser=None):
    """
    Start resync with nfs
    """
    zkj = zkjournal.ZookeeperJournal(zkurl, kwargs, adminuser)
    while True:
        try:
            if zkj.zk.connected:
                resync_with_nfs(zkj, journal_nfspath)
            else:
                zkj.journal_zk_start()
        except kazoo.exceptions.SessionExpiredError as err:
            _LOG.exception('Error - %s', err)
        except kazoo.exceptions.KazooException as err:
            _LOG.exception('Error - %s', err)
        except kazoo.handlers.threading.KazooTimeoutError as err:
            _LOG.exception('Error - %s', err)
        time.sleep(60)