Ejemplo n.º 1
0
    def get_all_tablet_types(self, keyspace, num_shards):
        """Get the types for all tablets in a keyspace.

    Args:
      keyspace: Name of keyspace to get tablet information on. (string)
      num_shards: number of shards in the keyspace. (int)

    Returns:
      List of pairs of tablet's name and type
    """
        tablet_info = []
        for shard_name in sharding_utils.get_shard_names(num_shards):
            tablet_info += self.get_tablet_types_for_shard(keyspace, shard_name)
        return tablet_info
Ejemplo n.º 2
0
    def get_all_tablet_types(self, keyspace, num_shards):
        """Get the types for all tablets in a keyspace.

    Args:
      keyspace: Name of keyspace to get tablet information on. (string)
      num_shards: number of shards in the keyspace. (int)

    Returns:
      List of pairs of tablet's name and type
    """
        tablet_info = []
        for shard_name in sharding_utils.get_shard_names(num_shards):
            tablet_info += self.get_tablet_types_for_shard(
                keyspace, shard_name)
        return tablet_info
Ejemplo n.º 3
0
    def use_named(self, instance_name):
        """Populate this instance based on a pre-existing environment.

    Args:
      instance_name: Name of the existing environment instance (string)
    """
        self.master_capable_tablets = {}
        for keyspace, num_shards in zip(self.keyspaces, self.num_shards):
            self.master_capable_tablets[keyspace] = {}
            for shard_name in sharding_utils.get_shard_names(num_shards):
                raw_shard_tablets = self.vtctl_helper.execute_vtctl_command(
                    ["ListShardTablets", "%s/%s" % (keyspace, shard_name)]
                )
                split_shard_tablets = [t.split(" ") for t in raw_shard_tablets.split("\n") if t]
                self.master_capable_tablets[keyspace][shard_name] = [
                    t[0]
                    for t in split_shard_tablets
                    if (self.get_tablet_cell(t[0]) in self.primary_cells and (t[3] == "master" or t[3] == "replica"))
                ]
Ejemplo n.º 4
0
    def use_named(self, instance_name):
        """Populate this instance based on a pre-existing environment.

    Args:
      instance_name: Name of the existing environment instance (string)
    """
        self.master_capable_tablets = {}
        for keyspace, num_shards in zip(self.keyspaces, self.num_shards):
            self.master_capable_tablets[keyspace] = {}
            for shard_name in sharding_utils.get_shard_names(num_shards):
                raw_shard_tablets = self.vtctl_helper.execute_vtctl_command(
                    ['ListShardTablets',
                     '%s/%s' % (keyspace, shard_name)])
                split_shard_tablets = [
                    t.split(' ') for t in raw_shard_tablets.split('\n') if t
                ]
                self.master_capable_tablets[keyspace][shard_name] = [
                    t[0] for t in split_shard_tablets
                    if (self.get_tablet_cell(t[0]) in self.primary_cells and (
                        t[3] == 'master' or t[3] == 'replica'))
                ]