当前位置: 首页>>代码示例>>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;未经允许,请勿转载。