diff --git a/src/dubboClient.php b/src/dubboClient.php index 69cd34a..6153f1f 100644 --- a/src/dubboClient.php +++ b/src/dubboClient.php @@ -14,7 +14,7 @@ */ class dubboClient{ protected $register; - static $protocols; + static $protocols = array(); public function __construct($options=array()) { @@ -46,7 +46,7 @@ public function getService($serviceName, $version, $group, $protocol = "jsonrpc" */ private function makeInvokerByProtocol($protocol){ - if(array_key_exists(self::$protocols,$protocol)){ + if(array_key_exists($protocol,self::$protocols)){ return self::$protocols[$protocol]; } diff --git a/src/invok/cluster.php b/src/invok/cluster.php index 3c6a448..e3ab60e 100644 --- a/src/invok/cluster.php +++ b/src/invok/cluster.php @@ -22,14 +22,14 @@ public static function getInstance(){ public function addProvider($invokerDesc,$host,$schema){ $desc = $invokerDesc->toString(); - $this->providerMap[$desc][] = $host; + self::$providerMap[$desc][] = $host; } public function getProvider($invokerDesc){ $desc = $invokerDesc->toString(); - $key = array_rand($this->providerMap[$desc]); - return $this->providerMap[$desc][$key]; + $key = array_rand(self::$providerMap[$desc]); + return self::$providerMap[$desc][$key]; } public function getProviders(){ diff --git a/src/register.php b/src/register.php index a3e91c8..27f5a60 100644 --- a/src/register.php +++ b/src/register.php @@ -170,15 +170,14 @@ public function zkinfo($invokerDesc){ */ private function achieveRegisterIp(){ try { - $registerIp = gethostbyaddr($_SERVER['SERVER_ADDR']); + if($_SERVER['SERVER_ADDR']) + $registerIp = gethostbyaddr($_SERVER['SERVER_ADDR']); if (empty($registerIp)) { if (substr(strtolower(PHP_OS), 0, 3) != 'win') { $ss = exec('/sbin/ifconfig | sed -n \'s/^ *.*addr:\\([0-9.]\\{7,\\}\\) .*$/\\1/p\'', $arr); $registerIp = $arr[0]; }else{ - /** @TODO - * @ implement the windows ip - **/ + // TODO: implement the windows ip } } }catch (\Exception $e){