Ejemplo n.º 1
0
def tell_constrains(instance,
                    machine,
                    appsMap,
                    residual_machine_disk,
                    residual_machine_cpu,
                    residual_machine_mem,
                    machine_instances_num_map,
                    residual_machine_m,
                    residual_machine_p,
                    residual_machine_pm,
                    instance_interferences,
                    print_info=False):
    if produce_seed.tell_disk_constraint(instance, machine, appsMap,
                                         residual_machine_disk):
        if print_info:
            print('检测disk不合')
        return False
    if produce_seed.tell_cpu_constraint(instance, machine, appsMap,
                                        residual_machine_cpu):
        if print_info:
            print('检测cpu不合')
        return False
    if produce_seed.tell_mem_constraint(instance, machine, appsMap,
                                        residual_machine_mem):
        if print_info:
            print('检测mem不合')
        return False
    if produce_seed.tell_app_interference_constraint(
            instance, machine, appsMap, machine_instances_num_map,
            instance_interferences, print_info):
        if print_info:
            print('检测app interfere不合')
            print(machine_instances_num_map[machine.machineId])
        return False
    if produce_seed.tell_m_constraint(instance, machine, appsMap,
                                      residual_machine_m):
        if print_info:
            print('检测m不合')
        return False
    if produce_seed.tell_p_constraint(instance, machine, appsMap,
                                      residual_machine_p):
        if print_info:
            print('检测p不合')
        return False
    if produce_seed.tell_pm_constraint(instance, machine, appsMap,
                                       residual_machine_pm):
        if print_info:
            print('检测pm不合')
        return False
    return True
Ejemplo n.º 2
0
fit = fitness.fitnessfun(machine_instances_map, machinesMap, appsMap, len(instancesMap),
                         len(instancesMap))
print(fit)

_, residual_machine_p, residual_machine_m, residual_machine_pm, \
residual_machine_disk, residual_machine_cpu, half_residual_machine_cpu, used_machine_cpu, \
machine_cpu_score, residual_machine_mem, machine_instances_num_map = produce_seed.init_exist_instances(sortedMachineList, cpu_threhold=1)

for machineId, instances in machine_instances_map.items():
    machine = machinesMap[machineId]
    for instance in instances:
        # print('instance:', instance.instanceId)
        if produce_seed.tell_disk_constraint(instance, machine, appsMap, residual_machine_disk):
            print('不满足disk约束')
            continue
        if produce_seed.tell_mem_constraint(instance, machine, appsMap, residual_machine_mem):
            print('不满足mem约束')
            continue
        if produce_seed.tell_app_interference_constraint(instance, machine, appsMap,
                                            machine_instances_num_map, instance_interferences):
            print('不满足app interfer约束')
            continue
        if produce_seed.tell_m_constraint(instance, machine, appsMap, residual_machine_m):
            print('不满足m约束')
            continue
        if produce_seed.tell_p_constraint(instance, machine, appsMap, residual_machine_p):
            print('不满足p约束')
            continue
        if produce_seed.tell_pm_constraint(instance, machine, appsMap, residual_machine_pm):
            continue
        if produce_seed.tell_cpu_constraint(instance, machine, appsMap, half_residual_machine_cpu):
Ejemplo n.º 3
0
def post_check(machinesMap, sortedMachineList, machine_instances_map, appsMap,
               instance_interferences):
    new_machine_instances_map, residual_machine_p, residual_machine_m, residual_machine_pm, \
    residual_machine_disk, residual_machine_cpu, half_residual_machine_cpu, used_machine_cpu, \
    machine_cpu_score, residual_machine_mem, machine_instances_num_map = produce_seed.init_exist_instances(
        sortedMachineList, appsMap, cpu_threhold=1)
    for machineId, instances in machine_instances_map.items():
        if machinesMap.get(machineId) is None:
            # print('instances 数量', len(instances))
            continue
        machine = machinesMap[machineId]
        for instance in instances:
            # print('instance:', instance.instanceId)
            if produce_seed.tell_disk_constraint(instance, machine, appsMap,
                                                 residual_machine_disk):
                print('不满足disk约束')
                continue
            if produce_seed.tell_mem_constraint(instance, machine, appsMap,
                                                residual_machine_mem):
                print('不满足mem约束')
                continue
            if produce_seed.tell_app_interference_constraint(
                    instance, machine, appsMap, machine_instances_num_map,
                    instance_interferences):
                print('不满足app interfer约束')
                continue
            if produce_seed.tell_m_constraint(instance, machine, appsMap,
                                              residual_machine_m):
                print('不满足m约束')
                continue
            if produce_seed.tell_p_constraint(instance, machine, appsMap,
                                              residual_machine_p):
                print('不满足p约束')
                continue
            if produce_seed.tell_pm_constraint(instance, machine, appsMap,
                                               residual_machine_pm):
                continue
            if produce_seed.tell_cpu_constraint(instance, machine, appsMap,
                                                half_residual_machine_cpu,
                                                machine_instances_map):

                print('不满足cpu约束')
                continue
            new_machine_instances_map[machineId].append(instance)
            if machine_instances_num_map.get(machineId).get(
                    instance.appId) is None:
                machine_instances_num_map[machineId][instance.appId] = 1
            else:
                machine_instances_num_map[machineId][instance.appId] += 1
            residual_machine_p[machineId] -= appsMap[instance.appId].p
            residual_machine_m[machineId] -= appsMap[instance.appId].m
            residual_machine_pm[machineId] -= appsMap[instance.appId].pm
            residual_machine_disk[machineId] -= appsMap[instance.appId].disk
            for i in range(T):
                residual_machine_cpu[machineId][i] -= appsMap[
                    instance.appId].cpus[i]
                half_residual_machine_cpu[machineId][i] -= appsMap[
                    instance.appId].cpus[i]
                used_machine_cpu[machineId][i] += appsMap[
                    instance.appId].cpus[i]
            for i in range(T):
                residual_machine_mem[machineId][i] -= appsMap[
                    instance.appId].mems[i]