Exemplo n.º 1
0
 def __init__(self, cpu, mem, port, master_addr):
     self._cpu = cpu
     self._mem = mem
     self._master_addr = master_addr
     self._mutex = thread.allocate_lock()
     self._channel = client.Channel(master_addr)
     self._version = 0
     self._my_addr = "%s:%d" % (socket.gethostname(), port)
     self._agent_id = -1
     self._task_status = {}
Exemplo n.º 2
0
    def AddMonitorRpc(self, request):
        req = json.loads(request.GET.get('json_param'))

        pb_request = scheduler_pb2.RpcMonitorRequest()
        pb_request.db_name = req['db_name']
        pb_request.table_name = req['table_name']
        pb_request.moduler_owner.extend(req['mail_list'])
        rule_set = req['rule_set']

        result = rule_set['result']
        self.ConvertRule(result, pb_request.rule_set.result)

        rule_list = rule_set['rule_list']
        for rule in rule_list:
            pb_rule = pb_request.rule_set.rule_list.add()
            self.ConvertRule(rule, pb_rule)

        rpc_channel = client.Channel(self.service_addr)
        sdk = scheduler_pb2.LogSchedulerService_Stub(rpc_channel)
        controller = client.Controller()
        controller.SetTimeout(5)
        pb_response = sdk.RpcMonitor(controller, pb_request)

        return True
Exemplo n.º 3
0
 def __init__(self, master_addr):
     self.channel = client.Channel(master_addr)
Exemplo n.º 4
0
# This is a sample code to show how to use python client of sofa-pbrpc.
#
# Preconditions:
#   * The protobuf python lib has been installed.
#   * The sofa-pbrpc python lib has been installed.
#   * The server in ../../sample/echo has been started.
#
# For more, please refer to `./README'.

from sofa.pbrpc import client
import echo_service_pb2
import sys

# Create service stub.
channel = client.Channel('127.0.0.1:12321')
service = echo_service_pb2.EchoServer_Stub(channel)

# Create controller.
# We set timeout to 1.5 seconds by controller.SetTimeout() method.
controller = client.Controller()
controller.SetTimeout(1.5)

# Prepare request.
request = echo_service_pb2.EchoRequest()
request.message = 'Hello World'

# Call method.
try:
    response = service.Echo(controller, request)
except client.TimeoutError:
Exemplo n.º 5
0
 def __init__(self, addr):
     self.channel = client.Channel(addr)
Exemplo n.º 6
0
 def __init__(self, lumia_ctrl_addr):
     self.channel = client.Channel(lumia_ctrl_addr)