def JudgeApp(self, request, context):
     """
     Decides whether the specified application can be accepted (i.e. whether its QoS requirements
     are realistic) based on the available measurement data.
     """
     app = Application.init_from_pb(request)
     # The application has to be already registered before, otherwise we cannot judge it
     if not app.name in self.applications:
         return predictor_pb.JudgeReply(
             result=predictor_pb.JudgeResult.Value("NEEDS_DATA"))
     with self._lock:
         # All isolation measurements need to be finished before we can judge the app.
         # if self._measuring_phases[app.name] == MeasuringPhase.ISOLATION:
         # Check every QoS requirement one-by-one:
         for component in app.components.values():
             for probe in component.probes:
                 measurement_name = \
                     MeasurementAggregator.compose_measurement_name(DEFAULT_HARDWARE_ID, [probe.alias])
                 if not self._single_process_predictor.has_measurement(
                         measurement_name):
                     return predictor_pb.JudgeReply(
                         result=predictor_pb.JudgeResult.Value(
                             "NEEDS_DATA"))
                 for requirement in probe.requirements:
                     prediction = False
                     if isinstance(requirement, TimeContract):
                         prediction = self._single_process_predictor.predict_time(
                             probe_name=measurement_name,
                             time_limit=requirement.time,
                             percentile=requirement.percentile)
                     elif isinstance(requirement, ThroughputContract):
                         prediction = self._single_process_predictor.predict_throughput(
                             probe_name=measurement_name,
                             max_mean_time=requirement.mean_request_time)
                     if not prediction:
                         return predictor_pb.JudgeReply(
                             result=predictor_pb.JudgeResult.Value(
                                 "REJECTED"))
         if not app.is_complete:
             return predictor_pb.JudgeReply(
                 result=predictor_pb.JudgeResult.Value("MEASURED"))
         # Application is accepted now
         # However, some QoS requirements may have been added between app registration and app evaluation.
         # Thus, we re-register all the probes to include these requirements
         self.applications[app.name] = app
         for component in app.components.values():
             self._probes_by_component[probe.component.id] = set()
             for probe in component.probes:
                 assert probe.alias in self._probes_by_id
                 self._register_probe(probe)
                 self._probes_by_component[probe.component.id].add(
                     probe.alias)
     return predictor_pb.JudgeReply(
         result=predictor_pb.JudgeResult.Value("ACCEPTED"))
예제 #2
0
 def add_application(self, app_pb) -> None:
     """
     Adds an application to the Knowledge. Converts the protobuf representation into the object representation. Also,
     processes the application's docker secret.
     :param app_pb: protobuf representation of the application architecture.
     """
     app = Application.init_from_pb(app_pb)
     self.applications[app_pb.name] = app
     for component in self.applications[app_pb.name].components.values():
         self.components[component.full_name] = component
     if app_pb.HasField("secret"):
         self._add_secret(app_pb.name, app_pb.secret.value)
     logging.info("An architecture for the %s application was processed." % app_pb.name)
예제 #3
0
 def add_new_application(self, application_pb):
     """
     Adds support for a new application.
     :param application_pb: Protobuf representation of the application
     """
     app = Application.init_from_pb(application_pb)
     app_name = application_pb.name
     self.clients[app_name] = {}
     self.virtual_clients[app_name] = {}
     for component in app.components.values():
         if component.type == ComponentType.UNMANAGED:
             self.virtual_clients[app_name][component.name] = []
             self.check_threshold(app_name, component.name)
     self.applications[app_name] = application_pb
    def RegisterApp(self, request, context):
        """
        Registers the specified application architecture with the performance data aggregator.
        """
        app = Application.init_from_pb(request)
        with self._lock:
            self.applications[app.name] = app
            for component in app.components.values():
                for probe in component.probes:
                    self._register_probe(probe)
                    self._scenario_generator.register_probe(probe)
                    if probe.signal_set != "":
                        if self._single_process_predictor.has_measurement(
                                MeasurementAggregator.compose_measurement_name(
                                    DEFAULT_HARDWARE_ID, [probe.alias])):
                            self._single_process_predictor.report_measurements(
                                probe.alias, probe.signal_set,
                                probe.execution_time_signal,
                                probe.run_count_signal)

        return predictor_pb.RegistrationAck()
예제 #5
0
파일: model.py 프로젝트: smartarch/qoscloud
 def __init__(self, architecture: arch_pb.Architecture):
     self.application: Application = Application.init_from_pb(architecture)
     self._name: str = architecture.name
     self.status = AppStatus.RECEIVED