private function autodetect_parseNodes()
    {
        foreach ($this->nodes as $node) {
            try {
                $client   = new Client('http://' . $node['host'] . ':' . $node['port']);
                $request  = $client->get('/_nodes/http');
                $response = $request->send()->json();

                foreach ($response['nodes'] as $newNode) {

                    //we don't want http-inaccessible nodes
                    if (!isset($newNode['http_address'])) {
                        continue;
                    }

                    preg_match('/inet\[\/([0-9\.]+):([0-9]+)\]/i', $newNode['http_address'], $match);

                    $tNode = array('host' => $match[1], 'port' => $match[2]);

                    //use host as key so that we don't add duplicates
                    $this->nodes[$match[1]] = $tNode;

                }

                //we have the complete node list, no need to keep checking
                break;

            } catch (\Guzzle\Http\Exception\BadResponseException $e) {
                //error with this node, continue onto the next one
            }
        }
    }
private function autodetect_parseNodes()
    {
        foreach ($this->nodes as $node) {
            try {
                $client   = new Client('http://' . $node['host'] . ':' . $node['port']);
                $request  = $client->get('/_nodes/http');
                $response = $request->send()->json();

                foreach ($response['nodes'] as $newNode) {

                    //we don't want http-inaccessible nodes
                    if (!isset($newNode['http_address'])) {
                        continue;
                    }

                    preg_match('/inet\[\/([0-9\.]+):([0-9]+)\]/i', $newNode['http_address'], $match);

                    $tNode = array('host' => $match[1], 'port' => $match[2]);

                    //use host as key so that we don't add duplicates
                    $this->nodes[$match[1]] = $tNode;

                }

                //we have the complete node list, no need to keep checking
                break;

            } catch (\Guzzle\Http\Exception\BadResponseException $e) {
                //error with this node, continue onto the next one
            }
        }
    }
private function autodetect_parseNodes ( ) { foreach ( $ this -> nodes as $ node ) { try { $ client = new Client ( 'http://' . $ node [ 'host' ] . ':' . $ node [ 'port' ] ) ; $ request = $ client -> get ( '/_nodes/http' ) ; $ response = $ request -> send ( ) -> json ( ) ; foreach ( $ response [ 'nodes' ] as $ newNode ) { //we don't want http-inaccessible nodes if ( ! isset ( $ newNode [ 'http_address' ] ) ) { continue ; } preg_match ( '/inet\[\/([0-9\.]+):([0-9]+)\]/i' , $ newNode [ 'http_address' ] , $ match ) ; $ tNode = array ( 'host' => $ match [ 1 ] , 'port' => $ match [ 2 ] ) ; //use host as key so that we don't add duplicates $ this -> nodes [ $ match [ 1 ] ] = $ tNode ; } //we have the complete node list, no need to keep checking break ; } catch ( \ Guzzle \ Http \ Exception \ BadResponseException $ e ) { //error with this node, continue onto the next one } } }
Autodetect the nodes in this cluster through Cluster State API
Autodetect the nodes in this cluster through Cluster State API