def connect(self, doozerd_server_address):
     """
         Connect to a given doozer cluster
     """
     #noinspection PyUnresolvedReferences
     self.client = doozer.connect(doozerd_server_address)
     self.revision = self.client.rev().rev
Esempio n. 2
0
def test_doozerdata():
    client = doozer.connect()
    d = DoozerData(client, callback=print_change)
    d.set('foo1', 'bar1')
    d.set('foo2', 'bar2')
    d.set('foo3', 'bar3')
    #create a second client

    client2 = doozer.connect()
    d2 = DoozerData(client2, callback=print_change)
    d2.set('foo4', 'bar4')
    #let the second client change values to
    #those should be printed.
    cv = gevent.spawn(change_value, d2)

    for path, rev, value in d.items():
        print path, '->', value

    print d.get('foo1')
    print d.get('foo2')

    d.delete_all()

    #should be empty.
    for di in d.items():
        print di

    #the change value function added content over time..
    gevent.sleep(3)
    print 'data in d1'
    for di in d.items():
        print di
    print 'data in d2'
    for dii in d2.items():
        print dii
        # there is content. in both instances.
    # because the change_value job adds data later.
    cv.join(cv)
Esempio n. 3
0
import os
import sys
sys.path.append(os.path.dirname(__file__) + "/..")

import gevent
from gevent import Timeout

from pydoozer import doozer


client = doozer.connect()
rev = client.rev().rev


def watch_test(rev):
    while True:
        try:
            change = client.wait("/watch", rev)
            print change.rev, change.value
            rev = change.rev + 1
        except Timeout, t:
            print t
            rev = client.rev().rev
            #noinspection PyUnusedLocal
            change = None

watch_job = gevent.spawn(watch_test, rev + 1)

for i in range(10):
    gevent.sleep(1)
    rev = client.set("/watch", "test4%d" % i, rev).rev