perfsim.observers

Contents

perfsim.observers#

Module contents#

Submodules#

perfsim.observers.cluster_log_observer module#

class perfsim.observers.cluster_log_observer.ClusterLogObserver(cluster)[source]#

Bases: LogObserver

This class is responsible for logging the events of the cluster.

Parameters:

cluster (Cluster)

after_finish_running_threads_on_a_host = <perfsim.observers.event.Event object>#
after_finish_running_a_thread = <perfsim.observers.event.Event object>#
before_transmitting_requests_in_network = <perfsim.observers.event.Event object>#
in_transmitting_an_active_transmission = <perfsim.observers.event.Event object>#
after_transmitting_an_active_transmission = <perfsim.observers.event.Event object>#
before_load_balancing_a_host = <perfsim.observers.event.Event object>#
before_calling_is_there_a_thread_that_ends_sooner_function = <perfsim.observers.event.Event object>#
before_checking_a_thread_ends_sooner = <perfsim.observers.event.Event object>#
after_calling_is_there_a_thread_that_ends_sooner_function = <perfsim.observers.event.Event object>#

perfsim.observers.core_log_observer module#

class perfsim.observers.core_log_observer.CoreLogObserver(core)[source]#

Bases: LogObserver

This class is an observer that logs the completion of a thread.

Parameters:

core (Core)

on_thread_completion = <perfsim.observers.event.Event object>#

perfsim.observers.cpu_log_observer module#

class perfsim.observers.cpu_log_observer.CPULogObserver(cpu)[source]#

Bases: LogObserver

This class is responsible for logging the events of the CPU.

Parameters:

cpu (CPU)

perfsim.observers.event module#

class perfsim.observers.event.Event(method)[source]#

Bases: object

This class is a decorator that marks a method as an event.

classmethod methods(subject)[source]#

Get the methods of the subject that are marked as events.

Parameters:

subject

Returns:

A dictionary of the methods of the subject that are marked as events.

perfsim.observers.event_observer module#

class perfsim.observers.event_observer.EventObserver(name, subject)[source]#

Bases: ABC

This class is an abstract class that represents an observer of an observable.

Parameters:
callable: Callable#
property events#

Get the events of the observer.

Returns:

The events of the observer.

property subject#

Get the subject of the observer.

Returns:

The subject of the observer.

name: str#
observe(event_name, **kwargs)[source]#

Observe an event.

Parameters:
  • event_name (str) – The name of the event to observe.

  • kwargs – The arguments of the event.

Returns:

The result of the event.

perfsim.observers.load_generator_log_observer module#

class perfsim.observers.load_generator_log_observer.LoadGeneratorLogObserver(load_generator)[source]#

Bases: LogObserver

This class is responsible for logging the events of the load generator.

Parameters:

load_generator (LoadGenerator)

before_traffic_start = <perfsim.observers.event.Event object>#
before_requests_start = <perfsim.observers.event.Event object>#
before_generate_threads = <perfsim.observers.event.Event object>#
before_exec_time_estimation = <perfsim.observers.event.Event object>#
before_executing_threads = <perfsim.observers.event.Event object>#
after_completing_load_generation = <perfsim.observers.event.Event object>#
after_next_batch_arrival_time_calculation = <perfsim.observers.event.Event object>#
before_generate_request_threads = <perfsim.observers.event.Event object>#
after_generate_request_threads = <perfsim.observers.event.Event object>#
after_estimating_time_of_next_event = <perfsim.observers.event.Event object>#
before_transmit_requests_in_network = <perfsim.observers.event.Event object>#
after_transmit_requests_in_network_and_load_balancing_threads = <perfsim.observers.event.Event object>#
before_request_created = <perfsim.observers.event.Event object>#
after_requests_start = <perfsim.observers.event.Event object>#

perfsim.observers.log_observer module#

class perfsim.observers.log_observer.LogObserver(name, subject, logger)[source]#

Bases: EventObserver, ABC

Parameters:
logger: Logger#
observe(event_name, **kwargs)[source]#

Observe an event.

Parameters:
  • event_name (str)

  • kwargs

Returns:

perfsim.observers.observable module#

