コード例 #1
0
ファイル: BSPPeer.py プロジェクト: apache/hama
 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!")
コード例 #2
0
ファイル: BSPPeer.py プロジェクト: apache/hama
    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)
コード例 #3
0
ファイル: BSPPeer.py プロジェクト: chlin501/apache-hama
    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)
コード例 #4
0
ファイル: BSPPeer.py プロジェクト: apache/hama
    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;
コード例 #5
0
ファイル: BSPPeer.py プロジェクト: chlin501/apache-hama
 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]
コード例 #6
0
ファイル: BSPPeer.py プロジェクト: apache/hama
 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
コード例 #7
0
ファイル: BSPPeer.py プロジェクト: apache/hama
 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]
コード例 #8
0
ファイル: BSPPeer.py プロジェクト: chlin501/apache-hama
 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
コード例 #9
0
ファイル: BSPPeer.py プロジェクト: chlin501/apache-hama
    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
コード例 #10
0
ファイル: BSPPeer.py プロジェクト: millecker/HamaStreaming
    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]
コード例 #11
0
ファイル: server.py プロジェクト: Hofsiedge/Access-system
def threaded_client(conn):
    try:
        while True:
            data = conn.recv()
            data = data[0] * 256 + data[1]
            data = BP.decode(data)
            print('Received data:', data)
            send_command(conn, data)
    except RuntimeError as e:
        print(e)
    #except Exception as e:
    #print('Exception caught')
    #print(e)
    finally:
        conn.close()
コード例 #12
0
ファイル: BSPPeer.py プロジェクト: chlin501/apache-hama
 def clear(self):
     println(bp.getProtocolString(bp.CLEAR))
コード例 #13
0
ファイル: BSPPeer.py プロジェクト: apache/hama
 def getPeerIndex(self):
     println(bp.getProtocolString(bp.GET_PEER_INDEX))
     return readLine()
コード例 #14
0
ファイル: BSPPeer.py プロジェクト: apache/hama
 def getPeerNameForIndex(self, index):
     println(bp.getProtocolString(bp.GET_PEERNAME))
     println(str(index));
     return readLine()
コード例 #15
0
ファイル: BSPPeer.py プロジェクト: apache/hama
 def reopenInput(self):
     println(bp.getProtocolString(bp.REOPEN_INPUT))
コード例 #16
0
ファイル: BSPPeer.py プロジェクト: chlin501/apache-hama
 def done(self):
     println(bp.getProtocolString(bp.TASK_DONE))
     println(bp.getProtocolString(bp.DONE))
コード例 #17
0
ファイル: BSPPeer.py プロジェクト: chlin501/apache-hama
 def runBSP(self):
     line = readLine()
     # start code is the first
     if line.startswith(bp.getProtocolString(bp.RUN_BSP)):
         self.bspClass.bsp(self)
         self.ack(bp.RUN_BSP)
コード例 #18
0
ファイル: BSPPeer.py プロジェクト: apache/hama
 def write(self, key, value):
     println(bp.getProtocolString(bp.WRITE_KEYVALUE))
     println(key)
     println(value)
コード例 #19
0
ファイル: BSPPeer.py プロジェクト: apache/hama
 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)
コード例 #20
0
ファイル: BSPPeer.py プロジェクト: apache/hama
 def done(self):
     println(bp.getProtocolString(bp.TASK_DONE))
     println(bp.getProtocolString(bp.DONE))
コード例 #21
0
ファイル: BSPPeer.py プロジェクト: chlin501/apache-hama
 def send(self, peer, msg):
     println(bp.getProtocolString(bp.SEND_MSG))
     println(peer)
     println(msg)
コード例 #22
0
ファイル: BSPPeer.py プロジェクト: chlin501/apache-hama
 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)
コード例 #23
0
ファイル: BSPPeer.py プロジェクト: chlin501/apache-hama
 def log(self, msg):
     println(bp.getProtocolString(bp.LOG) + msg)
