added option to use last known value for cluster data aggregation in case of data...
authorVictor Kirhenshtein <victor@netxms.org>
Thu, 26 May 2016 16:29:31 +0000 (19:29 +0300)
committerVictor Kirhenshtein <victor@netxms.org>
Thu, 26 May 2016 16:31:18 +0000 (19:31 +0300)
include/nxcldefs.h
src/java/client/netxms-client/src/main/java/org/netxms/client/datacollection/DataCollectionObject.java
src/java/netxms-eclipse/DataCollection/src/org/netxms/ui/eclipse/datacollection/propertypages/ClusterOptions.java
src/server/core/cluster.cpp
src/server/include/nms_dcoll.h
webui/webapp/DataCollection/src/org/netxms/ui/eclipse/datacollection/propertypages/ClusterOptions.java

index 5ddd8bc..2eeb32a 100644 (file)
@@ -723,6 +723,7 @@ enum SessionState
 #define DCF_CALCULATE_NODE_STATUS   ((UINT16)0x0400)
 #define DCF_SHOW_IN_OBJECT_OVERVIEW ((UINT16)0x0800)
 #define DCF_CACHE_MODE_MASK         ((UINT16)0x3000)
+#define DCF_AGGREGATE_WITH_ERRORS   ((UINT16)0x4000)
 
 /**
  * Get cluster aggregation function from DCI flags
index 6dc7f81..5b2c521 100644 (file)
@@ -59,11 +59,12 @@ public abstract class DataCollectionObject
        public static final int DT_NULL = 6;
        
        // common data collection flags
-       public static final int DCF_ADVANCED_SCHEDULE    = 0x0001;
-       public static final int DCF_AGGREGATE_ON_CLUSTER = 0x0080;
-   public static final int DCF_TRANSFORM_AGGREGATED = 0x0100;
-   public static final int DCF_NO_STORAGE           = 0x0200;
-   public static final int DCF_CACHE_MODE_MASK      = 0x3000;
+       public static final int DCF_ADVANCED_SCHEDULE     = 0x0001;
+       public static final int DCF_AGGREGATE_ON_CLUSTER  = 0x0080;
+   public static final int DCF_TRANSFORM_AGGREGATED  = 0x0100;
+   public static final int DCF_NO_STORAGE            = 0x0200;
+   public static final int DCF_CACHE_MODE_MASK       = 0x3000;
+   public static final int DCF_AGGREGATE_WITH_ERRORS = 0x4000;
        
        protected DataCollectionConfiguration owner;
        protected long id;
@@ -540,6 +541,31 @@ public abstract class DataCollectionObject
                        flags &= ~DCF_AGGREGATE_ON_CLUSTER;
        }
 
+   /**
+    * Include node DCI value into aggregated value even in case of 
+    * data collection error (system will use last known value in that case)
+    * 
+    * @return true if enabled
+    */
+   public boolean isAggregateWithErrors()
+   {
+      return (flags & DCF_AGGREGATE_WITH_ERRORS) != 0;
+   }
+
+   /**
+    * Enable or disable inclusion of node DCI value into aggregated value even
+    * in case of data collection error (system will use last known value in that case)
+    * 
+    * @param enable true to enable
+    */
+   public void setAggregateWithErrors(boolean enable)
+   {
+      if (enable)
+         flags |= DCF_AGGREGATE_WITH_ERRORS;
+      else
+         flags &= ~DCF_AGGREGATE_WITH_ERRORS;
+   }
+
    /**
     * @return 
     */