class perfsim.observers.observable.Observable[source]#

Bases: ABC

This class is an abstract class that represents an observable.

attach_observer(observer)[source]#

Attach an observer to the observable.

Parameters:

observer (EventObserver) – The observer to attach.

Returns:

None

notify_all_observers(**kwargs)[source]#

Notify all observers.

Parameters:

kwargs – The arguments to pass to the observers.

Returns:

notify_observers(event_name, **kwargs)[source]#

Notify the observers of an event.

Parameters:
  • event_name (str) – The name of the event.

  • kwargs – The arguments to pass to the observers.

Returns:

None

detach_observer(observer)[source]#

Detach an observer from the observable.

Parameters:

observer (EventObserver) – The observer to detach.

Returns:

None

register_event(event_name)[source]#

Register an event.

Parameters:

event_name (str)

Returns:

observers: Dict[str, Set[EventObserver]]#

A dictionary of observers, indexed by event type.

notify_observers_on_event: bool#
registered_events: Set[str]#
abstract register_events()[source]#

This is for performance optimization purposes. Instead of generating strings for each event, we can register the event_names as attributes, then we send the event_name as reference, instead of copying the string every time. This (slightly) improves performance, specially because we are calling the notify_observers method several times for each request during the simulation.

Returns:

perfsim.observers.replica_thread_log_observer module#

class perfsim.observers.replica_thread_log_observer.ReplicaThreadLogObserver(replica_thread)[source]#

Bases: LogObserver

This class is responsible for logging the replica thread events.

Parameters:

replica_thread (ReplicaThread)

before_executing_thread = <perfsim.observers.event.Event object>#
after_executing_thread = <perfsim.observers.event.Event object>#
before_killing_thread = <perfsim.observers.event.Event object>#

perfsim.observers.replica_thread_timeline_observer module#

class perfsim.observers.replica_thread_timeline_observer.ReplicaThreadTimelineObserver(replica_thread)[source]#

Bases: EventObserver

This class is responsible for logging the replica thread events.

Parameters:

replica_thread (ReplicaThread)

before_killing_thread = <perfsim.observers.event.Event object>#
before_executing_thread = <perfsim.observers.event.Event object>#
after_executing_thread = <perfsim.observers.event.Event object>#

perfsim.observers.request_log_observer module#

class perfsim.observers.request_log_observer.RequestLogObserver(request)[source]#

Bases: LogObserver

Parameters:

request (Request)

before_init_next_microservices = <perfsim.observers.event.Event object>#
print_current_and_next_nodes_and_replicas()[source]#
after_init_next_microservices = <perfsim.observers.event.Event object>#
before_finalizing_subchain = <perfsim.observers.event.Event object>#
before_concluding_request = <perfsim.observers.event.Event object>#
before_init_transmission = <perfsim.observers.event.Event object>#
on_init_transmission = <perfsim.observers.event.Event object>#
after_init_transmission = <perfsim.observers.event.Event object>#
before_finish_transmission = <perfsim.observers.event.Event object>#
after_finish_transmission = <perfsim.observers.event.Event object>#

perfsim.observers.results_observer module#

class perfsim.observers.results_observer.ResultsObserver(load_generator)[source]#

Bases: EventObserver

Parameters:

load_generator (LoadGenerator)

after_completing_load_generation = <perfsim.observers.event.Event object>#

perfsim.observers.topology_log_ovserver module#

class perfsim.observers.topology_log_ovserver.TopologyLogObserver(topology)[source]#

Bases: LogObserver

Parameters:

topology (Topology)

perfsim.observers.transmission_log_observer module#

class perfsim.observers.transmission_log_observer.TransmissionLogObserver(transmission)[source]#

Bases: LogObserver

Parameters:

transmission (Transmission)

on_current_bw_change = <perfsim.observers.event.Event object>#
on_all_transmissions_start = <perfsim.observers.event.Event object>#
on_all_transmissions_end = <perfsim.observers.event.Event object>#
on_before_transmission_time_calculation = <perfsim.observers.event.Event object>#
on_after_transmission_time_calculation = <perfsim.observers.event.Event object>#