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

Python utils.run_vtworker函数代码示例

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

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



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

示例1: run_split_diff

  def run_split_diff(self, keyspace_shard, source_tablets, destination_tablets):
    """Runs a vtworker SplitDiff on the given keyspace/shard, and then sets all
    former rdonly slaves back to rdonly.

    Args:
      keyspace_shard - keyspace/shard to run SplitDiff on (string)
      source_tablets - ShardTablets instance for the source shard
      destination_tablets - ShardTablets instance for the destination shard
    """
    logging.debug("Running vtworker SplitDiff for %s" % keyspace_shard)
    stdout, stderr = utils.run_vtworker(['-cell', 'test_nj', 'SplitDiff',
      keyspace_shard], auto_log=True)
开发者ID:haoqoo,项目名称:vitess,代码行数:12,代码来源:worker.py


示例2: run_split_diff

    def run_split_diff(self, keyspace_shard, source_tablets, destination_tablets):
        """Runs a vtworker SplitDiff on the given keyspace/shard.

    Sets all former rdonly slaves back to rdonly.

    Args:
      keyspace_shard: keyspace/shard to run SplitDiff on (string)
      source_tablets: ShardTablets instance for the source shard
      destination_tablets: ShardTablets instance for the destination shard
    """
        _ = source_tablets, destination_tablets
        logging.debug("Running vtworker SplitDiff for %s", keyspace_shard)
        _, _ = utils.run_vtworker(["-cell", "test_nj", "SplitDiff", keyspace_shard], auto_log=True)
开发者ID:richarwu,项目名称:vitess,代码行数:13,代码来源:worker.py


示例3: split_clone_fails_not_enough_health_rdonly_tablets

  def split_clone_fails_not_enough_health_rdonly_tablets(self):
    """Verify vtworker errors if there aren't enough healthy RDONLY tablets."""

    stdout, _ = utils.run_vtworker(
        ['-cell', 'test_nj',
         '--wait_for_healthy_rdonly_endpoints_timeout', '1s',
         'SplitClone',
         '--min_healthy_rdonly_endpoints', '2',
         'test_keyspace/0'],
        auto_log=True,
        expect_fail=True)
    self.assertIn(stdout, 'findTargets() failed: FindWorkerTablet() failed for'
                  ' test_nj/test_keyspace/0: not enough healthy rdonly'
                  ' endpoints to choose from in (test_nj,test_keyspace/0),'
                  ' have 1 healthy ones, need at least 2')
开发者ID:32kb,项目名称:vitess,代码行数:15,代码来源:worker.py


示例4: run_split_diff

  def run_split_diff(self, keyspace_shard, source_tablets, destination_tablets):
    """Runs a vtworker SplitDiff on the given keyspace/shard.

    Sets all former rdonly slaves back to rdonly.

    Args:
      keyspace_shard: keyspace/shard to run SplitDiff on (string)
      source_tablets: ShardTablets instance for the source shard
      destination_tablets: ShardTablets instance for the destination shard
    """
    _ = source_tablets, destination_tablets
    logging.debug('Running vtworker SplitDiff for %s', keyspace_shard)
    _, _ = utils.run_vtworker(
        ['-cell', 'test_nj', 'SplitDiff',
         '--min_healthy_rdonly_endpoints', '1',
         keyspace_shard], auto_log=True)
开发者ID:32kb,项目名称:vitess,代码行数:16,代码来源:worker.py


示例5: test_resharding


#.........这里部分代码省略.........
        shard_3_replica.init_tablet("spare", "test_keyspace", "c0-")
        shard_3_rdonly1.init_tablet("rdonly", "test_keyspace", "c0-")

        # start vttablet on the split shards (no db created,
        # so they're all not serving)
        shard_3_master.start_vttablet(wait_for_state=None, target_tablet_type="replica")
        for t in [shard_2_master, shard_2_replica1, shard_2_replica2, shard_3_replica, shard_3_rdonly1]:
            t.start_vttablet(wait_for_state=None)
        for t in [shard_2_master, shard_2_replica1, shard_2_replica2, shard_3_master, shard_3_replica, shard_3_rdonly1]:
            t.wait_for_vttablet_state("NOT_SERVING")

        utils.run_vtctl(["InitShardMaster", "test_keyspace/80-c0", shard_2_master.tablet_alias], auto_log=True)
        utils.run_vtctl(["InitShardMaster", "test_keyspace/c0-", shard_3_master.tablet_alias], auto_log=True)

        utils.run_vtctl(["RebuildKeyspaceGraph", "test_keyspace"], auto_log=True)
        utils.check_srv_keyspace(
            "test_nj",
            "test_keyspace",
            "Partitions(master): -80 80-\n" + "Partitions(rdonly): -80 80-\n" + "Partitions(replica): -80 80-\n",
            keyspace_id_type=keyspace_id_type,
        )

        # the worker will do everything. We test with source_reader_count=10
        # (down from default=20) as connection pool is not big enough for 20.
        # min_table_size_for_split is set to 1 as to force a split even on the
        # small table we have.
        # we need to create the schema, and the worker will do data copying
        for keyspace_shard in ("test_keyspace/80-c0", "test_keyspace/c0-"):
            utils.run_vtctl(
                ["CopySchemaShard", "--exclude_tables", "unrelated", shard_1_rdonly1.tablet_alias, keyspace_shard],
                auto_log=True,
            )

        utils.run_vtworker(
            [
                "--cell",
                "test_nj",
                "--command_display_interval",
                "10ms",
                "SplitClone",
                "--exclude_tables",
                "unrelated",
                "--strategy=-populate_blp_checkpoint",
                "--source_reader_count",
                "10",
                "--min_table_size_for_split",
                "1",
                "test_keyspace/80-",
            ],
            auto_log=True,
        )
        utils.run_vtctl(["ChangeSlaveType", shard_1_rdonly1.tablet_alias, "rdonly"], auto_log=True)

        # TODO(alainjobart): experiment with the dontStartBinlogPlayer option

        # check the startup values are in the right place
        self._check_startup_values()

        # check the schema too
        utils.run_vtctl(["ValidateSchemaKeyspace", "--exclude_tables=unrelated", "test_keyspace"], auto_log=True)

        # check the binlog players are running and exporting vars
        shard_2_master.wait_for_binlog_player_count(1)
        shard_3_master.wait_for_binlog_player_count(1)
        self._check_binlog_player_vars(shard_2_master)
        self._check_binlog_player_vars(shard_3_master)
