當前位置: 首頁>>代碼示例>>Python>>正文


Python ServerConf.getNodes方法代碼示例

本文整理匯總了Python中cpc.util.conf.server_conf.ServerConf.getNodes方法的典型用法代碼示例。如果您正苦於以下問題:Python ServerConf.getNodes方法的具體用法?Python ServerConf.getNodes怎麽用?Python ServerConf.getNodes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在cpc.util.conf.server_conf.ServerConf的用法示例。


在下文中一共展示了ServerConf.getNodes方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: run

# 需要導入模塊: from cpc.util.conf.server_conf import ServerConf [as 別名]
# 或者: from cpc.util.conf.server_conf.ServerConf import getNodes [as 別名]
    def run(self, serverState, request, response):
        conf = ServerConf()
        host = request.getParam('host')

        client_secure_port = request.getParam('client_secure_port')
        result = dict()
        #do we have a server with this hostname or fqdn?
        connectedNodes = conf.getNodes()

        if (connectedNodes.hostnameOrFQDNExists(host) == False):
            serv = RawServerMessage(host, client_secure_port)
            resp = ProcessedResponse(serv.sendAddNodeRequest(host))

            if resp.isOK():
                result = resp.getData()
                nodeConnectRequest = NodeConnectRequest(result['serverId'],
                    int(client_secure_port),None,None,result['fqdn'],host)

                conf.addSentNodeConnectRequest(nodeConnectRequest)
                result['nodeConnectRequest']=nodeConnectRequest
                log.info("Added node %s" % host)
                response.add('', result)
            else:
                response.add("Remote server said: %s"%resp.getMessage(),
                            status="ERROR")

        else:
            errorMessage = "%s is already trusted" % host
            response.add(errorMessage, status="ERROR")
            log.info(errorMessage)
開發者ID:abhirathb,項目名稱:copernicus,代碼行數:32,代碼來源:network.py

示例2: testRemoveNodes

# 需要導入模塊: from cpc.util.conf.server_conf import ServerConf [as 別名]
# 或者: from cpc.util.conf.server_conf.ServerConf import getNodes [as 別名]
 def testRemoveNodes(self):    
     conf = ServerConf(confdir=self.confDir)
     conf.addNode('localhost1')
     conf.addNode('localhost2')
     
     nodes = conf.getNodes()
     self.assertEquals(nodes.size(),2)
     
     self.assertTrue(nodes.exists("localhost1","13807"))
     self.assertTrue(nodes.exists("localhost2","13807") )
     
     conf.removeNode('localhost1')
     nodes = conf.getNodes()
     self.assertEquals(nodes.size(),1)
     
     self.assertFalse(nodes.exists("localhost1","13807"))
     self.assertTrue(nodes.exists("localhost2","13807") )
開發者ID:abhirathb,項目名稱:copernicus,代碼行數:19,代碼來源:test_server_conf.py

示例3: testStart2Servers

# 需要導入模塊: from cpc.util.conf.server_conf import ServerConf [as 別名]
# 或者: from cpc.util.conf.server_conf.ServerConf import getNodes [as 別名]
    def testStart2Servers(self):            

        numServers = 2

        self.createConfFolders(numServers)

        hostname = gethostname()
        
        node0HttpsPort = 13807
        node1HttpsPort = 13808
        node0HttpPort = 14807
        node1HttpPort = 14808

        for i in range(numServers):
            args = ['../../../../cpc-server','-c',self.serverConfs[i],'start']  #doing cpc.server.server.forkAndRun(cf, debug ) directly here will will for some strange reason mess up things when shutting down, the process wont shutdown 
            subprocess.call(args)
        
        time.sleep(2)
        
        #connect node 0 to node 1
        args = ['../../../../cpc-server','-c',self.serverConfs[0],'connnect-server',hostname,str(node1HttpPort)]  #doing cpc.server.server.forkAndRun(cf, debug ) directly here will will for some strange reason mess up things when shutting down, the process wont shutdown
        subprocess.call(args)

        args = ['../../../../cpc-server','-c',self.serverConfs[1],'trust',hostname,str(node0HttpsPort)]  #doing cpc.server.server.forkAndRun(cf, debug ) directly here will will for some strange reason mess up things when shutting down, the process wont shutdown
        subprocess.call(args)


        #verify existense of of nodes in each conf file
        conf1 = ServerConf(confdir=self.serverConfs[0], reload=True)
        node0Nodes = conf1.getNodes()
        self.assertTrue(node0Nodes.exists(hostname,node1HttpsPort))

        conf2 = ServerConf(confdir=self.serverConfs[1],reload=True)
        node1Nodes = conf2.getNodes()
        self.assertTrue(node1Nodes.exists(hostname,node0HttpsPort))
                
        
        #do a network topology call        
        conf = ConnectionBundle(confdir=self.serverConfs[0],reload=True)
        client = ClientMessage()        
        topology =ProcessedResponse(client.networkTopology()).getData()
         
        self.assertEquals(topology.size() ,2)
