public function testNotifyInvalidHttpCodeRecoverException()
 {
     App::alarm()->notifyInvalidHttpCode("testservice", 400);
     $result = App::alarm()->existCacheFile("alarm_testservice_400");
     $this->assertTrue((bool) $result);
     App::alarm()->notifyInvalidHttpCode("testservice", 0);
     $result = App::alarm()->existCacheFile("alarm_testservice_400");
     $this->assertFalse((bool) $result);
 }
Beispiel #2
0
 public function getDb()
 {
     if (null === $this->_db) {
         $options = $this->getOptions();
         // caching ini file data
         if (isset($options['host']) && isset($options['dbname'])) {
             $url = $options['host'];
             if (isset($options['port']) && $options['port']) {
                 $url .= ":" . $options['port'];
             }
             if (isset($options['username']) && $options['username']) {
                 $user = $options['username'] . ':';
                 if (isset($options['password']) && $options['username']) {
                     $user .= $options['password'];
                 }
                 $url = $user . "@" . $url;
             }
             $url = 'mongodb://' . $url;
             $params = array("connect" => true);
             if (isset($options['options']) && !empty($options['options'])) {
                 $params = $options['options'] + $params;
             }
             try {
                 $connection = new MongoClient($url, array('connect' => false) + $params);
                 $connection->connect();
                 $db = $connection->{$options}['dbname'];
                 $this->setDb($db);
                 \App::alarm()->restoreDBAlarmLog($options['dbname']);
             } catch (MongoConnectionException $e) {
                 \App::log('Error connecting to MongoDB server: ' . $options['host']);
                 \App::alarm()->errorDBAlarmLog($url);
                 if ($connection) {
                     $connection->close(true);
                 }
                 throw $e;
             } catch (\Exception $e) {
                 \App::log('Error: ' . $e->getMessage());
                 \App::alarm()->errorDBAlarmLog($url);
                 if ($connection) {
                     $connection->close(true);
                 }
                 throw $e;
             }
         }
     }
     return $this->_db;
 }
Beispiel #3
0
 protected function checkAlarmTimeSpent($serviceName)
 {
     $path = $this->_path;
     $start = $this->getRestService()->getLastResultTimeSpent();
     App::alarm()->checkTooMuchTimeSpentError($serviceName, $path, $start);
 }