Merge branch '1.2.4'
commit
7dffc83838
|
@ -39,11 +39,11 @@ typedef long (*FUNCEXEC)(SATvm *pstSavm, void *arg);
|
|||
#define MAX_CON_EVENTS 65535
|
||||
#define TVM_PORT_LISTEN 1801
|
||||
#define TVM_PORT_DOMAIN 1800
|
||||
#define MAX_LOCK_TIME 600
|
||||
#define TVM_LOCAL_SERV "LIS.tvm"
|
||||
#define TVM_REMOTE_DOM "RDS.tvm"
|
||||
#define LOCAL_HOST_IP "127.0.0.1"
|
||||
|
||||
|
||||
/*************************************************************************************************
|
||||
表结构&索引定义区
|
||||
*************************************************************************************************/
|
||||
|
@ -77,6 +77,7 @@ typedef struct __TVM_INTERFACE
|
|||
/*************************************************************************************************
|
||||
macro
|
||||
*************************************************************************************************/
|
||||
#define Tlog(...) vTraceLog(__FILE__, __LINE__, __VA_ARGS__)
|
||||
|
||||
/*************************************************************************************************
|
||||
function
|
||||
|
@ -84,6 +85,7 @@ typedef struct __TVM_INTERFACE
|
|||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
extern void vTraceLog(const char *pszFile, int nLine, const char *fmt, ...);
|
||||
|
||||
extern void lInitTitle(int argc, char **argv, char **envp);
|
||||
extern void vSetTitile(const char *name);
|
||||
|
|
|
@ -0,0 +1,106 @@
|
|||
/*
|
||||
* Copyright (c) 2018 Savens Liu
|
||||
*
|
||||
* The original has been patented, Open source is not equal to open rights.
|
||||
* Anyone can clone, download, learn and discuss for free. Without the permission
|
||||
* of the copyright owner or author, it shall not be merged, published, licensed or sold.
|
||||
* The copyright owner or author has the right to pursue his responsibility.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "tvm.h"
|
||||
|
||||
/************************************************************************************************
|
||||
function
|
||||
************************************************************************************************/
|
||||
extern void vCondInsInit(FdCond *pstCond, TABLE t);
|
||||
|
||||
/*************************************************************************************************
|
||||
description:dump the unused
|
||||
parameters:
|
||||
pstSavm --stvm handle
|
||||
t --table
|
||||
return:
|
||||
RC_SUCC --success
|
||||
RC_FAIL --failure
|
||||
*************************************************************************************************/
|
||||
long lUnuseDump(SATvm *pstSavm, TABLE t)
|
||||
{
|
||||
FILE *fp = NULL;
|
||||
char szFile[512];
|
||||
RunTime *pstRun = NULL;
|
||||
SHTruck *pstTruck = NULL;
|
||||
size_t lRow = 0, lOffset, lDump = 0;
|
||||
|
||||
if(!pstSavm)
|
||||
{
|
||||
pstSavm->m_lErrno = CONDIT_IS_NIL;
|
||||
return RC_FAIL;
|
||||
}
|
||||
|
||||
memset(szFile, 0, sizeof(szFile));
|
||||
if(RC_SUCC != lInitSATvm(pstSavm, t))
|
||||
return RC_FAIL;
|
||||
|
||||
vHoldConnect(pstSavm);
|
||||
if(NULL == (pstRun = (RunTime *)pInitHitTest(pstSavm, t)))
|
||||
return RC_FAIL;
|
||||
|
||||
if(RES_REMOT_SID == pstRun->m_lLocal)
|
||||
{
|
||||
pstSavm->m_lErrno = RMT_NOT_SUPPT;
|
||||
return RC_FAIL;
|
||||
}
|
||||
|
||||
snprintf(szFile, sizeof(szFile), "%s/%d.udb", getenv("TVMDBD"), t);
|
||||
if(NULL == (fp = fopen(szFile, "ab")))
|
||||
{
|
||||
pstSavm->m_lErrno = FILE_NOT_RSET;
|
||||
return RC_FAIL;
|
||||
}
|
||||
|
||||
lOffset = lGetTblData(t);
|
||||
pstRun->m_lCurLine = 0;
|
||||
pstSavm->lSize = lGetRowSize(t);
|
||||
pstTruck = (PSHTruck)pGetNode(pstRun->m_pvAddr, lOffset);
|
||||
for(lRow = 0; (lRow < ((TblDef *)pstRun->m_pvAddr)->m_lValid) && (lOffset < lGetTableSize(t));
|
||||
pstTruck = (PSHTruck)pGetNode(pstRun->m_pvAddr, lOffset))
|
||||
{
|
||||
if(IS_TRUCK_NULL(pstTruck) || pstTruck->m_lTimes == 0)
|
||||
{
|
||||
lOffset += lGetRowTruck(t);
|
||||
continue;
|
||||
}
|
||||
|
||||
fwrite(pstTruck->m_pvData, lGetRowSize(t), 1, fp);
|
||||
pstSavm->pstVoid = pstTruck->m_pvData;
|
||||
vCondInsInit(&pstSavm->stCond, t);
|
||||
lDelete(pstSavm);
|
||||
|
||||
lDump ++;
|
||||
lOffset += lGetRowTruck(t);
|
||||
}
|
||||
fclose(fp);
|
||||
vForceDisconnect(pstSavm, t);
|
||||
pstSavm->m_lEffect = lDump;
|
||||
|
||||
fprintf(stdout, "export table:%s valid:%ld, completed successfully !!\n", sGetTableName(t),
|
||||
pstSavm->m_lEffect);
|
||||
return RC_SUCC;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************************
|
||||
code end
|
||||
****************************************************************************************/
|
85
src/queue.c
85
src/queue.c
|
@ -28,6 +28,47 @@ extern long _lPushByRt(SATvm *pstSavm);
|
|||
extern long _lPopByRt(SATvm *pstSavm, void *psvOut);
|
||||
extern long _lPopupByRt(SATvm *pstSavm, size_t lExp, time_t lTime, size_t *plOut, void **pp);
|
||||
|
||||
/*************************************************************************************************
|
||||
description:Delete the queue that matches conditions
|
||||
parameters:
|
||||
pstSavm --stvm handle
|
||||
pvAddr --memory address
|
||||
t --table
|
||||
return:
|
||||
RC_SUCC --success
|
||||
RC_FAIL --failure
|
||||
*************************************************************************************************/
|
||||
long _lDeleteQueue(SATvm *pstSavm, void *pvAddr)
|
||||
{
|
||||
SHTruck *pstTruck = NULL;
|
||||
TblDef *pv = (TblDef *)pvAddr;
|
||||
size_t lRow, lOffset = pv->m_lListOfs;
|
||||
|
||||
for(pstSavm->m_lEffect = 0, lRow = 0; lRow < pv->m_lMaxRow; lOffset ++, lRow ++)
|
||||
{
|
||||
if(0 >= pv->m_lValid)
|
||||
break;
|
||||
|
||||
pstTruck = (PSHTruck)pGetNode(pvAddr, pv->m_lData + pv->m_lTruck * (lOffset % pv->m_lMaxRow));
|
||||
if(IS_TRUCK_NULL(pstTruck))
|
||||
continue;
|
||||
|
||||
if(RC_MISMA == lFeildMatch(&pstSavm->stCond, pstTruck->m_pvData, pstSavm->pstVoid))
|
||||
continue;
|
||||
|
||||
pstSavm->m_lEffect ++;
|
||||
if(0 > (int)__sync_sub_and_fetch(&pv->m_lValid, 1))
|
||||
{
|
||||
__sync_fetch_and_add(&pv->m_lValid, 1);
|
||||
break;
|
||||
}
|
||||
|
||||
SET_DATA_TRUCK(pstTruck, DATA_TRUCK_NULL);
|
||||
}
|
||||
|
||||
return RC_SUCC;
|
||||
}
|
||||
|
||||
/*************************************************************************************************
|
||||
description:push data to queue
|
||||
parameters:
|
||||
|
@ -295,6 +336,50 @@ retrys:
|
|||
return RC_SUCC;
|
||||
}
|
||||
|
||||
/*************************************************************************************************
|
||||
description:pop data from queue
|
||||
parameters:
|
||||
pstSavm --stvm handle
|
||||
psvOut --out data
|
||||
return:
|
||||
RC_SUCC --success
|
||||
RC_FAIL --failure
|
||||
*************************************************************************************************/
|
||||
long lTimePop(SATvm *pstSavm, void *pvOut, Uenum eWait)
|
||||
{
|
||||
long lRet;
|
||||
Timesp tm = {0, 1};
|
||||
RunTime *pstRun = NULL;
|
||||
|
||||
if(!pstSavm)
|
||||
{
|
||||
pstSavm->m_lErrno = CONDIT_IS_NIL;
|
||||
return RC_FAIL;
|
||||
}
|
||||
|
||||
if(NULL == (pstRun = (RunTime *)pInitMemTable(pstSavm, pstSavm->tblName)))
|
||||
return RC_FAIL;
|
||||
|
||||
if(TYPE_MQUEUE != pstRun->m_lType)
|
||||
{
|
||||
pstSavm->m_lErrno = NOT_SUPPT_OPT;
|
||||
vTblDisconnect(pstSavm, pstSavm->tblName);
|
||||
return RC_FAIL;
|
||||
}
|
||||
|
||||
if(RES_REMOT_SID == pstRun->m_lLocal)
|
||||
{
|
||||
Tremohold(pstSavm, pstRun);
|
||||
return _lPopByRt(pstSavm, pvOut);
|
||||
}
|
||||
|
||||
if(QUE_NORMAL == eWait) tm.tv_sec = MAX_LOCK_TIME;
|
||||
lRet = _lPop(pstSavm, pstRun->m_pvAddr, pvOut, &tm);
|
||||
vTblDisconnect(pstSavm, pstSavm->tblName);
|
||||
return lRet;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************************************
|
||||
description:pop data from queue
|
||||
parameters:
|
||||
|
|
|
@ -1091,7 +1091,7 @@ long lCreateByFile(char *pszFile)
|
|||
return RC_FAIL;
|
||||
}
|
||||
|
||||
if(NULL == (pszCreate = (char *)calloc(stBuf.st_size, 1)))
|
||||
if(NULL == (pszCreate = (char *)calloc(stBuf.st_size + 1, 1)))
|
||||
{
|
||||
fprintf(stderr, "create memory error, %s\n", strerror(errno));
|
||||
return RC_FAIL;
|
||||
|
@ -4387,7 +4387,8 @@ void vInitialCustom()
|
|||
//select nextval from SEQUENCE@SEQ_TEST
|
||||
snprintf(g_stCustom.m_pszWord, ALLOC_CMD_LEN, "SET,FROM,WHERE,COUNT(1),MAX,MIN,NEXTVAL,"
|
||||
"ORDER BY,GROUP BY,SEQUENCE@,SYS_TVM_FIELD,SYS_TVM_DOMAIN,SYS_TVM_SEQUE,TABLE,INTO,"
|
||||
"ON,INFO,INDEX,VALUES,DEBUG [ON|OFF],SHOWMODE [ROW|COLUMN],SHOWSIZE [NUM],CLICK,TO,");
|
||||
"ON,INFO,INDEX,VALUES,DEBUG [ON|OFF],SHOWMODE [ROW|COLUMN],SHOWSIZE [NUM],CLICK,TO,"
|
||||
"DELIMITER,");
|
||||
g_stCustom.m_lWord = lgetstrnum(g_stCustom.m_pszWord, ",");
|
||||
|
||||
rl_attempted_completion_function = pMatchCompletion;
|
||||
|
|
|
@ -33,14 +33,13 @@ Rowgrp *g_pstDomgrp = NULL, *g_pstTblgrp = NULL;
|
|||
extern char* pGetLog();
|
||||
extern long lGetBootType();
|
||||
extern void vSetBootType(long lType);
|
||||
extern long lTimePop(SATvm *pstSavm, void *pvOut, Uenum eWait);
|
||||
void* pParsePacket(SATvm *pstSavm, void *pstVoid, TFace *pstFace, void *pvBuffer, long lLen);
|
||||
void* pProtocaJava(SATvm *pstSavm, void *pstVoid, TFace *pstFace, void *pvBuffer, long lLen);
|
||||
|
||||
/*************************************************************************************************
|
||||
macro
|
||||
*************************************************************************************************/
|
||||
#define Tlog(...) vTraceLog(__FILE__, __LINE__, __VA_ARGS__)
|
||||
|
||||
#define checkrequest(s,c,f) if(MAX(f->m_lRows, f->m_lDLen) > c->m_lBuffer) \
|
||||
{ \
|
||||
if(MAX(f->m_lRows, f->m_lDLen) > DATA_MAX_LEN) \
|
||||
|
@ -1448,7 +1447,7 @@ long lEventOperate(SATvm *pstSavm, SKCon *pstCon, TFace *pstFace, char *pvDat
|
|||
TFree(pvOut);
|
||||
return RC_SUCC;
|
||||
case OPERATE_QUEPOP:
|
||||
if(RC_SUCC != lPop(pstSavm, (void *)pvData, pstFace->m_lFind))
|
||||
if(RC_SUCC != lTimePop(pstSavm, (void *)pvData, pstFace->m_lFind))
|
||||
{
|
||||
pstFace->m_lErrno = pstSavm->m_lErrno;
|
||||
lData = sizeof(TFace);
|
||||
|
@ -1852,6 +1851,7 @@ long lPollRequest(SATvm *pstSovm, SKCon *pstCon, TFace *pstFace, void *pstVoi
|
|||
}
|
||||
else
|
||||
{
|
||||
pstSovm->stRunTime[pstFace->m_table].m_lType = pstRun->m_lType;
|
||||
pstSovm->stRunTime[pstFace->m_table].m_bAttch = pstRun->m_bAttch;
|
||||
pstSovm->stRunTime[pstFace->m_table].m_pvAddr = pstRun->m_pvAddr;
|
||||
}
|
||||
|
|
25
src/tree.c
25
src/tree.c
|
@ -43,6 +43,7 @@ extern long _lQueryByRt(SATvm *pstSavm, size_t *plOut, void **ppsvOut);
|
|||
extern long _lExtremeByRt(SATvm *pstSavm, void *psvOut);
|
||||
extern void _vDropTableByRt(SATvm *pstSavm, TABLE t);
|
||||
extern long _lRenameTableByRt(SATvm *pstSavm, TABLE to, TABLE tn);
|
||||
extern long _lDeleteQueue(SATvm *pstSavm, void *pvAddr);
|
||||
|
||||
/*************************************************************************************************
|
||||
macro
|
||||
|
@ -4311,16 +4312,20 @@ long _lDeleteGroup(SATvm *pstSavm, void *pvAddr, TABLE t)
|
|||
RC_SUCC --success
|
||||
RC_FAIL --failure
|
||||
*************************************************************************************************/
|
||||
long _lDeleteTruck(SATvm *pstSavm, void *pvAddr, TABLE t)
|
||||
long _lDeleteTruck(SATvm *pstSavm, RunTime *pstRun, TABLE t)
|
||||
{
|
||||
bool bIsIdx = false;
|
||||
SHTree *pstRoot = NULL;
|
||||
SHTruck *pstTruck = NULL;
|
||||
char szIdx[MAX_INDEX_LEN];
|
||||
void *pvAddr = pstRun->m_pvAddr;
|
||||
RWLock *prwLock = (RWLock *)pGetRWLock(pvAddr);
|
||||
size_t lData = 0, lOffset = lGetTblData(t), lIdx;
|
||||
long lRow, lValid = ((TblDef *)pvAddr)->m_lValid;
|
||||
|
||||
if(TYPE_MQUEUE == pstRun->m_lType)
|
||||
return _lDeleteQueue(pstSavm, pvAddr);
|
||||
|
||||
if(HAVE_INDEX(t)) bIsIdx = true;
|
||||
|
||||
if(RC_SUCC != pthread_rwlock_wrlock(prwLock))
|
||||
|
@ -4476,13 +4481,6 @@ long lDelete(SATvm *pstSavm)
|
|||
if(NULL == (pstRun = (RunTime *)pInitMemTable(pstSavm, pstSavm->tblName)))
|
||||
return RC_FAIL;
|
||||
|
||||
if(TYPE_MQUEUE == pstRun->m_lType)
|
||||
{
|
||||
pstSavm->m_lErrno = NOT_SUPPT_OPT;
|
||||
vTblDisconnect(pstSavm, pstSavm->tblName);
|
||||
return RC_FAIL;
|
||||
}
|
||||
|
||||
if(RES_REMOT_SID == pstRun->m_lLocal)
|
||||
{
|
||||
Tremohold(pstSavm, pstRun);
|
||||
|
@ -4498,7 +4496,7 @@ long lDelete(SATvm *pstSavm)
|
|||
|
||||
if(!pstSavm->pstVoid)
|
||||
{
|
||||
lRet = _lDeleteTruck(pstSavm, pstRun->m_pvAddr, pstSavm->tblName);
|
||||
lRet = _lDeleteTruck(pstSavm, pstRun, pstSavm->tblName);
|
||||
vTblDisconnect(pstSavm, pstSavm->tblName);
|
||||
return lRet;
|
||||
}
|
||||
|
@ -4532,7 +4530,7 @@ long lDelete(SATvm *pstSavm)
|
|||
}
|
||||
}
|
||||
|
||||
lRet = _lDeleteTruck(pstSavm, pstRun->m_pvAddr, pstSavm->tblName);
|
||||
lRet = _lDeleteTruck(pstSavm, pstRun, pstSavm->tblName);
|
||||
vTblDisconnect(pstSavm, pstSavm->tblName);
|
||||
return lRet;
|
||||
}
|
||||
|
@ -9237,7 +9235,12 @@ long lImportFile(TABLE t, char *pszFile, char *pszFlag)
|
|||
|
||||
memset(pvData, 0, lGetRowSize(t));
|
||||
if(TYPE_MQUEUE == pstRun->m_lType)
|
||||
memcpy(pvData, szLine, lGetRowSize(t));
|
||||
{
|
||||
if(lGetFldNum(t) > 0)
|
||||
_lImportContext(szLine, lGetFldNum(t), pGetTblKey(t), pvData, pszFlag);
|
||||
else
|
||||
memcpy(pvData, szLine, lGetRowSize(t));
|
||||
}
|
||||
else
|
||||
_lImportContext(szLine, lGetFldNum(t), pGetTblKey(t), pvData, pszFlag);
|
||||
if(RC_SUCC != __lInsert(pstSavm, pstRun, pstSavm->tblName, 0))
|
||||
|
|
11
stvm.conf
11
stvm.conf
|
@ -4,7 +4,7 @@ MAXTABLE=255
|
|||
MAXFILED=3000
|
||||
MAXDOMAIN=1024
|
||||
MAXSEQUE=1024
|
||||
SERVER_EXEC=4
|
||||
SERVER_EXEC=2
|
||||
#SERVER_EXEC=1
|
||||
DEPLOY=cluster
|
||||
#DEPLOY=local
|
||||
|
@ -12,16 +12,7 @@ SERVER_PORT=5050
|
|||
LOGNAME="/home/stvm/log/stvm.log"
|
||||
|
||||
*LOCAL_RESOURCE
|
||||
TABLE=15 PERMIT=15
|
||||
|
||||
*REMOTE_DOMAIN
|
||||
GROUP=1 DOMAINID="DBS" WSADDR="192.168.5.20:5010" TIMEOUT=2 MAXTRY=3 KEEPALIVE=30
|
||||
GROUP=2 DOMAINID="CTS" WSADDR="192.168.5.20:5011" TIMEOUT=2 MAXTRY=3 KEEPALIVE=30
|
||||
|
||||
*REMOTE_TABLE
|
||||
TABLE=8 TABLENAME="TBL_BRH_INFO"
|
||||
MTABLE=17 DOMAINID="DBS"
|
||||
MTABLE=17 DOMAINID="CTS"
|
||||
TABLE=9 TABLENAME="TBL_ACCT_INFO"
|
||||
MTABLE=16 DOMAINID="DBS"
|
||||
MTABLE=16 DOMAINID="CTS"
|
||||
|
|
Loading…
Reference in New Issue