コード例 #1
0
    def __init__(self, machineNames):
        """
            constructor
        """
        RandomSimulator.__init__(self, machineNames)

        self.badMachines = ["machine1-3", "machine2-6", "machine2-7", "machine3-1"]

        self.badNodeHealthDelta = { }
        for name in self.deltaMap['health']:
            self.badNodeHealthDelta[name] = self.deltaMap['health'][name]

        self.badNodeMemoryDelta = numpy.random.normal(loc=0.02, scale=0.05, size=1000)

        self.weightedMachineNamesList = deepcopy(self.machineNames)
        for name in self.badMachines:
            for i in xrange(0,3):
                self.weightedMachineNamesList.append(name)

        self.weightedSeverities = deepcopy(self.severities)
        for i in xrange(0,4):
            self.weightedSeverities.append("FATAL")
        for i in xrange(0,3):
            self.weightedSeverities.append("ERROR")

        self.weightedFacilities = deepcopy(self.facilities)
        for i in xrange(0,4):
            self.weightedFacilities.append("KERNEL")
コード例 #2
0
    def __init__(self, machineNames):
        """
            constructor
        """
        self.lowCpuUsageDelta = numpy.random.normal(loc=-0.025, scale=0.05, size=1000)
        self.highCpuUsageDelta = numpy.random.normal(loc=0.025, scale=0.05, size=1000)

        RandomSimulator.__init__(self, machineNames)
コード例 #3
0
    def updates(self):
        updates = RandomSimulator.updates(self)

        updates['start'] = []
        updates['end'] = []

        for mapTask in self.map:
            if mapTask['start'] == self.time:
                updates['start'].append(mapTask)
                self.addMachine(mapTask['name'])
            elif mapTask['end'] == self.time:
                updates['end'].append(mapTask)
                self.removeMachine(mapTask['name'])

        for reduceTask in self.reduce:
            if reduceTask['start'] == self.time:
                updates['start'].append(reduceTask)
                self.addMachine(reduceTask['name'])
            elif reduceTask['end'] == self.time:
                updates['end'].append(reduceTask)
                self.removeMachine(reduceTask['name'])

        self.time += 1

        return updates
コード例 #4
0
    def __init__(self, machineNames, taskName, time):
        RandomSimulator.__init__(self, [])

        self.taskName = taskName

        numberOfMapJobs = 10
        self.map = []
        for i in xrange(0, numberOfMapJobs):
            mapJob = {
                'id': i,
                'name': "%s%s%d" % (self.taskName, "-mapJob", i),
                'start': time + 0,
                'duration': int(numpy.random.normal(loc=60, scale=5)),
                'location': getRandomElement(machineNames)
            }
            if mapJob['duration'] <= 0:
                mapJob['duration'] = 1
            mapJob['end'] = int(mapJob['start'] + mapJob['duration'])
            self.map.append(mapJob)

        numberOfReduceJobs = 10
        self.reduce = []
        for i in xrange(0, numberOfReduceJobs):
            reduceJob = {
                'id': numberOfMapJobs + i,
                'name': "%s%s%d" % (self.taskName, "-reduceJob", i),
                'start': time + int(numpy.random.normal(loc=60, scale=5)),
                'duration': int(numpy.random.normal(loc=60, scale=5)),
                'location': getRandomElement(machineNames)
            }
            if reduceJob['duration'] <= 0:
                reduceJob['duration'] = 1
            reduceJob['end'] = int(reduceJob['start'] + reduceJob['duration'])
            self.reduce.append(reduceJob)

        self.time = time
コード例 #5
0
    def randomizeProperty(self, nodeName, propertyName, associatedData=None):
        """
            Randomizes a property for a given node, returning its new value
        """

        # the following machines will have poor health
        if nodeName in self.badMachines:
            if propertyName == "health":
                return normalizeValue(self.nodeState[nodeName][propertyName] + self.badNodeHealthDelta[associatedData['severity']])
            elif propertyName == "memoryUsage":
                return normalizeValue(self.nodeState[nodeName][propertyName] + getRandomElement(self.badNodeMemoryDelta))

        if propertyName == "memoryUsage":
            return normalizeValue(self.nodeState[nodeName][propertyName] + numpy.random.normal(loc=-0.025, scale=0.05))

        return RandomSimulator.randomizeProperty(self, nodeName, propertyName, associatedData)
コード例 #6
0
    def randomizeProperty(self, nodeName, propertyName, associatedData=None):
        """
            Randomizes a property for a given node, returning its new value
        """

        # rack1 will have low CPU & memory utilization
        if propertyName == "cpuUsage" and "machine1" in nodeName:
            return normalizeValue(self.nodeState[nodeName][propertyName] + getRandomElement(self.lowCpuUsageDelta))

        # rack3 will have high CPU utilization
        elif propertyName == "cpuUsage" and "machine3" in nodeName:
            return normalizeValue(self.nodeState[nodeName][propertyName] + getRandomElement(self.highCpuUsageDelta))

        if propertyName == "contextSwitchRate":
            return normalizeValue(self.nodeState[nodeName]["cpuUsage"] + numpy.random.normal(loc=0, scale=0.10))

        else:
            return RandomSimulator.randomizeProperty(self, nodeName, propertyName, associatedData)