Ejemplo n.º 1
0
    def create(self, req):
        rc = req.params.get('requireCount')
        resetFlag = req.params.get('reset')
        if rc and isNumber(rc) and resetFlag and isNumber(resetFlag):
            rc = int(rc)
            resetFlag = int(resetFlag)

            if resetFlag:
                TomcatInstanceUtil.resetAllUsingInstances()

            uic = UsingInstancesDBUtil.getUsingInstancesCount()
            if rc > uic:
                needC = rc - uic
                while needC > 0:
                    TomcatInstanceUtil.createTomcatInstance()
                    needC -= 1
            elif rc < uic:
                deleteC = uic - rc
                TomcatInstanceUtil.deleteSpecifyNumberInstances(deleteC)

            TomcatInstanceUtil.ensureAllUsingInstancesActive()
            return UsingInstancesDBUtil.getAllUsingInstancesInfo()
        else:
            result = errorResultJson('The Post Body Must be {requireCount:x, reset:y} (ps:x must be number, reset must be 0 or 1)')
        return result
Ejemplo n.º 2
0
    def getInitialScheme(self):
        periodDB = shelve.open(periodRecoderFile)
        periodDB[periodRecoder] = None
        periodDB.close()

        fiboDB = shelve.open(fiboDataFile)
        fiboDB[fiboDataName] = None
        fiboDB.close()

        clearAllData()

        PerformanceDBUtil.clearPerformanceDataTable()
        WorkloadDBUtil.clearWorkloadTable()

        uiCount = UsingInstancesDBUtil.getUsingInstancesCount()

        if uiCount < initUsingInstancesNumbers:
            TomcatInstanceUtil.resetAllUsingInstances()
            self.acrcPlacementComponent.getPlacementScheme(
                initUsingInstancesNumbers - uiCount, True)
        elif uiCount > initUsingInstancesNumbers:
            self.acrcPlacementComponent.getPlacementScheme(
                uiCount - initUsingInstancesNumbers, False)
            TomcatInstanceUtil.resetAllUsingInstances()
        else:
            TomcatInstanceUtil.resetAllUsingInstances()
Ejemplo n.º 3
0
    def autonomicPeriodHandler(self):
        scaleContent = self.provisionComponent.getNumberOfVMsShouldBeScaled()

        # re-organize the code, maintaining the logic
        if scaleContent['vmNumbers'] == 0:
            TomcatInstanceUtil.resetAllUsingInstances()
        elif scaleContent['isUp']:
            TomcatInstanceUtil.resetAllUsingInstances()
            self.placementComponent.getPlacementScheme(scaleContent['vmNumbers'], scaleContent['isUp'])
        else:
            self.placementComponent.getPlacementScheme(scaleContent['vmNumbers'], scaleContent['isUp'])
            TomcatInstanceUtil.resetAllUsingInstances()