Return count of replicas of given partition.
507269
def count_replica(self, partition):
        """"""
        return sum(1 for b in partition.replicas if b in self.brokers)
1350524
def paused_partitions(self):
        """"""
        return set(partition for partition in self.assignment
                   if self.is_paused(partition))
838672
def count(self) -> int:
        ''''''
        counter = 0

        for pool in self._host_pools.values():
            counter += pool.count()

        return counter
495632
def check_backup_count_and_state(self, site):
        """"""
        basebackups = self.get_remote_basebackups_info(site)
        self.log.debug("Found %r basebackups", basebackups)

        if basebackups:
            last_backup_time = basebackups[-1]["metadata"]["start-time"]
        else:
            last_backup_time = None

        allowed_basebackup_count = self.config["backup_sites"][site]["basebackup_count"]
        if allowed_basebackup_count is None:
            allowed_basebackup_count = len(basebackups)

        while len(basebackups) > allowed_basebackup_count:
            self.log.warning("Too many basebackups: %d > %d, %r, starting to get rid of %r",
                             len(basebackups), allowed_basebackup_count, basebackups, basebackups[0]["name"])
            basebackup_to_be_deleted = basebackups.pop(0)
            pg_version = basebackup_to_be_deleted["metadata"].get("pg-version")
            last_wal_segment_still_needed = 0
            if basebackups:
                last_wal_segment_still_needed = basebackups[0]["metadata"]["start-wal-segment"]

            if last_wal_segment_still_needed:
                self.delete_remote_wal_before(last_wal_segment_still_needed, site, pg_version)
            self.delete_remote_basebackup(site, basebackup_to_be_deleted["name"], basebackup_to_be_deleted["metadata"])
        self.state["backup_sites"][site]["basebackups"] = basebackups

        return last_backup_time
806438
def count_siblings(self, partitions):
        
        count = sum(
            int(self.topic == partition.topic)
            for partition in partitions
        )
        return count
1045824
def do_numberrep(self, line):
        """"""
        n_replicas = self._split_args(line, 1, 0)[0]
        self._command_processor.get_session().get_replication_policy().set_number_of_replicas(
            n_replicas
        )
        self._print_info_if_verbose("Set number of replicas to {}".format(n_replicas))
483214
def count(self):
        ""
        return self.rpc_model.search_count(
            self.domain, context=self.context
        )
713960
def count(self, **query_dict):
        """"""
        param_dict = query_dict.copy()
        param_dict['count'] = 0
        resp_dict = self._get_query(**param_dict)
        return resp_dict['response']['numFound']
324933
def partition(self):
        """"""

        if not self.partitions:
            return None

        if len(self.partitions) > 1:
            raise ValueError(
                "Can't use this method when there is more than one partition")

        return list(self.partitions.values())[0]
923150
def _compute_count_availability(resource, status, previous_status):
    ''''''
    count_availability = resource.extras.get('check:count-availability', 1)
    return count_availability + 1 if status == previous_status else 1
1074847
def get_group_partition(group, partition_count):
    """"""
    def java_string_hashcode(s):
        h = 0
        for c in s:
            h = (31 * h + ord(c)) & 0xFFFFFFFF
        return ((h + 0x80000000) & 0xFFFFFFFF) - 0x80000000
    return abs(java_string_hashcode(group)) % partition_count
838156
def get_replicas(self, service_id: str) -> str:
        
        # Initialising empty list
        replicas = []

        # Raise an exception if we are not a manager
        if not self._manager:
            raise RuntimeError('Only the Swarm manager node can retrieve '
                               'replication level of the service')

        service_tasks = self._client.services.get(service_id).tasks()
        for task in service_tasks:
            if task['Status']['State'] == "running":
                replicas.append(task)
        return len(replicas)
293746
def objectcount(data, key):
    """"""
    objkey = key.upper()
    return len(data.dt[objkey])
729222
def is_unprocessed_local_replica(pid):
    """"""
    return d1_gmn.app.models.LocalReplica.objects.filter(
        pid__did=pid, info__status__status='queued'
    ).exists()
815098
def replicaStatus(self, url):
        """"""
        params = {"f" : "json"}
        url = url + "/status"
        return self._get(url=url,
                            param_dict=params,
                            securityHandler=self._securityHandler,
                            proxy_port=self._proxy_port,
                            proxy_url=self._proxy_url)
844950
def _count(self, cmd, collation=None, session=None):
        """"""
        def _cmd(session, server, sock_info, slave_ok):
            res = self._command(
                sock_info,
                cmd,
                slave_ok,
                allowable_errors=["ns missing"],
                codec_options=self.__write_response_codec_options,
                read_concern=self.read_concern,
                collation=collation,
                session=session)
            if res.get("errmsg", "") == "ns missing":
                return 0
            return int(res["n"])

        return self.__database.client._retryable_read(
            _cmd, self._read_preference_for(session), session)
844396
def display_replica_imbalance(cluster_topologies):
    
    assert cluster_topologies

    rg_ids = list(next(six.itervalues(cluster_topologies)).rgs.keys())
    assert all(
        set(rg_ids) == set(cluster_topology.rgs.keys())
        for cluster_topology in six.itervalues(cluster_topologies)
    )

    rg_imbalances = [
        stats.get_replication_group_imbalance_stats(
            list(cluster_topology.rgs.values()),
            list(cluster_topology.partitions.values()),
        )
        for cluster_topology in six.itervalues(cluster_topologies)
    ]

    _display_table_title_multicolumn(
        'Extra Replica Count',
        'Replication Group',
        rg_ids,
        list(cluster_topologies.keys()),
        [
            [erc[rg_id] for rg_id in rg_ids]
            for _, erc in rg_imbalances
        ],
    )

    for name, imbalance in zip(
            six.iterkeys(cluster_topologies),
            (imbalance for imbalance, _ in rg_imbalances)
    ):
        print(
            '\n'
            '{name}'
            'Total extra replica count: {imbalance}'
            .format(
                name='' if len(cluster_topologies) == 1 else name + '\n',
                imbalance=imbalance,
            )
        )