예제 #1
0
    def test_something_to_something_update(self):
        property_provider = TestPropertyProvider({CPU_ALLOCATOR: IP})
        config_manager = ConfigManager(property_provider)

        self.assertEqual(IP, config_manager.get_str(CPU_ALLOCATOR))
        property_provider.map[CPU_ALLOCATOR] = GREEDY
        self.assertEqual(GREEDY, config_manager.get_str(CPU_ALLOCATOR))
예제 #2
0
def get_url(config_manager: ConfigManager) -> Optional[str]:
    url_format = config_manager.get_str(PREDICTION_SERVICE_URL_FORMAT_STR)
    if url_format is None:
        return None

    return url_format.format(config_manager.get_region(),
                             config_manager.get_environment())
예제 #3
0
def __get_credential_path(config_manager: ConfigManager,
                          file_name: str) -> Optional[str]:
    credentials_path = config_manager.get_str(CREDENTIALS_PATH)
    if credentials_path is None:
        return None

    return os.path.join(credentials_path, file_name)
    def test_nothing_to_no_change_update(self):
        property_provider = TestPropertyProvider({})
        exit_handler = TestExitHandler()
        config_manager = ConfigManager(property_provider)
        self.assertEqual(None, config_manager.get_str(CPU_ALLOCATOR))
        watcher = RestartPropertyWatcher(config_manager, exit_handler, [CPU_ALLOCATOR])

        watcher.detect_changes()
        self.assertEqual(None, exit_handler.last_code)
    def test_none_to_something_update(self):
        property_provider = TestPropertyProvider({})
        exit_handler = TestExitHandler()
        config_manager = ConfigManager(property_provider)
        self.assertEqual(None, config_manager.get_str(CPU_ALLOCATOR))
        watcher = RestartPropertyWatcher(config_manager, exit_handler, [CPU_ALLOCATOR])

        property_provider.map[CPU_ALLOCATOR] = GREEDY
        watcher.detect_changes()
        self.assertEqual(GENERIC_PROPERTY_CHANGE_EXIT, exit_handler.last_code)
예제 #6
0
def get_free_thread_provider(
        config_manager: ConfigManager) -> FreeThreadProvider:
    free_thread_provider_str = config_manager.get_str(
        FREE_THREAD_PROVIDER, DEFAULT_FREE_THREAD_PROVIDER)
    free_thread_provider = None

    total_threshold = config_manager.get_float(TOTAL_THRESHOLD,
                                               DEFAULT_TOTAL_THRESHOLD)

    if free_thread_provider_str == EMPTY:
        free_thread_provider = EmptyFreeThreadProvider()
    elif free_thread_provider_str == OVERSUBSCRIBE:
        free_thread_provider = OversubscribeFreeThreadProvider(total_threshold)

    log.debug("Free thread provider: '{}'".format(
        free_thread_provider.__class__.__name__))
    return free_thread_provider
    def __init__(self,
                 cpu_usage_predictor_manager: CpuUsagePredictorManager,
                 config_manager: ConfigManager,
                 free_thread_provider: FreeThreadProvider):
        self.__reg = None
        self.__time_bound_call_count = 0
        self.__rebalance_failure_count = 0
        self.__ip_solver_params = IPSolverParameters(
            alpha_nu=config_manager.get_float(ALPHA_NU, DEFAULT_ALPHA_NU),
            alpha_llc=config_manager.get_float(ALPHA_LLC, DEFAULT_ALPHA_LLC),
            alpha_l12=config_manager.get_float(ALPHA_L12, DEFAULT_ALPHA_L12),
            alpha_order=config_manager.get_float(ALPHA_ORDER, DEFAULT_ALPHA_ORDER),
            alpha_prev=config_manager.get_float(ALPHA_PREV, DEFAULT_ALPHA_PREV))

        self.__solver_max_runtime_secs = config_manager.get_float(MAX_SOLVER_RUNTIME, DEFAULT_MAX_SOLVER_RUNTIME)
        self.__solver_name = config_manager.get_str(MIP_SOLVER, DEFAULT_MIP_SOLVER)
        self.__solver_mip_gap = config_manager.get_float(RELATIVE_MIP_GAP_STOP, DEFAULT_RELATIVE_MIP_GAP_STOP)
        self.__cpu_usage_predictor_manager = cpu_usage_predictor_manager
        self.__config_manager = config_manager
        self.__free_thread_provider = free_thread_provider
        self.__cnt_rebalance_calls = 0
        self.__call_meta = None  # track things __place_threads call
예제 #8
0
 def test_something_to_no_change_update(self):
     property_provider = TestPropertyProvider({CPU_ALLOCATOR: IP})
     config_manager = ConfigManager(property_provider)
     self.assertEqual(IP, config_manager.get_str(CPU_ALLOCATOR))
     self.assertEqual(IP, config_manager.get_str(CPU_ALLOCATOR))
예제 #9
0
 def test_construction_without_properties(self):
     property_provider = TestPropertyProvider({})
     config_manager = ConfigManager(property_provider)
     self.assertEqual(None, config_manager.get_str("foo"))
     self.assertEqual(None, config_manager.get_str(CPU_ALLOCATOR))