Exemplo n.º 1
0
 def reset_kv_stats(self):
     master_node = next(self.cluster_spec.masters)
     if self.test_config.cluster.enable_n2n_encryption:
         local.get_cbstats(self.master_node, 11210, "reset",
                           self.cluster_spec)
     else:
         for bucket in self.test_config.buckets:
             for server in self.rest.get_server_list(master_node, bucket):
                 port = self.rest.get_memcached_port(server)
                 self.memcached.reset_stats(server, port, bucket)
Exemplo n.º 2
0
    def _get_stats_from_server(self, bucket: str, server: str):
        stats = {}
        try:
            result = get_cbstats(server, self.CB_STATS_PORT, "all",
                                 self.cluster_spec)
            buckets_data = list(filter(lambda a: a != "", result.split("*")))
            for data in buckets_data:
                data = data.strip()
                if data.startswith(bucket):
                    data = data.split("\n", 1)[1]
                    data = data.replace("\"{", "{")
                    data = data.replace("}\"", "}")
                    data = data.replace("\\", "")
                    data = json.loads(data)
                    for (metric, number) in data.items():
                        if metric in self.METRICS:
                            if metric in stats:
                                stats[metric] += number
                            else:
                                stats[metric] = number
                    ep_magma_mem_used_diff = stats['mem_used_secondary'] -\
                        stats['ep_magma_total_mem_used']
                    if 'ep_magma_mem_used_diff' in stats:
                        stats[
                            'ep_magma_mem_used_diff'] += ep_magma_mem_used_diff
                    else:
                        stats[
                            'ep_magma_mem_used_diff'] = ep_magma_mem_used_diff
                    break
        except Exception:
            pass

        return stats
Exemplo n.º 3
0
    def _get_stats_from_server(self, bucket: str, server: str):
        stats = {}
        try:
            result = get_cbstats(server, self.CB_STATS_PORT, "kvstore",
                                 self.cluster_spec)
            buckets_data = list(filter(lambda a: a != "", result.split("*")))
            for data in buckets_data:
                data = data.strip()
                if data.startswith(bucket):
                    data = data.split("\n", 1)[1]
                    data = data.replace("\"{", "{")
                    data = data.replace("}\"", "}")
                    data = data.replace("\\", "")
                    data = json.loads(data)
                    for (shard, metrics) in data.items():
                        if not shard.endswith(":magma"):
                            continue
                        for metric in self.METRICS_ACROSS_SHARDS:
                            if metric in metrics.keys():
                                if metric in stats:
                                    stats[metric] += metrics[metric]
                                else:
                                    stats[metric] = metrics[metric]
                    break
        except Exception:
            pass

        return stats
Exemplo n.º 4
0
 def _get_num_shards(self, bucket: str, server: str):
     result = get_cbstats(server, self.CB_STATS_PORT, "workload",
                          self.cluster_spec)
     buckets_data = list(filter(lambda a: a != "", result.split("*")))
     for data in buckets_data:
         data = data.strip()
         if data.startswith(bucket):
             data = data.split("\n", 1)[1]
             data = data.replace("\"{", "{")
             data = data.replace("}\"", "}")
             data = data.replace("\\", "")
             data = json.loads(data)
             return data["ep_workload:num_shards"]
     return 1
Exemplo n.º 5
0
 def print_kvstore_stats(self):
     try:
         result = local.get_cbstats(self.master_node, self.CB_STATS_PORT,
                                    "kvstore", self.cluster_spec)
         buckets_data = list(filter(lambda a: a != "", result.split("*")))
         for data in buckets_data:
             data = data.strip()
             if data.startswith(self.test_config.buckets[0]):
                 data = data.split("\n", 1)[1]
                 data = data.replace("\"{", "{")
                 data = data.replace("}\"", "}")
                 data = data.replace("\\", "")
                 data = json.loads(data)
                 stats = {}
                 for key, value in data.items():
                     if key.startswith(
                         ("rw_0:", "rw_1:", "rw_2:", "rw_3:")):
                         stats[key] = value
                 logger.info("kvstore stats for first 4 shards: {}".format(
                     pretty_dict(stats)))
                 break
     except Exception:
         pass