Esempio n. 1
0
def run_load_generator():
    logger = getLogger("generator")

    apps = list(range(NUM_APPS))
    nodes = list(range(NUM_NODES))
    apps_nodes = list(itertools.product(apps, nodes))

    logger.info("Starting load generator")
    load_generator = drop.Drop()
    for curtime in range(BEGIN_TIME, END_TIME):
        random.shuffle(apps_nodes)
        for (app, node) in apps_nodes:
            send_topic = "{}".format(TOPIC_GENERATOR)
            message = {
                "time": curtime,
                "app": app,
                "node": node,
                "requests": random.randrange(1000)
            }
            load_generator.send_event(send_topic, message)

        if curtime % 60 * 5 == 0:
            logger.debug("current time: {}".format(curtime))

    logger.info("Stopping load generator")
    load_generator.cleanup()
Esempio n. 2
0
def run_aggregator():
    logger = getLogger("aggregator")

    aggregator = drop.Drop(subscriptions=[TOPIC_ACCUMULATOR])
    logger.info("Starting aggregator service")
    aggregator.receive_loop(ag_process_message)\

    aggregator.info("Stopping aggregator service")
    aggregator.cleanup()
Esempio n. 3
0
def run_accumulator():
    logger = getLogger("accumulator")

    accumulator = drop.Drop(subscriptions=[TOPIC_GENERATOR])
    logger.info("Starting accumulator service")
    accumulator.receive_loop(ac_process_message)

    logger.info("Stopping accumulator service")
    accumulator.cleanup()
Esempio n. 4
0
def run_storage():
    logger = getLogger("storage")

    storage = drop.Drop(subscriptions=[TOPIC_AGGREGATOR])
    logger.info("Starting storage service")
    storage.receive_loop(s_process_message)

    logger.info("Stopping storage service")
    storage.cleanup()
    for _, fd in files.items():
        fd.close()
Esempio n. 5
0
def main(output_dir, num, launch_build=True, port=1071):
    scenarios = get_drop_target_pairs(SCENARIOS)
    for i, ((sd, st), tp) in enumerate(scenarios):
        if isinstance(sd, str):
            drop_obj = sd
            drop_rotation = {"x": 0, "y": 0, "z": 0}
            drop_scale = 1
        else:
            drop_obj, drop_rotation, drop_scale = sd
        if isinstance(st, str):
            target_obj = st
            target_rotation = {"x": 0, "y": 0, "z": 0}
            target_scale = 1
        else:
            target_obj, target_rotation, target_scale = st

        suffix = scenario_pathname(drop_obj, target_obj, tp)
        output_path = os.path.join(output_dir, suffix)
        temp_path = 'tmp'

        drop_rotation_range = Rotator(
            {
                "x": [-20, 20],
                "y": [-20, 20],
                "z": [-20, 20]
            },
            seed=i,
            initial=drop_rotation)

        if i == 0:
            dc = drop.Drop(launch_build=launch_build,
                           port=port,
                           randomize=0,
                           seed=0,
                           height_range=[2.1, 2.1],
                           drop_scale_range=drop_scale,
                           drop_jitter=0.35,
                           drop_rotation_range=drop_rotation_range,
                           drop_objects=[drop_obj],
                           target_objects=[target_obj],
                           target_scale_range=target_scale,
                           target_rotation_range=target_rotation,
                           camera_radius=2.5,
                           camera_min_angle=0,
                           camera_max_angle=0)

            initialization_commands = dc.get_initialization_commands(
                width=256, height=256)
            dc.communicate(initialization_commands)
        else:
            dc.clear_static_data()
            dc.drop_scale_range = drop_scale
            dc.target_scale_range = target_scale
            dc.drop_rotation_range = drop_rotation_range
            dc.target_rotation_range = target_rotation
            dc.set_drop_types([drop_obj])
            dc.set_target_types([target_obj])

        dc.trial_loop(num, output_dir=output_path, temp_path=temp_path)

    dc.communicate({"$type": "terminate"})