提交 50ccfdc4 编写于 作者: 丁劲犇's avatar 丁劲犇 😸

A lot of improvement has been made, for cross-svr balance, and client test

上级 e66954e3
......@@ -136,6 +136,7 @@ void MainDialog::timerEvent(QTimerEvent * evt)
EXAMPLE_HEARTBEATING * pMsg = (EXAMPLE_HEARTBEATING *)ptr;
pMsg->Mark = 0xBEBE;
pMsg->tmStamp = time(0)&0x00ffff;
pMsg->source_id = 0;
//3/10 possibility to send a data block to server
client->SendData(array);
......@@ -178,7 +179,7 @@ void MainDialog::on_pushButton_clientLogin_clicked()
pMsg->data_length = nMsgLen;
pApp->header.MsgType = 0x3000;
pApp->header.MsgType = 0x0001;
pApp->MsgUnion.msg_ClientLoginReq.user_id = userID;
......@@ -300,7 +301,7 @@ void MainDialog::on_pushButton_clientLogout_clicked()
pMsg->data_length = nMsgLen;
pApp->header.MsgType = 0x3001;
pApp->header.MsgType = 0x1002;
pApp->MsgUnion.msg_ClientLogoutReq.UserName[0] = 0;
......@@ -443,20 +444,28 @@ int MainDialog::deal_current_message_block()
(ptr))+sizeof(EXAMPLE_TRANS_MSG)-1
);
if (pApp->header.MsgType==0x3800)
if (pApp->header.MsgType==0x7FFE)
{
if (pApp->MsgUnion.msg_ClientLoginRsp.DoneCode==0)
{
m_bLogedIn = true;
QMessageBox::information(this,tr("Succeed!"),tr("Log in succeed!"));
}
else if (pApp->MsgUnion.msg_ClientLoginRsp.DoneCode==1)
{
m_bLogedIn = true;
QMessageBox::information(this,tr("Succeed!"),tr("But you can connect to another idle svr:%1:%2!")
.arg((const char *)pApp->MsgUnion.msg_ClientLoginRsp.Address_Redirect)
.arg(pApp->MsgUnion.msg_ClientLoginRsp.port_Redirect)
);
}
else
QMessageBox::information(this,tr("Failed!"),tr("Log in Failed!"));
QMessageBox::information(this,tr("Failed!"),tr("Log in failed!"));
displayMessage(tr("Res = %1")
.arg(pApp->MsgUnion.msg_ClientLoginRsp.DoneCode)
);
.arg(pApp->MsgUnion.msg_ClientLoginRsp.DoneCode)
);
}
else if (pApp->header.MsgType==0x1803)
else if (pApp->header.MsgType==0x7FFC)
{
if (pApp->MsgUnion.msg_UploadUserListRsp.DoneCode==0)
QMessageBox::information(this,tr("Succeed!"),tr("upload succeed!"));
......@@ -467,7 +476,7 @@ int MainDialog::deal_current_message_block()
);
}
else if (pApp->header.MsgType==0x1804)
else if (pApp->header.MsgType==0x7FFB)
{
if (pApp->MsgUnion.msg_DownloadUserListRsp.DoneCode==0)
{
......@@ -486,7 +495,7 @@ int MainDialog::deal_current_message_block()
);
}
else if (pApp->header.MsgType==0x3801)
else if (pApp->header.MsgType==0x7FFD)
{
if (pApp->MsgUnion.msg_ClientLogoutRsp.DoneCode==0)
QMessageBox::information(this,tr("Succeed!"),tr("log out succeed!"));
......
#include "qghtcpclient.h"
#include <assert.h>
QGHTcpClient::QGHTcpClient(QObject *parent,int nPayLoad)
#include <QFile>
#include <QThread>
QGHSslClient::QGHSslClient(QObject *parent,int nPayLoad)
: QSslSocket(parent),
m_nPayLoad(nPayLoad)
{
assert(m_nPayLoad>=256 && m_nPayLoad<=16*1024*1024);
connect(this, SIGNAL(bytesWritten(qint64)), this, SLOT(some_data_sended(qint64)));
m_uuid = 0;
}
QGHSslClient::~QGHSslClient()
{
}
quint32 QGHSslClient::uuid()
{
return m_uuid;
}
void QGHSslClient::geneGlobalUUID(const QString & globalUuidFile)
{
QFile file(globalUuidFile);
int ctp = 0;
while (file.open(QIODevice::ReadWrite)==false)
{
ctp++;
if (ctp>=100)
{
this->disconnectFromHost();
return ;
}
QThread::currentThread()->sleep(20);
}
file.seek(0);
quint32 oldUUID =1;
if (file.size()>=sizeof(oldUUID))
file.read((char *)&oldUUID,sizeof(oldUUID));
oldUUID ++;
this->m_uuid = oldUUID;
file.seek(0);
file.write((char *)&oldUUID,sizeof(oldUUID));
file.flush();
file.close();
}
void QGHSslClient::some_data_sended(qint64 wsended)
{
while (m_buffer_sending.empty()==false)
{
QByteArray & arraySending = *m_buffer_sending.begin();
qint64 & currentOffset = *m_buffer_sending_offset.begin();
qint64 nTotalBytes = arraySending.size();
assert(nTotalBytes>=currentOffset);
qint64 nBytesWritten = write(arraySending.constData()+currentOffset,qMin((int)(nTotalBytes-currentOffset),m_nPayLoad));
currentOffset += nBytesWritten;
if (currentOffset>=nTotalBytes)
{
m_buffer_sending.pop_front();
m_buffer_sending_offset.pop_front();
}
else
break;
}
}
void QGHSslClient::SendData(QByteArray dtarray)
{
if (dtarray.size())
{
if (m_buffer_sending.empty()==true)
{
qint64 bytesWritten = write(dtarray.constData(),qMin(dtarray.size(),m_nPayLoad));
if (bytesWritten < dtarray.size())
{
m_buffer_sending.push_back(dtarray);
m_buffer_sending_offset.push_back(bytesWritten);
}
}
else
{
m_buffer_sending.push_back(dtarray);
m_buffer_sending_offset.push_back(0);
}
}
}
QGHTcpClient::QGHTcpClient(QObject *parent,int nPayLoad)
: QTcpSocket(parent),
m_nPayLoad(nPayLoad)
{
assert(m_nPayLoad>=256 && m_nPayLoad<=16*1024*1024);
connect(this, SIGNAL(bytesWritten(qint64)), this, SLOT(some_data_sended(qint64)));
m_uuid = 0;
}
quint32 QGHTcpClient::uuid()
{
return m_uuid;
}
void QGHTcpClient::geneGlobalUUID(const QString & globalUuidFile)
{
QFile file(globalUuidFile);
int ctp = 0;
while (file.open(QIODevice::ReadWrite)==false)
{
ctp++;
if (ctp>=100)
{
this->disconnectFromHost();
return ;
}
QThread::currentThread()->sleep(20);
}
file.seek(0);
quint32 oldUUID =1;
if (file.size()>=sizeof(oldUUID))
file.read((char *)&oldUUID,sizeof(oldUUID));
oldUUID ++;
this->m_uuid = oldUUID;
file.seek(0);
file.write((char *)&oldUUID,sizeof(oldUUID));
file.flush();
file.close();
}
QGHTcpClient::~QGHTcpClient()
{
......
......@@ -3,16 +3,39 @@
#include <QSslSocket>
#include <QList>
class QGHTcpClient : public QSslSocket
class QGHSslClient : public QSslSocket
{
Q_OBJECT
public:
QGHSslClient(QObject *parent,int nPayLoad = 4096);
~QGHSslClient();
quint32 uuid();
void geneGlobalUUID(const QString & globalUuidFile);
private:
quint32 m_uuid;
int m_nPayLoad;
QList<QByteArray> m_buffer_sending;
QList<qint64> m_buffer_sending_offset;
public slots:
void some_data_sended(qint64);
void SendData(QByteArray dtarray);
};
class QGHTcpClient : public QTcpSocket
{
Q_OBJECT
public:
QGHTcpClient(QObject *parent,int nPayLoad = 4096);
~QGHTcpClient();
quint32 uuid();
void geneGlobalUUID(const QString & globalUuidFile);
private:
int m_nPayLoad;
quint32 m_uuid; int m_nPayLoad;
QList<QByteArray> m_buffer_sending;
QList<qint64> m_buffer_sending_offset;
public slots:
......
#include "qtcpclienttest.h"
#include <QSettings>
#include <QCoreApplication>
#include <QFileDialog>
#include "../ZoomPipeline_FuncSvr/smartlink/st_message.h"
using namespace ExampleServer;
QTcpClientTest::QTcpClientTest(QWidget *parent, Qt::WindowFlags flags)
......@@ -15,7 +16,11 @@ QTcpClientTest::QTcpClientTest(QWidget *parent, Qt::WindowFlags flags)
ui.lcdNumber->display(settings.value("clientNum","32").toInt());
ui.horizontalSlider->setValue(settings.value("Payload","2048").toInt());
ui.label_load->setText(QString("Payload = %1").arg(settings.value("Payload","2048").toInt()));
ui.checkBox_SSL->setChecked(settings.value("SSL",false).toBool());
ui.lineEdit_globalFile->setText(settings.value("globalFile","/zpserver_syn.debug").toString());
ui.listView_msg->setModel(&model);
m_maxUUID = 2;
m_minUUID = 0xffffffff;
}
QTcpClientTest::~QTcpClientTest()
......@@ -34,58 +39,121 @@ void QTcpClientTest::on_action_Connect_triggered(bool bConn)
settings.setValue("port",ui.lineEdit_Port->text());
settings.setValue("clientNum",ui.dial->value());
settings.setValue("Payload",ui.horizontalSlider->value());
settings.setValue("SSL",ui.checkBox_SSL->isChecked());
settings.setValue("globalFile",ui.lineEdit_globalFile->text());
if (bConn==true)
{
nTimer = startTimer(100);
ui.dockWidget->setEnabled(false);
}
else
{
killTimer(nTimer);
ui.dockWidget->setEnabled(true);
QList<QTcpSocket*> listObj = m_clients.keys();
foreach(QTcpSocket * sock,listObj)
sock->disconnectFromHost();
}
}
void QTcpClientTest::on_client_trasferred(qint64 dtw)
{
QGHTcpClient * pSock = qobject_cast<QGHTcpClient*>(sender());
if (dtw <= sizeof(EXAMPLE_HEARTBEATING))
return;
QTcpSocket * pSock = qobject_cast<QTcpSocket*>(sender());
if (pSock)
{
displayMessage(QString("client %1 Transferrd %2 bytes.").arg((quintptr)pSock).arg(dtw));
QGHSslClient * pSockSsl = qobject_cast<QGHSslClient*>(sender());
QGHTcpClient * pSockTcp = qobject_cast<QGHTcpClient*>(sender());
if (pSockSsl)
displayMessage(QString("client %1 Transferrd %2 bytes.").arg(pSockSsl->uuid()).arg(dtw));
else if (pSockTcp)
displayMessage(QString("client %1 Transferrd %2 bytes.").arg(pSockTcp->uuid()).arg(dtw));
}
}
void QTcpClientTest::on_client_connected()
{
QGHTcpClient * pSock = qobject_cast<QGHTcpClient*>(sender());
if (pSock)
QGHSslClient * pSockSsl = qobject_cast<QGHSslClient*>(sender());
QGHTcpClient * pSockTcp = qobject_cast<QGHTcpClient*>(sender());
if (pSockSsl)
{
pSockSsl->geneGlobalUUID(ui.lineEdit_globalFile->text());
if (pSockSsl->uuid()>m_maxUUID)
m_maxUUID = pSockSsl->uuid();
if (pSockSsl->uuid()<m_minUUID)
m_minUUID = pSockSsl->uuid();
displayMessage(QString("client %1 connected.").arg(pSockSsl->uuid()));
QByteArray array(sizeof(EXAMPLE_HEARTBEATING),0);
char * ptr = array.data();
EXAMPLE_HEARTBEATING * pMsg = (EXAMPLE_HEARTBEATING *)ptr;
pMsg->Mark = 0xBEBE;
pMsg->source_id = pSockSsl->uuid();
pMsg->tmStamp = 0;
(pSockSsl)->SendData(array);
}
else if (pSockTcp)
{
displayMessage(QString("client %1 connected.").arg((quintptr)pSock));
pSockTcp->geneGlobalUUID(ui.lineEdit_globalFile->text());
if (pSockTcp->uuid()>m_maxUUID)
m_maxUUID = pSockTcp->uuid();
if (pSockTcp->uuid()<m_minUUID)
m_minUUID = pSockTcp->uuid();
displayMessage(QString("client %1 connected.").arg(pSockTcp->uuid()));
QByteArray array(sizeof(EXAMPLE_HEARTBEATING),0);
char * ptr = array.data();
EXAMPLE_HEARTBEATING * pMsg = (EXAMPLE_HEARTBEATING *)ptr;
pMsg->Mark = 0xBEBE;
pMsg->source_id = pSockTcp->uuid();
pMsg->tmStamp = 0;
(pSock)->SendData(array);
(pSockTcp)->SendData(array);
}
}
void QTcpClientTest::on_client_disconnected()
{
QGHTcpClient * pSock = qobject_cast<QGHTcpClient*>(sender());
if (pSock)
QGHSslClient * pSockSsl = qobject_cast<QGHSslClient*>(sender());
QGHTcpClient * pSockTcp = qobject_cast<QGHTcpClient*>(sender());
if (pSockSsl)
{
displayMessage(QString("client %1 disconnected.").arg(pSockSsl->uuid()));
//disconnect the signal immediately so that the system resource could be freed.
disconnect(pSockSsl, SIGNAL(readyRead()),this, SLOT(new_data_recieved()));
disconnect(pSockSsl, SIGNAL(encrypted()),this, SLOT(on_client_connected()));
disconnect(pSockSsl, SIGNAL(disconnected()),this,SLOT(on_client_disconnected()));
disconnect(pSockSsl, SIGNAL(error(QAbstractSocket::SocketError)),this, SLOT(displayError(QAbstractSocket::SocketError)));
disconnect(pSockSsl, SIGNAL(bytesWritten(qint64)), this, SLOT(on_client_trasferred(qint64)));
m_clients.remove(pSockSsl);
pSockSsl->deleteLater();
}
else if (pSockTcp)
{
displayMessage(QString("client %1 disconnected.").arg((quintptr)pSock));
displayMessage(QString("client %1 disconnected.").arg(pSockTcp->uuid()));
//disconnect the signal immediately so that the system resource could be freed.
disconnect(pSock, SIGNAL(readyRead()),this, SLOT(new_data_recieved()));
disconnect(pSock, SIGNAL(connected()),this, SLOT(on_client_connected()));
disconnect(pSock, SIGNAL(disconnected()),this,SLOT(on_client_disconnected()));
disconnect(pSock, SIGNAL(error(QAbstractSocket::SocketError)),this, SLOT(displayError(QAbstractSocket::SocketError)));
disconnect(pSock, SIGNAL(bytesWritten(qint64)), this, SLOT(on_client_trasferred(qint64)));
m_clients.remove(pSock);
pSock->deleteLater();
disconnect(pSockTcp, SIGNAL(readyRead()),this, SLOT(new_data_recieved()));
disconnect(pSockTcp, SIGNAL(connected()),this, SLOT(on_client_connected()));
disconnect(pSockTcp, SIGNAL(disconnected()),this,SLOT(on_client_disconnected()));
disconnect(pSockTcp, SIGNAL(error(QAbstractSocket::SocketError)),this, SLOT(displayError(QAbstractSocket::SocketError)));
disconnect(pSockTcp, SIGNAL(bytesWritten(qint64)), this, SLOT(on_client_trasferred(qint64)));
m_clients.remove(pSockTcp);
pSockTcp->deleteLater();
}
}
void QTcpClientTest::displayError(QAbstractSocket::SocketError /*err*/)
{
QGHTcpClient * sock = qobject_cast<QGHTcpClient *> (sender());
QTcpSocket * sock = qobject_cast<QTcpSocket *> (sender());
if (sock)
displayMessage(QString("client %1 error msg:").arg((quintptr)sock)+sock->errorString());
{
QGHSslClient * pSockSsl = qobject_cast<QGHSslClient*>(sock);
QGHTcpClient * pSockTcp = qobject_cast<QGHTcpClient*>(sock);
if (pSockSsl)
displayMessage(QString("client %1 error msg:").arg(pSockSsl->uuid())+sock->errorString());
else if (pSockTcp)
displayMessage(QString("client %1 error msg:").arg(pSockTcp->uuid())+sock->errorString());
}
}
void QTcpClientTest::new_data_recieved()
{
......@@ -93,8 +161,16 @@ void QTcpClientTest::new_data_recieved()
if (pSock)
{
QByteArray array =pSock->readAll();
if (array.size() <= sizeof(EXAMPLE_HEARTBEATING))
return;
//in this example, we just do nothing but to display the byte size.
displayMessage(QString("client %1 Recieved %2 bytes.").arg((quintptr)pSock).arg(array.size()));
QGHSslClient * pSockSsl = qobject_cast<QGHSslClient*>(pSock);
QGHTcpClient * pSockTcp = qobject_cast<QGHTcpClient*>(pSock);
if (pSockSsl)
displayMessage(QString("client %1 Recieved %2 bytes.").arg(pSockSsl->uuid()).arg(array.size()));
else if (pSockTcp)
displayMessage(QString("client %1 Recieved %2 bytes.").arg(pSockTcp->uuid()).arg(array.size()));
}
}
......@@ -105,43 +181,65 @@ void QTcpClientTest::timerEvent(QTimerEvent * evt)
{
int nTotalClients = ui.dial->value();
int nPayload = ui.horizontalSlider->value();
QList<QGHTcpClient*> listObj = m_clients.keys();
QList<QTcpSocket*> listObj = m_clients.keys();
nCount++;
if (nCount % 100 == 0)
{
//send heart-beating
foreach(QGHTcpClient * pSock,listObj)
foreach(QTcpSocket * pSock,listObj)
{
quint32 uuid = 0;
QGHSslClient * pSockSsl = qobject_cast<QGHSslClient*>(pSock);
QGHTcpClient * pSockTcp = qobject_cast<QGHTcpClient*>(pSock);
if (pSockSsl)
uuid = pSockSsl->uuid();
else if (pSockTcp)
uuid = pSockTcp->uuid();
else
continue;
QByteArray array(sizeof(EXAMPLE_HEARTBEATING),0);
char * ptr = array.data();
EXAMPLE_HEARTBEATING * pMsg = (EXAMPLE_HEARTBEATING *)ptr;
pMsg->Mark = 0xBEBE;
pMsg->source_id = uuid;
pMsg->tmStamp = 0;
(pSock)->SendData(array);
if (pSockSsl)
pSockSsl->SendData(array);
else if (pSockTcp)
pSockTcp->SendData(array);
}
}
foreach(QGHTcpClient * sock,listObj)
foreach(QTcpSocket * sock,listObj)
{
QGHTcpClient * sockDestin = listObj.at(rand() % listObj.size());
if (rand()%1000<5)
{
quint32 uuid = 0;
QGHSslClient * pSockSsl = qobject_cast<QGHSslClient*>(sock);
QGHTcpClient * pSockTcp = qobject_cast<QGHTcpClient*>(sock);
if (pSockSsl)
uuid = pSockSsl->uuid();
else if (pSockTcp)
uuid = pSockTcp->uuid();
else
continue;
quint16 nMsgLen = qrand()%(32)+nPayload-32-sizeof(EXAMPLE_TRANS_MSG);
QByteArray array(sizeof(EXAMPLE_TRANS_MSG) + nMsgLen - 1,0);
char * ptr = array.data();
EXAMPLE_TRANS_MSG * pMsg = (EXAMPLE_TRANS_MSG *)ptr;
pMsg->Mark = 0x55AA;
pMsg->source_id = (quint32)((quint64)(sock) & 0xffffffff );
pMsg->source_id = uuid;
pMsg->destin_id = (quint32)((quint64)(sockDestin) & 0xffffffff );;
pMsg->destin_id = getRadomUUIDDestin();
pMsg->data_length = nMsgLen;
for (int i=0;i<nMsgLen;i++)
pMsg->data[i] = '0' + i%10;
//3/10 possibility to send a data block to server
sock->SendData(array);
if (pSockSsl)
pSockSsl->SendData(array);
else if (pSockTcp)
pSockTcp->SendData(array);
}
}
//
......@@ -152,27 +250,39 @@ void QTcpClientTest::timerEvent(QTimerEvent * evt)
if (m_clients.size()>nTotalClients)
{
int nDel = m_clients.size()-nTotalClients;
QList<QGHTcpClient*> listObj = m_clients.keys();
QList<QTcpSocket*> listObj = m_clients.keys();
for (int i=0;i<nDel;i++)
{
listObj.at(i)->abort();
}
}
QGHTcpClient * client = new QGHTcpClient(this,ui.horizontalSlider->value());
//client->connectToHost(ui.lineEdit_ip->text(),ui.lineEdit_Port->text().toUShort());
m_clients[client] = QDateTime::currentDateTime();
connect(client, SIGNAL(readyRead()),this, SLOT(new_data_recieved()));
//connect(client, SIGNAL(connected()),this, SLOT(on_client_connected()));
connect(client, SIGNAL(disconnected()),this,SLOT(on_client_disconnected()));
connect(client, SIGNAL(error(QAbstractSocket::SocketError)),this, SLOT(displayError(QAbstractSocket::SocketError)));
connect(client, SIGNAL(bytesWritten(qint64)), this, SLOT(on_client_trasferred(qint64)));
connect(client, SIGNAL(encrypted()), this, SLOT(on_client_connected()));
QString strCerPath = QCoreApplication::applicationDirPath() + "/ca_cert.pem";
QList<QSslCertificate> lstCas = QSslCertificate::fromPath(strCerPath);
client->setCaCertificates(lstCas);
//debug
//client->setPeerVerifyMode(QSslSocket::VerifyNone);
client->connectToHostEncrypted(ui.lineEdit_ip->text(),ui.lineEdit_Port->text().toUShort());
if (ui.checkBox_SSL->isChecked()==true)
{
QGHSslClient * client = new QGHSslClient(this,ui.horizontalSlider->value());
//client->connectToHost(ui.lineEdit_ip->text(),ui.lineEdit_Port->text().toUShort());
m_clients[client] = QDateTime::currentDateTime();
connect(client, SIGNAL(readyRead()),this, SLOT(new_data_recieved()));
//connect(client, SIGNAL(connected()),this, SLOT(on_client_connected()));
connect(client, SIGNAL(disconnected()),this,SLOT(on_client_disconnected()));
connect(client, SIGNAL(error(QAbstractSocket::SocketError)),this, SLOT(displayError(QAbstractSocket::SocketError)));
connect(client, SIGNAL(bytesWritten(qint64)), this, SLOT(on_client_trasferred(qint64)));
connect(client, SIGNAL(encrypted()), this, SLOT(on_client_connected()));
QString strCerPath = QCoreApplication::applicationDirPath() + "/ca_cert.pem";
QList<QSslCertificate> lstCas = QSslCertificate::fromPath(strCerPath);
client->setCaCertificates(lstCas);
client->connectToHostEncrypted(ui.lineEdit_ip->text(),ui.lineEdit_Port->text().toUShort());
}
else
{
QGHTcpClient * client = new QGHTcpClient(this,ui.horizontalSlider->value());
m_clients[client] = QDateTime::currentDateTime();
connect(client, SIGNAL(readyRead()),this, SLOT(new_data_recieved()));
connect(client, SIGNAL(connected()),this, SLOT(on_client_connected()));
connect(client, SIGNAL(disconnected()),this,SLOT(on_client_disconnected()));
connect(client, SIGNAL(error(QAbstractSocket::SocketError)),this, SLOT(displayError(QAbstractSocket::SocketError)));
connect(client, SIGNAL(bytesWritten(qint64)), this, SLOT(on_client_trasferred(qint64)));
client->connectToHost(ui.lineEdit_ip->text(),ui.lineEdit_Port->text().toUShort());
}
}
}
}
......@@ -182,3 +292,18 @@ void QTcpClientTest::displayMessage(const QString &str)
while (model.rowCount()>=256)
model.removeRow(model.rowCount()-1);
}
quint32 QTcpClientTest::getRadomUUIDDestin()
{
int nTotalClients = ui.dial->value();
int nMinID = m_maxUUID - m_minUUID < nTotalClients ? m_minUUID:m_maxUUID - nTotalClients;
int nSpan = (m_maxUUID - nMinID + 1);
int nChoose = rand() % nSpan;
return nMinID + nChoose ;
}
void QTcpClientTest::on_toolButton_brFile_clicked()
{
QString file = QFileDialog::getOpenFileName(this,tr("Open UUID global Syn File"));
if (file.length()>0)
ui.lineEdit_globalFile->setText(file);
}
......@@ -17,13 +17,17 @@ public:
~QTcpClientTest();
virtual void timerEvent(QTimerEvent * evt);
private:
quint32 m_maxUUID;
quint32 m_minUUID;
quint32 getRadomUUIDDestin();
Ui::QTcpClientTestClass ui;
QMap<QGHTcpClient *, QDateTime> m_clients;
QMap<QTcpSocket *, QDateTime> m_clients;
int nTimer;
QStandardItemModel model;
public slots:
void on_horizontalSlider_valueChanged(int);
void on_action_Connect_triggered(bool);
void on_toolButton_brFile_clicked();
void new_data_recieved();
void on_client_trasferred(qint64);
void on_client_connected();
......
......@@ -6,15 +6,15 @@
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<height>400</height>
<width>647</width>
<height>482</height>
</rect>
</property>
<property name="windowTitle">
<string>QTcpClientTest</string>
</property>
<widget class="QWidget" name="centralWidget">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
......@@ -38,8 +38,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<height>23</height>
<width>647</width>
<height>19</height>
</rect>
</property>
<widget class="QMenu" name="menu_File">
......@@ -105,6 +105,34 @@
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="checkBox_SSL">
<property name="text">
<string>SSL(Need Certs)</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Global UUID file</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLineEdit" name="lineEdit_globalFile"/>
</item>
<item>
<widget class="QToolButton" name="toolButton_brFile">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="text">
......@@ -219,7 +247,7 @@
<connections>
<connection>
<sender>actionExit</sender>
<signal>activated()</signal>
<signal>triggered()</signal>
<receiver>QTcpClientTestClass</receiver>
<slot>close()</slot>
<hints>
......
......@@ -20,13 +20,17 @@ namespace ZP_Cluster{
struct tag_CSM_BasicInfo{
__UINT8_TYPE__ name [64];
__UINT8_TYPE__ Address[64];
__UINT16_TYPE__ port;
__UINT8_TYPE__ Address_LAN[64];
__UINT16_TYPE__ port_LAN;
__UINT8_TYPE__ Address_Pub[64];
__UINT16_TYPE__ port_Pub;
} basicInfo; //msgType 0x01
struct tag_CSM_Broadcast{
__UINT8_TYPE__ name [64];
__UINT8_TYPE__ Address[64];
__UINT16_TYPE__ port;
__UINT8_TYPE__ Address_LAN[64];
__UINT16_TYPE__ port_LAN;
__UINT8_TYPE__ Address_Pub[64];
__UINT16_TYPE__ port_Pub;
}broadcastMsg[1];//msgType 0x02
} payload;
......@@ -49,13 +53,17 @@ namespace ZP_Cluster{
} heartBeating;
struct tag_CSM_BasicInfo{
unsigned __int8 name [64];
unsigned __int8 Address[64];
unsigned __int16 port;
unsigned __int8 Address_LAN[64];
unsigned __int16 port_LAN;
unsigned __int8 Address_Pub[64];
unsigned __int16 port_Pub;
} basicInfo;
struct tag_CSM_Broadcast{
unsigned __int8 name [64];
unsigned __int8 Address[64];
unsigned __int16 port;
unsigned __int8 Address_LAN[64];
unsigned __int16 port_LAN;
unsigned __int8 Address_Pub[64];
unsigned __int16 port_Pub;
} broadcastMsg[1];
} payload;
} CROSS_SVR_MSG;
......
......@@ -9,7 +9,7 @@ namespace ZP_Cluster{
{
m_currentReadOffset = 0;
m_currentMessageSize = 0;
m_nPortPublish = 0;
m_nPortLAN = m_nPortPub = 0;
m_last_Report = QDateTime::currentDateTime();
m_nRemoteClientNums = 0;
}
......@@ -26,14 +26,24 @@ namespace ZP_Cluster{
{
return m_strTermName;
}
QHostAddress zp_ClusterNode::addrPublish()
QHostAddress zp_ClusterNode::addrLAN()
{
return m_addrPublish;
return m_addrLAN;
}
int zp_ClusterNode::portPublish()
int zp_ClusterNode::portLAN()
{
return m_nPortPublish;
return m_nPortLAN;
}
QHostAddress zp_ClusterNode::addrPub()
{
return m_addrPub;
}
int zp_ClusterNode::portPub()
{
return m_nPortPub;
}
QObject * zp_ClusterNode::sock()
{
return m_pSock;
......@@ -210,10 +220,11 @@ namespace ZP_Cluster{
}
break;
case 0x01://basicInfo, when connection established, this message should be used
if (m_currentBlock.length()>=64)
emit evt_Message(this,"Debug:" + m_currentBlock.toHex().left(64) + "..." + m_currentBlock.toHex().right(64));
else
emit evt_Message(this,"Debug:" + m_currentBlock.toHex());
// UnComment code below, will generate debug output.
// if (m_currentBlock.length()>=64)
// emit evt_Message(this,"Debug:" + m_currentBlock.toHex().left(64) + "..." + m_currentBlock.toHex().right(64));
// else
// emit evt_Message(this,"Debug:" + m_currentBlock.toHex());
if (bytesLeft==0)
{
......@@ -221,8 +232,10 @@ namespace ZP_Cluster{
if (strName != m_pTerm->name())
{
this->m_strTermName = strName;
m_nPortPublish = pMsg->payload.basicInfo.port;
m_addrPublish = QHostAddress((const char *)pMsg->payload.basicInfo.Address);
m_nPortLAN = pMsg->payload.basicInfo.port_LAN;
m_addrLAN = QHostAddress((const char *)pMsg->payload.basicInfo.Address_LAN);
m_nPortPub = pMsg->payload.basicInfo.port_Pub;
m_addrPub = QHostAddress((const char *)pMsg->payload.basicInfo.Address_Pub);
if (false==m_pTerm->regisitNewServer(this))
{
this->m_strTermName.clear();
......@@ -243,10 +256,11 @@ namespace ZP_Cluster{
}
break;
case 0x02: //Server - broadcast messages
if (m_currentBlock.length()>=64)
emit evt_Message(this,"Debug:" + m_currentBlock.toHex().left(64) + "..." + m_currentBlock.toHex().right(64));
else
emit evt_Message(this,"Debug:" + m_currentBlock.toHex());
// UnComment code below, will generate debug output.
// if (m_currentBlock.length()>=64)
// emit evt_Message(this,"Debug:" + m_currentBlock.toHex().left(64) + "..." + m_currentBlock.toHex().right(64));
// else
// emit evt_Message(this,"Debug:" + m_currentBlock.toHex());
if (bytesLeft==0)
{
......@@ -256,8 +270,8 @@ namespace ZP_Cluster{
QString strName ((const char *)pMsg->payload.broadcastMsg[i].name);
if (strName != m_pTerm->name() && m_pTerm->SvrNodeFromName(strName)==NULL)
{
QHostAddress addrToConnectTo((const char *)pMsg->payload.broadcastMsg[i].Address);
quint16 PortToConnectTo = pMsg->payload.broadcastMsg[i].port;
QHostAddress addrToConnectTo((const char *)pMsg->payload.broadcastMsg[i].Address_LAN);
quint16 PortToConnectTo = pMsg->payload.broadcastMsg[i].port_LAN;
//because cross-connection is not good, we just want the low Addr:port connect to max Addr:Port.
//Connect to New Servers
if (strName > m_pTerm->name())
......@@ -269,10 +283,11 @@ namespace ZP_Cluster{
}
break;
case 0x03:
if (m_currentBlock.length()>=64)
emit evt_Message(this,"Debug:" + m_currentBlock.toHex().left(64) + "..." + m_currentBlock.toHex().right(64));
else
emit evt_Message(this,"Debug:" + m_currentBlock.toHex());
// UnComment code below, will generate debug output.
// if (m_currentBlock.length()>=64)
// emit evt_Message(this,"Debug:" + m_currentBlock.toHex().left(64) + "..." + m_currentBlock.toHex().right(64));
// else
// emit evt_Message(this,"Debug:" + m_currentBlock.toHex());
if (m_currentMessageSize==m_currentBlock.size())
{
......@@ -324,11 +339,17 @@ namespace ZP_Cluster{
strncpy((char *)(pMsg->payload.basicInfo.name),
m_pTerm->name().toStdString().c_str(),
sizeof(pMsg->payload.basicInfo.name)-1);
strncpy((char *)(pMsg->payload.basicInfo.Address),
m_pTerm->publishAddr().toString().toStdString().c_str(),
sizeof(pMsg->payload.basicInfo.Address)-1);
strncpy((char *)(pMsg->payload.basicInfo.Address_LAN),
m_pTerm->LANAddr().toString().toStdString().c_str(),
sizeof(pMsg->payload.basicInfo.Address_LAN)-1);
pMsg->payload.basicInfo.port_LAN = m_pTerm->LANPort();
strncpy((char *)(pMsg->payload.basicInfo.Address_Pub),
m_pTerm->PublishAddr().toString().toStdString().c_str(),
sizeof(pMsg->payload.basicInfo.Address_Pub)-1);
pMsg->payload.basicInfo.port = m_pTerm->publishPort();
pMsg->payload.basicInfo.port_Pub = m_pTerm->PublishPort();
emit evt_SendDataToClient(sock(),array);
......
......@@ -39,8 +39,10 @@ namespace ZP_Cluster{
public:
QString termName();
QHostAddress addrPublish();
int portPublish() ;
QHostAddress addrLAN();
int portLAN() ;
QHostAddress addrPub();
int portPub() ;
QObject * sock() ;
//!Messages
......@@ -53,9 +55,10 @@ namespace ZP_Cluster{
QObject * m_pSock;
//the data members.
QString m_strTermName; //the Terminal's name
QHostAddress m_addrPublish; //The publish address for other terms to connect to
int m_nPortPublish; //The publish port for other terms to connect to
QHostAddress m_addrLAN; //The LAN address for other terms to connect to
int m_nPortLAN; //The LAN port for other terms to connect to
QHostAddress m_addrPub; //The Publish address for clients to connect to
int m_nPortPub; //The Publish port for clients to connect to
//Data Process
//The raw data queue and its mutex
QList<QByteArray> m_list_RawData;
......
......@@ -17,7 +17,7 @@ namespace ZP_Cluster{
connect(m_pClusterNet,&ZPNetwork::zp_net_Engine::evt_ClientDisconnected, this,&zp_ClusterTerm::on_evt_ClientDisconnected,Qt::QueuedConnection);
connect(m_pClusterNet,&ZPNetwork::zp_net_Engine::evt_NewClientConnected, this,&zp_ClusterTerm::on_evt_NewClientConnected,Qt::QueuedConnection);
//connect(m_pClusterNet,&ZPNetwork::zp_net_Engine::evt_ClientEncrypted, this,&zp_ClusterTerm::on_evt_ClientEncrypted);
m_nPortPublish = 0;
m_nPortLAN = m_nPortPub = 0;
m_nHeartBeatingTime = 20;
m_factory = std::bind(&zp_ClusterTerm::default_factory,this,_1,_2,_3);
}
......@@ -64,9 +64,38 @@ namespace ZP_Cluster{
m_factory = fac;
}
int zp_ClusterTerm::publishPort(){
int zp_ClusterTerm::LANPort(){
return m_nPortPublish;
return m_nPortLAN;
}
QHostAddress zp_ClusterTerm::LANAddr()
{
return m_addrLAN;
}
QHostAddress zp_ClusterTerm::setLANAddr(QHostAddress addr)
{
return m_addrLAN = addr;
}
int zp_ClusterTerm::setLANPort(int port)
{
return m_nPortLAN = port;
}
int zp_ClusterTerm::PublishPort(){
return m_nPortPub;
}
QHostAddress zp_ClusterTerm::PublishAddr()
{
return m_addrPub;
}
QHostAddress zp_ClusterTerm::setPublishAddr(QHostAddress addr)
{
return m_addrPub = addr;
}
int zp_ClusterTerm::setPublishPort(int port)
{
return m_nPortPub = port;
}
ZPNetwork::zp_net_Engine * zp_ClusterTerm::netEng()
{
......@@ -84,18 +113,6 @@ namespace ZP_Cluster{
{
return m_strTermName;
}
QHostAddress zp_ClusterTerm::publishAddr()
{
return m_addrPublish;
}
QHostAddress zp_ClusterTerm::setPublishAddr(QHostAddress addr)
{
return m_addrPublish = addr;
}
int zp_ClusterTerm::setPublishPort(int port)
{
return m_nPortPublish = port;
}
int zp_ClusterTerm::heartBeatingThrdHold()
{
return m_nHeartBeatingTime;
......@@ -130,25 +147,46 @@ namespace ZP_Cluster{
m_hash_mutex.unlock();
return lst;
}
QHostAddress zp_ClusterTerm::SvrAddr(const QString & name)
QHostAddress zp_ClusterTerm::SvrLANAddr(const QString & name)
{
QHostAddress addr;
m_hash_mutex.lock();
if (m_hash_Name2node.contains(name))
addr = m_hash_Name2node[name]->addrPublish();
addr = m_hash_Name2node[name]->addrLAN();
m_hash_mutex.unlock();
return addr;
}
int zp_ClusterTerm::SvrPort(const QString & name)
int zp_ClusterTerm::SvrLANPort(const QString & name)
{
int port = 0;
m_hash_mutex.lock();
if (m_hash_Name2node.contains(name))
port = m_hash_Name2node[name]->portPublish();
port = m_hash_Name2node[name]->portLAN();
m_hash_mutex.unlock();
return port;
}
QHostAddress zp_ClusterTerm::SvrPubAddr(const QString & name)
{
QHostAddress addr;
m_hash_mutex.lock();
if (m_hash_Name2node.contains(name))
addr = m_hash_Name2node[name]->addrPub();
m_hash_mutex.unlock();
return addr;
}
int zp_ClusterTerm::SvrPubPort(const QString & name)
{
int port = 0;
m_hash_mutex.lock();
if (m_hash_Name2node.contains(name))
port = m_hash_Name2node[name]->portPub();
m_hash_mutex.unlock();
return port;
}
quint32 zp_ClusterTerm::remoteClientNums(const QString & name)
{
quint32 res = 0;
......@@ -392,20 +430,29 @@ namespace ZP_Cluster{
strncpy((char *)pMsg->payload.broadcastMsg[ct].name,
pNode->termName().toStdString().c_str(),
sizeof(pMsg->payload.broadcastMsg[ct].name)-1);
strncpy((char *)pMsg->payload.broadcastMsg[ct].Address,
pNode->addrPublish().toString().toStdString().c_str(),
sizeof(pMsg->payload.broadcastMsg[ct].Address)-1);
pMsg->payload.broadcastMsg[ct].port = pNode->portPublish();
strncpy((char *)pMsg->payload.broadcastMsg[ct].Address_LAN,
pNode->addrLAN().toString().toStdString().c_str(),
sizeof(pMsg->payload.broadcastMsg[ct].Address_LAN)-1);
pMsg->payload.broadcastMsg[ct].port_LAN = pNode->portLAN();
strncpy((char *)pMsg->payload.broadcastMsg[ct].Address_Pub,
pNode->addrPub().toString().toStdString().c_str(),
sizeof(pMsg->payload.broadcastMsg[ct].Address_Pub)-1);
pMsg->payload.broadcastMsg[ct].port_Pub = pNode->portPub();
++ct;
}
m_hash_mutex.unlock();
strncpy((char *)pMsg->payload.broadcastMsg[ct].name,
this->name().toStdString().c_str(),
sizeof(pMsg->payload.broadcastMsg[ct].name)-1);
strncpy((char *)pMsg->payload.broadcastMsg[ct].Address,
this->publishAddr().toString().toStdString().c_str(),
sizeof(pMsg->payload.broadcastMsg[ct].Address)-1);
pMsg->payload.broadcastMsg[ct].port = this->publishPort();
strncpy((char *)pMsg->payload.broadcastMsg[ct].Address_LAN,
this->LANAddr().toString().toStdString().c_str(),
sizeof(pMsg->payload.broadcastMsg[ct].Address_LAN)-1);
pMsg->payload.broadcastMsg[ct].port_LAN = this->LANPort();
strncpy((char *)pMsg->payload.broadcastMsg[ct].Address_Pub,
this->PublishAddr().toString().toStdString().c_str(),
sizeof(pMsg->payload.broadcastMsg[ct].Address_Pub)-1);
pMsg->payload.broadcastMsg[ct].port_Pub = this->PublishPort();
m_hash_mutex.lock();
QList<QString> sockkeys = m_hash_Name2node.keys();
//Msgs
......@@ -449,4 +496,46 @@ namespace ZP_Cluster{
netEng()->SendDataToClient(m_hash_Name2node[svrName]->sock(),array);
m_hash_mutex.unlock();
}
QString zp_ClusterTerm::minPayloadServer(quint8 bufAddresses[/*64*/],quint16 * pnPort)
{
QString serverName = this->name();
strncpy((char *)bufAddresses
,this->PublishAddr().toString().toStdString().c_str()
,64);
*pnPort = this->PublishPort();
m_hash_mutex.lock();
QList<QString> keys = m_hash_Name2node.keys();
int nsz = keys.size();
if (nsz==0)
{
m_hash_mutex.unlock();
return serverName;
}
//Msgs
int nMinVal = this->m_nClientNums;
zp_ClusterNode * pMinNode = 0;
int ct = 0;
foreach (QString key,keys)
{
zp_ClusterNode * pNode = m_hash_Name2node[key];
if (pNode->clientNums() < nMinVal )
{
nMinVal = pNode->clientNums();
pMinNode = pNode;
}
++ct;
}
if (pMinNode)
{
strncpy((char *)bufAddresses
,pMinNode->addrPub().toString().toStdString().c_str()
,64);
*pnPort = pMinNode->portPub();
serverName = pMinNode->termName();
}
m_hash_mutex.unlock();
return serverName;
}
}
......@@ -37,13 +37,43 @@ namespace ZP_Cluster{
ZPTaskEngine::zp_pipeline * taskEng();
bool canExit();
//Server Group Mapping
public:
zp_ClusterNode * SvrNodeFromName(const QString &);
zp_ClusterNode * SvrNodeFromSocket(QObject *);
QStringList SvrNames();
quint32 remoteClientNums(const QString & name);
QHostAddress SvrLANAddr(const QString & name);
int SvrLANPort(const QString & name);
QHostAddress SvrPubAddr(const QString & name);
int SvrPubPort(const QString & name);
//Client Num set, for cross-svr balance
void setClientNums(quint32 nnum);
quint32 clientNums();
//Propties
public:
//properties.
QString setName(const QString & s);
QString name();
QHostAddress publishAddr();
int publishPort();
//LAN Address, for other servers
QHostAddress LANAddr();
int LANPort();
QHostAddress setLANAddr(QHostAddress addr);
int setLANPort(int port);
//Publish Address, for clients.
QHostAddress PublishAddr();
int PublishPort();
QHostAddress setPublishAddr(QHostAddress addr);
int setPublishPort(int port);
//Re-Direct Test.
QString minPayloadServer(quint8 bufAddresses[/*64*/],quint16 * pnPort);
int heartBeatingThrdHold() ;
void setHeartBeatingThrd(const int n);
bool regisitNewServer(zp_ClusterNode *);
......@@ -63,8 +93,10 @@ namespace ZP_Cluster{
int m_nHeartBeatingTime;
quint32 m_nClientNums; //the clients this server now connected.
QString m_strTermName;//the Terminal's name
QHostAddress m_addrPublish; //The publish address for other terms to connect to
int m_nPortPublish;//The publish port for other terms to connect to
QHostAddress m_addrLAN; //The LAN address for other server-terms to connect to
int m_nPortLAN;//The LAN port for other server-terms to connect to
QHostAddress m_addrPub; //The Publish address for clients to connect to
int m_nPortPub;//The Publish port for clients to connect to
ZPNetwork::zp_net_Engine * m_pClusterNet;
ZPTaskEngine::zp_pipeline * m_pClusterEng;
//This list hold dead nodes that still in task queue,avoiding crash
......@@ -73,18 +105,6 @@ namespace ZP_Cluster{
QMutex m_hash_mutex;
QMap<QString , zp_ClusterNode *> m_hash_Name2node;
QMap<QObject *,zp_ClusterNode *> m_hash_sock2node;
//Server Group Mapping
public:
zp_ClusterNode * SvrNodeFromName(const QString &);
zp_ClusterNode * SvrNodeFromSocket(QObject *);
QStringList SvrNames();
QHostAddress SvrAddr(const QString & name);
int SvrPort(const QString & name);
quint32 remoteClientNums(const QString & name);
//Client Num set, for cross-svr balance
void setClientNums(quint32 nnum);
quint32 clientNums();
signals:
void evt_Message(QObject * ,const QString &);
......
......@@ -6,6 +6,14 @@
#include <QCoreApplication>
#include <QHostAddress>
#include "zp_net_threadpool.h"
#include <QMutex>
//Trans st
QMutex g_mutex_sta;
quint64 g_bytesRecieved = 0;
quint64 g_bytesSent = 0;
quint64 g_secRecieved = 0;
quint64 g_secSent = 0;
namespace ZPNetwork{
zp_netTransThread::zp_netTransThread(zp_net_Engine *pThreadPool,int nPayLoad,QObject *parent) :
QObject(parent)
......@@ -237,7 +245,15 @@ namespace ZPNetwork{
{
QTcpSocket * pSock = qobject_cast<QTcpSocket*>(sender());
if (pSock)
emit evt_Data_recieved(pSock,pSock->readAll());
{
QByteArray array = pSock->readAll();
int sz = array.size();
g_mutex_sta.lock();
g_bytesRecieved +=sz;
g_secRecieved += sz;
g_mutex_sta.unlock();
emit evt_Data_recieved(pSock,array);
}
}
/**
* @brief this slot will be called when internal socket successfully
......@@ -248,6 +264,10 @@ namespace ZPNetwork{
*/
void zp_netTransThread::some_data_sended(qint64 wsended)
{
g_mutex_sta.lock();
g_bytesSent +=wsended;
g_secSent += wsended;
g_mutex_sta.unlock();
QTcpSocket * pSock = qobject_cast<QTcpSocket*>(sender());
if (pSock)
{
......
......@@ -18,7 +18,9 @@ namespace ExampleServer{
,m_pTaskEngine(taskeng)
,m_pDatabaseRes(pDb)
,m_pCluster(pCluster)
,m_nBalanceMax(1024)
{
m_nHeartBeatingDeadThrd = 180;
connect (m_pThreadEngine,&ZPNetwork::zp_net_Engine::evt_NewClientConnected,this,&st_client_table::on_evt_NewClientConnected,Qt::QueuedConnection);
connect (m_pThreadEngine,&ZPNetwork::zp_net_Engine::evt_ClientEncrypted,this,&st_client_table::on_evt_ClientEncrypted,Qt::QueuedConnection);
......@@ -36,6 +38,16 @@ namespace ExampleServer{
_1,_2,_3)
);
}
void st_client_table::setBalanceMax(int nmax)
{
m_nBalanceMax = nmax;
}
int st_client_table::balanceMax()
{
return m_nBalanceMax;
}
int st_client_table::heartBeatingThrd()
{
......@@ -332,7 +344,7 @@ namespace ExampleServer{
}
}
m_hash_mutex.unlock();
emit evt_Message(this,tr("Recieved remote user-data to uuid:%1,DATA:%2").arg(uuid).arg(QString("HEX")+QString(msg.toHex())));
//emit evt_Message(this,tr("Recieved remote user-data to uuid:%1,DATA:%2").arg(uuid).arg(QString("HEX")+QString(msg.toHex())));
return bres;
}
......@@ -424,5 +436,16 @@ namespace ExampleServer{
m_mutex_cross_svr_map.unlock();
return svr;
}
bool st_client_table::NeedRedirect(quint8 bufAddresses[/*64*/],quint16 * pnPort)
{
if (m_pCluster->clientNums()<m_nBalanceMax)
return false;
QString strServerName = m_pCluster->minPayloadServer(bufAddresses,pnPort);
if (strServerName==m_pCluster->name())
return false;
return true;
}
}
......@@ -56,6 +56,12 @@ namespace ExampleServer{
//Server Name find
QString cross_svr_find_uuid(quint32 uuid);
//Cluster Global Balance
bool NeedRedirect(quint8 bufAddresses[/*64*/],quint16 * pnPort);
void setBalanceMax(int nmax);
int balanceMax();
protected:
//This list hold dead nodes that still in task queue,avoiding crash
QList<st_clientNode_baseTrans *> m_nodeToBeDel;
......@@ -81,6 +87,9 @@ namespace ExampleServer{
QString m_strDBName_event;
QString m_largeFileFolder;
//Cluster max balance value, when clients exceeds this val, balance will happen.
int m_nBalanceMax;
//cluster Nodes Map
std::unordered_map<quint32,QString> m_hash_remoteClient2SvrName;
QMutex m_mutex_cross_svr_map;
......
......@@ -41,7 +41,7 @@ namespace ExampleServer{
pMsg->data_length = nMsgLen;
pApp->header.MsgType = 0x3800;
pApp->header.MsgType = 0x7FFE;
stMsg_ClientLoginRsp & reply = pApp->MsgUnion.msg_ClientLoginRsp;
......@@ -80,6 +80,11 @@ namespace ExampleServer{
{
reply.DoneCode = 3;
}
//Cluster-Balance.
if (m_pClientTable->NeedRedirect(reply.Address_Redirect,&reply.port_Redirect))
{
reply.DoneCode = 1;
}
}
// else
// strcpy(reply.TextInfo,"UserID Is Invalid.Accunt locked by svr");
......@@ -111,7 +116,7 @@ namespace ExampleServer{
return reply.DoneCode==0?true:false;
return reply.DoneCode==3?false:true;
}
bool st_clientNodeAppLayer::Box2Svr_UploadUserTable()
{
......@@ -146,7 +151,7 @@ namespace ExampleServer{
pMsg->data_length = nMsgLen;
pApp->header.MsgType = 0x1803;
pApp->header.MsgType = 0x7FFC;
stMsg_UploadUserListRsp & reply = pApp->MsgUnion.msg_UploadUserListRsp;
......@@ -209,7 +214,7 @@ namespace ExampleServer{
pMsg->data_length = nMsgLen;
pApp->header.MsgType = 0x1804;
pApp->header.MsgType = 0x7FFB;
stMsg_DownloadUserListRsp & reply = pApp->MsgUnion.msg_DownloadUserListRsp;
......@@ -257,7 +262,7 @@ namespace ExampleServer{
pMsg->data_length = nMsgLen;
pApp->header.MsgType = 0x3801;
pApp->header.MsgType = 0x7FFD;
stMsg_ClientLogoutRsp & reply = pApp->MsgUnion.msg_ClientLogoutRsp;
......
......@@ -94,11 +94,11 @@ namespace ExampleServer{
int st_clientNodeAppLayer::deal_current_message_block()
{
//then , Start deal to-server messages
//Server - deal messages
if (m_currentBlock.length()>=64)
emit evt_Message(this,"Debug:" + m_currentBlock.toHex().left(64) + "..." + m_currentBlock.toHex().right(64));
else
emit evt_Message(this,"Debug:" + m_currentBlock.toHex());
//Uncomment these codes to enable debug msg dump.
// if (m_currentBlock.length()>=64)
// emit evt_Message(this,"Debug:" + m_currentBlock.toHex().left(64) + "..." + m_currentBlock.toHex().right(64));
// else
// emit evt_Message(this,"Debug:" + m_currentBlock.toHex());
if (m_currentHeader.destin_id==0x00000001)
{
if (this->m_bLoggedIn==false || this->m_bUUIDRecieved==false)
......@@ -188,7 +188,7 @@ namespace ExampleServer{
//qDebug()<<m_current_app_header.header.MsgType<<"\n";
switch (m_current_app_header.header.MsgType)
{
case 0x3000:
case 0x0001:
if (bytesLeft()>0)
// message is not complete, return
return true;
......@@ -267,7 +267,7 @@ namespace ExampleServer{
else
res = this->Box2Svr_DownloadUserTable();
break;
case 0x3001:
case 0x1002:
if (bytesLeft()>0)
// message is not complete, return
return true;
......
......@@ -22,15 +22,15 @@ namespace ExampleServer{
int deal_current_message_block();
//!Message Dealers, imp in st_clientnode_msgdeal.cpp
bool Deal_ToServer_Handshakes();
//0x3000<->0x3800 msg, stMsg_ClientLoginReq
//0x0001<->0x7FFE msg, stMsg_ClientLoginReq
bool LoginClient();
//!Deal node2Svr Msgs
bool Deal_Node2Svr_Msgs();
//0x1003 - 0x1803
//0x1003 - 0x7FFC
bool Box2Svr_UploadUserTable();
//0x1004 - 0x1804
//0x1004 - 0x7FFB
bool Box2Svr_DownloadUserTable();
//0x3001 - 0x3801
//0x1002 - 0x7FFD
bool ClientLogout();
//data items
protected:
......
......@@ -137,6 +137,19 @@ namespace ExampleServer{
continue;
//Send back
emit evt_SendDataToClient(this->sock(),m_currentBlock);
//Try to Get UUID Immediately
if (m_bUUIDRecieved==false)
{
EXAMPLE_HEARTBEATING * pHbMsg = (EXAMPLE_HEARTBEATING *)(ptrCurrData);
if (bIsValidUserId(pHbMsg->source_id))
{
m_bUUIDRecieved = true;
m_uuid = pHbMsg->source_id;
//regisit client node to hash-table;
m_pClientTable->regisitClientUUID(this);
}
}
//This Message is Over. Start a new one.
m_currentMessageSize = 0;
m_currentBlock = QByteArray();
......@@ -243,12 +256,21 @@ namespace ExampleServer{
if (!( bIsValidUserId(m_currentHeader.source_id)
||
(m_currentHeader.source_id==0xffffffff)
))
)
)
{
emit evt_Message(this,tr("Client ID is invalid! Close client immediatly."));
m_currentBlock = QByteArray();
emit evt_close_client(this->sock());
}
if (bIsValidUserId(m_currentHeader.source_id)==true &&
m_uuid != m_currentHeader.source_id)
{
emit evt_Message(this,tr("Client ID Changed in Runtime! Close client immediatly."));
m_currentBlock = QByteArray();
emit evt_close_client(this->sock());
}
}
......
......@@ -21,6 +21,7 @@ namespace ExampleServer{
typedef struct tag_example_heartBeating
{
__UINT16_TYPE__ Mark; //Always be 0xBeBe
__UINT32_TYPE__ source_id ; //0xffffffff means from server
__UINT16_TYPE__ tmStamp;
} EXAMPLE_HEARTBEATING;
#endif
......@@ -36,6 +37,7 @@ namespace ExampleServer{
typedef struct tag_example_heartBeating
{
unsigned __int16 Mark; //Always be 0xBeBe
unsigned __int32 source_id ; //0xffffffff means from server
unsigned __int16 tmStamp;
} EXAMPLE_HEARTBEATING;
#endif
......
......@@ -9,19 +9,31 @@ namespace ExampleServer{
#include <stdint.h>
//User Login request
//SMARTLINK_MSG_APP::MsgType = 0x3000
//SMARTLINK_MSG_APP::MsgType = 0x0001
typedef struct tag_stMsg_ClientLoginReq{
__UINT32_TYPE__ user_id;
char Passwd[1];
}stMsg_ClientLoginReq;
//User Log response
//SMARTLINK_MSG_APP::MsgType = 0x3800
//SMARTLINK_MSG_APP::MsgType = 0x7FFE
typedef struct tag_stMsg_ClientLoginRsp{
__UINT8_TYPE__ DoneCode;
__UINT32_TYPE__ UserID;
__UINT8_TYPE__ Address_Redirect[64];// for server-cluster balance, may be this login should be re-direct to another address
__UINT16_TYPE__ port_Redirect; // and a port num.
} stMsg_ClientLoginRsp;
//0x1002
typedef struct tag_stMsg_ClientLogoutReq{
char UserName[1];//max 32
}stMsg_ClientLogoutReq;
//0x7FFD
typedef struct tag_stMsg_ClientLogoutRsp{
__UINT8_TYPE__ DoneCode;
}stMsg_ClientLogoutRsp;
//UploadUserListReq,0x1003
typedef struct tag_stMsg_UploadUserListReq{
......@@ -30,7 +42,7 @@ namespace ExampleServer{
}stMsg_UploadUserListReq;
//User Log response
//SMARTLINK_MSG_APP::MsgType = 0x1803
//SMARTLINK_MSG_APP::MsgType = 0x7FFC
typedef struct tag_stMsg_UploadUserListRsp{
__UINT8_TYPE__ DoneCode;
} stMsg_UploadUserListRsp;
......@@ -40,7 +52,7 @@ namespace ExampleServer{
} stMsg_DownloadUserListReq;
//SMARTLINK_MSG_APP::MsgType = 0x1804
//SMARTLINK_MSG_APP::MsgType = 0x7FFB
typedef struct tag_stMsg_DownloadUserListRsp{
__UINT8_TYPE__ DoneCode;
__UINT16_TYPE__ UserNum;
......@@ -48,15 +60,7 @@ namespace ExampleServer{
} stMsg_DownloadUserListRsp;
//0x3001
typedef struct tag_stMsg_ClientLogoutReq{
char UserName[1];//max 32
}stMsg_ClientLogoutReq;
//0x3801
typedef struct tag_stMsg_ClientLogoutRsp{
__UINT8_TYPE__ DoneCode;
}stMsg_ClientLogoutRsp;
typedef struct tag_example_app_layer{
struct tag_app_layer_header{
......@@ -80,19 +84,30 @@ namespace ExampleServer{
#if defined(_MSC_VER)
//User Login request
//SMARTLINK_MSG_APP::MsgType = 0x3000
//SMARTLINK_MSG_APP::MsgType = 0x0001
typedef struct tag_stMsg_ClientLoginReq{
unsigned __int32 user_id;
char Passwd[1];
}stMsg_ClientLoginReq;
//User Log response
//SMARTLINK_MSG_APP::MsgType = 0x3800
//SMARTLINK_MSG_APP::MsgType = 0x7FFE
typedef struct tag_stMsg_ClientLoginRsp{
unsigned __int8 DoneCode;
unsigned __int8 DoneCode; //0- successful, 1-redirect, 3-failed.
unsigned __int32 UserID;
unsigned __int8 Address_Redirect[64];// for server-cluster balance, may be this login should be re-direct to another address
unsigned __int16 port_Redirect; // and a port num.
} stMsg_ClientLoginRsp;
//0x1002
typedef struct tag_stMsg_ClientLogoutReq{
char UserName[1];//max 32
}stMsg_ClientLogoutReq;
//0x7FFD
typedef struct tag_stMsg_ClientLogoutRsp{
unsigned __int8 DoneCode;
}stMsg_ClientLogoutRsp;
//UploadUserListReq,0x1003
typedef struct tag_stMsg_UploadUserListReq{
......@@ -101,7 +116,7 @@ namespace ExampleServer{
}stMsg_UploadUserListReq;
//User Log response
//SMARTLINK_MSG_APP::MsgType = 0x1803
//SMARTLINK_MSG_APP::MsgType = 0x7FFC
typedef struct tag_stMsg_UploadUserListRsp{
unsigned __int8 DoneCode;
//char TextInfo[64];
......@@ -113,22 +128,13 @@ namespace ExampleServer{
} stMsg_DownloadUserListReq;
//SMARTLINK_MSG_APP::MsgType = 0x1804
//SMARTLINK_MSG_APP::MsgType = 0x7FFB
typedef struct tag_stMsg_DownloadUserListRsp{
unsigned __int8 DoneCode;
unsigned __int16 UserNum;
unsigned __int32 pUserIDList[1];
} stMsg_DownloadUserListRsp;
//0x3001
typedef struct tag_stMsg_ClientLogoutReq{
char UserName[1];//max 32
}stMsg_ClientLogoutReq;
//0x3801
typedef struct tag_stMsg_ClientLogoutRsp{
unsigned __int8 DoneCode;
}stMsg_ClientLogoutRsp;
typedef struct tag_example_app_layer{
......
......@@ -14,9 +14,16 @@
using namespace ZPNetwork;
using namespace ZPTaskEngine;
using namespace ZP_Cluster;
ZPMainFrame::ZPMainFrame(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::ZPMainFrame)
extern quint64 g_bytesRecieved;
extern quint64 g_bytesSent;
extern quint64 g_secRecieved;
extern quint64 g_secSent;
ZPMainFrame::ZPMainFrame(QWidget *parent)
:QMainWindow(parent)
,ui(new Ui::ZPMainFrame)
{
m_currentConffile = QCoreApplication::applicationFilePath()+".ini";
ui->setupUi(this);
......@@ -142,12 +149,16 @@ void ZPMainFrame::initUI()
ui->comboBox_db_type->setModel(pCombo);
m_pModelCluster= new QStandardItemModel(0,4,this);
m_pModelCluster= new QStandardItemModel(0,6,this);
m_pModelCluster->setHeaderData(0,Qt::Horizontal,tr("Name"));
m_pModelCluster->setHeaderData(1,Qt::Horizontal,tr("Address"));
m_pModelCluster->setHeaderData(2,Qt::Horizontal,tr("Port"));
m_pModelCluster->setHeaderData(1,Qt::Horizontal,tr("LAN_Address"));
m_pModelCluster->setHeaderData(2,Qt::Horizontal,tr("LAN_Port"));
m_pModelCluster->setHeaderData(3,Qt::Horizontal,tr("Clients"));
m_pModelCluster->setHeaderData(4,Qt::Horizontal,tr("Pub_Address"));
m_pModelCluster->setHeaderData(5,Qt::Horizontal,tr("Pub_Port"));
ui->tableView_activeTerms->setModel(m_pModelCluster);
m_pStatusLabel = new QLabel(this);
this->statusBar()->addWidget(m_pStatusLabel);
}
void ZPMainFrame::on_evt_MessageNetwork(QObject * psource,const QString & strMsg)
......@@ -267,12 +278,17 @@ void ZPMainFrame::timerEvent(QTimerEvent * e)
}
//Cluster----------------------------
str_msg += tr("Cluster Group Paras:\n");
str_msg += tr("\tTerminal %1 : %2, published Address: %3:%4\n")
str_msg += tr("Cluster Paras:\n");
str_msg += tr("\tTerminal %1 : %2\n\t\tLAN Address: %3:%4\n\t\t Publish: %5:%6\n\t\tbalance max clients=%7\n")
.arg(m_pClusterTerm->name())
.arg(!m_pClusterTerm->netEng()->ListenerNames().empty())
.arg(m_pClusterTerm->publishAddr().toString())
.arg(m_pClusterTerm->publishPort());
.arg(m_pClusterTerm->LANAddr().toString())
.arg(m_pClusterTerm->LANPort())
.arg(m_pClusterTerm->PublishAddr().toString())
.arg(m_pClusterTerm->PublishPort())
.arg(m_clientTable->balanceMax())
;
nClientThreads = m_pClusterTerm->netEng()->TransThreadNum();
str_msg += "\t"+tr("Trans Threads: %1\n").arg(nClientThreads);
for (int i=0;i<nClientThreads;i++)
......@@ -302,19 +318,33 @@ void ZPMainFrame::timerEvent(QTimerEvent * e)
int nInserted = 0;
m_pModelCluster->insertRow(nInserted);
m_pModelCluster->setData(m_pModelCluster->index(nInserted,0),this->m_pClusterTerm->name());
m_pModelCluster->setData(m_pModelCluster->index(nInserted,1),m_pClusterTerm->publishAddr().toString());
m_pModelCluster->setData(m_pModelCluster->index(nInserted,2),m_pClusterTerm->publishPort());
m_pModelCluster->setData(m_pModelCluster->index(nInserted,1),m_pClusterTerm->LANAddr().toString());
m_pModelCluster->setData(m_pModelCluster->index(nInserted,2),m_pClusterTerm->LANPort());
m_pModelCluster->setData(m_pModelCluster->index(nInserted,3),m_pClusterTerm->clientNums());
m_pModelCluster->setData(m_pModelCluster->index(nInserted,4),m_pClusterTerm->PublishAddr().toString());
m_pModelCluster->setData(m_pModelCluster->index(nInserted,5),m_pClusterTerm->PublishPort());
++nInserted;
foreach (QString strNodeName,lstCluster)
{
m_pModelCluster->insertRow(nInserted);
m_pModelCluster->setData(m_pModelCluster->index(nInserted,0),strNodeName);
m_pModelCluster->setData(m_pModelCluster->index(nInserted,1),m_pClusterTerm->SvrAddr(strNodeName).toString());
m_pModelCluster->setData(m_pModelCluster->index(nInserted,2),m_pClusterTerm->SvrPort(strNodeName));
m_pModelCluster->setData(m_pModelCluster->index(nInserted,1),m_pClusterTerm->SvrLANAddr(strNodeName).toString());
m_pModelCluster->setData(m_pModelCluster->index(nInserted,2),m_pClusterTerm->SvrLANPort(strNodeName));
m_pModelCluster->setData(m_pModelCluster->index(nInserted,3),m_pClusterTerm->remoteClientNums(strNodeName));
m_pModelCluster->setData(m_pModelCluster->index(nInserted,4),m_pClusterTerm->SvrPubAddr(strNodeName).toString());
m_pModelCluster->setData(m_pModelCluster->index(nInserted,5),m_pClusterTerm->SvrPubPort(strNodeName));
++nInserted;
}
QString str = QDateTime::currentDateTime().toString();
str += tr(" Rec %1B(%3 kbps) Sent %2B(%4 kbps)")
.arg(g_bytesRecieved)
.arg(g_bytesSent)
.arg(g_secRecieved*8/1024/2)
.arg(g_secSent*8/1024/2)
;
g_secRecieved = g_secSent = 0;
m_pStatusLabel->setText(str);
}
else if (e->timerId()==m_nTimerCheck)
{
......@@ -325,7 +355,6 @@ void ZPMainFrame::timerEvent(QTimerEvent * e)
m_pClusterTerm->KickDeadClients();
m_nTimerCheck = startTimer(5000);
}
}
void ZPMainFrame::on_action_Start_Stop_triggered(bool setordel)
{
......@@ -451,11 +480,14 @@ void ZPMainFrame::forkServer(const QString & config_file)
QString strSL_LargetFolder = settings.value("Smartlink/SL_LargetFolder","NUL").toString();
m_clientTable->setLargeFileFolder(strSL_LargetFolder);
int nmaxBalance = settings.value("Smartlink/nmaxBalance","1024").toInt();
m_clientTable->setBalanceMax(nmaxBalance);
//clusters
QString strClusterTermAddr = settings.value("Cluster/strClusterTermAddr","0.0.0.0").toString();
QString strClusterTermPort = settings.value("Cluster/strClusterTermPort","25600").toString();
QString strClusterPubName = settings.value("Cluster/strClusterPubName","Term 001").toString();
QString strClusterLANAddr = settings.value("Cluster/strClusterLANAddr","127.0.0.1").toString();
QString strClusterLANPort = settings.value("Cluster/strClusterLANPort","25600").toString();
QString strClusterPubAddr = settings.value("Cluster/strClusterPubAddr","192.168.1.111").toString();
QString strClusterPubPort = settings.value("Cluster/strClusterPubPort","25600").toString();
int nClusterTransThreads = settings.value("Cluster/nClusterTransThreads","4").toInt();
......@@ -471,6 +503,8 @@ void ZPMainFrame::forkServer(const QString & config_file)
this->m_pClusterTerm->netEng()->AddClientTransThreads(nClusterTransThreads,false);
this->m_pClusterTerm->taskEng()->addThreads(nClusterWorkingThreads);
this->m_pClusterTerm->setName(strClusterPubName);
this->m_pClusterTerm->setLANAddr(QHostAddress(strClusterLANAddr));
this->m_pClusterTerm->setLANPort(strClusterLANPort.toInt());
this->m_pClusterTerm->setPublishAddr(QHostAddress(strClusterPubAddr));
this->m_pClusterTerm->setPublishPort(strClusterPubPort.toInt());
this->m_pClusterTerm->StartListen(QHostAddress(strClusterTermAddr),strClusterTermPort.toInt());
......@@ -577,8 +611,8 @@ void ZPMainFrame::LoadSettings(const QString & config_file)
QString strSLDB_mainEvent = settings.value("Smartlink/SLDB_mainEvt","EMPTY").toString();
ui->lineEdit_SL_DB_ME->setText(strSLDB_mainEvent);
QString strSL_LargetFolder = settings.value("Smartlink/SL_LargetFolder","NUL").toString();
ui->lineEdit_SL_LargetFolder->setText(strSL_LargetFolder);
int nmaxBalance = settings.value("Smartlink/nmaxBalance","1024").toInt();
ui->spinBox_cluster_max_payload->setValue(nmaxBalance);
//Cluster
QString strClusterTermAddr = settings.value("Cluster/strClusterTermAddr","0.0.0.0").toString();
......@@ -587,10 +621,17 @@ void ZPMainFrame::LoadSettings(const QString & config_file)
ui->lineEdit_cluster_term_port->setText(strClusterTermPort);
QString strClusterPubName = settings.value("Cluster/strClusterPubName","Term 001").toString();
ui->lineEdit_cluster_pub_name->setText(strClusterPubName);
QString strClusterLANAddr = settings.value("Cluster/strClusterLANAddr","127.0.0.1").toString();
ui->lineEdit_cluster_LAN_Addr->setText(strClusterLANAddr);
QString strClusterLANPort = settings.value("Cluster/strClusterLANPort","25600").toString();
ui->lineEdit_cluster_LAN_Port->setText(strClusterLANPort);
QString strClusterPubAddr = settings.value("Cluster/strClusterPubAddr","192.168.1.111").toString();
ui->lineEdit_cluster_pub_Addr->setText(strClusterPubAddr);
QString strClusterPubPort = settings.value("Cluster/strClusterPubPort","25600").toString();
ui->lineEdit_cluster_pub_Port->setText(strClusterPubPort);
int nClusterTransThreads = settings.value("Cluster/nClusterTransThreads","4").toInt();
ui->horizontalSlider_cluster_transThreads->setValue(nClusterTransThreads);
int nClusterWorkingThreads = settings.value("Cluster/nClusterWorkingThreads","4").toInt();
......@@ -665,13 +706,16 @@ void ZPMainFrame::SaveSettings(const QString & config_file)
settings.setValue("Smartlink/SLDB_useracc",strSLDB_useracc);
QString strSLDB_mainEvent = ui->lineEdit_SL_DB_ME->text();
settings.setValue("Smartlink/SLDB_mainEvt",strSLDB_mainEvent);
QString strSL_LargetFolder = ui->lineEdit_SL_LargetFolder->text();
settings.setValue("Smartlink/SL_LargetFolder",strSL_LargetFolder);
int nmaxBalance = ui->spinBox_cluster_max_payload->value();
settings.setValue("Smartlink/nmaxBalance",nmaxBalance);
//Cluster
settings.setValue("Cluster/strClusterTermAddr",ui->lineEdit_cluster_term_addr->text());
settings.setValue("Cluster/strClusterTermPort",ui->lineEdit_cluster_term_port->text());
settings.setValue("Cluster/strClusterPubName", ui->lineEdit_cluster_pub_name->text());
settings.setValue("Cluster/strClusterLANAddr",ui->lineEdit_cluster_LAN_Addr->text());
settings.setValue("Cluster/strClusterLANPort",ui->lineEdit_cluster_LAN_Port->text());
settings.setValue("Cluster/strClusterPubAddr",ui->lineEdit_cluster_pub_Addr->text());
settings.setValue("Cluster/strClusterPubPort",ui->lineEdit_cluster_pub_Port->text());
settings.setValue("Cluster/nClusterTransThreads",ui->horizontalSlider_cluster_transThreads->value());
......
......@@ -3,6 +3,7 @@
#include <QMainWindow>
#include <QStandardItemModel>
#include <QLabel>
#include <QSet>
#include <QMap>
#include "network/zp_net_threadpool.h"
......@@ -47,6 +48,7 @@ protected:
private:
Ui::ZPMainFrame *ui;
QLabel * m_pStatusLabel;
ZPNetwork::zp_net_Engine * m_netEngine;
ZPTaskEngine::zp_pipeline * m_taskEngine;
ExampleServer::st_client_table * m_clientTable;
......
......@@ -525,6 +525,16 @@
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_12">
<item>
<widget class="QLabel" name="label_23">
<property name="text">
<string>Publish Name</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_cluster_pub_name"/>
</item>
<item>
<widget class="QLabel" name="label_20">
<property name="text">
......@@ -545,6 +555,19 @@
<item>
<widget class="QLineEdit" name="lineEdit_cluster_term_port"/>
</item>
<item>
<spacer name="horizontalSpacer_10">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
......@@ -637,22 +660,22 @@
<item>
<widget class="QLabel" name="label_21">
<property name="text">
<string>Publish Address</string>
<string>LAN Address</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_cluster_pub_Addr"/>
<widget class="QLineEdit" name="lineEdit_cluster_LAN_Addr"/>
</item>
<item>
<widget class="QLabel" name="label_22">
<property name="text">
<string>Publish Port</string>
<string>LAN Port</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_cluster_pub_Port"/>
<widget class="QLineEdit" name="lineEdit_cluster_LAN_Port"/>
</item>
<item>
<spacer name="horizontalSpacer_7">
......@@ -667,19 +690,36 @@
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_cluster_apply">
<property name="text">
<string>&amp;Save</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_17">
<item>
<widget class="QLabel" name="label_23">
<widget class="QLabel" name="label_27">
<property name="text">
<string>Publish Name</string>
<string>Publish Address</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_cluster_pub_name"/>
<widget class="QLineEdit" name="lineEdit_cluster_pub_Addr"/>
</item>
<item>
<widget class="QLabel" name="label_26">
<property name="text">
<string>Publish Port</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_cluster_pub_Port"/>
</item>
<item>
<spacer name="horizontalSpacer_9">
......@@ -694,13 +734,6 @@
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_cluster_apply">
<property name="text">
<string>&amp;Save</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_join">
<property name="text">
......@@ -718,7 +751,7 @@
<normaloff>:/icons/Resources/Alienware (27).png</normaloff>:/icons/Resources/Alienware (27).png</iconset>
</attribute>
<attribute name="title">
<string>Smartlink</string>
<string>Example Server</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
......@@ -800,19 +833,32 @@
<item>
<widget class="QLabel" name="label_18">
<property name="text">
<string>Large data root folder</string>
<string>Cluster balance max payload</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_SL_LargetFolder"/>
<widget class="QSpinBox" name="spinBox_cluster_max_payload">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>16384</number>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton_SL_BR_LargeFolder">
<property name="text">
<string>...</string>
<spacer name="horizontalSpacer_11">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
......@@ -949,7 +995,7 @@
<x>0</x>
<y>0</y>
<width>640</width>
<height>21</height>
<height>19</height>
</rect>
</property>
<widget class="QMenu" name="menu_Control">
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册