Exemplo n.º 1
0
def fake_monitor(tconf):
    def getThroughput(self, instId):
        return self.throughputs[instId].throughput

    throughputs = dict()
    instances = Instances()
    for i in range(NUM_OF_REPLICAS):
        throughputs[i] = Monitor.create_throughput_measurement(tconf,
                                                               start_ts=0)
        instances.add(i)
    monitor = FakeSomething(
        throughputs=throughputs,
        instances=instances,
        Delta=tconf.DELTA,
        throughput_avg_strategy_cls=MedianLowStrategy,
    )
    monitor.numOrderedRequests = dict()
    for i in range(NUM_OF_REPLICAS):
        monitor.numOrderedRequests[i] = (100, 100)
    monitor.getThroughputs = functools.partial(Monitor.getThroughputs, monitor)
    monitor.getThroughput = functools.partial(getThroughput, monitor)
    monitor.getInstanceMetrics = functools.partial(Monitor.getInstanceMetrics,
                                                   monitor)
    monitor.masterThroughputRatio = functools.partial(
        Monitor.masterThroughputRatio, monitor)
    return monitor
Exemplo n.º 2
0
def fake_monitor(tconf):
    def getThroughput(self, instId):
        return self.throughputs[instId].throughput

    throughputs = dict()
    instances = Instances()
    num_of_replicas = 5
    for i in range(num_of_replicas):
        throughputs[i] = Monitor.create_throughput_measurement(tconf)
        instances.add(i)
    monitor = FakeSomething(
        throughputs=throughputs,
        instances=instances,
        Delta=tconf.DELTA,
        throughput_avg_strategy_cls=MedianLowStrategy,
        )
    monitor.numOrderedRequests = dict()
    for i in range(num_of_replicas):
        monitor.numOrderedRequests[i] = (100, 100)
    monitor.getThroughputs = functools.partial(Monitor.getThroughputs, monitor)
    monitor.getThroughput = functools.partial(getThroughput, monitor)
    monitor.getInstanceMetrics = functools.partial(Monitor.getInstanceMetrics, monitor)
    monitor.instance_throughput_ratio = functools.partial(Monitor.instance_throughput_ratio, monitor)
    monitor.is_instance_throughput_too_low = functools.partial(Monitor.is_instance_throughput_too_low, monitor)
    monitor.addInstance = functools.partial(Monitor.addInstance, monitor)
    return monitor