コード例 #24
0
ファイル: BSPPeer.py プロジェクト: apache/hama
 def getNumPeers(self):
     println(bp.getProtocolString(bp.GET_PEER_COUNT))
     return readLine()
コード例 #25
0
ファイル: BSPPeer.py プロジェクト: chlin501/apache-hama
 def reopenInput(self):
     println(bp.getProtocolString(bp.REOPEN_INPUT))
コード例 #26
0
ファイル: BSPPeer.py プロジェクト: apache/hama
 def clear(self):
     println(bp.getProtocolString(bp.CLEAR))
コード例 #27
0
ファイル: BSPPeer.py プロジェクト: chlin501/apache-hama
 def write(self, key, value):
     println(bp.getProtocolString(bp.WRITE_KEYVALUE))
     println(key)
     println(value)
コード例 #28
0
ファイル: BSPPeer.py プロジェクト: chlin501/apache-hama
 def getNumPeers(self):
     println(bp.getProtocolString(bp.GET_PEER_COUNT))
     return readLine()
コード例 #29
0
ファイル: BSPPeer.py プロジェクト: chlin501/apache-hama
 def getPeerIndex(self):
     println(bp.getProtocolString(bp.GET_PEER_INDEX))
     return readLine()
コード例 #30
0
ファイル: BSPPeer.py プロジェクト: apache/hama
 def runBSP(self):
     line = readLine()
     # start code is the first
     if line.startswith(bp.getProtocolString(bp.RUN_BSP)):
         self.bspClass.bsp(self);
         self.ack(bp.RUN_BSP)
コード例 #31
0
ファイル: BSPPeer.py プロジェクト: chlin501/apache-hama
 def ack(self, code):
     println(bp.getAckProtocolString(code))
コード例 #32
0
ファイル: BSPPeer.py プロジェクト: apache/hama
 def ack(self, code):
     println(bp.getAckProtocolString(code))
コード例 #33
0
ファイル: BSPPeer.py プロジェクト: chlin501/apache-hama
 def getNumCurrentMessages(self):
     println(bp.getProtocolString(bp.GET_MSG_COUNT))
     return readLine()
コード例 #34
0
ファイル: BSPPeer.py プロジェクト: apache/hama
 def log(self, msg):
     println(bp.getProtocolString(bp.LOG) + msg)
コード例 #35
0
ファイル: BSPPeer.py プロジェクト: chlin501/apache-hama
 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!")
コード例 #36
0
ファイル: BSPPeer.py プロジェクト: apache/hama
 def send(self, peer, msg):
     println(bp.getProtocolString(bp.SEND_MSG))
     println(peer)
     println(msg)
コード例 #37
0
ファイル: BSPPeer.py プロジェクト: chlin501/apache-hama
 def getSuperstepCount(self):
     println(bp.getProtocolString(bp.GET_SUPERSTEP_COUNT))
     return readLine()
コード例 #38
0
ファイル: BSPPeer.py プロジェクト: apache/hama
 def getNumCurrentMessages(self):
     println(bp.getProtocolString(bp.GET_MSG_COUNT))
     return readLine()
コード例 #39
0
ファイル: server.py プロジェクト: Hofsiedge/Access-system
def send_passer_name(conn, message):
    message = message.encode('utf-8')
    for i in range(len(message)):
        conn.send(bytes(divmod(BP.passing(message[i]), 256)))
    conn.send(bytes(divmod(BP.passing(0), 256)))
コード例 #40
0
ファイル: BSPPeer.py プロジェクト: apache/hama
 def getSuperstepCount(self):
     println(bp.getProtocolString(bp.GET_SUPERSTEP_COUNT))
     return readLine()
コード例 #41
0
ファイル: BSPPeer.py プロジェクト: chlin501/apache-hama
 def getPeerNameForIndex(self, index):
     println(bp.getProtocolString(bp.GET_PEERNAME))
     println(str(index))
     return readLine()