开发者ID:hadoop835,项目名称:vitess,代码行数:67,代码来源:resharding.py


示例6: test_resharding

  def test_resharding(self):
    # create the keyspace with just one shard
    utils.run_vtctl(['CreateKeyspace',
                     'test_keyspace'])
    utils.run_vtctl(['SetKeyspaceShardingInfo', '-force', 'test_keyspace',
                     'keyspace_id', keyspace_id_type])

    shard_master.init_tablet( 'master',  'test_keyspace', '0')
    shard_replica.init_tablet('replica', 'test_keyspace', '0')
    shard_rdonly1.init_tablet( 'rdonly',  'test_keyspace', '0')

    utils.run_vtctl(['RebuildKeyspaceGraph', 'test_keyspace'], auto_log=True)

    # create databases so vttablet can start behaving normally
    for t in [shard_master, shard_replica, shard_rdonly1]:
      t.create_db('vt_test_keyspace')
      t.start_vttablet(wait_for_state=None)

    # wait for the tablets
    shard_master.wait_for_vttablet_state('SERVING')
    shard_replica.wait_for_vttablet_state('SERVING')
    shard_rdonly1.wait_for_vttablet_state('SERVING')

    # reparent to make the tablets work
    utils.run_vtctl(['ReparentShard', '-force', 'test_keyspace/0',
                     shard_master.tablet_alias], auto_log=True)

    # create the tables and add startup values
    self._create_schema()
    self._insert_startup_values()

    # change the schema, backfill keyspace_id, and change schema again
    self._add_sharding_key_to_schema()
    self._backfill_keyspace_id(shard_master)
    self._mark_sharding_key_not_null()

    # create the split shards
    shard_0_master.init_tablet( 'master',  'test_keyspace', '-80')
    shard_0_replica.init_tablet('replica', 'test_keyspace', '-80')
    shard_0_rdonly1.init_tablet( 'rdonly',  'test_keyspace', '-80')
    shard_1_master.init_tablet( 'master',  'test_keyspace', '80-')
    shard_1_replica.init_tablet('replica', 'test_keyspace', '80-')
    shard_1_rdonly1.init_tablet( 'rdonly',  'test_keyspace', '80-')

    # start vttablet on the split shards (no db created,
    # so they're all not serving)
    for t in [shard_0_master, shard_0_replica, shard_0_rdonly1,
              shard_1_master, shard_1_replica, shard_1_rdonly1]:
      t.start_vttablet(wait_for_state=None)
    for t in [shard_0_master, shard_0_replica, shard_0_rdonly1,
              shard_1_master, shard_1_replica, shard_1_rdonly1]:
      t.wait_for_vttablet_state('NOT_SERVING')

    utils.run_vtctl(['ReparentShard', '-force', 'test_keyspace/-80',
                     shard_0_master.tablet_alias], auto_log=True)
    utils.run_vtctl(['ReparentShard', '-force', 'test_keyspace/80-',
                     shard_1_master.tablet_alias], auto_log=True)

    utils.run_vtctl(['RebuildKeyspaceGraph', 'test_keyspace'],
                    auto_log=True)
    utils.check_srv_keyspace('test_nj', 'test_keyspace',
                             'Partitions(master): -\n' +
                             'Partitions(rdonly): -\n' +
                             'Partitions(replica): -\n',
                             keyspace_id_type=keyspace_id_type)

    # we need to create the schema, and the worker will do data copying
    for keyspace_shard in ('test_keyspace/-80', 'test_keyspace/80-'):
      utils.run_vtctl(['CopySchemaShard',
                       '--exclude_tables', 'unrelated',
                       shard_rdonly1.tablet_alias,
                       keyspace_shard],
                      auto_log=True)

    utils.run_vtworker(['--cell', 'test_nj',
                        '--command_display_interval', '10ms',
                        'SplitClone',
                        '--exclude_tables' ,'unrelated',
                        '--strategy=-populate_blp_checkpoint',
                        '--source_reader_count', '10',
                        '--min_table_size_for_split', '1',
                        'test_keyspace/0'],
                       auto_log=True)
    utils.run_vtctl(['ChangeSlaveType', shard_rdonly1.tablet_alias, 'rdonly'],
                     auto_log=True)

    # check the startup values are in the right place
    self._check_startup_values()

    # check the schema too
    utils.run_vtctl(['ValidateSchemaKeyspace', 'test_keyspace'], auto_log=True)

    # check the binlog players are running
    logging.debug("Waiting for binlog players to start on new masters...")
    shard_0_master.wait_for_binlog_player_count(1)
    shard_1_master.wait_for_binlog_player_count(1)

    # testing filtered replication: insert a bunch of data on shard 1,
    # check we get most of it after a few seconds, wait for binlog server
    # timeout, check we get all of it.
