当前位置: 首页>>代码示例>>Python>>正文


Python State.isUsable方法代码示例

本文整理汇总了Python中uds.core.util.State.State.isUsable方法的典型用法代码示例。如果您正苦于以下问题:Python State.isUsable方法的具体用法?Python State.isUsable怎么用?Python State.isUsable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在uds.core.util.State.State的用法示例。


在下文中一共展示了State.isUsable方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: reduceL1Cache

# 需要导入模块: from uds.core.util.State import State [as 别名]
# 或者: from uds.core.util.State.State import isUsable [as 别名]
    def reduceL1Cache(self, sp, cacheL1, cacheL2, assigned):
        logger.debug("Reducing L1 cache erasing a service in cache for {0}".format(sp))
        # We will try to destroy the newest cacheL1 element that is USABLE if the deployer can't cancel a new service creation
        cacheItems = sp.cachedUserServices().filter(UserServiceManager.getCacheStateFilter(services.UserDeployment.L1_CACHE)).order_by('-creation_date')
        if len(cacheItems) == 0:
            logger.debug('There is more services than configured, but could not reduce cache cause its already empty')
            return

        if cacheL2 < sp.cache_l2_srvs:
            valid = None
            for n in cacheItems:
                if n.needsOsManager():
                    if State.isUsable(n.state) is False or State.isUsable(n.os_state):
                        valid = n
                        break
                else:
                    valid = n
                    break

            if valid is not None:
                valid.moveToLevel(services.UserDeployment.L2_CACHE)
                return

        cache = cacheItems[0]
        cache.removeOrCancel()
开发者ID:aiminickwong,项目名称:openuds,代码行数:27,代码来源:ServiceCacheUpdater.py

示例2: growL1Cache

# 需要导入模块: from uds.core.util.State import State [as 别名]
# 或者: from uds.core.util.State.State import isUsable [as 别名]
    def growL1Cache(self, sp, cacheL1, cacheL2, assigned):
        '''
        This method tries to enlarge L1 cache.

        If for some reason the number of deployed services (Counting all, ACTIVE
        and PREPARING, assigned, L1 and L2) is over max allowed service deployments,
        this method will not grow the L1 cache
        '''
        logger.debug("Growing L1 cache creating a new service for {0}".format(sp))
        # First, we try to assign from L2 cache
        if cacheL2 > 0:
            valid = None
            with transaction.atomic():
                for n in sp.cachedUserServices().select_for_update().filter(UserServiceManager.getCacheStateFilter(services.UserDeployment.L2_CACHE)).order_by('creation_date'):
                    if n.needsOsManager():
                        if State.isUsable(n.state) is False or State.isUsable(n.os_state):
                            valid = n
                            break
                    else:
                        valid = n
                        break

            if valid is not None:
                valid.moveToLevel(services.UserDeployment.L1_CACHE)
                return
        try:
            UserServiceManager.manager().createCacheFor(sp.activePublication(), services.UserDeployment.L1_CACHE)
        except MaxServicesReachedException as e:
            log.doLog(sp, log.ERROR, 'Max number of services reached for this service', log.INTERNAL)
            logger.error(str(e))
        except:
            logger.exception('Exception')
开发者ID:aiminickwong,项目名称:openuds,代码行数:34,代码来源:ServiceCacheUpdater.py

示例3: unpublish

# 需要导入模块: from uds.core.util.State import State [as 别名]
# 或者: from uds.core.util.State.State import isUsable [as 别名]
 def unpublish(self, servicePoolPub):  # pylint: disable=no-self-use
     '''
     Unpublishes an active (usable) or removable publication
     :param servicePoolPub: Publication to unpublish
     '''
     if State.isUsable(servicePoolPub.state) is False and State.isRemovable(servicePoolPub.state) is False:
         raise PublishException(_('Can\'t unpublish non usable publication')
                                )
     if servicePoolPub.userServices.exclude(state__in=State.INFO_STATES).count() > 0:
         raise PublishException(_('Can\'t unpublish publications with services in process'))
     try:
         pubInstance = servicePoolPub.getInstance()
         state = pubInstance.destroy()
         servicePoolPub.setState(State.REMOVING)
         PublicationFinishChecker.checkAndUpdateState(servicePoolPub, pubInstance, state)
     except Exception, e:
         raise PublishException(str(e))
开发者ID:AlexeyBychkov,项目名称:openuds,代码行数:19,代码来源:PublicationManager.py

示例4: isUsable

# 需要导入模块: from uds.core.util.State import State [as 别名]
# 或者: from uds.core.util.State.State import isUsable [as 别名]
 def isUsable(self):
     '''
     Returns if this service is usable
     '''
     return State.isUsable(self.state)
开发者ID:glyptodon,项目名称:openuds,代码行数:7,代码来源:UserService.py

示例5: isUsable

# 需要导入模块: from uds.core.util.State import State [as 别名]
# 或者: from uds.core.util.State.State import isUsable [as 别名]
 def isUsable(self):
     """
     Returns if this service is usable
     """
     return State.isUsable(self.state)
开发者ID:AlexeyBychkov,项目名称:openuds,代码行数:7,代码来源:UserService.py


注:本文中的uds.core.util.State.State.isUsable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。