How to use the avro.ipc.HTTPTransceiver function in avro

To help you get started, we’ve selected a few avro examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github parallel-ml / asplos2018-workshop / mutiple-devices / vgg16 / 11devices / initial.py View on Github external
def send_request(bytestr, mode, tag=''):
    """
        This function sends data to next layer. It will pop an available
        next layer device IP address defined at IP table, and send data
        to that IP. After, it will put the available IP back.

        Args:
            bytestr: The encoded byte string for image.
            mode: Specify next layer option.
    """
    init = Initializer.create_init()
    queue = init.queue

    addr = queue.get()
    client = ipc.HTTPTransceiver(addr, 12345)
    requestor = ipc.Requestor(PROTOCOL, client)

    data = dict()
    data['input'] = bytestr
    data['next'] = mode
    data['tag'] = tag

    start = time.time()
    requestor.request('forward', data)
    end = time.time()

    init.node_timer(mode, end - start)

    client.close()
    queue.put(addr)
github parallel-ml / asplos2018-workshop / mutiple-devices / alexnet / initial.py View on Github external
def send_request(bytestr, mode, tag=''):
    """
        This function sends data to next layer. It will pop an available
        next layer device IP address defined at IP table, and send data
        to that IP. After, it will put the available IP back.

        Args:
            bytestr: The encoded byte string for image.
            mode: Specify next layer option.
    """
    init = Initializer.create_init()
    queue = init.queue

    addr = queue.get()
    client = ipc.HTTPTransceiver(addr, 12345)
    requestor = ipc.Requestor(PROTOCOL, client)

    data = dict()
    data['input'] = bytestr
    data['next'] = mode
    data['tag'] = tag

    start = time.time()
    requestor.request('forward', data)
    end = time.time()

    init.node_timer(mode, end - start)

    client.close()
    queue.put(addr)
github apache / cassandra / contrib / py_stress / avro_stress.py View on Github external
def get_client(host='127.0.0.1', port=9170):
    schema = os.path.join(root, 'interface/avro', 'cassandra.avpr')
    proto = protocol.parse(open(schema).read())
    client = ipc.HTTPTransceiver(host, port)
    return ipc.Requestor(proto, client)
github apache / avro / lang / py3 / avro / tool.py View on Github external
def send_message(uri, proto, msg, datum):
  url_obj = urllib.parse.urlparse(uri)
  client = ipc.HTTPTransceiver(url_obj.hostname, url_obj.port)
  proto_json = file(proto, 'r').read()
  requestor = ipc.Requestor(protocol.Parse(proto_json), client)
  print(requestor.request(msg, datum))
github apache / avro / lang / py / avro / tether / tether_task.py View on Github external
def request(self,*args,**param):
    transciever=ipc.HTTPTransceiver(self.server,self.port)
    requestor=ipc.Requestor(self.protocol, transciever)
    return requestor.request(*args,**param)
github sunsuk7tp / MyCassandra / MyCassandra-0.2.1 / contrib / py_stress / avro_stress.py View on Github external
def get_client(host='127.0.0.1', port=9170):
    schema = os.path.join(root, 'interface/avro', 'cassandra.avpr')
    proto = protocol.parse(open(schema).read())
    client = ipc.HTTPTransceiver(host, port)
    return ipc.Requestor(proto, client)
github phunt / avro-rpc-quickstart / src / main / python / send_message.py View on Github external
PROTOCOL = protocol.parse(open("../avro/mail.avpr").read())

server_addr = ('localhost', 9090)

class UsageError(Exception):
    def __init__(self, value):
        self.value = value
    def __str__(self):
        return repr(self.value)

if __name__ == '__main__':
    if len(sys.argv) != 4:
        raise UsageError("Usage:   ")

    # client code - attach to the server and send a message
    client = ipc.HTTPTransceiver(server_addr[0], server_addr[1])
    requestor = ipc.Requestor(PROTOCOL, client)
    
    # fill in the Message record and send it
    message = dict()
    message['to'] = sys.argv[1]
    message['from'] = sys.argv[2]
    message['body'] = sys.argv[3]

    params = dict()
    params['message'] = message
    print("Result: " + requestor.request('send', params))

    # cleanup
    client.close()
github parallel-ml / asplos2018-workshop / mutiple-devices / vgg16 / 8devices / node.py View on Github external
"""
            Send data to other devices. The data packet contains data and models name.
            Ip address of next device pop from Queue of a ip list.

            Args:
                 X: numpy array
                 name: next device models name
                 tag: mark the current layer label
        """
        node = Node.create()
        queue = node.ip[name]
        address = queue.get()

        # initializer use port 9999 to receive data
        port = 9999 if name == 'initial' else 12345
        client = ipc.HTTPTransceiver(address, port)
        requestor = ipc.Requestor(PROTOCOL, client)

        node.name = name

        data = dict()
        data['input'] = X.tostring()
        data['next'] = name
        data['tag'] = tag
        node.log('finish assembly')
        start = time.time()
        requestor.request('forward', data)
        end = time.time()
        node.timer(end - start)

        node.log('node gets request back')
        client.close()