Exemplo n.º 1
0
    def testDelete1(self):
        key = "_Delete1"
        c = scalaris.JSONConnection(url=scalaris.DEFAULT_URL)
        rdht = ReplicatedDHT(conn=c)
        sc = scalaris.TransactionSingleOp(conn=c)

        for i in xrange(len(_TEST_DATA)):
            sc.write(str(self._testTime) + key + str(i), _TEST_DATA[i])

        # now try to delete the data:
        for i in xrange(len(_TEST_DATA)):
            ok = rdht.delete(str(self._testTime) + key + str(i))
            self.assertEqual(ok, 4)
            results = rdht.get_last_delete_result()
            self.assertEqual(
                (results.ok, results.locks_set, results.undefined), (4, 0, 0))
            self._checkKeyDoesNotExist(str(self._testTime) + key + str(i))

            # try again (should be successful with 0 deletes)
            ok = rdht.delete(str(self._testTime) + key + str(i))
            self.assertEqual(ok, 0)
            results = rdht.get_last_delete_result()
            self.assertEqual(
                (results.ok, results.locks_set, results.undefined), (0, 0, 4))
            self._checkKeyDoesNotExist(str(self._testTime) + key + str(i))

        c.close()
Exemplo n.º 2
0
 def _checkKeyDoesNotExist(self, key):
     conn = scalaris.TransactionSingleOp()
     try:
         conn.read(key)
         self.fail('the value at ' + key + ' should not exist anymore')
     except scalaris.NotFoundError:
         # nothing to do here
         pass
     conn.close_connection()
Exemplo n.º 3
0
def _transSingleOpBench3(testruns, value, name):
    key = str(_benchTime) + name
    results = []

    for i in xrange(testruns):
        for retry in xrange(3):
            try:
                _testBegin()
                tx = scalaris.TransactionSingleOp()

                for j in xrange(_TRANSACTIONS_PER_TESTRUN):
                    tx.write(key + str(i) + str(j), value)

                tx.close_connection()
                results.append(_testEnd(_TRANSACTIONS_PER_TESTRUN))
                break
            except:
                # _printException()
                if (retry == 2):
                    return -1
    return _getAvgSpeed(results)
Exemplo n.º 4
0
 def init(self):
     self._tx = scalaris.TransactionSingleOp(conn = _getConnection())
Exemplo n.º 5
0
 def operation(self, j):
     tx = scalaris.TransactionSingleOp(conn = self._connection)
     tx.write(self._key + '_' + str(j), self._value)
    if (sys.argv[1] == "read"):
        basekey = sys.argv[2]
        language = sys.argv[3]
        basekey += '_' + language
        mode = 'read'
        print 'Python-JSON-API: reading from ' + language
    elif (sys.argv[1] == "write"):
        basekey = sys.argv[2]
        basekey += '_json_python'
        mode = 'write'
        print 'Python-JSON-API: writing values'
    else:
        print 'unknown commands: ' + str(sys.argv)
        sys.exit(1)

    sc = scalaris.TransactionSingleOp()

    failed = 0
    failed += read_write_boolean(basekey, sc, mode)
    failed += read_write_integer(basekey, sc, mode)
    failed += read_write_long(basekey, sc, mode)
    failed += read_write_biginteger(basekey, sc, mode)
    failed += read_write_double(basekey, sc, mode)
    failed += read_write_string(basekey, sc, mode)
    failed += read_write_binary(basekey, sc, mode)
    failed += read_write_list(basekey, sc, mode)
    failed += read_write_map(basekey, sc, mode)
    print ''

    if (failed > 0):
        print str(failed) + ' number of ' + mode + 's failed.'