def __init__(self, sim, **kwargs): # Distributions to change locations and devices self.do_move = Bernoulli(kwargs.get('move_prob', settings.simulation.move_prob)) self.do_switch = Bernoulli(kwargs.get('switch_prob', settings.simulation.switch_prob)) # Initialize the Process super(MobileWorkload, self).__init__(sim, **kwargs)
def __init__(self, sim, connections, **kwargs): """ Initialize the workload with the simulation (containing both the environment and the topology for work), the set of connections to cause outages for as a group, and any additional arguments. """ self.sim = sim self.connections = connections self.do_outage = Bernoulli( kwargs.pop('outage_prob', settings.simulation.outage_prob)) # NOTE: This will not call any methods on the connections (on purpose) self._state = ONLINE # Distribution of outage duration self.outage_duration = BoundedNormal( kwargs.pop('outage_mean', settings.simulation.outage_mean), kwargs.pop('outage_stddev', settings.simulation.outage_stddev), floor=10.0, ) # Distribution of online duration self.online_duration = BoundedNormal( kwargs.pop('online_mean', settings.simulation.online_mean), kwargs.pop('online_stddev', settings.simulation.online_stddev), floor=10.0, ) # Initialize the Process super(OutageGenerator, self).__init__(sim.env)
def __init__(self, sim, **kwargs): """ Initialize workload probabilities and distributions before passing all optional keyword arguments to the super class. """ # Distribution for whether or not to change objects self.do_object = Bernoulli( kwargs.pop('object_prob', settings.simulation.object_prob)) self.do_read = Bernoulli( kwargs.pop('read_prob', settings.simulation.read_prob)) # Interval distribution for the wait (in ms) to the next access. self.next_access = BoundedNormal( kwargs.pop('access_mean', settings.simulation.access_mean), kwargs.pop('access_stddev', settings.simulation.access_stddev), floor=1.0, ) # Initialize the Workload super(RoutineWorkload, self).__init__(sim, **kwargs) # If current is None, update the state of the workload: if self.current is None: self.update()
def __init__(self, sim, devices, **kwargs): """ Instead of specifying a single device for the workload, specify multiple devices that we ping pong betweeen with accesses. """ if len(devices) < 2: raise WorkloadException( "Ping Pong requires at least two devices to play") self.players = devices self.do_move = Bernoulli( kwargs.get('move_prob', settings.simulation.move_prob)) kwargs['device'] = Discrete(devices).get() super(PingPongWorkload, self).__init__(sim, **kwargs)
def __init__(self, sim, n_objects=None, conflict_prob=None, loc_max_users=None, **defaults): """ Initialize the conflict workload allocation with the following params: - n_objects: number of objects per user (constant or range) - conflict_prob: the likelihood of assigning an object to multiple replicas - loc_max_users: the maximum users per location during allocation Workloads are allocated to each location in a round robin fashion up to the maximum number of users or if the location maximum limits are reached (or no devices remain to allocate to). """ # Initialize the topology workload super(ConflictWorkloadAllocation, self).__init__(sim, **defaults) # Initialize parameters or get from settings self.n_objects = n_objects self.loc_max_users = loc_max_users self.do_conflict = Bernoulli(conflict_prob or settings.simulation.conflict_prob) # Reorganize the devices into locations tracking the location index # as well as how many users are assigned to each location via a map. self.locidx = 0 self.locations = {device.location: 0 for device in self.devices} self.devices = { location: [device for device in self.devices if device.location == location] for location in self.locations.keys() }
def __init__(self, simulation, **kwargs): super(FederatedEventualReplica, self).__init__(simulation, **kwargs) # Federated settings self.do_sync = Bernoulli(kwargs.get('sync_prob', SYNC_PROB)) self.do_local = Bernoulli(kwargs.get('local_prob', LOCAL_PROB))