configuration parameter DBWriter.MaxRecordsPerTransaction added to database
[public/netxms.git] / src / server / tools / nxdbmgr / upgrade_v30.cpp
index 9fb3c6a..08a9af6 100644 (file)
 #include "nxdbmgr.h"
 
 /**
 #include "nxdbmgr.h"
 
 /**
+ * Upgrade from 30.8 to 30.9 (changes also included into 22.2)
+ */
+static bool H_UpgradeFromV8()
+{
+   if (GetSchemaLevelForMajorVersion(22) < 2)
+   {
+      CHK_EXEC(CreateConfigParam(_T("DBWriter.MaxRecordsPerTransaction"), _T("1000"), _T("Maximum number of records per one transaction for delayed database writes."), 'I', true, true, false, false));
+      CHK_EXEC(SetSchemaLevelForMajorVersion(22, 2));
+   }
+   CHK_EXEC(SetMinorSchemaVersion(9));
+   return true;
+}
+
+/**
+ * Upgrade from 30.7 to 30.8 (changes also included into 22.1)
+ */
+static bool H_UpgradeFromV7()
+{
+   if (GetSchemaLevelForMajorVersion(22) < 1)
+   {
+      int count = ConfigReadInt(_T("NumberOfDataCollectors"), 250);
+      TCHAR value[64];
+      _sntprintf(value, 64,_T("%d"), std::max(250, count));
+      CHK_EXEC(CreateConfigParam(_T("DataCollector.ThreadPool.BaseSize"), _T("10"), _T("Base size for data collector thread pool."), 'I', true, true, false, false));
+      CHK_EXEC(CreateConfigParam(_T("DataCollector.ThreadPool.MaxSize"), value, _T("Maximum size for data collector thread pool."), 'I', true, true, false, false));
+      CHK_EXEC(SQLQuery(_T("UPDATE config SET default_value='250' WHERE var_name='DataCollector.ThreadPool.MaxSize'")));
+      CHK_EXEC(SQLQuery(_T("DELETE FROM config WHERE var_name='NumberOfDataCollectors'")));
+      CHK_EXEC(SetSchemaLevelForMajorVersion(22, 1));
+   }
+   CHK_EXEC(SetMinorSchemaVersion(8));
+   return true;
+}
+
+/**
  * Upgrade from 30.6 to 30.7 (changes also included into 21.4)
  */
 static bool H_UpgradeFromV6()
  * Upgrade from 30.6 to 30.7 (changes also included into 21.4)
  */
 static bool H_UpgradeFromV6()
@@ -66,7 +100,7 @@ static bool H_UpgradeFromV6()
       }
       else if (!g_bIgnoreErrors)
          return false;
       }
       else if (!g_bIgnoreErrors)
          return false;
-      CHK_EXEC(SetMajorSchemaVersion(21, 4));
+      CHK_EXEC(SetSchemaLevelForMajorVersion(21, 4));
    }
    CHK_EXEC(SetMinorSchemaVersion(7));
    return true;
    }
    CHK_EXEC(SetMinorSchemaVersion(7));
    return true;
@@ -85,9 +119,9 @@ static bool H_UpgradeFromV5()
                _T("<END>");
       CHK_EXEC(SQLBatch(batch));
 
                _T("<END>");
       CHK_EXEC(SQLBatch(batch));
 
-      DBSetNotNullConstraint(g_hCoreDB, _T("nodes"), _T("fail_time_snmp"));
-      DBSetNotNullConstraint(g_hCoreDB, _T("nodes"), _T("fail_time_agent"));
-      CHK_EXEC(SetMajorSchemaVersion(21, 3));
+      CHK_EXEC(DBSetNotNullConstraint(g_hCoreDB, _T("nodes"), _T("fail_time_snmp")));
+      CHK_EXEC(DBSetNotNullConstraint(g_hCoreDB, _T("nodes"), _T("fail_time_agent")));
+      CHK_EXEC(SetSchemaLevelForMajorVersion(21, 3));
    }
    CHK_EXEC(SetMinorSchemaVersion(6));
    return true;
    }
    CHK_EXEC(SetMinorSchemaVersion(6));
    return true;
@@ -105,7 +139,7 @@ static bool H_UpgradeFromV4()
                _T("ALTER TABLE nodes ADD fail_time_agent integer\n")
                _T("<END>");
       CHK_EXEC(SQLBatch(batch));
                _T("ALTER TABLE nodes ADD fail_time_agent integer\n")
                _T("<END>");
       CHK_EXEC(SQLBatch(batch));
-      CHK_EXEC(SetMajorSchemaVersion(21, 2));
+      CHK_EXEC(SetSchemaLevelForMajorVersion(21, 2));
    }
    CHK_EXEC(SetMinorSchemaVersion(5));
    return true;
    }
    CHK_EXEC(SetMinorSchemaVersion(5));
    return true;
@@ -466,6 +500,8 @@ static struct
    bool (* upgradeProc)();
 } s_dbUpgradeMap[] =
 {
    bool (* upgradeProc)();
 } s_dbUpgradeMap[] =
 {
+   { 8, 30, 9, H_UpgradeFromV8 },
+   { 7, 30, 8, H_UpgradeFromV7 },
    { 6, 30, 7, H_UpgradeFromV6 },
    { 5, 30, 6, H_UpgradeFromV5 },
    { 4, 30, 5, H_UpgradeFromV4 },
    { 6, 30, 7, H_UpgradeFromV6 },
    { 5, 30, 6, H_UpgradeFromV5 },
    { 4, 30, 5, H_UpgradeFromV4 },