• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python events.trigger函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mysql.fabric.events.trigger函数的典型用法代码示例。如果您正苦于以下问题:Python trigger函数的具体用法?Python trigger怎么用?Python trigger使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: _do_block_write_master

def _do_block_write_master(group_id, master_uuid, update_only=False):
    """Block and disable write access to the current master.

    Note that connections are not killed and blocking the master
    may take some time.
    """
    master = _server.MySQLServer.fetch(_uuid.UUID(master_uuid))
    assert(master.status == _server.MySQLServer.PRIMARY)
    master.mode = _server.MySQLServer.READ_ONLY
    master.status = _server.MySQLServer.SECONDARY

    if not update_only:
        master.connect()
        _utils.set_read_only(master, True)
        _utils.set_offline_mode(master, True)

    # Temporarily unset the master in this group.
    group = _server.Group.fetch(group_id)
    _set_group_master_replication(group, None)

    # At the end, we notify that a server was demoted.
    # Any function that implements this event should not
    # run any action that updates Fabric. The event was
    # designed to trigger external actions such as:
    #
    # . Updating an external entity.
    #
    # . Fencing off a server.
    _events.trigger("SERVER_DEMOTED", set([group_id]),
        group_id, str(master.uuid)
    )
开发者ID:gmo-media,项目名称:mikasafabric,代码行数:31,代码来源:highavailability.py


示例2: _change_to_candidate

def _change_to_candidate(group_id, master_uuid, update_only=False):
    """Switch to candidate slave.
    """
    forbidden_status = (_server.MySQLServer.FAULTY, )
    master = _server.MySQLServer.fetch(_uuid.UUID(master_uuid))
    master.mode = _server.MySQLServer.READ_WRITE
    master.status = _server.MySQLServer.PRIMARY

    if not update_only:
        # Prepare the server to be the master
        master.connect()
        _utils.reset_slave(master)
        _utils.set_read_only(master, False)

    group = _server.Group.fetch(group_id)
    _set_group_master_replication(group, master.uuid, update_only)

    if not update_only:
        # Make slaves point to the master.
        for server in group.servers():
            if server.uuid != _uuid.UUID(master_uuid) and \
                server.status not in forbidden_status:
                try:
                    server.connect()
                    _utils.switch_master(server, master)
                except _errors.DatabaseError as error:
                    _LOGGER.debug(
                        "Error configuring slave (%s).", server.uuid,
                        exc_info=error
                    )

    # At the end, we notify that a server was promoted.
    _events.trigger("SERVER_PROMOTED", set([group_id]),
        group_id, master_uuid
    )
开发者ID:rockiebond,项目名称:mysql-fabric,代码行数:35,代码来源:highavailability.py


示例3: check_properties_5

def check_properties_5(param_01, param_02):
    """Check properties 5.
    """
    _events.trigger(
        EVENT_CHECK_PROPERTIES_2, set(["lock"]), "NEW 01", "NEW 02"
        )

    job = _executor.ExecutorThread.executor_object().current_job
    checkpoint = _checkpoint.Checkpoint.fetch(job.procedure.uuid)
    return checkpoint
开发者ID:rockiebond,项目名称:mysql-fabric,代码行数:10,代码来源:test_checkpoints.py


示例4: execute

    def execute(self, provider_id, username, password, url, tenant=None,
                provider_type="OPENSTACK", default_image=None,
                default_flavor=None, extra=None, synchronous=True):
        """Register a provider.

        :param provider_id: Provider's Id.
        :param username: User name to use during authentication.
        :param password: Password to use during authentication.
        :param url: URL that is used as an access point.
        :param tenant: Tenant's name, i.e. who will access resources
                       in the cloud.
        :param provider_type: Provider type.
        :param image: Default image's name that will be used upon creating
                      a machine if one is not provided.
        :param image: Default flavor's name that will be used upon creating
                      a machine if one is not provided.

        :param extra: Define parameters that are specific to a provider.
        :param synchronous: Whether one should wait until the execution finishes
                            or not.
        :return: Tuple with job's uuid and status.
        """
        procedures = _events.trigger(
            REGISTER_PROVIDER, self.get_lockable_objects(), provider_id,
            provider_type, username, password, url, tenant, default_image,
            default_flavor, extra
        )
        return self.wait_for_procedures(procedures, synchronous)
