Example #1
0
def run():
    args = parse_args()

    configure_logging(args.logconf)

    cluster_config = config.get_cluster_config(
        args.cluster_type,
        args.cluster_name,
        args.discovery_base_path,
    )

    if args.group_parser:
        rg_parser = dynamic_import(args.group_parser, ReplicationGroupParser)()
    else:
        rg_parser = DefaultReplicationGroupParser()

    if args.partition_measurer:
        partition_measurer = dynamic_import(args.partition_measurer,
                                            PartitionMeasurer)
    else:
        partition_measurer = UniformPartitionMeasurer

    if args.cluster_balancer:
        cluster_balancer = dynamic_import(args.cluster_balancer,
                                          ClusterBalancer)
    else:
        cluster_balancer = PartitionCountBalancer

    args.command(
        cluster_config,
        rg_parser,
        partition_measurer,
        cluster_balancer,
        args,
    )
Example #2
0
def get_task_class(tasks, task_args):
    """Reads in a list of tasks provided by the user,
    loads the appropiate task, and returns two lists,
    pre_stop_tasks and post_stop_tasks
    :param tasks: list of strings locating tasks to load
    :type tasks: list
    :param task_args: list of strings to be used as args
    :type task_args: list
    """
    pre_stop_tasks = []
    post_stop_tasks = []
    task_to_task_args = dict(list(zip(tasks, task_args)))
    tasks_classes = [PreStopTask, PostStopTask]

    for func, task_args in task_to_task_args.items():
        for task_class in tasks_classes:
            imported_class = dynamic_import(func, task_class)
            if imported_class:
                if task_class is PreStopTask:
                    pre_stop_tasks.append(imported_class(task_args))
                elif task_class is PostStopTask:
                    post_stop_tasks.append(imported_class(task_args))
                else:
                    print("ERROR: Class is not a type of Pre/Post StopTask:" +
                          func)
                    sys.exit(1)
    return pre_stop_tasks, post_stop_tasks
Example #3
0
def get_task_class(tasks, task_args):
    """Reads in a list of tasks provided by the user,
    loads the appropiate task, and returns two lists,
    pre_stop_tasks and post_stop_tasks
    :param tasks: list of strings locating tasks to load
    :type tasks: list
    :param task_args: list of strings to be used as args
    :type task_args: list
    """
    pre_stop_tasks = []
    post_stop_tasks = []
    task_to_task_args = dict(list(zip(tasks, task_args)))
    tasks_classes = [PreStopTask, PostStopTask]

    for func, task_args in task_to_task_args.items():
        for task_class in tasks_classes:
            imported_class = dynamic_import(func, task_class)
            if imported_class:
                if task_class is PreStopTask:
                    pre_stop_tasks.append(imported_class(task_args))
                elif task_class is PostStopTask:
                    post_stop_tasks.append(imported_class(task_args))
                else:
                    print("ERROR: Class is not a type of Pre/Post StopTask:" + func)
                    sys.exit(1)
    return pre_stop_tasks, post_stop_tasks
Example #4
0
def run():
    args = parse_args()

    configure_logging(args.logconf)

    cluster_config = config.get_cluster_config(
        args.cluster_type,
        args.cluster_name,
        args.discovery_base_path,
    )

    if args.group_parser:
        rg_parser = dynamic_import(args.group_parser, ReplicationGroupParser)()
    else:
        rg_parser = DefaultReplicationGroupParser()

    if args.partition_measurer:
        partition_measurer = dynamic_import(
            args.partition_measurer,
            PartitionMeasurer
        )
    else:
        partition_measurer = UniformPartitionMeasurer

    if args.cluster_balancer:
        cluster_balancer = dynamic_import(
            args.cluster_balancer,
            ClusterBalancer
        )
    else:
        cluster_balancer = PartitionCountBalancer

    args.command(
        cluster_config,
        rg_parser,
        partition_measurer,
        cluster_balancer,
        args,
    )