HCE Project Python language Distributed Tasks Manager Application, Distributed Crawler Application and client API bindings.  2.0.0-chaika
Hierarchical Cluster Engine Python language binding
IDGenerator.py
Go to the documentation of this file.
1 '''
2 Created on Feb 4, 2014
3 
4 @author: igor, bgv
5 '''
6 
7 
8 import socket
9 import time
10 import uuid
11 from transport.Singelon import Singleton
12 
13 
15 class IDGenerator(object):
16  '''
17  The class is used to generate unique ID for connections
18  '''
19  __metaclass__ = Singleton
20 
21  def __init__(self):
22  '''
23  Constructor
24  '''
25  #@var _connection_uid
26  #a member variable, holds generator internal state
27  self._connection_uid = 0
28 
29 
30  """
31  Generate unique connection id
32  """
33 
36  def get_connection_uid(self, idType=0):
37  ret = None
38 
39  self._connection_uid = self._connection_uid + 1
40  if idType == 0:
41  ret = socket.gethostname() + "-" + str(time.time()) + "-" + uuid.uuid1().hex + "-" + str(self._connection_uid)
42  else:
43  ret = str(self._connection_uid)
44 
45  return ret
46 
def get_connection_uid(self, idType=0)
generate unique connection id
Definition: IDGenerator.py:36
IDGenerator is used to generate unique id for connections.
Definition: IDGenerator.py:15