Esempio n. 1
0
import math
import numpy as np

from ACRCUtil.ACRCRuleChecker import ACRCRuleChecker
from ACRCUtil.ProvisionComponent import ProvisionComponent
from DBUtil.UsingInstancesDBUtil import UsingInstancesDBUtil
from DBUtil.WorkloadDBUtil import WorkloadDBUtil
from LoggingUtil import getLogUtil
from NormalUtil import *
from NovaUtil.TomcatInstanceUtil import TomcatInstanceUtil
from PredictUtil import *
from PredictUtil.ACRCPredictUtil import ACRCPredictUtil

# 不传参数默认日志级别是info
logger = getLogUtil('ACRCProvisionComponent')


class EACRCProvisionComponent(ProvisionComponent):
    def __init__(self,
                 predictor=ACRCPredictUtil(),
                 ruleChecker=ACRCRuleChecker()):
        super(EACRCProvisionComponent, self).__init__(predictor, ruleChecker)

    def getNumberOfVMsShouldBeScaled(self):
        if not self.predictor or not self.ruleChecker:
            raise Exception('no predictor or ruleChecker')

        newestHD = WorkloadDBUtil.getNewestWorkload()

        if not newestHD:
Esempio n. 2
0
from ACRCUtil.ExperimentInit import ExperimentInit
from ACRCUtil.ACRCPlacementComponent import ACRCPlacementComponent
from DBUtil.PMAndAZDBUtil import PMAndAZDBUtil
from DBUtil.PMCPUDBUtil import PMCPUDBUtil
from DBUtil.VMCPUDBUtil import VMCPUDBUtil
from PredictUtil import *
from PredictUtil.PMCPUPredictUtil import PMCPUPredictUtil
from PredictUtil.VMCPUPredictUtil import VMCPUPredictUtil
import httplib, urllib
from LoggingUtil import getLogUtil

# ipEndOfComputes = [50, 60, 70, 80, 210, 220, 230, 240]
ipEndOfComputes = [50, 70, 80, 210, 220, 230, 240]
ipEndOfExThree = [50, 210, 220, 230]
ipEndOfController = 40
cpuLogger = getLogUtil('VMOrPMCPUUtilPredict')


class Controller(object):
    def getThreadInfo(self, req):
        tarId = req.params.get('id')

        if not tarId:
            return errorResultJson('Please pass id!')

        if PMAndAZDBUtil.isPMId(tarId):
            tarIP = PMAndAZDBUtil.getInnerIPByPMId(tarId)
            if not tarIP:
                return errorResultJson(tarId + ' cannot be found')

            os.system('/home/sk/cloudEx/shellScript/getThreadInfo.sh ' + tarIP.split('.')[-1] + ' > /dev/null')
Esempio n. 3
0
#!/usr/bin/env python
# encoding: utf-8

import shelve
from DBUtil.PerformanceDBUtil import PerformanceDBUtil
from ACRCUtil.SLAHandler import SLAHandler
from LoggingUtil import getLogUtil

fiboDataFile = '/home/sk/image/cloudExData/fiboData.db'
fiboDataName = 'FIBODATA'

# 不传参数默认日志级别是info
logger = getLogUtil('ACRCRuleChecker')


class ACRCRuleChecker(object):
    def __init__(self, slaHandler=SLAHandler()):
        self.slaHandler = slaHandler

    # 是否违反了时延违反百分比
    def isBreakRTPercentSLA(self, rtPercent):
        if rtPercent > self.slaHandler.getSLABreakPercent():
            return True
        else:
            return False

    def isBreakCpuUpperLimitSLA(self, cpuUtil):
        if cpuUtil > self.slaHandler.getCpuUpperLimitSLA():
            return True
        else:
            return False
#!/usr/bin/env python
# encoding: utf-8

from ACRCUtil.PlacementComponent import PlacementComponent
from ACRCUtil import topoFilePath
from ACRCUtil import analyseJsonFormatConfigFile
from DBUtil.UsingInstancesDBUtil import UsingInstancesDBUtil
from operator import attrgetter
from NovaUtil.TomcatInstanceUtil import TomcatInstanceUtil
from LoggingUtil import getLogUtil
from ACRCUtil.SLAHandler import SLAHandler
import logging

#不传参数默认日志级别是info
logger = getLogUtil('ACRCPlacementComponent', logging.DEBUG)


class ACRCPlacementComponent(PlacementComponent):
    def __init__(self, topoFile=topoFilePath, slaHandler=SLAHandler()):
        self.topoFilePath = topoFilePath
        self.slaHandler = slaHandler
        self.updateCloudInfo(topoFilePath)

    def calculateSubTreeInvalidProbability(self, treeNode):
        if not treeNode.children:
            return 1 - treeNode.availability
        else:
            subTreesInvalidProbability = []

            for subTree in treeNode.children:
                subTreesInvalidProbability.append(