コード例 #1
0
ファイル: starter2.py プロジェクト: talalahmad/primitives
	def rip(self):
		
		disk_storage = storage.storage()
		self.clean();
		thread = []

		for i in range(0,self.how_many):
			from_number = self.start_number+i;
			print from_number;
			from_name = from_number;
			node_name = self.myself;
			t="NEW"

			node = nodes[0]
			print node;

		 	data_to_be_sent = {}
		 	data_to_be_sent['i'] = from_name;
		 	data_to_be_sent['t'] = "NEW";
		 	from_number = str(from_number)
		 	data_to_be_sent['d'] = from_number+","+from_number+","+from_number+","+from_number;
			syslog.syslog("BALU: uid=%s and time=%s" %(from_name,str(time.time())))
			try:
		 		thread.append(get.get('http://'+node+':8080/server','',data_to_be_sent));
		 		thread[-1].start();
		 	except IndexError:
		 		print "there was an indexError"
		 	syslog.syslog("BALU: Node selected is %s" %node);
		for i in range(0,self.how_many):
			thread[i].join()
コード例 #2
0
ファイル: starter.py プロジェクト: talalahmad/primitives
	def rip(self):
		for i in range(0,len(nodes)-1):
			myssh.connect_before(nodes[i],keys[i],self.how_many)

		disk_storage = storage.storage()
		self.clean();
		thread = []

		for i in range(0,self.how_many):
			from_number = self.start_number+i;
			print from_number;
			from_name = from_number;
			node_name = self.myself;
			t="NEW"

			x = int(from_number)%10
			if x == 1:
				node = nodes[1]
			elif x ==2:
				node = nodes[2]
			elif x ==3:
				node = nodes[3]
			elif x ==4:
				node = nodes[4]
			elif x ==5:
				node = nodes[5]
			elif x ==6:
				node = nodes[6]
			elif x ==7:
				node = nodes[7]
			elif x ==8:
				node = nodes[8]
			elif x ==9:
				node = nodes[9]
			else:
				node = nodes[0]
			print node;

		 	data_to_be_sent = {}
		 	data_to_be_sent['i'] = from_name;
		 	data_to_be_sent['t'] = "NEW";
		 	from_number = str(from_number)
		 	data_to_be_sent['d'] = from_number+","+from_number+","+from_number+","+from_number;
			syslog.syslog("BALU: uid=%s and time=%s" %(from_name,str(time.time())))
			try:
		 		thread.append(get.get('http://'+node+':8080/server','',data_to_be_sent));
		 		thread[-1].start();
		 	except IndexError:
		 		print "there was an indexError"
		 	syslog.syslog("BALU: Node selected is %s" %node);
		for i in range(0,self.how_many):
			thread[i].join()

		for i in range(0,len(nodes)-1):
			myssh.connect_after(nodes[i],keys[i],self.how_many)
コード例 #3
0
ファイル: starter2.py プロジェクト: talalahmad/primitives
	def rip(self):
		disk_storage = storage.storage()
		disk_storage.clean();

		for i in range(0,self.how_many):
			from_number = self.start_number+i;
		#	print from_number;
			from_name = from_number;
			node_name = self.myself;
			t="NEW"
			output = disk_storage.store(from_number,from_name,node_name,t)
			if output is True:
				#have to send back a response saying that i have saved something. 
				syslog.syslog("BALU: uid=%s and time=%s" %(from_number,str(time.time())))
			elif output is False:
				syslog.syslog("BALU: uid=%s and time=%s" %(from_number,str(time.time())))