#.........这里部分代码省略.........
开发者ID:chengc017,项目名称:vitess,代码行数:101,代码来源:initial_sharding.py


示例7: test_resharding


#.........这里部分代码省略.........
    utils.vtgate.wait_for_endpoints('test_keyspace.80-.master', 1)
    utils.vtgate.wait_for_endpoints('test_keyspace.80-.replica', 1)
    utils.vtgate.wait_for_endpoints('test_keyspace.80-.rdonly', 1)

    # check the Map Reduce API works correctly, should use ExecuteKeyRanges now,
    # as we are sharded (with just one shard).
    # again, we have 3 values in the database, asking for 4 splits will get us
    # a single query.
    sql = 'select id, msg from resharding1'
    s = utils.vtgate.split_query(sql, 'test_keyspace', 4)
    self.assertEqual(len(s), 1)
    self.assertEqual(s[0]['key_range_part']['keyspace'], 'test_keyspace')
    # There must be one empty KeyRange which represents the full keyspace.
    self.assertEqual(len(s[0]['key_range_part']['key_ranges']), 1)
    self.assertEqual(s[0]['key_range_part']['key_ranges'][0], {})

    utils.check_srv_keyspace('test_nj', 'test_keyspace',
                             'Partitions(master): -\n'
                             'Partitions(rdonly): -\n'
                             'Partitions(replica): -\n',
                             keyspace_id_type=base_sharding.keyspace_id_type,
                             sharding_column_name='custom_ksid_col')

    # we need to create the schema, and the worker will do data copying
    for keyspace_shard in ('test_keyspace/-80', 'test_keyspace/80-'):
      utils.run_vtctl(['CopySchemaShard',
                       '--exclude_tables', 'unrelated',
                       shard_rdonly1.tablet_alias,
                       keyspace_shard],
                      auto_log=True)
    utils.run_vtctl(['RunHealthCheck', shard_rdonly1.tablet_alias])

    # Run vtworker as daemon for the following SplitClone commands.
    worker_proc, worker_port, worker_rpc_port = utils.run_vtworker_bg(
        ['--cell', 'test_nj', '--command_display_interval', '10ms'],
        auto_log=True)

    # Initial clone (online).
    workerclient_proc = utils.run_vtworker_client_bg(
        ['SplitClone',
         '--offline=false',
         '--exclude_tables', 'unrelated',
         '--min_table_size_for_split', '1',
         '--min_healthy_rdonly_tablets', '1',
         'test_keyspace/0'],
        worker_rpc_port)
    utils.wait_procs([workerclient_proc])
    self.verify_reconciliation_counters(worker_port, 'Online', 'resharding1',
                                        3, 0, 0)

    # Reset vtworker such that we can run the next command.
    workerclient_proc = utils.run_vtworker_client_bg(['Reset'], worker_rpc_port)
    utils.wait_procs([workerclient_proc])

    # Modify the destination shard. SplitClone will revert the changes.
    # Delete row 1 (provokes an insert).
    shard_0_master.mquery('vt_test_keyspace',
                          'delete from resharding1 where id=1', write=True)
    # Delete row 2 (provokes an insert).
    shard_1_master.mquery('vt_test_keyspace',
                          'delete from resharding1 where id=2', write=True)
    # Update row 3 (provokes an update).
    shard_1_master.mquery('vt_test_keyspace',
                          "update resharding1 set msg='msg-not-3' where id=3",
                          write=True)
    # Insert row 4 (provokes a delete).
开发者ID:arunlodhi,项目名称:vitess,代码行数:67,代码来源:initial_sharding.py


示例8: setUpModule

