IT. Expert System.

PHP

Updates status for all hosts associated with this


Mongo::getHosts

(PECL mongo >=1.1.0)

Mongo::getHostsUpdates status for all hosts associated with this

Description

public array Mongo::getHosts ( void )

This method is only useful with a connection to a replica set. It returns the status of all of the hosts in the set. Without a replica set, it will just return an array with one element containing the host that you are connected to.

See the query section of this manual for information on distributing reads to slaves.

Parameters

This function has no parameters.

Return Values

Returns an array of information about the hosts in the set. Includes each host's hostname, its health (1 is healthy), its state (1 is primary, 2 is secondary, 0 is anything else), the amount of time it took to ping the server, and when the last ping occurred. For example, on a three-member replica set, it might look something like:

array(2) { ["A:27017"]=> array(4) {  ["host"]=>  "A"  ["port"]=>  27017  ["health"]=>  int(1)  ["state"]=>  int(2)  ["ping"]=>  int(369)  ["lastPing"]=>  int(1309470644) } ["B:27017"]=> array(4) {  ["host"]=>  "B"  ["port"]=>  27017  ["health"]=>  int(1)  ["state"]=>  int(1)  ["ping"]=>  int(139)  ["lastPing"]=>  int(1309470644) } ["C:27017"]=> array(4) {  ["host"]=>  "C"  ["port"]=>  27017  ["health"]=>  int(1)  ["state"]=>  int(2)  ["ping"]=>  int(1012)  ["lastPing"]=>  int(1309470644) } }

In the example above, B and C are secondaries (state 2). B is likely to be selected for queries if slaveOkay is set, as it has a lower ping time (and thus is likely closer or handling less load) than C.

Changelog

Version Description
1.2.10

Support for non-replicasets was added.

The returned array elements now also include the hostname and port.



Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 1224 / . Delta: 0.02208 с