当前位置: 首页>>代码示例>>Python>>正文


Python BinaryProtocol.BinaryProtocol类代码示例

本文整理汇总了Python中BinaryProtocol.BinaryProtocol的典型用法代码示例。如果您正苦于以下问题:Python BinaryProtocol类的具体用法?Python BinaryProtocol怎么用?Python BinaryProtocol使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了BinaryProtocol类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: sync

 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,代码行数:7,代码来源:BSPPeer.py

示例2: initialize

    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,代码行数:31,代码来源:BSPPeer.py

示例3: readNext

 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,代码行数:8,代码来源:BSPPeer.py

示例4: getAllPeerNames

 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,代码行数:8,代码来源:BSPPeer.py

示例5: getCurrentMessage

    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,代码行数:8,代码来源:BSPPeer.py

示例6: getCurrentMessage

    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,代码行数:14,代码来源:BSPPeer.py

示例7: send

 def send(self, peer, msg):
     println(bp.getProtocolString(bp.SEND_MSG))
     println(peer)
     println(msg)
开发者ID:apache,项目名称:hama,代码行数:4,代码来源:BSPPeer.py

示例8: log

 def log(self, msg):
     println(bp.getProtocolString(bp.LOG) + msg)
开发者ID:apache,项目名称:hama,代码行数:2,代码来源:BSPPeer.py

示例9: done

 def done(self):
     println(bp.getProtocolString(bp.TASK_DONE))
     println(bp.getProtocolString(bp.DONE))
开发者ID:apache,项目名称:hama,代码行数:3,代码来源:BSPPeer.py

示例10: ack

 def ack(self, code):
     println(bp.getAckProtocolString(code))
开发者ID:apache,项目名称:hama,代码行数:2,代码来源:BSPPeer.py

示例11: getPeerNameForIndex

 def getPeerNameForIndex(self, index):
     println(bp.getProtocolString(bp.GET_PEERNAME))
     println(str(index));
     return readLine()
开发者ID:apache,项目名称:hama,代码行数:4,代码来源:BSPPeer.py

示例12: reopenInput

 def reopenInput(self):
     println(bp.getProtocolString(bp.REOPEN_INPUT))
开发者ID:apache,项目名称:hama,代码行数:2,代码来源:BSPPeer.py

示例13: write

 def write(self, key, value):
     println(bp.getProtocolString(bp.WRITE_KEYVALUE))
     println(key)
     println(value)
开发者ID:apache,项目名称:hama,代码行数:4,代码来源:BSPPeer.py

示例14: clear

 def clear(self):
     println(bp.getProtocolString(bp.CLEAR))
开发者ID:apache,项目名称:hama,代码行数:2,代码来源:BSPPeer.py

示例15: getNumPeers

 def getNumPeers(self):
     println(bp.getProtocolString(bp.GET_PEER_COUNT))
     return readLine()
开发者ID:apache,项目名称:hama,代码行数:3,代码来源:BSPPeer.py


注:本文中的BinaryProtocol.BinaryProtocol类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。