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


Python AutoScaleConnection.update方法代码示例

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


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

示例1: _remove_from_worker_pool

# 需要导入模块: from boto.ec2.autoscale import AutoScaleConnection [as 别名]
# 或者: from boto.ec2.autoscale.AutoScaleConnection import update [as 别名]
def _remove_from_worker_pool():
    """
    Ensures that this instance is shut down, and unregisted from the worker
    pool.
    """

    # Retrieve the current state of the pool.
    pool = AutoScaleConnection().get_all_groups(["LSDA Worker Pool"])[0]

    if pool.desired_capacity <= pool.min_size:
        return

    # Reduce the pool size and shut ourself down.
    pool.desired_capacity -= 1
    pool.update()
开发者ID:fatlotus,项目名称:lsda-management,代码行数:17,代码来源:management.py

示例2: main

# 需要导入模块: from boto.ec2.autoscale import AutoScaleConnection [as 别名]
# 或者: from boto.ec2.autoscale.AutoScaleConnection import update [as 别名]
def main():
    """
    Main entry point for the automated scaling daemon.
    """

    # Configure logging.
    logging.basicConfig(
        format = "%(asctime)-15s %(levelname)5s %(message)s",
        level = logging.INFO
    )

    # Read configuration.
    options = yaml.load(open("config.yaml"))

    # Connect to the RabbitMQ cluster.
    params = pika.ConnectionParameters(host=options["amqp"])
    conn = pika.BlockingConnection(params)

    channel = conn.channel()

    while True:
        # Ensure that we have things stuck in the queue for the given amount
        # of time.
        for i in xrange(DELAY / 5):
            queue_length = get_queue_length(channel, "stable")

            logging.info("Queue length: {}".format(queue_length))

            if queue_length == 0:
                break
            time.sleep(5)

        else:
            # Scale up!
            group = AutoScaleConnection().get_all_groups(["LSDA Worker Pool"])[0]
            group.desired_capacity = min(
              group.desired_capacity + 2, group.max_size)
            group.update()

            logging.info(
              "Triggering increase to {}".format(group.desired_capacity))

            time.sleep(300)

        # Wait until next polling event.
        time.sleep(30)
开发者ID:fatlotus,项目名称:lsda-automation,代码行数:48,代码来源:scale_up.py


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