예제 #1
0
 public function testSetStats()
 {
     $stats = new Stats();
     $stats->setPid(8991);
     $cluster = new Cluster();
     $cluster->setStats($stats);
     $this->assertEquals($stats, $cluster->getStats());
 }
예제 #2
0
 public function testSetGetBytesWritten()
 {
     $stats = new Stats();
     $this->assertEquals('0 bytes', $stats->getBytesWritten());
     $stats->setBytesWritten(1799);
     $this->assertEquals('2 Kb', $stats->getBytesWritten());
 }
 /**
  * @return Stats
  */
 public function getStats()
 {
     //if no stats available for the nodes, return
     if ($clusterStats = $this->getClient()->getStats()) {
         $stats = new Stats();
         $nodeCount = count($clusterStats);
         if ($nodeCount > 0) {
             foreach ($clusterStats as $node => $nodeStatistics) {
                 if (!isset($nodeStatistics['version'])) {
                     continue;
                 }
                 if ($nodeStatistics['pid'] > 0) {
                     $stats->incrementActiveNodes();
                 }
                 if ($nodeCount == 1) {
                     $stats->setPid($nodeStatistics['pid']);
                     $stats->setUptime($nodeStatistics['uptime']);
                     $stats->setThreads($nodeStatistics['threads']);
                     $stats->setPointerSize($nodeStatistics['pointer_size']);
                     $stats->setVersion($nodeStatistics['version']);
                 }
                 $stats->setCurrItems($stats->getCurrItems() + $nodeStatistics['curr_items']);
                 $stats->setTotalItems($stats->getTotalItems() + $nodeStatistics['total_items']);
                 $stats->setLimitMaxbytes($stats->getLimitMaxbytes() + $nodeStatistics['limit_maxbytes']);
                 $stats->setCurrConnections($stats->getCurrConnections() + $nodeStatistics['curr_connections']);
                 $stats->setTotalConnections($stats->getTotalConnections() + $nodeStatistics['total_connections']);
                 $stats->setConnectionStructures($stats->getConnectionStructures() + $nodeStatistics['connection_structures']);
                 $stats->setBytes($stats->getBytes() + $nodeStatistics['bytes']);
                 $stats->setCmdGet($stats->getCmdGet() + $nodeStatistics['cmd_get']);
                 $stats->setCmdSet($stats->getCmdSet() + $nodeStatistics['cmd_set']);
                 $stats->setGetHits($stats->getGetHits() + $nodeStatistics['get_hits']);
                 $stats->setGetMisses($stats->getGetMisses() + $nodeStatistics['get_misses']);
                 $stats->setEvictions($stats->getEvictions() + $nodeStatistics['evictions']);
                 $stats->setBytesRead($stats->getBytesRead() + $nodeStatistics['bytes_read']);
                 $stats->setBytesWritten($stats->getBytesWritten() + $nodeStatistics['bytes_written']);
             }
         }
         return $stats;
     }
     return null;
 }