def setUpModule():
  try:
    environment.topo_server().setup()

    setup_procs = [
        src_master.init_mysql(),
        src_replica.init_mysql(),
        src_rdonly1.init_mysql(),
        src_rdonly2.init_mysql(),
        dst_master.init_mysql(),
        dst_replica.init_mysql(),
        ]
    utils.Vtctld().start()
    utils.wait_procs(setup_procs)

    # Set up binlog stream from shard 0 to shard 1.
    # Modeled after initial_sharding.py.
    utils.run_vtctl(['CreateKeyspace', 'test_keyspace'])
    utils.run_vtctl(['SetKeyspaceShardingInfo', '-force', 'test_keyspace',
                     'keyspace_id', keyrange_constants.KIT_UINT64])

    src_master.init_tablet('master', 'test_keyspace', '0')
    src_replica.init_tablet('replica', 'test_keyspace', '0')
    src_rdonly1.init_tablet('rdonly', 'test_keyspace', '0')
    src_rdonly2.init_tablet('rdonly', 'test_keyspace', '0')

    utils.run_vtctl(['RebuildShardGraph', 'test_keyspace/0'])
    utils.validate_topology()

    utils.run_vtctl(['RebuildKeyspaceGraph', 'test_keyspace'], auto_log=True)

    for t in [src_master, src_replica, src_rdonly1, src_rdonly2]:
      t.create_db('vt_test_keyspace')
      t.start_vttablet(wait_for_state=None)

    for t in [src_master, src_replica, src_rdonly1, src_rdonly2]:
      t.wait_for_vttablet_state('SERVING')

    utils.run_vtctl(['InitShardMaster', 'test_keyspace/0',
                     src_master.tablet_alias], auto_log=True)

    # Create schema
    logging.debug("Creating schema...")
    create_table = '''create table test_table(
        id bigint auto_increment,
        keyspace_id bigint(20) unsigned,
        msg varchar(64),
        primary key (id),
        index by_msg (msg)
        ) Engine=InnoDB'''

    utils.run_vtctl(['ApplySchema',
                     '-sql=' + create_table,
                     'test_keyspace'], auto_log=True)

    # Create destination shard.
    dst_master.init_tablet('master', 'test_keyspace', '-')
    dst_replica.init_tablet('replica', 'test_keyspace', '-')
    dst_master.start_vttablet(wait_for_state='NOT_SERVING')
    dst_replica.start_vttablet(wait_for_state='NOT_SERVING')

    utils.run_vtctl(['InitShardMaster', 'test_keyspace/-',
                     dst_master.tablet_alias], auto_log=True)
    utils.run_vtctl(['RebuildKeyspaceGraph', 'test_keyspace'], auto_log=True)

    # copy the schema
    utils.run_vtctl(['CopySchemaShard', src_replica.tablet_alias,
                     'test_keyspace/-'], auto_log=True)

    # run the clone worked (this is a degenerate case, source and destination
    # both have the full keyrange. Happens to work correctly).
    logging.debug("Running the clone worker to start binlog stream...")
    utils.run_vtworker(['--cell', 'test_nj',
                        'SplitClone',
                        '--strategy=-populate_blp_checkpoint',
                        '--source_reader_count', '10',
                        '--min_table_size_for_split', '1',
                        'test_keyspace/0'],
                        auto_log=True)
    dst_master.wait_for_binlog_player_count(1)

    # Wait for dst_replica to be ready.
    dst_replica.wait_for_binlog_server_state("Enabled")
  except:
    tearDownModule()
    raise
开发者ID:haoqoo,项目名称:vitess,代码行数:86,代码来源:binlog.py


示例9: test_vertical_split


#.........这里部分代码省略.........
                     source_rdonly.tablet_alias], auto_log=True)

    # perform the restore.
    utils.run_vtctl(['ShardMultiRestore',
                     '--strategy' ,'populateBlpCheckpoint',
                     '--tables', 'moving.*',
                     'destination_keyspace/0', source_rdonly.tablet_alias],
                    auto_log=True)

    topology.refresh_keyspace(self.vtgate_client, 'destination_keyspace')

    # check values are present
    self._check_values(destination_master, 'vt_destination_keyspace', 'moving1',
                       moving1_first, 100)
    self._check_values(destination_master, 'vt_destination_keyspace', 'moving2',
                       moving2_first, 100)
    self._check_values(destination_master, 'vt_destination_keyspace', 'view1',
                       moving1_first, 100)

    # check the binlog players is running
    destination_master.wait_for_binlog_player_count(1)

    # add values to source, make sure they're replicated
    moving1_first_add1 = self._insert_values('moving1', 100)
    staying1_first_add1 = self._insert_values('staying1', 100)
    moving2_first_add1 = self._insert_values('moving2', 100)
    self._check_values_timeout(destination_master, 'vt_destination_keyspace',
                               'moving1', moving1_first_add1, 100)
    self._check_values_timeout(destination_master, 'vt_destination_keyspace',
                               'moving2', moving2_first_add1, 100)

    # use the vtworker checker to compare the data
    logging.debug("Running vtworker VerticalSplitDiff")
    utils.run_vtworker(['-cell', 'test_nj', 'VerticalSplitDiff', 'destination_keyspace/0'],
                       auto_log=True)
    utils.run_vtctl(['ChangeSlaveType', source_rdonly.tablet_alias, 'rdonly'],
                    auto_log=True)
    utils.run_vtctl(['ChangeSlaveType', destination_rdonly.tablet_alias,
                     'rdonly'], auto_log=True)

    utils.pause("Good time to test vtworker for diffs")

    # get status for destination master tablet, make sure we have it all
    destination_master_status = destination_master.get_status()
    self.assertIn('Binlog player state: Running', destination_master_status)
    self.assertIn('moving.*', destination_master_status)
    self.assertIn('<td><b>All</b>: 1000<br><b>Query</b>: 700<br><b>Transaction</b>: 300<br></td>', destination_master_status)
    self.assertIn('</html>', destination_master_status)

    # check we can't migrate the master just yet
    utils.run_vtctl(['MigrateServedFrom', 'destination_keyspace/0', 'master'],
                    expect_fail=True)

    # now serve rdonly from the destination shards
    utils.run_vtctl(['MigrateServedFrom', 'destination_keyspace/0', 'rdonly'],
                    auto_log=True)
    self._check_srv_keyspace('ServedFrom(master): source_keyspace\n' +
                             'ServedFrom(replica): source_keyspace\n')
    self._check_blacklisted_tables(source_master, None)
    self._check_blacklisted_tables(source_replica, None)
    self._check_blacklisted_tables(source_rdonly, ['moving.*'])
    self._check_client_conn_redirection('source_keyspace', 'destination_keyspace', ['rdonly'], ['master', 'replica'], ['moving1', 'moving2'])

    # then serve replica from the destination shards
    utils.run_vtctl(['MigrateServedFrom', 'destination_keyspace/0', 'replica'],
                    auto_log=True)