開發者ID:abhirathb,項目名稱:copernicus,代碼行數:45,代碼來源:test_network.py

示例4: establishOutBoundConnections

# 需要導入模塊: from cpc.util.conf.server_conf import ServerConf [as 別名]
# 或者: from cpc.util.conf.server_conf.ServerConf import getNodes [as 別名]
def establishOutBoundConnections():
    conf = ServerConf()

    log.log(cpc.util.log.TRACE,"Starting to establish outgoing connections")

    for node in conf.getNodes().nodes.itervalues():
        establishOutboundConnection(node)

    log.log(cpc.util.log.TRACE,"Finished establishing outgoing "
                               "connections")
開發者ID:abhirathb,項目名稱:copernicus,代碼行數:12,代碼來源:server_state.py

示例5: establishInboundConnections

# 需要導入模塊: from cpc.util.conf.server_conf import ServerConf [as 別名]
# 或者: from cpc.util.conf.server_conf.ServerConf import getNodes [as 別名]
def establishInboundConnections(serverState):
    """
    for each node that is not connected
    try to establish an inbound connection
    """
    conf = ServerConf()
    log.log(cpc.util.log.TRACE,"Starting to establish incoming connections")
    for node in conf.getNodes().nodes.itervalues():
        establishInboundConnection(node, serverState)

    log.log(cpc.util.log.TRACE,"Finished establishing incoming "
                                   "connections")
開發者ID:abhirathb,項目名稱:copernicus,代碼行數:14,代碼來源:server_state.py

示例6: requestNetworkTopology

# 需要導入模塊: from cpc.util.conf.server_conf import ServerConf [as 別名]
# 或者: from cpc.util.conf.server_conf.ServerConf import getNodes [as 別名]
    def requestNetworkTopology(topology,serverState=None):
        """
        Asks each neigbouring node for their network topology

        inputs:
            topology:Nodes The list of the topology generated so far
            serverState:ServerState
                if provided worker states are fetched.
                since this method is called by getNetworkTopology() which in turn
                is called from places where we do not pass (and don't want) the serverState
                we provide this option. Also it is not needed as the calling server always
                knows the most up to date state of its own workers.

        """
        conf = ServerConf()
        thisNode = Node.getSelfNode(conf)
        thisNode.setNodes(conf.getNodes())
        topology.addNode(thisNode)
        if serverState:
            thisNode.workerStates = WorkerStateHandler.getConnectedWorkers(serverState.getWorkerStates())

        for node in thisNode.getNodes().nodes.itervalues():
            if topology.exists(node.getId()) == False:
                #connect to correct node
                if node.isConnected():
                    try:
                        clnt = DirectServerMessage(node,conf=conf)
                        #send along the current topology
                        rawresp = clnt.networkTopology(topology)
                        processedResponse = ProcessedResponse(rawresp)
                        topology = processedResponse.getData()
                    except ServerConnectionError as e:
                        #we cannot connect to the node,
                        # and its marked as unreachable
                        #we must still add it to the topology
                        log.error("node %s unreachable when asking for network "
                                  "topology: error was %s"%(node.getId(),e.__str__()))
                        topology.addNode(node)

                #todo notify in topology that this node is not connected?
        return topology
開發者ID:abhirathb,項目名稱:copernicus,代碼行數:43,代碼來源:server_to_server_message.py

示例7: reestablishConnections

# 需要導入模塊: from cpc.util.conf.server_conf import ServerConf [as 別名]
# 或者: from cpc.util.conf.server_conf.ServerConf import getNodes [as 別名]
def reestablishConnections(serverState):
    '''
    Tries to periodically check for nodes that have gone down and reestablish
     connections to them
    '''
    log.log(cpc.util.log.TRACE,"Starting reestablish connection thread")
    conf = ServerConf()
    while True:
        for node in conf.getNodes().nodes.itervalues():
            if not node.isConnected():
                establishInboundConnection(node,serverState)
                establishOutboundConnection(node)

            if not node.isConnected():
                log.log(cpc.util.log.TRACE,("Tried to reestablish a "
                                            "connection"
                                            " to %s but failed "%node.toString()))


        reconnectInterval = conf.getReconnectInterval()
        time.sleep(reconnectInterval)
開發者ID:abhirathb,項目名稱:copernicus,代碼行數:23,代碼來源:server_state.py

示例8: broadcastToNeighboursOnly

# 需要導入模塊: from cpc.util.conf.server_conf import ServerConf [as 別名]
# 或者: from cpc.util.conf.server_conf.ServerConf import getNodes [as 別名]
 def broadcastToNeighboursOnly(self, fields, files=[], headers=dict()):
     conf = ServerConf()
     for node in conf.getNodes().nodes.itervalues():
         self._sendMessage(node, fields, files, headers)
開發者ID:kassonlab,項目名稱:copernicus,代碼行數:6,代碼來源:broadcast_message.py


注:本文中的cpc.util.conf.server_conf.ServerConf.getNodes方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。