index 5d882ce..7dc6dc5 100644 (file)
@@ -1,6 +1,6 @@
 /**
  * NetXMS - open source network management system
- * Copyright (C) 2003-2013 Victor Kirhenshtein
+ * Copyright (C) 2003-2016 Victor Kirhenshtein
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -53,6 +53,7 @@ public class ClusterOptions extends PropertyPage
        private Combo clusterResource;
        private Map<Integer, Long> clusterResourceMap;
        private Button checkAggregate;
+   private Button checkAggregateWithErrors;
        private Button checkRunScript;
        private Combo aggregationFunction;
 
@@ -131,6 +132,10 @@ public class ClusterOptions extends PropertyPage
        checkAggregate.setText(Messages.get().ClusterOptions_AggregateFromNodes);
        checkAggregate.setSelection(editor.getObject().isAggregateOnCluster());
        
+      checkAggregateWithErrors = new Button(aggregationGroup, SWT.CHECK);
+      checkAggregateWithErrors.setText("Use last known value for aggregation in case of data collection error");
+      checkAggregateWithErrors.setSelection(editor.getObject().isAggregateWithErrors());
+         
       checkRunScript = new Button(aggregationGroup, SWT.CHECK);
       checkRunScript.setText(Messages.get().ClusterOptions_RunScriptOnAggregatedData);
       checkRunScript.setSelection(editor.getObject().isTransformAggregated());
@@ -175,6 +180,7 @@ public class ClusterOptions extends PropertyPage
                        editor.getObject().setResourceId(clusterResourceMap.get(clusterResource.getSelectionIndex()));
                }
                editor.getObject().setAggregateOnCluster(checkAggregate.getSelection());
+      editor.getObject().setAggregateWithErrors(checkAggregateWithErrors.getSelection());
       editor.getObject().setTransformAggregated(checkRunScript.getSelection());
                if (editor.getObject() instanceof DataCollectionItem)
                {
index 44b9ec9..343a19c 100644 (file)
@@ -674,7 +674,7 @@ UINT32 Cluster::collectAggregatedData(DCItem *item, TCHAR *buffer)
       if ((dco != NULL) &&
           (dco->getType() == DCO_TYPE_ITEM) &&
           (dco->getStatus() == ITEM_STATUS_ACTIVE) &&
-          (dco->getErrorCount() == 0) &&
+          ((dco->getErrorCount() == 0) || dco->isAggregateWithErrors()) &&
           dco->matchClusterResource())
       {
          ItemValue *v = ((DCItem *)dco)->getInternalLastValue();
@@ -738,7 +738,7 @@ UINT32 Cluster::collectAggregatedData(DCTable *table, Table **result)
       if ((dco != NULL) &&
           (dco->getType() == DCO_TYPE_TABLE) &&
           (dco->getStatus() == ITEM_STATUS_ACTIVE) &&
-          (dco->getErrorCount() == 0) &&
+          ((dco->getErrorCount() == 0) || dco->isAggregateWithErrors()) &&
           dco->matchClusterResource())
       {
          Table *v = ((DCTable *)dco)->getLastValue();
index cf0abee..4e9e258 100644 (file)
@@ -268,6 +268,7 @@ public:
    bool isShowInObjectOverview() const { return (m_flags & DCF_SHOW_IN_OBJECT_OVERVIEW) ? true : false; }
    bool isAggregateOnCluster() const { return (m_flags & DCF_AGGREGATE_ON_CLUSTER) ? true : false; }
        bool isStatusDCO() const { return (m_flags & DCF_CALCULATE_NODE_STATUS) ? true : false; }
+   bool isAggregateWithErrors() const { return (m_flags & DCF_AGGREGATE_WITH_ERRORS) ? true : false; }
    int getAggregationFunction() const { return DCF_GET_AGGREGATION_FUNCTION(m_flags); }
    int getRetentionTime() const { return m_iRetentionTime; }
    int getEffectiveRetentionTime() const { return (m_iRetentionTime > 0) ? m_iRetentionTime : m_defaultRetentionTime; }
index 5d882ce..7dc6dc5 100644 (file)
@@ -1,6 +1,6 @@
 /**
  * NetXMS - open source network management system
- * Copyright (C) 2003-2013 Victor Kirhenshtein
+ * Copyright (C) 2003-2016 Victor Kirhenshtein
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -53,6 +53,7 @@ public class ClusterOptions extends PropertyPage
        private Combo clusterResource;
        private Map<Integer, Long> clusterResourceMap;
        private Button checkAggregate;
+   private Button checkAggregateWithErrors;
        private Button checkRunScript;
        private Combo aggregationFunction;
 
@@ -131,6 +132,10 @@ public class ClusterOptions extends PropertyPage
        checkAggregate.setText(Messages.get().ClusterOptions_AggregateFromNodes);
        checkAggregate.setSelection(editor.getObject().isAggregateOnCluster());
        
+      checkAggregateWithErrors = new Button(aggregationGroup, SWT.CHECK);
+      checkAggregateWithErrors.setText("Use last known value for aggregation in case of data collection error");
+      checkAggregateWithErrors.setSelection(editor.getObject().isAggregateWithErrors());
+         
       checkRunScript = new Button(aggregationGroup, SWT.CHECK);
       checkRunScript.setText(Messages.get().ClusterOptions_RunScriptOnAggregatedData);
       checkRunScript.setSelection(editor.getObject().isTransformAggregated());
@@ -175,6 +180,7 @@ public class ClusterOptions extends PropertyPage
                        editor.getObject().setResourceId(clusterResourceMap.get(clusterResource.getSelectionIndex()));
                }
                editor.getObject().setAggregateOnCluster(checkAggregate.getSelection());
+      editor.getObject().setAggregateWithErrors(checkAggregateWithErrors.getSelection());
       editor.getObject().setTransformAggregated(checkRunScript.getSelection());
                if (editor.getObject() instanceof DataCollectionItem)
                {