开发者ID:dvska,项目名称:vitess,代码行数:67,代码来源:vertical_split.py


示例10: test_vertical_split

  def test_vertical_split(self):
    utils.run_vtctl(['CreateKeyspace',
                     'source_keyspace'])
    utils.run_vtctl(['CreateKeyspace',
                     '--served-from', 'master:source_keyspace,replica:source_keyspace,rdonly:source_keyspace',
                     'destination_keyspace'])
    source_master.init_tablet('master', 'source_keyspace', '0')
    source_replica.init_tablet('replica', 'source_keyspace', '0')
    source_rdonly.init_tablet('rdonly', 'source_keyspace', '0')
    destination_master.init_tablet('master', 'destination_keyspace', '0')
    destination_replica.init_tablet('replica', 'destination_keyspace', '0')
    destination_rdonly.init_tablet('rdonly', 'destination_keyspace', '0')

    utils.run_vtctl(['RebuildKeyspaceGraph', 'source_keyspace'], auto_log=True)
    utils.run_vtctl(['RebuildKeyspaceGraph', 'destination_keyspace'],
                    auto_log=True)
    self._check_srv_keyspace('ServedFrom(master): source_keyspace\n' +
                             'ServedFrom(rdonly): source_keyspace\n' +
                             'ServedFrom(replica): source_keyspace\n')

    # create databases so vttablet can start behaving normally
    for t in [source_master, source_replica, source_rdonly]:
      t.create_db('vt_source_keyspace')
      t.start_vttablet(wait_for_state=None)
    for t in [destination_master, destination_replica, destination_rdonly]:
      t.start_vttablet(wait_for_state=None)

    # wait for the tablets
    for t in [source_master, source_replica, source_rdonly]:
      t.wait_for_vttablet_state('SERVING')
    for t in [destination_master, destination_replica, destination_rdonly]:
      t.wait_for_vttablet_state('CONNECTING')

    # reparent to make the tablets work
    utils.run_vtctl(['ReparentShard', '-force', 'source_keyspace/0',
                     source_master.tablet_alias], auto_log=True)
    utils.run_vtctl(['ReparentShard', '-force', 'destination_keyspace/0',
                     destination_master.tablet_alias], auto_log=True)

    # create the schema on the source keyspace, add some values
    self._create_source_schema()
    moving1_first = self._insert_values('moving1', 100)
    moving2_first = self._insert_values('moving2', 100)
    staying1_first = self._insert_values('staying1', 100)
    staying2_first = self._insert_values('staying2', 100)
    self._check_values(source_master, 'vt_source_keyspace', 'moving1',
                       moving1_first, 100)
    self._check_values(source_master, 'vt_source_keyspace', 'moving2',
                       moving2_first, 100)
    self._check_values(source_master, 'vt_source_keyspace', 'staying1',
                       staying1_first, 100)
    self._check_values(source_master, 'vt_source_keyspace', 'staying2',
                       staying2_first, 100)
    self._check_values(source_master, 'vt_source_keyspace', 'view1',
                       moving1_first, 100)

    # take the snapshot for the split
    utils.run_vtctl(['MultiSnapshot',
                     '--tables', 'moving1,moving2,view1',
                     source_rdonly.tablet_alias], auto_log=True)

    # perform the restore.
    utils.run_vtctl(['ShardMultiRestore',
                     '--strategy' ,'populateBlpCheckpoint',
                     '--tables', 'moving1,moving2',
                     'destination_keyspace/0', source_rdonly.tablet_alias],
                    auto_log=True)

    # check values are present
    self._check_values(destination_master, 'vt_destination_keyspace', 'moving1',
                       moving1_first, 100)
    self._check_values(destination_master, 'vt_destination_keyspace', 'moving2',
                       moving2_first, 100)
    self._check_values(destination_master, 'vt_destination_keyspace', 'view1',
                       moving1_first, 100)

    # check the binlog players is running
    destination_master.wait_for_binlog_player_count(1)

    # add values to source, make sure they're replicated
    moving1_first_add1 = self._insert_values('moving1', 100)
    staying1_first_add1 = self._insert_values('staying1', 100)
    moving2_first_add1 = self._insert_values('moving2', 100)
    self._check_values_timeout(destination_master, 'vt_destination_keyspace',
                               'moving1', moving1_first_add1, 100)
    self._check_values_timeout(destination_master, 'vt_destination_keyspace',
                               'moving2', moving2_first_add1, 100)

    # use the vtworker checker to compare the data
    logging.debug("Running vtworker VerticalSplitDiff")
    utils.run_vtworker(['-cell', 'test_nj', 'VerticalSplitDiff', 'destination_keyspace/0'],
                       auto_log=True)
    utils.run_vtctl(['ChangeSlaveType', source_rdonly.tablet_alias, 'rdonly'],
                    auto_log=True)
    utils.run_vtctl(['ChangeSlaveType', destination_rdonly.tablet_alias,
                     'rdonly'], auto_log=True)

    utils.pause("Good time to test vtworker for diffs")

    # check we can't migrate the master just yet
#.........这里部分代码省略.........
开发者ID:minmaxflow,项目名称:vitess,代码行数:101,代码来源:vertical_split.py


