Exemplo n.º 1
0
    def __init__(self, env, *args, **kwargs):
        self.work_queue = []
        self.message_size_gen = Uniform(MIN_MSG_SIZE, MAX_MSG_SIZE, 'int')
        self.message_value_gen = Uniform(MIN_MSG_VALUE, MAX_MSG_VALUE, 'int')
        self.msg_received = env.event()

        super(PingProgram, self).__init__(env, *args, **kwargs)
Exemplo n.º 2
0
    def script(self):
        rack_options = {
            'size': RACK_SIZE
        }
        node_options = {
            'cpus': NODE_CPUS,
            'memory': NODE_MEMORY
        }
        gen = Cluster.create(
            self.env,
            size=CLUSTER_SIZE,
            rack_options=rack_options,
            node_options=node_options,
        )
        cluster = gen.next()
        self.cluster = cluster

        # create program generator
        pgen = PingProgram.create(self.env, cpus=1, memory=4, ports=[3333, 4444])

        # create nodes using cluster's node generator
        nodes = [cluster.add() for i in range(NODE_COUNT)]

        # assign new programs to each node
        for n in nodes:
            n.assign(pgen.next())

        # set some programs to start working instead of waiting
        starters = random.sample(nodes, START_COUNT)
        work_maker = Uniform(10, 50, 'int')
        for n in starters:
            p = n.programs[n.programs.keys()[0]]
            p.work_queue.append(work_maker.next())
Exemplo n.º 3
0
 def __init__(self, env, station):
     self.station = station
     self.uniform = Uniform(*T_INTER)
     super(CarGenerator, self).__init__(env)
Exemplo n.º 4
0
    def __init__(self, env, station):
        self.station = station
        self.fuel_level = Uniform(*FUELTANK_LEVEL).get()

        super(Car, self).__init__(env)