本文整理汇总了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)
示例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!")
示例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]
示例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
示例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;
示例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]
示例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)
示例8: log
# 需要导入模块: from BinaryProtocol import BinaryProtocol [as 别名]
# 或者: from BinaryProtocol.BinaryProtocol import getProtocolString [as 别名]
def log(self, msg):
println(bp.getProtocolString(bp.LOG) + msg)
示例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))
示例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)
示例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()
示例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)
示例13: clear
# 需要导入模块: from BinaryProtocol import BinaryProtocol [as 别名]
# 或者: from BinaryProtocol.BinaryProtocol import getProtocolString [as 别名]
def clear(self):
println(bp.getProtocolString(bp.CLEAR))
示例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()
示例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()