From 7fb9233de90ce469b812eb2dd01677d992358802 Mon Sep 17 00:00:00 2001 From: goldenhawking Date: Tue, 16 Sep 2014 20:29:09 +0800 Subject: [PATCH] Add a cluster-reconnection method. when cluster nodes lost all connections, it will attempt to re-connect to target cluster every 2 mins --- ZoomPipeline_FuncSvr/zpmainframe.cpp | 17 +++++++++++++++++ ZoomPipeline_FuncSvr/zpmainframe.h | 2 ++ 2 files changed, 19 insertions(+) diff --git a/ZoomPipeline_FuncSvr/zpmainframe.cpp b/ZoomPipeline_FuncSvr/zpmainframe.cpp index 9c53f40..7714c48 100644 --- a/ZoomPipeline_FuncSvr/zpmainframe.cpp +++ b/ZoomPipeline_FuncSvr/zpmainframe.cpp @@ -365,6 +365,19 @@ void ZPMainFrame::timerEvent(QTimerEvent * e) m_clientTable->KickDeadClients(); m_pClusterTerm->SendHeartBeatings(); m_pClusterTerm->KickDeadClients(); + if (ui->action_Start_Stop->isChecked()==true) + { + //Cluster re-connection Test + QStringList lstCluster = m_pClusterTerm->SvrNames(); + if (lstCluster.size()==0 && m_dtmLastClusterJoin.secsTo(QDateTime::currentDateTime())>=120) + { + QSettings settings(this->m_currentConfigFile,QSettings::IniFormat); + QString strAddr = settings.value("history/clusterAddr","192.168.1.118").toString(); + QString strPort = settings.value("history/clusterPort","25600").toString(); + m_pClusterTerm->JoinCluster(QHostAddress(strAddr),strPort.toInt()); + m_dtmLastClusterJoin = QDateTime::currentDateTime(); + } + } m_nTimerCheck = startTimer(5000); } } @@ -373,6 +386,8 @@ void ZPMainFrame::on_action_Start_Stop_triggered(bool setordel) if (setordel==true) { forkServer(m_currentConfigFile); + //Cluster Reconnection Dtm Protect + m_dtmLastClusterJoin = QDateTime::currentDateTime(); } else { @@ -815,6 +830,8 @@ void ZPMainFrame::on_actionReload_config_file_triggered() m_currentConfigFile = filename; LoadSettings(m_currentConfigFile); forkServer(m_currentConfigFile); + //Cluster Reconnection Dtm Protect + m_dtmLastClusterJoin = QDateTime::currentDateTime(); } } void ZPMainFrame::on_pushButton_db_add_clicked() diff --git a/ZoomPipeline_FuncSvr/zpmainframe.h b/ZoomPipeline_FuncSvr/zpmainframe.h index 5aa8182..579be10 100644 --- a/ZoomPipeline_FuncSvr/zpmainframe.h +++ b/ZoomPipeline_FuncSvr/zpmainframe.h @@ -59,6 +59,8 @@ private: ExampleServer::st_client_table * m_clientTable; ZPDatabase::DatabaseResource * m_pDatabases; ZP_Cluster::zp_ClusterTerm * m_pClusterTerm; + //Cluster Reconnection + QDateTime m_dtmLastClusterJoin; int m_nTimerId; void initUI(); void LoadSettings(QString config_file); -- GitLab