示例11: test_vertical_split

    def test_vertical_split(self):
        # the worker will do everything. We test with source_reader_count=10
        # (down from default=20) as connection pool is not big enough for 20.
        # min_table_size_for_split is set to 1 as to force a split even on the
        # small table we have.
        utils.run_vtctl(
            ["CopySchemaShard", "--tables", "moving.*,view1", source_rdonly1.tablet_alias, "destination_keyspace/0"],
            auto_log=True,
        )

        utils.run_vtworker(
            [
                "--cell",
                "test_nj",
                "--command_display_interval",
                "10ms",
                "VerticalSplitClone",
                "--tables",
                "moving.*,view1",
                "--source_reader_count",
                "10",
                "--min_table_size_for_split",
                "1",
                "destination_keyspace/0",
            ],
            auto_log=True,
        )
        # One of the two source rdonly tablets went spare after the clone.
        # Force a healthcheck on both to get them back to "rdonly".
        for t in [source_rdonly1, source_rdonly2]:
            utils.run_vtctl(["RunHealthCheck", t.tablet_alias, "rdonly"])

        # check values are present
        self._check_values(destination_master, "vt_destination_keyspace", "moving1", self.moving1_first, 100)
        self._check_values(destination_master, "vt_destination_keyspace", "moving2", self.moving2_first, 100)
        self._check_values(destination_master, "vt_destination_keyspace", "view1", self.moving1_first, 100)

        # check the binlog players is running
        destination_master.wait_for_binlog_player_count(1)

        # add values to source, make sure they're replicated
        moving1_first_add1 = self._insert_values("moving1", 100)
        _ = self._insert_values("staying1", 100)
        moving2_first_add1 = self._insert_values("moving2", 100)
        self._check_values_timeout(destination_master, "vt_destination_keyspace", "moving1", moving1_first_add1, 100)
        self._check_values_timeout(destination_master, "vt_destination_keyspace", "moving2", moving2_first_add1, 100)

        # use vtworker to compare the data
        for t in [destination_rdonly1, destination_rdonly2]:
            utils.run_vtctl(["RunHealthCheck", t.tablet_alias, "rdonly"])
        logging.debug("Running vtworker VerticalSplitDiff")
        utils.run_vtworker(["-cell", "test_nj", "VerticalSplitDiff", "destination_keyspace/0"], auto_log=True)
        # One of each source and dest rdonly tablet went spare after the diff.
        # Force a healthcheck on all four to get them back to "rdonly".
        for t in [source_rdonly1, source_rdonly2, destination_rdonly1, destination_rdonly2]:
            utils.run_vtctl(["RunHealthCheck", t.tablet_alias, "rdonly"])

        utils.pause("Good time to test vtworker for diffs")

        # get status for destination master tablet, make sure we have it all
        destination_master_status = destination_master.get_status()
        self.assertIn("Binlog player state: Running", destination_master_status)
        self.assertIn("moving.*", destination_master_status)
        self.assertIn(
            "<td><b>All</b>: 1000<br><b>Query</b>: 700<br>" "<b>Transaction</b>: 300<br></td>",
            destination_master_status,
        )
        self.assertIn("</html>", destination_master_status)

        # check query service is off on destination master, as filtered
        # replication is enabled. Even health check should not interfere.
        destination_master_vars = utils.get_vars(destination_master.port)
        self.assertEqual(destination_master_vars["TabletStateName"], "NOT_SERVING")

        # check we can't migrate the master just yet
        utils.run_vtctl(["MigrateServedFrom", "destination_keyspace/0", "master"], expect_fail=True)

        # migrate rdonly only in test_ny cell, make sure nothing is migrated
        # in test_nj
        utils.run_vtctl(["MigrateServedFrom", "--cells=test_ny", "destination_keyspace/0", "rdonly"], auto_log=True)
        self._check_srv_keyspace(
            "ServedFrom(master): source_keyspace\n"
            "ServedFrom(rdonly): source_keyspace\n"
            "ServedFrom(replica): source_keyspace\n"
        )
        self._check_blacklisted_tables(source_master, None)
        self._check_blacklisted_tables(source_replica, None)
        self._check_blacklisted_tables(source_rdonly1, None)
        self._check_blacklisted_tables(source_rdonly2, None)

        # migrate test_nj only, using command line manual fix command,
        # and restore it back.
        keyspace_json = utils.run_vtctl_json(["GetKeyspace", "destination_keyspace"])
        found = False
        for ksf in keyspace_json["served_froms"]:
            if ksf["tablet_type"] == topodata_pb2.RDONLY:
                found = True
                self.assertEqual(ksf["cells"], ["test_nj"])
        self.assertTrue(found)
        utils.run_vtctl(
#.........这里部分代码省略.........
开发者ID:Rastusik,项目名称:vitess,代码行数:101,代码来源:vertical_split.py


示例12: setUpModule

def setUpModule():
  try:
    environment.topo_server().setup()

    setup_procs = [t.init_mysql() for t in all_tablets]
    utils.Vtctld().start()
    utils.wait_procs(setup_procs)

    # Set up binlog stream from shard 0 to shard 1.
    # Modeled after initial_sharding.py.
    utils.run_vtctl(['CreateKeyspace', 'test_keyspace'])
    utils.run_vtctl(['SetKeyspaceShardingInfo', '-force', 'test_keyspace',
                     'keyspace_id', keyrange_constants.KIT_UINT64])

    src_master.init_tablet('master', 'test_keyspace', '0')
    src_replica.init_tablet('replica', 'test_keyspace', '0')
    src_rdonly.init_tablet('rdonly', 'test_keyspace', '0')

    utils.validate_topology()

    for t in [src_master, src_replica, src_rdonly]:
      t.create_db('vt_test_keyspace')
      t.start_vttablet(wait_for_state=None)

    src_master.wait_for_vttablet_state('SERVING')
    for t in [src_replica, src_rdonly]:
      t.wait_for_vttablet_state('NOT_SERVING')

    utils.run_vtctl(['InitShardMaster', 'test_keyspace/0',
                     src_master.tablet_alias], auto_log=True)

    # Create schema
    logging.debug('Creating schema...')
    create_table = '''create table test_table(
        id bigint auto_increment,
        keyspace_id bigint(20) unsigned,
        msg varchar(64),
        primary key (id),
        index by_msg (msg)
        ) Engine=InnoDB'''

    utils.run_vtctl(['ApplySchema',
                     '-sql=' + create_table,
                     'test_keyspace'], auto_log=True)

    # run a health check on source replica so it responds to discovery
    # (for binlog players) and on the source rdonlys (for workers)
    utils.run_vtctl(['RunHealthCheck', src_replica.tablet_alias])
    utils.run_vtctl(['RunHealthCheck', src_rdonly.tablet_alias])

    # Create destination shard (won't be serving as there is no DB)
    dst_master.init_tablet('master', 'test_keyspace', '-')
    dst_replica.init_tablet('replica', 'test_keyspace', '-')
    dst_rdonly.init_tablet('rdonly', 'test_keyspace', '-')
    dst_master.start_vttablet(wait_for_state='NOT_SERVING')
    dst_replica.start_vttablet(wait_for_state='NOT_SERVING')
    dst_rdonly.start_vttablet(wait_for_state='NOT_SERVING')

    utils.run_vtctl(['InitShardMaster', 'test_keyspace/-',
                     dst_master.tablet_alias], auto_log=True)

    # copy the schema
    utils.run_vtctl(['CopySchemaShard', src_replica.tablet_alias,
                     'test_keyspace/-'], auto_log=True)

    # run the clone worker (this is a degenerate case, source and destination
    # both have the full keyrange. Happens to work correctly).
    logging.debug('Running the clone worker to start binlog stream...')
    utils.run_vtworker(['--cell', 'test_nj',
                        'SplitClone',
                        '--chunk_count', '10',
                        '--min_rows_per_chunk', '1',
                        '--min_healthy_rdonly_tablets', '1',
                        'test_keyspace/0'],
                       auto_log=True)
    dst_master.wait_for_binlog_player_count(1)

    # Wait for dst_replica to be ready.
    dst_replica.wait_for_binlog_server_state('Enabled')
  except:
    tearDownModule()
    raise
开发者ID:erzel,项目名称:vitess,代码行数:82,代码来源:binlog.py


示例13: test_vertical_split

    def test_vertical_split(self):
        utils.run_vtctl(["CreateKeyspace", "source_keyspace"])
        utils.run_vtctl(
            [
                "CreateKeyspace",
                "--served_from",
                "master:source_keyspace,replica:source_keyspace,rdonly:source_keyspace",
                "destination_keyspace",
            ]
        )
        source_master.init_tablet("master", "source_keyspace", "0")
        source_replica.init_tablet("replica", "source_keyspace", "0")
        source_rdonly1.init_tablet("rdonly", "source_keyspace", "0")
        source_rdonly2.init_tablet("rdonly", "source_keyspace", "0")

        # rebuild destination keyspace to make sure there is a serving
        # graph entry, even though there is no tablet yet.
        utils.run_vtctl(["RebuildKeyspaceGraph", "source_keyspace"], auto_log=True)
        utils.run_vtctl(["RebuildKeyspaceGraph", "destination_keyspace"], auto_log=True)
        self._check_srv_keyspace(
            "ServedFrom(master): source_keyspace\n"
            + "ServedFrom(rdonly): source_keyspace\n"
            + "ServedFrom(replica): source_keyspace\n"
        )

        destination_master.init_tablet("master", "destination_keyspace", "0")
        destination_replica.init_tablet("replica", "destination_keyspace", "0")
        destination_rdonly1.init_tablet("rdonly", "destination_keyspace", "0")
        destination_rdonly2.init_tablet("rdonly", "destination_keyspace", "0")

        utils.run_vtctl(["RebuildKeyspaceGraph", "source_keyspace"], auto_log=True)
        utils.run_vtctl(["RebuildKeyspaceGraph", "destination_keyspace"], auto_log=True)
        self._check_srv_keyspace(
            "ServedFrom(master): source_keyspace\n"
            + "ServedFrom(rdonly): source_keyspace\n"
            + "ServedFrom(replica): source_keyspace\n"
        )

        # create databases so vttablet can start behaving normally
        for t in [source_master, source_replica, source_rdonly1, source_rdonly2]:
            t.create_db("vt_source_keyspace")
            t.start_vttablet(wait_for_state=None)
        destination_master.start_vttablet(wait_for_state=None, target_tablet_type="replica")
        for t in [destination_replica, destination_rdonly1, destination_rdonly2]:
            t.start_vttablet(wait_for_state=None)

        # wait for the tablets
        for t in [source_master, source_replica, source_rdonly1, source_rdonly2]:
            t.wait_for_vttablet_state("SERVING")
        for t in [destination_master, destination_replica, destination_rdonly1, destination_rdonly2]:
            t.wait_for_vttablet_state("NOT_SERVING")

        # reparent to make the tablets work
        utils.run_vtctl(["InitShardMaster", "source_keyspace/0", source_master.tablet_alias], auto_log=True)
        utils.run_vtctl(["InitShardMaster", "destination_keyspace/0", destination_master.tablet_alias], auto_log=True)

        # create the schema on the source keyspace, add some values
        self._create_source_schema()
        moving1_first = self._insert_values("moving1", 100)
        moving2_first = self._insert_values("moving2", 100)
        staying1_first = self._insert_values("staying1", 100)
        staying2_first = self._insert_values("staying2", 100)
        self._check_values(source_master, "vt_source_keyspace", "moving1", moving1_first, 100)
        self._check_values(source_master, "vt_source_keyspace", "moving2", moving2_first, 100)
        self._check_values(source_master, "vt_source_keyspace", "staying1", staying1_first, 100)
        self._check_values(source_master, "vt_source_keyspace", "staying2", staying2_first, 100)
        self._check_values(source_master, "vt_source_keyspace", "view1", moving1_first, 100)

        # the worker will do everything. We test with source_reader_count=10
        # (down from default=20) as connection pool is not big enough for 20.
        # min_table_size_for_split is set to 1 as to force a split even on the
        # small table we have.
        utils.run_vtctl(
            ["CopySchemaShard", "--tables", "moving.*,view1", source_rdonly1.tablet_alias, "destination_keyspace/0"],
            auto_log=True,
        )

        utils.run_vtworker(
            [
                "--cell",
                "test_nj",
                "--command_display_interval",
                "10ms",
                "VerticalSplitClone",
                "--tables",
                "moving.*,view1",
                "--strategy=-populate_blp_checkpoint",
                "--source_reader_count",
                "10",
                "--min_table_size_for_split",
                "1",
                "destination_keyspace/0",
            ],
            auto_log=True,
        )
        utils.run_vtctl(["ChangeSlaveType", source_rdonly1.tablet_alias, "rdonly"], auto_log=True)
        utils.run_vtctl(["ChangeSlaveType", source_rdonly2.tablet_alias, "rdonly"], auto_log=True)

        # check values are present
        self._check_values(destination_master, "vt_destination_keyspace", "moving1", moving1_first, 100)
#.........这里部分代码省略.........
开发者ID:payintel,项目名称:vitess,代码行数:101,代码来源:vertical_split.py


示例14: test_resharding


#.........这里部分代码省略.........
    shard_3_master.start_vttablet(wait_for_state=None,
                                  target_tablet_type='replica')
    for t in [shard_2_master, shard_2_replica1, shard_2_replica2,
              shard_3_replica, shard_3_rdonly1]:
      t.start_vttablet(wait_for_state=None)
    for t in [shard_2_master, shard_2_replica1, shard_2_replica2,
              shard_3_master, shard_3_replica, shard_3_rdonly1]:
      t.wait_for_vttablet_state('NOT_SERVING')

    utils.run_vtctl(['InitShardMaster', 'test_keyspace/80-c0',
                     shard_2_master.tablet_alias], auto_log=True)
    utils.run_vtctl(['InitShardMaster', 'test_keyspace/c0-',
                     shard_3_master.tablet_alias], auto_log=True)

    utils.run_vtctl(['RebuildKeyspaceGraph', 'test_keyspace'],
                    auto_log=True)
    utils.check_srv_keyspace(
        'test_nj', 'test_keyspace',
        'Partitions(master): -80 80-\n'
        'Partitions(rdonly): -80 80-\n'
        'Partitions(replica): -80 80-\n',
        keyspace_id_type=keyspace_id_type)

    # the worker will do everything. We test with source_reader_count=10
    # (down from default=20) as connection pool is not big enough for 20.
    # min_table_size_for_split is set to 1 as to force a split even on the
    # small table we have.
    # we need to create the schema, and the worker will do data copying
    for keyspace_shard in ('test_keyspace/80-c0', 'test_keyspace/c0-'):
      utils.run_vtctl(['CopySchemaShard', '--exclude_tables', 'unrelated',
                       shard_1_rdonly1.tablet_alias, keyspace_shard],
                      auto_log=True)

    utils.run_vtworker(['--cell', 'test_nj',
                        '--command_display_interval', '10ms',
                        'SplitClone',
                        '--exclude_tables', 'unrelated',
                        '--source_reader_count', '10',
                        '--min_table_size_for_split', '1',
                        'test_keyspace/80-'],
                       auto_log=True)
    utils.run_vtctl(['ChangeSlaveType', shard_1_rdonly1.tablet_alias,
                     'rdonly'], auto_log=True)

    # TODO(alainjobart): experiment with the dontStartBinlogPlayer option

    # check the startup values are in the right place
    self._check_startup_values()

    # check the schema too
    utils.run_vtctl(['ValidateSchemaKeyspace', '--exclude_tables=unrelated',
                     'test_keyspace'], auto_log=True)

    # check the binlog players are running and exporting vars
    shard_2_master.wait_for_binlog_player_count(1)
    shard_3_master.wait_for_binlog_player_count(1)
    self._check_binlog_player_vars(shard_2_master)
    self._check_binlog_player_vars(shard_3_master)

    # check that binlog server exported the stats vars
    self._check_binlog_server_vars(shard_1_slave1)

    self._check_stream_health_equals_binlog_player_vars(shard_2_master)
    self._check_stream_health_equals_binlog_player_vars(shard_3_master)

    # testing filtered replication: insert a bunch of data on shard 1,
开发者ID:Rastusik,项目名称:vitess,代码行数:67,代码来源:resharding.py


示例15: test_vertical_split

该文章已有0人参与评论

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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