コード例 #1
0
ファイル: shared_period.py プロジェクト: krohan100/pydssim
 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
コード例 #2
0
ファイル: default_peer.py プロジェクト: krohan100/pydssim
    def __init__(self, urn=createURN("peer"),serverPort=4000, maxNeighbor=1):
        
        AbstractPeer.initialize(self,  urn,serverPort, maxNeighbor)
    
    

        
コード例 #3
0
 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()))
コード例 #4
0
ファイル: portal_peer.py プロジェクト: krohan100/pydssim
 def __init__(self, urn=createURN("peer"),serverPort=4000, maxNeighbor=1):
     
     AbstractPeer.initialize(self,  urn,serverPort,maxNeighbor,peerType = AbstractPeer.PORTAL)
     
     
     self.__superPeers = {}
     
     self.__dimension = 1
コード例 #5
0
ファイル: equivalence.py プロジェクト: krohan100/pydssim
 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())
コード例 #6
0
ファイル: main.py プロジェクト: lglmoura/PyDDSIM
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])
コード例 #7
0
ファイル: abstract_history.py プロジェクト: krohan100/pydssim
 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
コード例 #8
0
ファイル: abstract_trading.py プロジェクト: lglmoura/PyDDSIM
 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))
コード例 #9
0
ファイル: main.py プロジェクト: lglmoura/PyDDSIM
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()
コード例 #10
0
ファイル: abstract_peer.py プロジェクト: krohan100/pydssim
 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
コード例 #11
0
ファイル: abstract_trust.py プロジェクト: lglmoura/PyDDSIM
    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)
        )
コード例 #12
0
ファイル: rpyc_peer.py プロジェクト: krohan100/pydssim
 def __init__(self,network, pid=createURN("rpycpeer"),udpPort=4000):
     
     AbstractPeer.initialize(self,  network, pid,udpPort)
コード例 #13
0
ファイル: super_peer.py プロジェクト: krohan100/pydssim
 def __init__(self, urn=createURN("peer"),serverPort=4000, maxNeighbor=1):
     
     self.__superPeerNeighbors = {}
     self.__levelNeighbor = 1
     
     AbstractPeer.initialize(self, urn,serverPort, maxNeighbor, peerType = AbstractPeer.SUPER)
コード例 #14
0
ファイル: main.py プロジェクト: lglmoura/PyDDSIM
def teste(t1=createURN("testesteste"), t2=randint(0, 10), t3="t3", t4="t4"):
    print t1, t2, t3, t4