def UI(args):
	global url
	# if len(args)>1:
	# 	get_url(args[1])
	# else:
	# 	get_url()
	url = args[1]
	con = client.kv739_init(url)
	if con==-1:
		print "Connection refused!"
		exit(0);
	else:
		print "Connection successful!"


	while(1):
		cmd = raw_input("cmd: [G]et/[P]ut/[Q]uit/[D]elete: ")
		if cmd.upper() == 'G':
			key = raw_input( "Key: " )
			print "Key:", key 
                        t1=time.time()
			r, val = client.kv739_get(key)
                        t2=time.time()
                        print "Time:{0:.6f}".format(t2-t1)
			print "Code:", r
			print "Value:", val
		elif cmd.upper() == 'P':
			key = raw_input( "Key: " )
			print "Values:",
			value = sys.stdin.readline().strip()
                        t1=now()
			ret, o_val = client.kv739_put(key, value)
                        t2=now()
                        print("Time:",str(float(t2)-float(t1)))
			if ret not in [0,1,-1]:
				print "Wrong return value:", ret
			elif ret == 0:
				print "Updated Key\nKey:", key 
				print "Old Value:", o_val
				print "New Value:", value
			else:
				print "Inserted Key\nKey:", key 
				print "New Value:", value
		elif cmd.upper() == 'D':
			key = raw_input( "Key: " )
			print "Key:", key 
                        t1=now()
			ret, o_val = client.kv739_delete(key)
                        t2=now()
                        print("Time:",str(float(t2)-float(t1)))
			# delete the shit
			print "Code:", ret
			if ret == 200:
				print "O_Val:", o_val
		elif cmd.upper() == 'Q':
			print 
			exit(0)
import client
import os


if __name__ == '__main__':
	print 'Assuming Server is Down'
	print 'Return Code = '+str(client.kv739_init('adg-desktop-07.cs.wisc.edu:8081'))
	print ' PUT Request with key=arko and value=is bored'
        print '(Return Code , Old_Value) = '+ str(client.kv739_put('arko','is bored'))
	print 'Turning Server Back On'
	print 'Return Code = '+str(client.kv739_init('adg-desktop-07.cs.wisc.edu:8080'))
	print ' PUT Request with key=arko and value=is bored'
	print '(Return Code , Old_Value) = '+str(client.kv739_put('arko','is bored'))
	print ' PUT Request with key=arko and value=will be bored'
        print '(Return Code , Old_Value) = '+str(client.kv739_put('arko','will be bored'))
	print ' GET Request with key=arko '
	print '(Return Code , Value) = '+str(client.kv739_get('arko'))
	print ' DELETE Request with key=arko'
	print '(Return Code , Value ) = '+str(client.kv739_delete('arko'))
	print ' GET Request with key=arko '
	print '(Return Code , Value ) = '+str(client.kv739_get('arko'))

	print ' Checking for incorrect string format error cases '
	print ' PUT Request with key=[arko] and value=is bored'
        print '(Return Code , Old_Value) = '+ str(client.kv739_put('[arko]','is bored'))
	print ' PUT Request with key=arko and value=[is bored]'
        print '(Return Code , Old_Value) = '+ str(client.kv739_put('arko','[is bored]'))
	print ' PUT Request with key= and value=is bored'
        print '(Return Code , Old_Value) = '+ str(client.kv739_put('','is bored'))
	print ' PUT Request with key=arko and value='
        print '(Return Code , Old_Value) = '+ str(client.kv739_put('arko',''))
Example #3
0
		time_dt = time_diff.microseconds
		total_diff = total_diff + time_dt
		if time_min == None:
			time_min = time_dt
			time_max = time_dt
		elif time_dt < time_min:
			time_min = time_dt
		elif time_dt > time_max:
			time_max = time_dt
	client_tput = (N*1000000.)/total_diff
	time_avg =	float(total_diff)/N
	print 'req/s,', str(client_tput)
	print 'kb/s,', str(client_tput * value_size / (1024.))
	print 'avgDelay,', str(time_avg)
	print 'maxDelay,', str(time_max)
	print 'minDelay,', str(time_min)

if __name__ == '__main__':
	if len(sys.argv) < 2 or client.kv739_init(sys.argv[1]) == -1:
		print 'Please provide server <host:port>'
		sys.exit()
	for (k,v) in [(4, 2), (8, 8), (16, 32), (32, 128), (64, 512), (128, 2048)]:
		print 'Tests for key(%d) and value(%d)' % (k,v)
		print 'PUT'
		test('put', k, v)
		print 'GET'
		test('get', k, v)
		print 'DELETE'
		test('delete', k, v)