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


Python BinaryProtocol.getProtocolString方法代碼示例

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


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

示例1: initialize

# 需要導入模塊: from BinaryProtocol import BinaryProtocol [as 別名]
# 或者: from BinaryProtocol.BinaryProtocol import getProtocolString [as 別名]
    def initialize(self):
        """
        INIT protocol works as follows:
        START OP_CODE
        PROTOCOL_NUMBER
        SET_BSPJOB_CONF OP_CODE
        NUMBER OF CONF ITEMS (#KEY + #VALUES)
        N-LINES, where line is key and the following the value
        """
        # parse our initial values
        line = readLine()
        # start code is the first
        if line == bp.getProtocolString(bp.START):
            # check the protocol compatibility
            protocolNumber = int(readLine())
            if protocolNumber != self.PROTOCOL_VERSION:
                raise RuntimeError(
                    "Protocol version mismatch: Expected: " + str(self.PROTOCOL_VERSION) +
                    " but got: " + str(protocolNumber))
        line = readLine()
        # parse the configurations
        if line == bp.getProtocolString(bp.SET_BSPJOB_CONF):
            numberOfItems = readLine()
            key = None
            value = None
            for i in range(0, int(numberOfItems), 2):
                key = readLine()
                value = readLine()
                self.config.put(key, value)

        self.ack(bp.START)
開發者ID:apache,項目名稱:hama,代碼行數:33,代碼來源:BSPPeer.py

示例2: sync

# 需要導入模塊: from BinaryProtocol import BinaryProtocol [as 別名]
# 或者: from BinaryProtocol.BinaryProtocol import getProtocolString [as 別名]
 def sync(self):
     println(bp.getProtocolString(bp.SYNC))
     # this should block now until we get a response
     line = readLine()
     if line != (bp.getProtocolString(bp.SYNC) + "_SUCCESS"):
         raise RuntimeError(
             "Barrier sync failed!")
開發者ID:apache,項目名稱:hama,代碼行數:9,代碼來源:BSPPeer.py

示例3: readNext

# 需要導入模塊: from BinaryProtocol import BinaryProtocol [as 別名]
# 或者: from BinaryProtocol.BinaryProtocol import getProtocolString [as 別名]
 def readNext(self):
     println(bp.getProtocolString(bp.READ_KEYVALUE))
     line = readLine()
     secondLine = readLine()
     # if no message is send it will send %%-1%%
     if line == "%%-1%%" and secondLine == "%%-1%%":
         return False
     return [line, secondLine]
開發者ID:apache,項目名稱:hama,代碼行數:10,代碼來源:BSPPeer.py

示例4: getAllPeerNames

# 需要導入模塊: from BinaryProtocol import BinaryProtocol [as 別名]
# 或者: from BinaryProtocol.BinaryProtocol import getProtocolString [as 別名]
 def getAllPeerNames(self):
     println(bp.getProtocolString(bp.GET_ALL_PEERNAME))
     ln = readLine()
     names = []
     for i in range(int(ln)):
         peerName = readLine()
         names.append(peerName)
     return names
開發者ID:apache,項目名稱:hama,代碼行數:10,代碼來源:BSPPeer.py

示例5: getCurrentMessage

# 需要導入模塊: from BinaryProtocol import BinaryProtocol [as 別名]
# 或者: from BinaryProtocol.BinaryProtocol import getProtocolString [as 別名]
    def getCurrentMessage(self):
        println(bp.getProtocolString(bp.GET_MSG))
        line = readLine()
        # if no message is send it will send %%-1%%
        if line == "%%-1%%":
            return False

        return line;
開發者ID:apache,項目名稱:hama,代碼行數:10,代碼來源:BSPPeer.py

示例6: getCurrentMessage