开发者ID:gmo-media,项目名称:mikasafabric,代码行数:28,代码来源:provider.py


示例5: test_properties_5

    def test_properties_5(self):
        """5 - Within a job, triggering a set of independent jobs.
        """
        procedures = _events.trigger(
            EVENT_CHECK_PROPERTIES_5, set(["lock"]), "PARAM 01", "PARAM 02"
            )

        # Get the result (Checkpoint object) from the procedure.
        self.assertEqual(len(procedures), 1)
        result = None
        procedure = None
        for procedure in procedures:
            procedure.wait()
            result = procedure.result

            # Fetch and check all the properties.
            self.assertEqual(len(result), 1)
            for checkpoint in result:
                self.assertEqual(checkpoint.param_args,
                    ("PARAM 01", "PARAM 02")
                )
                self.assertEqual(checkpoint.param_kwargs, {})
                self.assertNotEqual(checkpoint.started, None)
                self.assertEqual(checkpoint.finished, None)
                self.assertEqual(checkpoint.do_action, check_properties_5)

        # There should not be any entry for this procedure.
        self.assertEqual(len(_checkpoint.Checkpoint.fetch(procedure.uuid)), 0)
开发者ID:rockiebond,项目名称:mysql-fabric,代码行数:28,代码来源:test_checkpoints.py


示例6: execute

    def execute(self, shard_id, group_id, update_only=False,
                synchronous=True):
        """Move the shard represented by the shard_id to the destination group.

        :param shard_id: The ID of the shard that needs to be moved.
        :param group_id: The ID of the group to which the shard needs to
                         be moved.
        :update_only: Only update the state store and skip provisioning.
        :param synchronous: Whether one should wait until the execution finishes
                        or not.
        """
        mysqldump_binary = _services_utils.read_config_value(
                                self.config,
                                'sharding',
                                'mysqldump_program'
                            )
        mysqlclient_binary = _services_utils.read_config_value(
                                self.config,
                                'sharding',
                                'mysqlclient_program'
                            )
        config_file = self.config.config_file if self.config.config_file else ""

        procedures = _events.trigger(
            CHECK_SHARD_INFORMATION, self.get_lockable_objects(), shard_id,
            group_id, mysqldump_binary, mysqlclient_binary, None, config_file,
            "", "MOVE", update_only
        )
        return self.wait_for_procedures(procedures, synchronous)
开发者ID:mgsanusi,项目名称:DeepChrome,代码行数:29,代码来源:resharding.py


示例7: execute

 def execute(self, param, synchronous=True):
     """Method that is remotely executed.
     """
     procedures = _events.trigger(
         NEW_PROCEDURE_GROUP_1, self.get_lockable_objects(), param
     )
     return self.wait_for_procedures(procedures, synchronous)
开发者ID:rockiebond,项目名称:mysql-fabric,代码行数:7,代码来源:test_command.py


示例8: execute

 def execute(self, synchronous=True):
     """Method that is remotely executed.
     """
     procedures = _events.trigger(
         NEW_EXECUTION_EVENT_1, self.get_lockable_objects()
     )
     return self.wait_for_procedures(procedures, synchronous)
开发者ID:rockiebond,项目名称:mysql-fabric,代码行数:7,代码来源:test_handler_events.py


示例9: _change_to_candidate

def _change_to_candidate(group_id, master_uuid, update_only=False):
    """Switch to candidate slave.
    """
    forbidden_status = (_server.MySQLServer.FAULTY, )
    master = _server.MySQLServer.fetch(_uuid.UUID(master_uuid))
    master.mode = _server.MySQLServer.READ_WRITE
    master.status = _server.MySQLServer.PRIMARY

    if not update_only:
        # Prepare the server to be the master
        master.connect()
        _utils.reset_slave(master)
        _utils.set_read_only(master, False)
        _utils.set_offline_mode(master, False)

    group = _server.Group.fetch(group_id)
    _set_group_master_replication(group, master.uuid, update_only)

    if not update_only:
        # Make slaves point to the master.
        for server in group.servers():
            if server.uuid != _uuid.UUID(master_uuid) and \
                server.status not in forbidden_status:
                try:
                    server.connect()
                    _utils.switch_master(server, master)
                except _errors.DatabaseError as error:
                    _LOGGER.debug(
                        "Error configuring slave (%s): %s.", server.uuid, error
                    )


    ### Restore FailureDetector's status before starting failover/switchover
    if _detector.FailureDetector.was_active:
        _detector.FailureDetector.was_active = None
        group.status = _server.Group.ACTIVE
        _detector.FailureDetector.register_group(group_id)

    # At the end, we notify that a server was promoted.
    # Any function that implements this event should not
    # run any action that updates Fabric. The event was
    # designed to trigger external actions such as:
    #
    # . Updating an external entity.
    _events.trigger("SERVER_PROMOTED", set([group_id]),
        group_id, master_uuid
    )
