Beispiel #1
0
def read():
    c = StoreClient('test', [('n1', 6666)])
    missing = []
    for k in range(1, 501):
        val = c.get(str(k))
        if not val:
            #print k
            missing.append(k)
    return missing
Beispiel #2
0
def write():
    c = StoreClient('test', [('n1', 6666)])
    for k in range(1, 2001, 5):
        try:
            c.put(str(k), str(datetime.datetime.now()));
        except VoldemortException:
            print "Exception caught, retry..."
            sleep(15)
    return True
Beispiel #3
0
def read():
    c = StoreClient('test', [('n2', 6668)])
    missing = []
    for k in range(1, 2001):
        try:
            val = c.get(str(k))
            if not val:
            #print k
                missing.append(k)
        except VoldemortEcxeption:
            #print "Ecxeption caught, retry..."
            sleep(1)
    return missing
Beispiel #4
0
    def test_missing_store(self):
        """
        Tests that we get an exception when we try to get a non-existent store.
        """

        try:
            s = StoreClient('does-not-exist', [('localhost', 6666)])
        except VoldemortException:
            self.assertTrue(True)
            return

        self.assertTrue(False)
Beispiel #5
0
class DarkMaster(object):
	def __init__(self, db_user, db_passwd, db_store, db_hosts):
		"""Description: Init method for the database connection manager
			:param db_user: The username for the database
			:type str:

			:param db_passwd: Password
			:type str:

			:param db_store: The name of the store you need to connect to
			:type str:

			:param db_hosts: A list of db hosts and the ports they run the database on
			:type list: List of host/port tuples like this:
				[('127.0.0.1', '6666'), ('192.168.100.105', '6666')]
			"""
		self.db_user = db_user
		self.db_passwd = db_passwd
		self.db_store = db_store
		self.db_hosts = db_hosts
		self._store = None

	@property
	def store(self):
		if self._store is None:
			self._connect()
		return self._store

	def _connect(self):
		self._store = StoreClient(self.db_store, self.db_hosts)

	def get_object(self, id):
		return self.store.get(id)

	def delete(self, id):
		self.store.delete(id)
		return True

	def all(self):
		self._store.get_all()
Beispiel #6
0
 def _reinit_json_client(self):
     s = StoreClient('json_test', [('localhost', 6666)])
     for k in [1, 2, 3]:
         s.delete(k)
     return s
Beispiel #7
0
 def _reinit_raw_client(self):
     s = StoreClient('test', [('localhost', 6666)])
     for k in ['a', 'b', 'c']:
         s.delete(k)
     return s
Beispiel #8
0
def write():
    c = StoreClient('test', [('n1', 6666)])
    for k in range(1, 501, 5):
        c.put(str(k), str(datetime.datetime.now()));
    return True
Beispiel #9
0
	def _connect(self):
		self._store = StoreClient(self.db_store, self.db_hosts)
Beispiel #10
0
import logging
import time
from voldemort import StoreClient

if __name__ == '__main__':
	
	logging.basicConfig(level=logging.INFO,)
	
	## some random tests
	s = StoreClient('test', [('localhost', 6666)])
	version = s.put("hello", "1")
	assert s.get("hello")[0][0] == "1"
	s.put("hello", "2", version)
	assert s.get("hello")[0][0] == "2"
	s.put("hello", "3")
	assert s.get("hello")[0][0] == "3"
	s.delete("hello")
	assert len(s.get("hello")) == 0
	
	## test get_all
	pairs = [("a1", "1"), ("a2", "2"), ("a3", "3"), ("a4", "4")]
	for k, v in pairs:
		s.put(k, v)
		
	vals = s.get_all([k for k, v in pairs])
	for k, v in pairs:
		assert vals[k][0][0] == v 
	
	requests = 10000
	
	## Time get requests
Beispiel #11
0
def dele():
    c = StoreClient('test', [('n1', 6666)])
    for k in range(1, 2001):
        c.delete(str(k))