PHP Doku:: Updates status for all hosts associated with this - mongo.getHosts.html

Verlauf / Chronik / History: (3) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzDatenbankerweiterungenAnbieterspezifische DatenbankerweiterungenMongoDB Native DriverCore ClassesThe Mongo classMongo::getHosts

Ein Service von Reinhard Neidl - Webprogrammierung.

The Mongo class

<<Mongo::__get

Mongo::getSlave>>

Mongo::getHosts

(PECL mongo >=1.1.0)

Mongo::getHostsUpdates status for all hosts associated with this

Beschreibung

public array Mongo::getHosts ( void )

This method can only be used with a connection to a replica set. It returns the status of all of the hosts in the set and updates the connection information (the updating is invisible to the user).

This is called automatically by the driver every five seconds.

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

Parameter-Liste

Diese Funktion hat keine Parameter.

Rückgabewerte

Returns an array of information about the hosts in the set. Includes each host's hostname, id in the set, health (1 is healthy), the uptime, and how up-to-date the host is compared to the primary. For example, on a three-member replica set running locally, it might look something like:

Array
(
    [ubuntu:27017] => Array
        (
            [_id] => 0
            [name] => ubuntu:27017
            [health] => 1
            [state] => 1
            [stateStr] => PRIMARY
            [optime] => MongoTimestamp Object
                (
                    [sec] => 1
                    [inc] => 1291155754
                )

            [optimeDate] => MongoDate Object
                (
                    [sec] => 1291155754
                    [usec] => 0
                )

            [self] => 1
        )

    [ubuntu:27019] => Array
        (
            [_id] => 2
            [name] => ubuntu:27019
            [health] => 1
            [state] => 2
            [stateStr] => SECONDARY
            [uptime] => 91928
            [optime] => MongoTimestamp Object
                (
                    [sec] => 1
                    [inc] => 1291155754
                )

            [optimeDate] => MongoDate Object
                (
                    [sec] => 1291155754
                    [usec] => 0
                )

            [lastHeartbeat] => MongoDate Object
                (
                    [sec] => 1291158846
                    [usec] => 0
                )

        )

    [ubuntu:27018] => Array
        (
            [_id] => 1
            [name] => ubuntu:27018
            [health] => 1
            [state] => 2
            [stateStr] => SECONDARY
            [uptime] => 91944
            [optime] => MongoTimestamp Object
                (
                    [sec] => 1
                    [inc] => 1291155754
                )

            [optimeDate] => MongoDate Object
                (
                    [sec] => 1291155754
                    [usec] => 0
                )

            [lastHeartbeat] => MongoDate Object
                (
                    [sec] => 1291158846
                    [usec] => 0
                )

        )

)

This returns NULL if the connection is not connected to a replica set or has not been initialized, yet.


Keine BenutzerBeiträge.
- Beiträge aktualisieren...



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)