# 需要導入模塊: from BinaryProtocol import BinaryProtocol [as 別名]
# 或者: from BinaryProtocol.BinaryProtocol import getProtocolString [as 別名]
    def getCurrentMessage(self):
        println(bp.getProtocolString(bp.GET_MSG))
        line = readLine()
        # if no message is send it will send %%-1%%
        if line == "%%-1%%":
            return False

        # TODO
        # Problem reported by Roman:
        # If I send any message of the length L, I receive the message with
        # additional (L-1)/2 '^@' symbols after it.

        # return line;
        return line[:len(line)-len(line)//3]
開發者ID:millecker,項目名稱:HamaStreaming,代碼行數:16,代碼來源:BSPPeer.py

示例7: send

# 需要導入模塊: from BinaryProtocol import BinaryProtocol [as 別名]
# 或者: from BinaryProtocol.BinaryProtocol import getProtocolString [as 別名]
 def send(self, peer, msg):
     println(bp.getProtocolString(bp.SEND_MSG))
     println(peer)
     println(msg)
開發者ID:apache,項目名稱:hama,代碼行數:6,代碼來源:BSPPeer.py

示例8: log

# 需要導入模塊: from BinaryProtocol import BinaryProtocol [as 別名]
# 或者: from BinaryProtocol.BinaryProtocol import getProtocolString [as 別名]
 def log(self, msg):
     println(bp.getProtocolString(bp.LOG) + msg)
開發者ID:apache,項目名稱:hama,代碼行數:4,代碼來源:BSPPeer.py

示例9: done

# 需要導入模塊: from BinaryProtocol import BinaryProtocol [as 別名]
# 或者: from BinaryProtocol.BinaryProtocol import getProtocolString [as 別名]
 def done(self):
     println(bp.getProtocolString(bp.TASK_DONE))
     println(bp.getProtocolString(bp.DONE))
開發者ID:apache,項目名稱:hama,代碼行數:5,代碼來源:BSPPeer.py

示例10: runCleanup

# 需要導入模塊: from BinaryProtocol import BinaryProtocol [as 別名]
# 或者: from BinaryProtocol.BinaryProtocol import getProtocolString [as 別名]
 def runCleanup(self):
     line = readLine()
     # start code is the first
     if line.startswith(bp.getProtocolString(bp.RUN_CLEANUP)):
         self.bspClass.cleanup(self);
         self.ack(bp.RUN_CLEANUP)
開發者ID:apache,項目名稱:hama,代碼行數:8,代碼來源:BSPPeer.py

示例11: getPeerNameForIndex

# 需要導入模塊: from BinaryProtocol import BinaryProtocol [as 別名]
# 或者: from BinaryProtocol.BinaryProtocol import getProtocolString [as 別名]
 def getPeerNameForIndex(self, index):
     println(bp.getProtocolString(bp.GET_PEERNAME))
     println(str(index));
     return readLine()
開發者ID:apache,項目名稱:hama,代碼行數:6,代碼來源:BSPPeer.py

示例12: write

# 需要導入模塊: from BinaryProtocol import BinaryProtocol [as 別名]
# 或者: from BinaryProtocol.BinaryProtocol import getProtocolString [as 別名]
 def write(self, key, value):
     println(bp.getProtocolString(bp.WRITE_KEYVALUE))
     println(key)
     println(value)
開發者ID:apache,項目名稱:hama,代碼行數:6,代碼來源:BSPPeer.py

示例13: clear

# 需要導入模塊: from BinaryProtocol import BinaryProtocol [as 別名]
# 或者: from BinaryProtocol.BinaryProtocol import getProtocolString [as 別名]
 def clear(self):
     println(bp.getProtocolString(bp.CLEAR))
開發者ID:apache,項目名稱:hama,代碼行數:4,代碼來源:BSPPeer.py

示例14: getNumPeers

# 需要導入模塊: from BinaryProtocol import BinaryProtocol [as 別名]
# 或者: from BinaryProtocol.BinaryProtocol import getProtocolString [as 別名]
 def getNumPeers(self):
     println(bp.getProtocolString(bp.GET_PEER_COUNT))
     return readLine()
開發者ID:apache,項目名稱:hama,代碼行數:5,代碼來源:BSPPeer.py

示例15: getPeerIndex

# 需要導入模塊: from BinaryProtocol import BinaryProtocol [as 別名]
# 或者: from BinaryProtocol.BinaryProtocol import getProtocolString [as 別名]
 def getPeerIndex(self):
     println(bp.getProtocolString(bp.GET_PEER_INDEX))
     return readLine()
開發者ID:apache,項目名稱:hama,代碼行數:5,代碼來源:BSPPeer.py


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