MongoDB\Driver\Server::getInfo
(mongodb >=1.0.0)
MongoDB\Driver\Server::getInfo - 이 서버를 설명하는 정보 배열을 반환합니다.
설명
final public MongoDB\Driver\Server::getInfo(): array
서버를 설명하는 정보 배열을 반환합니다. 이 배열은 » 서버 모니터링을 통해 얻은 가장 최근의 » hello 명령 응답에서 파생됩니다.
메모: 드라이버가 부하 분산기에 연결되면 이 메서드는 초기 연결 핸드셰이크에서 지원 서버의 » hello 명령 응답을 반환합니다. 이는 로드 밸런서 자체에 대한 정보를 반환하는 다른 메서드(예: MongoDB\Driver\Server::getType())와 대조됩니다.
매개변수
이 함수에는 매개변수가 없습니다.
반환 값
이 서버를 설명하는 정보 배열을 반환합니다.
오류/예외
- 인수 구문 분석 오류에 대해 MongoDB\Driver\Exception\InvalidArgumentException을 던집니다.
Examples
예제 #1 MongoDB\Driver\Server::getInfo() 예제
<?php
$manager = new MongoDB\Driver\Manager('mongodb://localhost:27017/');
$rp = new MongoDB\Driver\ReadPreference('primary');
$server = $manager->selectServer($rp);
var_dump($server->getInfo());
?>
위의 예는 다음과 유사한 결과를 출력합니다.
array(23) { ["helloOk"]=> bool(true) ["topologyVersion"]=> array(2) { ["processId"]=> object(MongoDB\BSON\ObjectId)#4 (1) { ["oid"]=> string(24) "617b6d696a3a89d2f77e6df0" } ["counter"]=> int(6) } ["hosts"]=> array(1) { [0]=> string(15) "localhost:27017" } ["setName"]=> string(3) "rs0" ["setVersion"]=> int(1) ["ismaster"]=> bool(true) ["secondary"]=> bool(false) ["primary"]=> string(15) "localhost:27017" ["me"]=> string(15) "localhost:27017" ["electionId"]=> object(MongoDB\BSON\ObjectId)#5 (1) { ["oid"]=> string(24) "7fffffff0000000000000001" } ["lastWrite"]=> array(4) { ["opTime"]=> array(2) { ["ts"]=> object(MongoDB\BSON\Timestamp)#6 (2) { ["increment"]=> string(1) "1" ["timestamp"]=> string(10) "1635478989" } ["t"]=> int(1) } ["lastWriteDate"]=> object(MongoDB\BSON\UTCDateTime)#7 (1) { ["milliseconds"]=> string(13) "1635478989000" } ["majorityOpTime"]=> array(2) { ["ts"]=> object(MongoDB\BSON\Timestamp)#8 (2) { ["increment"]=> string(1) "1" ["timestamp"]=> string(10) "1635478989" } ["t"]=> int(1) } ["majorityWriteDate"]=> object(MongoDB\BSON\UTCDateTime)#9 (1) { ["milliseconds"]=> string(13) "1635478989000" } } ["maxBsonObjectSize"]=> int(16777216) ["maxMessageSizeBytes"]=> int(48000000) ["maxWriteBatchSize"]=> int(100000) ["localTime"]=> object(MongoDB\BSON\UTCDateTime)#10 (1) { ["milliseconds"]=> string(13) "1635478992136" } ["logicalSessionTimeoutMinutes"]=> int(30) ["connectionId"]=> int(3) ["minWireVersion"]=> int(0) ["maxWireVersion"]=> int(13) ["readOnly"]=> bool(false) ["ok"]=> float(1) ["$clusterTime"]=> array(2) { ["clusterTime"]=> object(MongoDB\BSON\Timestamp)#11 (2) { ["increment"]=> string(1) "1" ["timestamp"]=> string(10) "1635478989" } ["signature"]=> array(2) { ["hash"]=> object(MongoDB\BSON\Binary)#12 (2) { ["data"]=> string(20) "" ["type"]=> int(0) } ["keyId"]=> int(0) } } ["operationTime"]=> object(MongoDB\BSON\Timestamp)#13 (2) { ["increment"]=> string(1) "1" ["timestamp"]=> string(10) "1635478989" } }
변경 로그
버전 | 설명 |
---|---|
PECL mongodb 1.11.0 | 드라이버가 로드 밸런서에 연결되면 이 메서드는 초기 연결 핸드셰이크에서 지원 서버의 hello 명령 응답을 반환합니다. |
노트
참고: 서버가 쓰기 작업을 실행할 수 있는지 확인하는 것은 호출자의 책임입니다. 예를 들어, 보조(해당 "로컬" 데이터베이스 제외)에서 쓰기 작업을 실행하면 실패합니다.
기타
- MongoDB 매뉴얼의 » hello 명령
- » Server Discovery and Monitoring Specification