def setUp(self):
     self.context = TopologyContextImpl(
         config={},
         topology=mock_protobuf.get_mock_topology(),
         task_to_component={},
         my_task_id="task_id",
         metrics_collector=None,
         topo_pex_path="path.to.pex")
 def setUp(self):
   self.context = TopologyContextImpl(
     config={},
     topology=mock_protobuf.get_mock_topology(),
     task_to_component={},
     my_task_id="task_id",
     metrics_collector=None,
     topo_pex_path="path.to.pex")
Ejemplo n.º 3
0
def get_a_sample_pplan():
    """Returns a legitimate looking physical plan

  This topology has 1 spout and 2 bolts. Currently no input/output streams.
  There is only one stream manager.

  [Instance 1: spout1]
    - instance_id = "instance1"
    - task_id = 100
    - component_index = 0
    - component_name = "spout1"

  [Instance 2: bolt1]
    - instance_id = "instance2"
    - task_id = 200
    - component_index = 0
    - component_name = "bolt1"

  [instance 3: bolt2]
    - instance_id = "instance3"
    - task_id = 300
    - component_index = 0
    - component_name = "bolt2"

  :returns: PhysicalPlan message and a list of dictionaries for each instance containing
            (instance_id, task_id, comp_index, comp_name)
  """

    spout_1 = mock_protobuf.get_mock_spout(
        component=mock_protobuf.get_mock_component(name="spout1"))
    bolt_1 = mock_protobuf.get_mock_bolt(
        component=mock_protobuf.get_mock_component(name="bolt1"))
    bolt_2 = mock_protobuf.get_mock_bolt(
        component=mock_protobuf.get_mock_component(name="bolt2"))

    topology = mock_protobuf.get_mock_topology(spouts=[spout_1],
                                               bolts=[bolt_1, bolt_2])

    instance_ids = ["instance1", "instance2", "instancer3"]
    task_ids = [100, 200, 300]
    comp_indexes = [0, 0, 0]
    comp_names = ["spout1", "bolt1", "bolt2"]
    instances = []

    for i_id, t_id, c_i, c_name in zip(instance_ids, task_ids, comp_indexes,
                                       comp_names):
        info = mock_protobuf.get_mock_instance_info(task_id=t_id,
                                                    component_index=c_i,
                                                    component_name=c_name)
        instance = mock_protobuf.get_mock_instance(instance_id=i_id, info=info)
        instances.append(instance)

    pplan = mock_protobuf.get_mock_pplan(topology=topology,
                                         instances=instances)

    keys = ["instance_id", "task_id", "comp_index", "comp_name"]
    zipped = list(zip(instance_ids, task_ids, comp_indexes, comp_names))
    return pplan, [dict(list(zip(keys, z))) for z in zipped]
Ejemplo n.º 4
0
def get_a_sample_pplan():
  """Returns a legitimate looking physical plan

  This topology has 1 spout and 2 bolts. Currently no input/output streams.
  There is only one stream manager.

  [Instance 1: spout1]
    - instance_id = "instance1"
    - task_id = 100
    - component_index = 0
    - component_name = "spout1"

  [Instance 2: bolt1]
    - instance_id = "instance2"
    - task_id = 200
    - component_index = 0
    - component_name = "bolt1"

  [instance 3: bolt2]
    - instance_id = "instance3"
    - task_id = 300
    - component_index = 0
    - component_name = "bolt2"

  :returns: PhysicalPlan message and a list of dictionaries for each instance containing
            (instance_id, task_id, comp_index, comp_name)
  """

  spout_1 = mock_protobuf.get_mock_spout(component=mock_protobuf.get_mock_component(name="spout1"))
  bolt_1 = mock_protobuf.get_mock_bolt(component=mock_protobuf.get_mock_component(name="bolt1"))
  bolt_2 = mock_protobuf.get_mock_bolt(component=mock_protobuf.get_mock_component(name="bolt2"))

  topology = mock_protobuf.get_mock_topology(spouts=[spout_1], bolts=[bolt_1, bolt_2])


  instance_ids = ["instance1", "instance2", "instancer3"]
  task_ids = [100, 200, 300]
  comp_indexes = [0, 0, 0]
  comp_names = ["spout1", "bolt1", "bolt2"]
  instances = []

  for i_id, t_id, c_i, c_name in zip(instance_ids, task_ids, comp_indexes, comp_names):
    info = mock_protobuf.get_mock_instance_info(task_id=t_id,
                                                component_index=c_i,
                                                component_name=c_name)
    instance = mock_protobuf.get_mock_instance(instance_id=i_id, info=info)
    instances.append(instance)

  pplan = mock_protobuf.get_mock_pplan(topology=topology, instances=instances)

  keys = ["instance_id", "task_id", "comp_index", "comp_name"]
  zipped = zip(instance_ids, task_ids, comp_indexes, comp_names)
  return pplan, [dict(zip(keys, z)) for z in zipped]
Ejemplo n.º 5
0
def get_mock_requst_packets(is_message):
  """Returns a list of valid IncomingPackets with non-zero REQID and the corresponding raw data"""
  pkt_list = []
  raw_list = []
  message_list = [mock_protobuf.get_mock_register_response(),
                  mock_protobuf.get_mock_config(),
                  mock_protobuf.get_mock_bolt(),
                  mock_protobuf.get_mock_topology()]

  # normal packet (PhysicalPlan as request)
  for message in message_list:
    if is_message:
      reqid = REQID.generate_zero()
    else:
      reqid = REQID.generate()
    normal_pkt = convert_to_incoming_packet(reqid, message)
    pkt_list.append(normal_pkt)
    raw_list.append((reqid, message))

  return pkt_list, raw_list
Ejemplo n.º 6
0
def get_mock_requst_packets(is_message):
    """Returns a list of valid IncomingPackets with non-zero REQID and the corresponding raw data"""
    pkt_list = []
    raw_list = []
    message_list = [
        mock_protobuf.get_mock_register_response(),
        mock_protobuf.get_mock_config(),
        mock_protobuf.get_mock_bolt(),
        mock_protobuf.get_mock_topology()
    ]

    # normal packet (PhysicalPlan as request)
    for message in message_list:
        if is_message:
            reqid = REQID.generate_zero()
        else:
            reqid = REQID.generate()
        normal_pkt = convert_to_incoming_packet(reqid, message)
        pkt_list.append(normal_pkt)
        raw_list.append((reqid, message))

    return pkt_list, raw_list