def __init__(self,service,periodStart,periodEnd,quantity,owner=createURN("ownershipCertificate"),metric="MB",status=IDLE): ''' Constructor ''' self.__uuid = createURN("shareservice") self.__ownershipCertificate = owner self.__service = service self.__periodStart = periodStart self.__periodEnd = periodEnd self.__quantity = quantity self.__metric = metric self.__status = status
def __init__(self, urn=createURN("peer"),serverPort=4000, maxNeighbor=1): AbstractPeer.initialize(self, urn,serverPort, maxNeighbor)
def initialize(self, peer,typeRepository): self.__uuid = createURN(typeRepository) self.__typeRepository = typeRepository self.__peer = peer self.__elements = {} RepositoryLogger() RepositoryLogger().resgiterLoggingInfo("Initialize Repository URN %s of peer %s "%(self.__class__.__name__,self.__peer.getURN()))
def __init__(self, urn=createURN("peer"),serverPort=4000, maxNeighbor=1): AbstractPeer.initialize(self, urn,serverPort,maxNeighbor,peerType = AbstractPeer.PORTAL) self.__superPeers = {} self.__dimension = 1
def __init__(self,service,serviceQuantity,equivalence,equivalenceQuantity,periodStart,periodEnd): ''' Constructor period = randomDate("1/1/2010 1:30", "1/12/2010 4:50", random()) ''' self.__uuid = createURN("equivalence") self.__service = service self.__serviceQuantity = serviceQuantity self.__equivalenceS = equivalence self.__equivalenceQuantity = equivalenceQuantity self.__periodStart = periodStart self.__periodEnd = periodEnd EquivalenceLogger().resgiterLoggingInfo("Create Equivalence between %s and = %s periodStar = %s and periodEnd = %s"%self.getAllNeed())
def get2(tam=5): optionMap = [ServiceMap(), HardwareMap()] optionClass = [Service, Hardware] for i in range(0, randint(1, tam)): option = randint(0, 1) resourceMap = ResourceMap(optionMap[option]) map = resourceMap.Map() concept = map.keys()[randint(0, len(map.keys()) - 1)] resour = randint(0, (len(map[concept]) - 1)) print "id %d conce %s resour %d rrr %s" % (i, concept, resour, map[concept][resour]) service = optionClass[option](pid=createURN("peer"), resource=map[concept][resour])
def initialize(self, peerSource,tradingUUID,tradingServiceResource,tradingServiceUUID,tradingMetric,tradingQuantity,equivalenceEquivalenceResource, equivalenceEquivalenceUUID,sharePeriodMetric,equivalenceQuantityTrand,tradingDPeriodStart,tradingTPeriodStart,tradingDPeriodEnd,tradingTPeriodEnd): self.__uuid = createURN("trading") self.__peerSource = peerSource self.__tradingUUID = tradingUUID self.__tradingServiceResource = tradingServiceResource self.__tradingServiceUUID = tradingServiceUUID self.__tradingQuantity = tradingQuantity self.__equivalenceEquivalenceResource = equivalenceEquivalenceResource self.__equivalenceEquivalenceUUID = equivalenceEquivalenceUUID self.__equivalenceQuantityTrand = equivalenceQuantityTrand self.__periodStart = "%s %s"%(tradingDPeriodStart,tradingTPeriodStart) self.__periodEnd = "%s %s"%(tradingDPeriodEnd,tradingTPeriodEnd) self.__status = AbstractTrading.STARTED
def initialize(self, snow,service,periodStart,periodEnd,quantity,type=CLIENT,metric="MB"): self.__uuid = createURN("trading") self.__service = service self.__periodStart = periodStart self.__periodEnd = periodEnd self.__quantity = quantity self.__metric = metric self.__status = AbstractTrading.STARTED self.__attempt = 1 self.__type = type self.__snow = snow self.__peersTrading = {} TradingLogger().resgiterLoggingInfo("Trading URN = %s,"%(self.__uuid))
def get(tam=3): optionMap = [ServiceMap(), HardwareMap()] optionClass = [Service, Hardware] for i in range(0, tam): option = randint(0, 1) resourceMap = ResourceMap(optionMap[option]) map = resourceMap.Map() concept = map.keys()[randint(0, len(map.keys()) - 1)] initial = randint(0, (len(map[concept]) / 2) - 1) end = randint((len(map[concept]) / 2), len(map[concept]) - 1) print "id %d conce %s initial %d End %d" % (i, concept, initial, end) for ix in range(initial, end): service = optionClass[option](pid=createURN("peer"), resource=map[concept][ix]) print service.getUUID(), service.getResource()
def initialize(self, urn=createURN("peer"), serverPort=3000, maxPeers=1, peerType = SIMPLE): import socket self.__peerType = peerType self.__maxPeers = int(maxPeers) self.__serverPort = int(serverPort) self.__attemptedConnectionNumber = 0 self.__serverHost = socket.gethostbyname(socket.gethostname()) self.__pid = '%s:%d' % (self.__serverHost, self.__serverPort) self.__peerLock = threading.Lock() self.__peerNeighbors = {} self.__shutdown = False self.__handlers = {} self.__router = None self.__urn = urn self.__isConnected = False PeerLogger().resgiterLoggingInfo("Initialize Peer => URN = %s, IP = %s port = %s"%(self.__urn,self.__serverHost,self.__serverPort)) self.__dispatcher = self.__createHandleMessage() self.__services = ServiceRepository(self) self.__trustManager = TrustManager(self) self.__tradingManager = TradingManager(self) self.__sharedResource = SharedRecourceRepository(self) self.__historyResource = HistoryRepository(self) self.__equivalences = EquivalenceRepository(self) self.__mySuperPeer = self.__pid #self.__trust = self.__connectionTime = 0 self.__disconnectionTime = 0 self.__scheduledDisconnection = False
def initialize( self, peerUUID, resourceUUID, resourceDescription, trustType=DIRECT, rating=0.5, period=randomDate("1/1/2010 1:30", "1/12/2010 4:50", random()), status=False, ): self.__uuid = createURN(trustType) self.__resourceUUID = resourceUUID self.__resourceDescription = resourceDescription self.__peerUUID = peerUUID self.__rating = rating self.__period = period self.__status = status self.__trustType = trustType TrustLogger().resgiterLoggingInfo( "Initialize Trust = URN = %s,Peer = %s ,Time %s, Description = %s rating = %f and status = %s" % (self.__uuid, self.__peerUUID, self.__period, self.__resourceDescription, self.__rating, self.__status) )
def __init__(self,network, pid=createURN("rpycpeer"),udpPort=4000): AbstractPeer.initialize(self, network, pid,udpPort)
def __init__(self, urn=createURN("peer"),serverPort=4000, maxNeighbor=1): self.__superPeerNeighbors = {} self.__levelNeighbor = 1 AbstractPeer.initialize(self, urn,serverPort, maxNeighbor, peerType = AbstractPeer.SUPER)
def teste(t1=createURN("testesteste"), t2=randint(0, 10), t3="t3", t4="t4"): print t1, t2, t3, t4