Author:   Lars Michelsen <[email protected]>
Date:     Wed Jan 11 22:05:07 2012 +0100
Committer:   Lars Michelsen <[email protected]>
Commit-Date: Wed Jan 11 22:05:07 2012 +0100

Undefined backend in single objects doos not prevent whole map loading anymore

---

 ChangeLog                                          |    1 +
 share/server/core/classes/CoreBackendMgmt.php      |   55 ++++++++++----------
 share/server/core/classes/GlobalMapCfg.php         |    3 +-
 .../core/classes/objects/NagVisStatefulObject.php  |    2 +-
 4 files changed, 32 insertions(+), 29 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2e6e07a..f7ac9b7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,7 @@
 Core
   * Bugfix: Made upper/lower case rotation_id/backend_id definitions possible
   * Added ; and | to allowed signs for urls
+  * Undefined backend in single objects doos not prevent whole map loading 
anymore
 
 Frontend
   * Showing dummy shape image when configured shape does not exist
diff --git a/share/server/core/classes/CoreBackendMgmt.php 
b/share/server/core/classes/CoreBackendMgmt.php
index f15491c..4c61d6e 100644
--- a/share/server/core/classes/CoreBackendMgmt.php
+++ b/share/server/core/classes/CoreBackendMgmt.php
@@ -444,36 +444,37 @@ class CoreBackendMgmt {
      * @author         Lars Michelsen <[email protected]>
      */
     private function initializeBackend($backendId) {
-        if($this->checkBackendExists($backendId, true)) {
-            /**
-             * The status host can be used to prevent annoying timeouts when a 
backend is not
-             * reachable. This is only useful in multi backend setups.
-             *
-             * It works as follows: The assumption is that there is a "local" 
backend which
-             * monitors the host of the "remote" backend. When the remote 
backend host is
-             * reported as UP the backend is queried as normal.
-             * When the remote backend host is reported as "DOWN" or 
"UNREACHABLE" NagVis won't
-             * try to connect to the backend anymore until the backend host 
gets available again.
-             */
-      $statusHost = cfg('backend_' . $backendId, 'statushost');
-      if($statusHost != '' && !$this->backendAlive($backendId, $statusHost)) {
-                $this->aError[$backendId] = new 
BackendConnectionProblem(l('The backend is reported as dead by the statusHost 
([STATUSHOST]).', Array('STATUSHOST' => $statusHost)));
-                return false;
-            }
+        if(!$this->checkBackendExists($backendId, false)) {
+            $this->aError[$backendId] = new 
BackendConnectionProblem(l('backendNotDefined',
+                                            Array('BACKENDID'   => 
$backendId)));
+            return false;
+        }
+        /**
+         * The status host can be used to prevent annoying timeouts when a 
backend is not
+         * reachable. This is only useful in multi backend setups.
+         *
+         * It works as follows: The assumption is that there is a "local" 
backend which
+         * monitors the host of the "remote" backend. When the remote backend 
host is
+         * reported as UP the backend is queried as normal.
+         * When the remote backend host is reported as "DOWN" or "UNREACHABLE" 
NagVis won't
+         * try to connect to the backend anymore until the backend host gets 
available again.
+         */
+        $statusHost = cfg('backend_' . $backendId, 'statushost');
+        if($statusHost != '' && !$this->backendAlive($backendId, $statusHost)) 
{
+            $this->aError[$backendId] = new BackendConnectionProblem(l('The 
backend is reported as dead by the statusHost ([STATUSHOST]).', 
Array('STATUSHOST' => $statusHost)));
+            return false;
+        }
 
-            try {
-                $backendClass = 'GlobalBackend' . cfg('backend_' . $backendId, 
'backendtype');
-                $this->BACKENDS[$backendId] = new $backendClass($this->CORE, 
$backendId);
+        try {
+            $backendClass = 'GlobalBackend' . cfg('backend_' . $backendId, 
'backendtype');
+            $this->BACKENDS[$backendId] = new $backendClass($this->CORE, 
$backendId);
 
-                // Mark backend as initialized
-                $this->aInitialized[$backendId] = true;
+            // Mark backend as initialized
+            $this->aInitialized[$backendId] = true;
 
-                return true;
-            } catch(BackendException $e) {
-                $this->aError[$backendId] = $e;
-                return false;
-            }
-        } else {
+            return true;
+        } catch(BackendException $e) {
+            $this->aError[$backendId] = $e;
             return false;
         }
     }
diff --git a/share/server/core/classes/GlobalMapCfg.php 
b/share/server/core/classes/GlobalMapCfg.php
index 3577225..fa9ed92 100644
--- a/share/server/core/classes/GlobalMapCfg.php
+++ b/share/server/core/classes/GlobalMapCfg.php
@@ -640,7 +640,8 @@ class GlobalMapCfg {
                     }
 
                     // Check if the configured backend is defined in main 
configuration file
-                    if($key == 'backend_id' && !in_array($val, 
$this->CORE->getDefinedBackends())) {
+                    // Raise such an exception only when error is found in 
global section
+                    if($type == 'global' && $key == 'backend_id' && 
!in_array($val, $this->CORE->getDefinedBackends())) {
                         throw new $exception(l('backendNotDefined', 
Array('BACKENDID' => $val)));
                     }
                 }
diff --git a/share/server/core/classes/objects/NagVisStatefulObject.php 
b/share/server/core/classes/objects/NagVisStatefulObject.php
index 650625c..fbf4fd4 100644
--- a/share/server/core/classes/objects/NagVisStatefulObject.php
+++ b/share/server/core/classes/objects/NagVisStatefulObject.php
@@ -805,7 +805,7 @@ class NagVisStatefulObject extends NagVisObject {
      */
     public function setBackendProblem($s) {
         $this->problem_msg = l('Problem (Backend: [BACKENDID]): [MSG]',
-                                                                      
Array('BACKENDID' => $this->backend_id, 'MSG' => $s));
+                               Array('BACKENDID' => $this->backend_id, 'MSG' 
=> $s));
     }
 
     /**


------------------------------------------------------------------------------
RSA(R) Conference 2012
Mar 27 - Feb 2
Save $400 by Jan. 27
Register now!
http://p.sf.net/sfu/rsa-sfdev2dev2
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins

Reply via email to