开发者ID:gmo-media,项目名称:mikasafabric,代码行数:47,代码来源:highavailability.py


示例10: execute

    def execute(self, group_id, destn_address, server_id=None, timeout=None,
                synchronous=True):
        """Clone the objects of a given server into a destination server.

        :param group_id: The ID of the source group.
        :param destn_address: The address of the destination MySQL Server.
        :param source_id: The address or UUID of the source MySQL Server.
        :param timeout: Time in seconds after which an error is reported
                        if the destination server is unreachable.
        :param synchronous: Whether one should wait until the execution
                            finishes or not.
        """
        # If the destination server is already part of a Fabric Group, raise
        # an error
        destn_server_uuid = _lookup_uuid(destn_address, timeout)
        _check_server_not_in_any_group(destn_server_uuid)
        host, port = split_host_port(
            destn_address, _backup.MySQLDump.MYSQL_DEFAULT_PORT
        )

        # Fetch information on backup and restore programs.
        config_file = self.config.config_file if self.config.config_file else ""

        mysqldump_binary = _utils.read_config_value(
                                self.config,
                                'sharding',
                                'mysqldump_program'
                            )
        mysqlclient_binary = _utils.read_config_value(
                                self.config,
                                'sharding',
                                'mysqlclient_program'
                            )

        if not _utils.is_valid_binary(mysqldump_binary):
            raise _errors.ServerError(MYSQLDUMP_NOT_FOUND % mysqldump_binary)

        if not _utils.is_valid_binary(mysqlclient_binary):
            raise _errors.ServerError(MYSQLCLIENT_NOT_FOUND % mysqlclient_binary)

        # Fetch a reference to source server.
        if server_id:
            server = _retrieve_server(server_id, group_id)
        else:
            group = _retrieve_group(group_id)
            server = _utils.fetch_backup_server(group)

        # Schedule the clone operation through the executor.
        procedures = _events.trigger(
            BACKUP_SERVER,
            self.get_lockable_objects(),
            str(server.uuid),
            host,
            port,
            mysqldump_binary,
            mysqlclient_binary,
            config_file
        )
        return self.wait_for_procedures(procedures, synchronous)
开发者ID:ioggstream,项目名称:mysql-utilities,代码行数:59,代码来源:server.py


示例11: execute

    def execute(self, shard_id, synchronous=True):
        """Enable the Shard represented by the shard_id.

        :param shard_id: The shard ID of the shard that needs to be removed.
        :param synchronous: Whether one should wait until the execution finishes
                        or not.
        """
        procedures = _events.trigger(
            SHARD_ENABLE, self.get_lockable_objects(), shard_id
        )
        return self.wait_for_procedures(procedures, synchronous)
开发者ID:ioggstream,项目名称:mysql-utilities,代码行数:11,代码来源:sharding.py


示例12: execute

    def execute(self, synchronous=True):
        """Deactivate all groups.

        :param synchronous: Whether one should wait until the execution
                            finishes or not.
        :return: Tuple with job's uuid and status.
        """
        procedures = _events.trigger(
            DEACTIVATE_ALL, self.get_lockable_objects()
        )
        return self.wait_for_procedures(procedures, synchronous)
开发者ID:gmo-media,项目名称:mikasafabric,代码行数:11,代码来源:server.py


示例13: execute

    def execute(self, group_id, force=False, synchronous=True):
        """Remove a group.

        :param group_id: Group's id.
        :param force: If the group is not empty, remove it serves.
        :param synchronous: Whether one should wait until the execution finishes
                            or not.
        :return: Tuple with job's uuid and status.
        """
        procedures = _events.trigger(
            DESTROY_GROUP, self.get_lockable_objects(), group_id, force
        )
        return self.wait_for_procedures(procedures, synchronous)
开发者ID:rockiebond,项目名称:mysql-fabric,代码行数:13,代码来源:server.py


示例14: _do_block_write_master

def _do_block_write_master(group_id, master_uuid, update_only=False):
    """Block and disable write access to the current master.

    Note that connections are not killed and blocking the master
    may take some time.
    """
    master = _server.MySQLServer.fetch(_uuid.UUID(master_uuid))
    assert(master.status == _server.MySQLServer.PRIMARY)
    master.mode = _server.MySQLServer.READ_ONLY
    master.status = _server.MySQLServer.SECONDARY

    if not update_only:
        master.connect()
        _utils.set_read_only(master, True)

    # Temporarily unset the master in this group.
    group = _server.Group.fetch(group_id)
    _set_group_master_replication(group, None)

    # At the end, we notify that a server was demoted.
    _events.trigger("SERVER_DEMOTED", set([group_id]),
        group_id, str(master.uuid)
    )
开发者ID:rockiebond,项目名称:mysql-fabric,代码行数:23,代码来源:highavailability.py


示例15: execute

    def execute(self, shard_mapping_id, synchronous=True):
        """Remove the shard mapping definition represented by the Shard Mapping
        ID. This method is exposed through the XML-RPC framework and creates a
        job and enqueues it in the executor.

        :param shard_mapping_id: The shard mapping ID of the shard mapping
                                definition that needs to be removed.
        :param synchronous: Whether one should wait until the execution finishes
                            or not.
        """
        procedures = _events.trigger(
            REMOVE_SHARD_MAPPING_DEFN, self.get_lockable_objects(), shard_mapping_id
        )
        return self.wait_for_procedures(procedures, synchronous)
开发者ID:rockiebond,项目名称:mysql-fabric,代码行数:14,代码来源:sharding.py


示例16: execute

    def execute(self, server_id, reporter="unknown", error="unknown",
                update_only=False, synchronous=True):
        """Report a server issue.

        :param server_id: Servers's UUID or HOST:PORT.
        :param reporter: Who has reported the issue, usually an IP address or a
                         host name.
        :param error: Error that has been reported.
        :param update_only: Only update the state store and skip provisioning.
        """
        procedures = _events.trigger(
            REPORT_FAILURE, self.get_lockable_objects(), server_id, reporter,
            error, update_only
        )
        return self.wait_for_procedures(procedures, synchronous)
开发者ID:gmo-media,项目名称:mikasafabric,代码行数:15,代码来源:failure_tracker.py


示例17: execute

    def execute(self, table_name, synchronous=True):
        """Given the table name prune the tables according to the defined
        sharding specification for the table. The command prunes all the
        tables that are part of this shard. There might be multiple tables that
        are part of the same shard, these tables will be related together by
        the same sharding key.

        :param table_name: The table that needs to be sharded.
        :param synchronous: Whether one should wait until the execution finishes
                            or not.
        """
        procedures = _events.trigger(
            PRUNE_SHARD_TABLES, self.get_lockable_objects(), table_name
        )
        return self.wait_for_procedures(procedures, synchronous)
开发者ID:rockiebond,项目名称:mysql-fabric,代码行数:15,代码来源:resharding.py


示例18: execute

    def execute(self, event, locks, *args, **kwargs):
        """Trigger the execution of an event.

        :param event: Event's identification.
        :type event: String
        :param args: Event's non-keyworded arguments.
        :param kwargs: Event's keyworded arguments.
        :return: List of the procedures' uuids that were created.
        """
        lockable_objects = set()
        for lock in locks.split(","):
            lockable_objects.add(lock.strip())
        return [ str(proc.uuid) \
                 for proc in _events.trigger(event, lockable_objects,
                                             *args, **kwargs)
               ]
开发者ID:rockiebond,项目名称:mysql-fabric,代码行数:16,代码来源:event.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python server.Group类代码示例发布时间:2022-05-27
下一篇:
Python utils.read_lc_string函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap