1.2.4 Beta

pull/1/head
deffpuzzl 2018-06-08 16:58:44 +08:00
parent f66d162cb5
commit f60c22d8ae
25 changed files with 604 additions and 256 deletions

45
demo/asypush.c Normal file
View File

@ -0,0 +1,45 @@
#include "tvm.h"
#include "tmain.h"
#define QUEUE_USER_INFO 21
typedef struct __QUEUE_USER_INFO
{
long acct_id;
char user_no[21];
char user_type[2];
char user_nm[81];
char user_addr[161];
char user_phone[31];
}dbUser;
int main(int argc, char *argv[])
{
dbUser stUser;
SATvm *pstSavm = (SATvm *)pGetSATvm();
if(RC_SUCC != lTvmConnect(pstSavm, "127.0.0.1", 5050, 2))
{
fprintf(stderr, "init failed, err:(%d)(%s)\n", pstSavm->m_lErrno, sGetTError(pstSavm->m_lErrno));
return RC_FAIL;
}
queueinit(pstSavm, stUser, QUEUE_USER_INFO); // 绑定变量
stUser.acct_id = time(NULL); // 对结构体赋值
strcpy(stUser.user_no, "20180223"); // 对结构体赋值
strcpy(stUser.user_type, "1"); // 对结构体赋值
strcpy(stUser.user_nm, "Savens Liu"); // 对结构体赋值
strcpy(stUser.user_addr, "China"); // 对结构体赋值
strcpy(stUser.user_phone, "18672911111"); // 对结构体赋值
if(RC_SUCC != lAsyPush(pstSavm)) // 插入记录
{
fprintf(stderr, "Push error:(%d)(%s)\n", pstSavm->m_lErrno, sGetTError(pstSavm->m_lErrno));
return RC_FAIL;
}
vTvmDisconnect(pstSavm);
fprintf(stdout, "asypush success\n");
return RC_SUCC;
}

View File

@ -13,7 +13,7 @@ typedef struct __TBL_USER_INFO
char user_phone[31]; char user_phone[31];
}dbUser; }dbUser;
long lCountUserInfo() int main(int argc, char *argv[])
{ {
dbUser stUser; dbUser stUser;
size_t lRow = 0; size_t lRow = 0;
@ -22,7 +22,8 @@ long lCountUserInfo()
/* 初始化TBL_USER_INFO表每张表都需要初始化一次, 对于表重建后,需要重新初始化一次。*/ /* 初始化TBL_USER_INFO表每张表都需要初始化一次, 对于表重建后,需要重新初始化一次。*/
if(RC_SUCC != lInitSATvm(pstSavm, TBL_USER_INFO)) if(RC_SUCC != lInitSATvm(pstSavm, TBL_USER_INFO))
{ {
fprintf(stderr, "init failed, err:(%d)(%s)\n", pstSavm->m_lErrno, sGetTError(pstSavm->m_lErrno)); fprintf(stderr, "init failed, err:(%d)(%s)\n", pstSavm->m_lErrno,
sGetTError(pstSavm->m_lErrno));
return RC_FAIL; return RC_FAIL;
} }
@ -32,20 +33,11 @@ long lCountUserInfo()
if(RC_SUCC != lCount(pstSavm, (void *)&lRow)) if(RC_SUCC != lCount(pstSavm, (void *)&lRow))
{ {
fprintf(stderr, "Count error: (%d) (%s)\n", pstSavm->m_lErrno, sGetTError(pstSavm->m_lErrno)); fprintf(stderr, "Count error: (%d) (%s)\n", pstSavm->m_lErrno,
sGetTError(pstSavm->m_lErrno));
return RC_FAIL; return RC_FAIL;
} }
fprintf(stdout, "Count:%ld\n\n", lRow); fprintf(stdout, "Count:%ld\n\n", lRow);
return RC_SUCC; return RC_SUCC;
} }
int main(int argc, char *argv[])
{
if(RC_SUCC != lCountUserInfo())
return RC_FAIL;
return RC_SUCC;
}

View File

@ -13,7 +13,7 @@ typedef struct __TBL_USER_INFO
char user_phone[31]; char user_phone[31];
}dbUser; }dbUser;
long lDeleteUserInfo() int main(int argc, char *argv[])
{ {
dbUser stUser; dbUser stUser;
SATvm *pstSavm = (SATvm *)pGetSATvm(); SATvm *pstSavm = (SATvm *)pGetSATvm();
@ -21,7 +21,8 @@ long lDeleteUserInfo()
/* 初始化TBL_USER_INFO表每张表都需要初始化一次, 对于表重建后,需要重新初始化一次。*/ /* 初始化TBL_USER_INFO表每张表都需要初始化一次, 对于表重建后,需要重新初始化一次。*/
if(RC_SUCC != lInitSATvm(pstSavm, TBL_USER_INFO)) if(RC_SUCC != lInitSATvm(pstSavm, TBL_USER_INFO))
{ {
fprintf(stderr, "init failed, err:(%d)(%s)\n", pstSavm->m_lErrno, sGetTError(pstSavm->m_lErrno)); fprintf(stderr, "init failed, err:(%d)(%s)\n", pstSavm->m_lErrno,
sGetTError(pstSavm->m_lErrno));
return RC_FAIL; return RC_FAIL;
} }
@ -31,20 +32,10 @@ long lDeleteUserInfo()
if(RC_SUCC != lDelete(pstSavm)) if(RC_SUCC != lDelete(pstSavm))
{ {
fprintf(stderr, "Delete error: (%d) (%s)\n", pstSavm->m_lErrno, sGetTError(pstSavm->m_lErrno)); fprintf(stderr, "Delete error: (%d) (%s)\n", pstSavm->m_lErrno,
sGetTError(pstSavm->m_lErrno));
return RC_FAIL; return RC_FAIL;
} }
return RC_SUCC; return RC_SUCC;
} }
int main(int argc, char *argv[])
{
if(RC_SUCC != lDeleteUserInfo())
return RC_FAIL;
return RC_SUCC;
}

View File

@ -3,44 +3,16 @@
#define TBL_USER_INFO 20 #define TBL_USER_INFO 20
typedef struct __TBL_USER_INFO int main(int argc, char *argv[])
{ {
long acct_id;
char user_no[21];
char user_type[2];
char user_nm[81];
char user_addr[161];
char user_phone[31];
}dbUser;
long lDropUserInfo()
{
dbUser stUser;
SATvm *pstSavm = (SATvm *)pGetSATvm(); SATvm *pstSavm = (SATvm *)pGetSATvm();
/* 初始化TBL_USER_INFO表每张表都需要初始化一次, 对于表重建后,需要重新初始化一次。*/
if(RC_SUCC != lInitSATvm(pstSavm, TBL_USER_INFO))
{
fprintf(stderr, "init failed, err:(%d)(%s)\n", pstSavm->m_lErrno, sGetTError(pstSavm->m_lErrno));
return RC_FAIL;
}
if(RC_SUCC != lDropTable(pstSavm, TBL_USER_INFO)) if(RC_SUCC != lDropTable(pstSavm, TBL_USER_INFO))
{ {
fprintf(stderr, "drop table error:(%d)(%s)\n", pstSavm->m_lErrno, sGetTError(pstSavm->m_lErrno)); fprintf(stderr, "drop table error:(%d)(%s)\n", pstSavm->m_lErrno,
sGetTError(pstSavm->m_lErrno));
return RC_FAIL; return RC_FAIL;
} }
return RC_SUCC; return RC_SUCC;
} }
int main(int argc, char *argv[])
{
if(RC_SUCC != lDropUserInfo())
return RC_FAIL;
return RC_SUCC;
}

View File

@ -13,7 +13,7 @@ typedef struct __TBL_USER_INFO
char user_phone[31]; char user_phone[31];
}dbUser; }dbUser;
long lExtremeUserInfo() int main(int argc, char *argv[])
{ {
dbUser stUser; dbUser stUser;
SATvm *pstSavm = (SATvm *)pGetSATvm(); SATvm *pstSavm = (SATvm *)pGetSATvm();
@ -21,7 +21,8 @@ long lExtremeUserInfo()
/* 初始化TBL_USER_INFO表每张表都需要初始化一次, 对于表重建后,需要重新初始化一次。*/ /* 初始化TBL_USER_INFO表每张表都需要初始化一次, 对于表重建后,需要重新初始化一次。*/
if(RC_SUCC != lInitSATvm(pstSavm, TBL_USER_INFO)) if(RC_SUCC != lInitSATvm(pstSavm, TBL_USER_INFO))
{ {
fprintf(stderr, "init failed, err:(%d)(%s)\n", pstSavm->m_lErrno, sGetTError(pstSavm->m_lErrno)); fprintf(stderr, "init failed, err:(%d)(%s)\n", pstSavm->m_lErrno,
sGetTError(pstSavm->m_lErrno));
return RC_FAIL; return RC_FAIL;
} }
@ -32,7 +33,8 @@ long lExtremeUserInfo()
decorate(pstSavm, dbUser, user_phone, MATCH_MAX); decorate(pstSavm, dbUser, user_phone, MATCH_MAX);
if(RC_SUCC != lExtreme(pstSavm, (void *)&stUser)) if(RC_SUCC != lExtreme(pstSavm, (void *)&stUser))
{ {
fprintf(stderr, "Extreme error: (%d) (%s)\n", pstSavm->m_lErrno, sGetTError(pstSavm->m_lErrno)); fprintf(stderr, "Extreme error: (%d) (%s)\n", pstSavm->m_lErrno,
sGetTError(pstSavm->m_lErrno));
return RC_FAIL; return RC_FAIL;
} }
@ -40,13 +42,3 @@ long lExtremeUserInfo()
return RC_SUCC; return RC_SUCC;
} }
int main(int argc, char *argv[])
{
if(RC_SUCC != lExtremeUserInfo())
return RC_FAIL;
return RC_SUCC;
}

View File

@ -13,7 +13,7 @@ typedef struct __TBL_USER_INFO
char user_phone[31]; char user_phone[31];
}dbUser; }dbUser;
long lGroupUserInfo() int main(int argc, char *argv[])
{ {
size_t i, lRow = 0; size_t i, lRow = 0;
dbUser stUser, *pstUser = NULL; dbUser stUser, *pstUser = NULL;
@ -22,7 +22,8 @@ long lGroupUserInfo()
/* 初始化TBL_USER_INFO表每张表都需要初始化一次, 对于表重建后,需要重新初始化一次。*/ /* 初始化TBL_USER_INFO表每张表都需要初始化一次, 对于表重建后,需要重新初始化一次。*/
if(RC_SUCC != lInitSATvm(pstSavm, TBL_USER_INFO)) if(RC_SUCC != lInitSATvm(pstSavm, TBL_USER_INFO))
{ {
fprintf(stderr, "init failed, err:(%d)(%s)\n", pstSavm->m_lErrno, sGetTError(pstSavm->m_lErrno)); fprintf(stderr, "init failed, err:(%d)(%s)\n", pstSavm->m_lErrno,
sGetTError(pstSavm->m_lErrno));
return RC_FAIL; return RC_FAIL;
} }
@ -33,7 +34,8 @@ long lGroupUserInfo()
decorate(pstSavm, dbUser, user_phone, GROUP_BY | ORDER_DESC); decorate(pstSavm, dbUser, user_phone, GROUP_BY | ORDER_DESC);
if(RC_SUCC != lGroup(pstSavm, &lRow, (void **)&pstUser)) if(RC_SUCC != lGroup(pstSavm, &lRow, (void **)&pstUser))
{ {
fprintf(stderr, "Group error: (%d) (%s)\n", pstSavm->m_lErrno, sGetTError(pstSavm->m_lErrno)); fprintf(stderr, "Group error: (%d) (%s)\n", pstSavm->m_lErrno,
sGetTError(pstSavm->m_lErrno));
return RC_FAIL; return RC_FAIL;
} }
@ -44,13 +46,3 @@ long lGroupUserInfo()
return RC_SUCC; return RC_SUCC;
} }
int main(int argc, char *argv[])
{
if(RC_SUCC != lGroupUserInfo())
return RC_FAIL;
return RC_SUCC;
}

View File

@ -1,7 +1,7 @@
#include "tvm.h" #include "tvm.h"
#include "tmain.h" #include "tmain.h"
#define TBL_USER_INFO 21 #define TBL_USER_INFO 20
typedef struct __TBL_USER_INFO typedef struct __TBL_USER_INFO
{ {
@ -13,7 +13,7 @@ typedef struct __TBL_USER_INFO
char user_phone[31]; char user_phone[31];
}dbUser; }dbUser;
long lInsertUserInfo() int main(int argc, char *argv[])
{ {
dbUser stUser; dbUser stUser;
SATvm *pstSavm = (SATvm *)pGetSATvm(); SATvm *pstSavm = (SATvm *)pGetSATvm();
@ -21,13 +21,13 @@ long lInsertUserInfo()
/* 初始化TBL_USER_INFO表每张表都需要初始化一次, 对于表重建后,需要重新初始化一次。*/ /* 初始化TBL_USER_INFO表每张表都需要初始化一次, 对于表重建后,需要重新初始化一次。*/
if(RC_SUCC != lInitSATvm(pstSavm, TBL_USER_INFO)) if(RC_SUCC != lInitSATvm(pstSavm, TBL_USER_INFO))
{ {
fprintf(stderr, "init failed, err:(%d)(%s)\n", pstSavm->m_lErrno, sGetTError(pstSavm->m_lErrno)); fprintf(stderr, "init failed, err:(%d)(%s)\n", pstSavm->m_lErrno,
sGetTError(pstSavm->m_lErrno));
return RC_FAIL; return RC_FAIL;
} }
conditinit(pstSavm, stUser, TBL_USER_INFO); // 绑定变量 conditinit(pstSavm, stUser, TBL_USER_INFO); // 绑定变量
// stUser.acct_id = time(NULL); // 对结构体赋值
// stUser.acct_id = 10021; // 对结构体赋值
strcpy(stUser.user_no, "20180223"); // 对结构体赋值 strcpy(stUser.user_no, "20180223"); // 对结构体赋值
strcpy(stUser.user_type, "1"); // 对结构体赋值 strcpy(stUser.user_type, "1"); // 对结构体赋值
strcpy(stUser.user_nm, "Savens Liu"); // 对结构体赋值 strcpy(stUser.user_nm, "Savens Liu"); // 对结构体赋值
@ -37,23 +37,12 @@ long lInsertUserInfo()
if(RC_SUCC != lInsert(pstSavm)) // 插入记录 if(RC_SUCC != lInsert(pstSavm)) // 插入记录
{ {
fprintf(stderr, "Insert error:(%d)(%s)\n", pstSavm->m_lErrno, sGetTError(pstSavm->m_lErrno)); fprintf(stderr, "Insert error:(%d)(%s)\n", pstSavm->m_lErrno,
sGetTError(pstSavm->m_lErrno));
return RC_FAIL; return RC_FAIL;
} }
return RC_SUCC; fprintf(stdout, "insert success, effect:%d\n", pstSavm->m_lEffect);
}
int main(int argc, char *argv[])
{
if(RC_SUCC != lInsertUserInfo())
return RC_FAIL;
fprintf(stdout, "新增记录成功, completed successfully!!!\n");
fflush(stderr);
return RC_SUCC; return RC_SUCC;
} }

View File

@ -1,6 +1,6 @@
INCDIR= -I/usr/include -I$(HOME)/include -I./ -I./include -I../include INCDIR= -I/usr/include -I$(HOME)/include -I./ -I./include -I../include
#LIBDIR= -L$(HOME)/lib -L../lib -lm -lc -ldl -lpthread -static -lstvm #LIBDIR= -L$(HOME)/lib -L../lib -lm -lc -ldl -lpthread -static -lstvm
LIBDIR= -L$(HOME)/lib -L../lib -lstvm -lm -lc -ldl -lpthread LIBDIR= -L$(HOME)/lib -L../lib -lstvm -lm -lc -ldl -lrt -lpthread
CC=cc -fPIC -g CC=cc -fPIC -g
CO=-c -pg CO=-c -pg
OUTLIB=../lib OUTLIB=../lib
@ -11,6 +11,8 @@ CREATE=create_table
QUEUE=create_queue QUEUE=create_queue
PUSH=push PUSH=push
POP=pop POP=pop
TVMPOP=tvmpop
TVMREPLACE=tvmreplace
INSERT=insert INSERT=insert
SELECT=select SELECT=select
QUERY=query QUERY=query
@ -25,12 +27,22 @@ CLICK=click
REPLACE=replace REPLACE=replace
POPUP=popup POPUP=popup
PRESSURE=press_demo PRESSURE=press_demo
TVMPUSH=tvmpush
ASYPUSH=asypush
all: $(CREATE) $(INSERT) $(QUEUE) $(PUSH) $(POP) $(SELECT) $(QUERY) $(DELETE) $(UPDATE) $(COUNT) $(GROUP) $(EXTREME) $(TRUNCATE) $(DROP) $(PRESSURE) $(CLICK) $(POPUP) $(REPLACE) clean all: $(CREATE) $(INSERT) $(QUEUE) $(PUSH) $(POP) $(SELECT) $(QUERY) $(DELETE) $(UPDATE) $(COUNT) $(GROUP) $(EXTREME) $(TRUNCATE) $(DROP) $(PRESSURE) $(CLICK) $(POPUP) $(REPLACE) $(TVMPUSH) $(ASYPUSH) $(TVMPOP) $(TVMREPLACE) clean
$(CREATE): create_table.o $(CREATE): create_table.o
$(CC) -o $@ $< $(LIBDIR) $(CC) -o $@ $< $(LIBDIR)
$(TVMREPLACE): tvmreplace.o
$(CC) -o $@ $< $(LIBDIR)
$(TVMPOP): tvmpop.o
$(CC) -o $@ $< $(LIBDIR)
$(PUSH): push.o $(PUSH): push.o
$(CC) -o $@ $< $(LIBDIR) $(CC) -o $@ $< $(LIBDIR)
$(TVMPUSH): tvmpush.o
$(CC) -o $@ $< $(LIBDIR)
$(ASYPUSH): asypush.o
$(CC) -o $@ $< $(LIBDIR)
$(POP): pop.o $(POP): pop.o
$(CC) -o $@ $< $(LIBDIR) $(CC) -o $@ $< $(LIBDIR)
$(INSERT): insert.o $(INSERT): insert.o

41
demo/pop.c Normal file
View File

@ -0,0 +1,41 @@
#include "tvm.h"
#include "tmain.h"
#define QUEUE_USER_INFO 21
typedef struct __QUEUE_USER_INFO
{
long acct_id;
char user_no[21];
char user_type[2];
char user_nm[81];
char user_addr[161];
char user_phone[31];
}dbUser;
int main(int argc, char *argv[])
{
dbUser stUser;
SATvm *pstSavm = (SATvm *)pGetSATvm();
/* 初始化QUEUE_USER_INFO表每张表都需要初始化一次, 对于表重建后,需要重新初始化一次。*/
if(RC_SUCC != lInitSATvm(pstSavm, QUEUE_USER_INFO))
{
fprintf(stderr, "attch failed, err:(%d)(%s)\n", pstSavm->m_lErrno,
sGetTError(pstSavm->m_lErrno));
return RC_FAIL;
}
queueinit(pstSavm, stUser, QUEUE_USER_INFO); // 绑定变量
if(RC_SUCC != lPop(pstSavm, (void *)&stUser, QUE_NORMAL)) // POP记录
{
fprintf(stderr, "Pop error:(%d)(%s)\n", pstSavm->m_lErrno, sGetTError(pstSavm->m_lErrno));
return RC_FAIL;
}
fprintf(stdout, "acct_id:%ld, user_no:%s, user_type:%s, user_nm:%s, user_addr:%s, "
"user_phone:%s\n", stUser.acct_id, stUser.user_no, stUser.user_type, stUser.user_nm,
stUser.user_addr, stUser.user_phone);
return RC_SUCC;
}

52
demo/popup.c Normal file
View File

@ -0,0 +1,52 @@
#include "tvm.h"
#include "tmain.h"
#define QUEUE_USER_INFO 21
typedef struct __QUEUE_USER_INFO
{
long acct_id;
char user_no[21];
char user_type[2];
char user_nm[81];
char user_addr[161];
char user_phone[31];
}dbUser;
int main(int argc, char *argv[])
{
long i, lRows = 0, lTime;
dbUser stUser, *pstUser = NULL;
SATvm *pstSavm = (SATvm *)pGetSATvm();
/* 初始化QUEUE_USER_INFO表每张表都需要初始化一次, 对于表重建后,需要重新初始化一次。*/
if(RC_SUCC != lInitSATvm(pstSavm, QUEUE_USER_INFO))
{
fprintf(stderr, "init failed, err:(%d)(%s)\n", pstSavm->m_lErrno,
sGetTError(pstSavm->m_lErrno));
return RC_FAIL;
}
lTime = time(NULL);
queuenull(pstSavm, sizeof(dbUser), QUEUE_USER_INFO);
if(RC_SUCC != lPopup(pstSavm, 3, 5, &lRows, (void **)&pstUser))
{
fprintf(stderr, "Pop error:(%u)(%s), time:%ld, effect:%d\n", pstSavm->m_lErrno,
sGetTError(pstSavm->m_lErrno), time(NULL) - lTime, pstSavm->m_lEffect);
}
if(0 != pstSavm->m_lErrno && 0 == pstSavm->m_lEffect)
return RC_FAIL;
for(i = 0; i < lRows; i ++)
{
fprintf(stdout, "row:%ld, acct_id:%ld, user_no:%s, user_type:%s, "
"user_nm:%s, user_addr:%s, user_phone:%s\n", i, pstUser[i].acct_id,
pstUser[i].user_no, pstUser[i].user_type, pstUser[i].user_nm,
pstUser[i].user_addr, pstUser[i].user_phone);
}
TFree(pstUser);
return RC_SUCC;
}

46
demo/push.c Normal file
View File

@ -0,0 +1,46 @@
#include "tvm.h"
#include "tmain.h"
#define QUEUE_USER_INFO 21
typedef struct __QUEUE_USER_INFO
{
long acct_id;
char user_no[21];
char user_type[2];
char user_nm[81];
char user_addr[161];
char user_phone[31];
}dbUser;
int main(int argc, char *argv[])
{
dbUser stUser;
SATvm *pstSavm = (SATvm *)pGetSATvm();
/* 初始化QUEUE_USER_INFO表每张表都需要初始化一次, 对于表重建后,需要重新初始化一次。*/
if(RC_SUCC != lInitSATvm(pstSavm, QUEUE_USER_INFO))
{
fprintf(stderr, "init failed, err:(%d)(%s)\n", pstSavm->m_lErrno,
sGetTError(pstSavm->m_lErrno));
return RC_FAIL;
}
queueinit(pstSavm, stUser, QUEUE_USER_INFO); // 绑定变量
stUser.acct_id = time(NULL); // 对结构体赋值
strcpy(stUser.user_no, "20180223"); // 对结构体赋值
strcpy(stUser.user_type, "1"); // 对结构体赋值
strcpy(stUser.user_nm, "Savens Liu"); // 对结构体赋值
strcpy(stUser.user_addr, "China"); // 对结构体赋值
strcpy(stUser.user_phone, "18672911111"); // 对结构体赋值
if(RC_SUCC != lPush(pstSavm)) // 插入记录
{
fprintf(stderr, "Insert error:(%d)(%s)\n", pstSavm->m_lErrno,
sGetTError(pstSavm->m_lErrno));
return RC_FAIL;
}
fprintf(stdout, "push success, effect:%d\n", pstSavm->m_lEffect);
return RC_SUCC;
}

View File

@ -13,7 +13,7 @@ typedef struct __TBL_USER_INFO
char user_phone[31]; char user_phone[31];
}dbUser; }dbUser;
long lQueryUserInfo() int main(int argc, char *argv[])
{ {
size_t i, lRow = 0; size_t i, lRow = 0;
dbUser stUser, *pstUser = NULL; dbUser stUser, *pstUser = NULL;
@ -22,37 +22,30 @@ long lQueryUserInfo()
/* 初始化TBL_USER_INFO表每张表都需要初始化一次, 对于表重建后,需要重新初始化一次。*/ /* 初始化TBL_USER_INFO表每张表都需要初始化一次, 对于表重建后,需要重新初始化一次。*/
if(RC_SUCC != lInitSATvm(pstSavm, TBL_USER_INFO)) if(RC_SUCC != lInitSATvm(pstSavm, TBL_USER_INFO))
{ {
fprintf(stderr, "init failed, err:(%d)(%s)\n", pstSavm->m_lErrno, sGetTError(pstSavm->m_lErrno)); fprintf(stderr, "init failed, err:(%d)(%s)\n", pstSavm->m_lErrno,
sGetTError(pstSavm->m_lErrno));
return RC_FAIL; return RC_FAIL;
} }
conditinit(pstSavm, stUser, TBL_USER_INFO); // 绑定变量 conditinit(pstSavm, stUser, TBL_USER_INFO); // 绑定变量
conditnum(pstSavm, stUser, acct_id, 2018053017);
stringset(pstSavm, stUser, user_type, "1"); // 查询条件赋值 stringset(pstSavm, stUser, user_type, "1"); // 查询条件赋值
stringset(pstSavm, stUser, user_no, "20180224"); // 查询条件赋值 stringset(pstSavm, stUser, user_no, "20180223"); // 查询条件赋值
if(RC_SUCC != lQuery(pstSavm, &lRow, (void **)&pstUser)) if(RC_SUCC != lQuery(pstSavm, &lRow, (void **)&pstUser))
{ {
fprintf(stderr, "Query error:(%d)(%s)\n", pstSavm->m_lErrno, sGetTError(pstSavm->m_lErrno)); fprintf(stderr, "Query error:(%d)(%s)\n", pstSavm->m_lErrno,
sGetTError(pstSavm->m_lErrno));
return RC_FAIL; return RC_FAIL;
} }
for(i = 0; i < lRow; i ++) for(i = 0; i < lRow; i ++)
{ {
fprintf(stdout, "acct_id:%ld, user_no:%s, user_type:%s, user_nm:%s, user_addr:%s, user_phone:%s\n", fprintf(stdout, "acct_id:%ld, user_no:%s, user_type:%s, user_nm:%s, "
pstUser[i].acct_id, pstUser[i].user_no, pstUser[i].user_type, pstUser[i].user_nm, pstUser[i].user_addr, "user_addr:%s, user_phone:%s\n", pstUser[i].acct_id, pstUser[i].user_no,
pstUser[i].user_type, pstUser[i].user_nm, pstUser[i].user_addr,
pstUser[i].user_phone); pstUser[i].user_phone);
} }
TFree(pstUser); TFree(pstUser);
return RC_SUCC; return RC_SUCC;
} }
int main(int argc, char *argv[])
{
if(RC_SUCC != lQueryUserInfo())
return RC_FAIL;
return RC_SUCC;
}

View File

@ -13,7 +13,7 @@ typedef struct __TBL_USER_INFO
char user_phone[31]; char user_phone[31];
}dbUser; }dbUser;
long lSelectUserInfo() int main(int argc, char *argv[])
{ {
dbUser stUser; dbUser stUser;
SATvm *pstSavm = (SATvm *)pGetSATvm(); SATvm *pstSavm = (SATvm *)pGetSATvm();
@ -21,34 +21,26 @@ long lSelectUserInfo()
/* 初始化TBL_USER_INFO表每张表都需要初始化一次, 对于表重建后,需要重新初始化一次。*/ /* 初始化TBL_USER_INFO表每张表都需要初始化一次, 对于表重建后,需要重新初始化一次。*/
if(RC_SUCC != lInitSATvm(pstSavm, TBL_USER_INFO)) if(RC_SUCC != lInitSATvm(pstSavm, TBL_USER_INFO))
{ {
fprintf(stderr, "init failed, err:(%d)(%s)\n", pstSavm->m_lErrno, sGetTError(pstSavm->m_lErrno)); fprintf(stderr, "init failed, err:(%d)(%s)\n", pstSavm->m_lErrno,
sGetTError(pstSavm->m_lErrno));
return RC_FAIL; return RC_FAIL;
} }
conditinit(pstSavm, stUser, TBL_USER_INFO); // 绑定变量 conditinit(pstSavm, stUser, TBL_USER_INFO); // 绑定变量
conditnum(pstSavm, stUser, acct_id, 2018053017); // 查询条件赋值 conditnum(pstSavm, stUser, acct_id, 2018053017); // 查询条件赋值
stringset(pstSavm, stUser, user_type, "1"); // 查询条件赋值 conditstr(pstSavm, stUser, user_type, "1"); // 查询条件赋值
stringset(pstSavm, stUser, user_no, "20180224"); // 查询条件赋值 conditstr(pstSavm, stUser, user_no, "20180223"); // 查询条件赋值
if(RC_SUCC != lSelect(pstSavm, (void *)&stUser)) if(RC_SUCC != lSelect(pstSavm, (void *)&stUser))
{ {
fprintf(stderr, "Select error: (%d) (%s)\n", pstSavm->m_lErrno, sGetTError(pstSavm->m_lErrno)); fprintf(stderr, "Select error: (%d) (%s)\n", pstSavm->m_lErrno,
sGetTError(pstSavm->m_lErrno));
return RC_FAIL; return RC_FAIL;
} }
fprintf(stdout, "acct_id:%ld, user_no:%s, user_type:%s, user_nm:%s, user_addr:%s, user_phone:%s\n", fprintf(stdout, "acct_id:%ld, user_no:%s, user_type:%s, user_nm:%s, "
stUser.acct_id, stUser.user_no, stUser.user_type, stUser.user_nm, stUser.user_addr, stUser.user_phone); "user_addr:%s, user_phone:%s\n", stUser.acct_id, stUser.user_no,
stUser.user_type, stUser.user_nm, stUser.user_addr, stUser.user_phone);
return RC_SUCC; return RC_SUCC;
} }
int main(int argc, char *argv[])
{
if(RC_SUCC != lSelectUserInfo())
return RC_FAIL;
return RC_SUCC;
}

View File

@ -3,25 +3,15 @@
#define TBL_USER_INFO 20 #define TBL_USER_INFO 20
typedef struct __TBL_USER_INFO int main(int argc, char *argv[])
{ {
long acct_id;
char user_no[21];
char user_type[2];
char user_nm[81];
char user_addr[161];
char user_phone[31];
}dbUser;
long lTruncateUserInfo()
{
dbUser stUser;
SATvm *pstSavm = (SATvm *)pGetSATvm(); SATvm *pstSavm = (SATvm *)pGetSATvm();
/* 初始化TBL_USER_INFO表每张表都需要初始化一次, 对于表重建后,需要重新初始化一次。*/ /* 初始化TBL_USER_INFO表每张表都需要初始化一次, 对于表重建后,需要重新初始化一次。*/
if(RC_SUCC != lInitSATvm(pstSavm, TBL_USER_INFO)) if(RC_SUCC != lInitSATvm(pstSavm, TBL_USER_INFO))
{ {
fprintf(stderr, "init failed, err:(%d)(%s)\n", pstSavm->m_lErrno, sGetTError(pstSavm->m_lErrno)); fprintf(stderr, "init failed, err:(%d)(%s)\n", pstSavm->m_lErrno,
sGetTError(pstSavm->m_lErrno));
return RC_FAIL; return RC_FAIL;
} }
@ -34,14 +24,3 @@ long lTruncateUserInfo()
return RC_SUCC; return RC_SUCC;
} }
int main(int argc, char *argv[])
{
if(RC_SUCC != lTruncateUserInfo())
return RC_FAIL;
return RC_SUCC;
}

42
demo/tvmpop.c Normal file
View File

@ -0,0 +1,42 @@
#include "tvm.h"
#include "tmain.h"
#define QUEUE_USER_INFO 21
typedef struct __QUEUE_USER_INFO
{
long acct_id;
char user_no[21];
char user_type[2];
char user_nm[81];
char user_addr[161];
char user_phone[31];
}dbUser;
int main(int argc, char *argv[])
{
dbUser stUser;
SATvm *pstSavm = (SATvm *)pGetSATvm();
if(RC_SUCC != lTvmConnect(pstSavm, "127.0.0.1", 5050, 2))
{
fprintf(stderr, "init failed, err:(%d)(%s)\n", pstSavm->m_lErrno,
sGetTError(pstSavm->m_lErrno));
return RC_FAIL;
}
queueinit(pstSavm, stUser, QUEUE_USER_INFO);
if(RC_SUCC != lTvmPop(pstSavm, (void *)&stUser, QUE_NORMAL)) // 插入记录
{
fprintf(stderr, "Pop error:(%d)(%s)\n", pstSavm->m_lErrno, sGetTError(pstSavm->m_lErrno));
return RC_FAIL;
}
vTvmDisconnect(pstSavm);
fprintf(stdout, "acct_id:%ld, user_no:%s, user_type:%s, user_nm:%s, user_addr:%s, "
"user_phone:%s\n", stUser.acct_id, stUser.user_no, stUser.user_type, stUser.user_nm,
stUser.user_addr, stUser.user_phone);
return RC_SUCC;
}

47
demo/tvmpush.c Normal file
View File

@ -0,0 +1,47 @@
#include "tvm.h"
#include "tmain.h"
#define QUEUE_USER_INFO 21
typedef struct __QUEUE_USER_INFO
{
long acct_id;
char user_no[21];
char user_type[2];
char user_nm[81];
char user_addr[161];
char user_phone[31];
}dbUser;
int main(int argc, char *argv[])
{
dbUser stUser;
SATvm *pstSavm = (SATvm *)pGetSATvm();
if(RC_SUCC != lTvmConnect(pstSavm, "127.0.0.1", 5050, 2))
{
fprintf(stderr, "init failed, err:(%d)(%s)\n", pstSavm->m_lErrno, sGetTError(pstSavm->m_lErrno));
return RC_FAIL;
}
queueinit(pstSavm, stUser, QUEUE_USER_INFO); // 绑定变量
stUser.acct_id = time(NULL); // 对结构体赋值
strcpy(stUser.user_no, "20180223"); // 对结构体赋值
strcpy(stUser.user_type, "1"); // 对结构体赋值
strcpy(stUser.user_nm, "Savens Liu"); // 对结构体赋值
strcpy(stUser.user_addr, "China"); // 对结构体赋值
strcpy(stUser.user_phone, "18672911111"); // 对结构体赋值
if(RC_SUCC != lTvmPush(pstSavm)) // 插入记录
{
fprintf(stderr, "Push error:(%d)(%s)\n", pstSavm->m_lErrno, sGetTError(pstSavm->m_lErrno));
return RC_FAIL;
}
vTvmDisconnect(pstSavm);
fprintf(stdout, "push success, effect:%d\n", pstSavm->m_lEffect);
return RC_SUCC;
}

49
demo/tvmreplace.c Normal file
View File

@ -0,0 +1,49 @@
#include "tvm.h"
#include "tmain.h"
#define TBL_USER_INFO 20
typedef struct __TBL_USER_INFO
{
long acct_id;
char user_no[21];
char user_type[2];
char user_nm[81];
char user_addr[161];
char user_phone[31];
}dbUser;
int main(int argc, char *argv[])
{
dbUser stUser, stUpd;
SATvm *pstSavm = (SATvm *)pGetSATvm();
if(RC_SUCC != lTvmConnect(pstSavm, "127.0.0.1", 5050, 2))
{
fprintf(stderr, "connect failed, err:(%d)(%s)\n", pstSavm->m_lErrno,
sGetTError(pstSavm->m_lErrno));
return RC_FAIL;
}
updateinit(pstSavm, stUpd);
conditinit(pstSavm, stUser, TBL_USER_INFO); // 绑定变量
conditstr(pstSavm, stUser, user_no, "20180529"); // 查询条件赋值
conditstr(pstSavm, stUser, user_type, "1"); // 查询条件赋值
updatestr(pstSavm, stUser, user_addr, "china"); // 查询条件赋值
updatestr(pstSavm, stUser, user_phone, "1869112XAZZ");
updatestr(pstSavm, stUser, user_nm, "DeffPuzzL"); // 查询条件赋值
updatestr(pstSavm, stUser, user_type, "1"); // 查询条件赋值
updatestr(pstSavm, stUser, user_no, "20180529"); // 查询条件赋值
if(RC_SUCC != lTvmReplace(pstSavm, (void *)&stUser))
// if(RC_SUCC != lAsyReplace(pstSavm, (void *)&stUser))
{
fprintf(stderr, "Replace error: (%d) (%s), ep(%d)\n", pstSavm->m_lErrno,
sGetTError(pstSavm->m_lErrno), pstSavm->m_lEType);
return RC_FAIL;
}
vTvmDisconnect(pstSavm);
return RC_SUCC;
}

View File

@ -13,7 +13,7 @@ typedef struct __TBL_USER_INFO
char user_phone[31]; char user_phone[31];
}dbUser; }dbUser;
long lUpdateUserInfo() int main(int argc, char *argv[])
{ {
dbUser stUser, stUpd; dbUser stUser, stUpd;
SATvm *pstSavm = (SATvm *)pGetSATvm(); SATvm *pstSavm = (SATvm *)pGetSATvm();
@ -21,32 +21,23 @@ long lUpdateUserInfo()
/* 初始化TBL_USER_INFO表每张表都需要初始化一次, 对于表重建后,需要重新初始化一次。*/ /* 初始化TBL_USER_INFO表每张表都需要初始化一次, 对于表重建后,需要重新初始化一次。*/
if(RC_SUCC != lInitSATvm(pstSavm, TBL_USER_INFO)) if(RC_SUCC != lInitSATvm(pstSavm, TBL_USER_INFO))
{ {
fprintf(stderr, "init failed, err:(%d)(%s)\n", pstSavm->m_lErrno, sGetTError(pstSavm->m_lErrno)); fprintf(stderr, "init failed, err:(%d)(%s)\n", pstSavm->m_lErrno,
sGetTError(pstSavm->m_lErrno));
return RC_FAIL; return RC_FAIL;
} }
updateinit(pstSavm, stUpd); updateinit(pstSavm, stUpd);
conditinit(pstSavm, stUser, TBL_USER_INFO); // 绑定变量 conditinit(pstSavm, stUser, TBL_USER_INFO); // 绑定变量
stringset(pstSavm, stUser, user_type, "1"); // 查询条件赋值 conditstr(pstSavm, stUser, user_type, "1"); // 查询条件赋值
stringset(pstSavm, stUser, user_no, "20180224"); // 查询条件赋值 conditstr(pstSavm, stUser, user_no, "20180223"); // 查询条件赋值
stringupd(pstSavm, stUpd, user_phone, "1869112XXXX"); updatestr(pstSavm, stUpd, user_phone, "1869112XXXX");
if(RC_SUCC != lUpdate(pstSavm, (void *)&stUpd)) if(RC_SUCC != lUpdate(pstSavm, (void *)&stUpd))
{ {
fprintf(stderr, "Update error: (%d) (%s)\n", pstSavm->m_lErrno, sGetTError(pstSavm->m_lErrno)); fprintf(stderr, "Update error: (%d) (%s)\n", pstSavm->m_lErrno,
sGetTError(pstSavm->m_lErrno));
return RC_FAIL; return RC_FAIL;
} }
return RC_SUCC; return RC_SUCC;
} }
int main(int argc, char *argv[])
{
if(RC_SUCC != lUpdateUserInfo())
return RC_FAIL;
return RC_SUCC;
}

View File

@ -137,6 +137,7 @@ extern long lTvmRebuildIndex(SATvm *pstSavm, TABLE t);
extern long lTvmResetLock(SATvm *pstSavm, TABLE t); extern long lTvmResetLock(SATvm *pstSavm, TABLE t);
// asynchronous interface // asynchronous interface
extern long lAsyPush(SATvm *pstSavm);
extern long lAsyInsert(SATvm *pstSavm); extern long lAsyInsert(SATvm *pstSavm);
extern long lAsyDelete(SATvm *pstSavm); extern long lAsyDelete(SATvm *pstSavm);
extern long lAsyUpdate(SATvm *pstSavm, void *pvData); extern long lAsyUpdate(SATvm *pstSavm, void *pvData);

View File

@ -75,6 +75,7 @@ typedef long CREATE;
#define OPERAYS_DELETE 1026 #define OPERAYS_DELETE 1026
#define OPERAYS_UPDATE 1027 #define OPERAYS_UPDATE 1027
#define OPERATS_REPLACE 1028 #define OPERATS_REPLACE 1028
#define OPERAYS_QUEPUSH 1029
#define OPERATE_REPLACE 13 #define OPERATE_REPLACE 13
#define OPERATE_TRCATE 14 #define OPERATE_TRCATE 14
@ -354,11 +355,11 @@ typedef long CREATE;
p->pstVoid = (void *)&(s); \ p->pstVoid = (void *)&(s); \
}while(0); }while(0);
#define conditnull(p,d,t) do{ \ #define conditnull(p,l,t) do{ \
p->stCond.uFldcmp = 0; \ p->stCond.uFldcmp = 0; \
p->stUpdt.uFldcmp = 0; \ p->stUpdt.uFldcmp = 0; \
p->lFind = 0; \ p->lFind = 0; \
p->lSize = sizeof(d); \ p->lSize = l; \
p->tblName = t; \ p->tblName = t; \
p->pstVoid = NULL; \ p->pstVoid = NULL; \
}while(0); }while(0);
@ -370,11 +371,17 @@ typedef long CREATE;
p->pstVoid = (void *)&v; \ p->pstVoid = (void *)&v; \
}while(0); }while(0);
#define queuerbind(p,v,l,t) do{ \ #define queuebind(p,v,t) do{ \
p->lSize = l; \ p->lSize = l; \
p->tblName = t; \ p->tblName = t; \
p->pstVoid = (void *)v; \ p->pstVoid = (void *)v; \
}while(0); }while(0);
#define queuenull(p,l,t) do{ \
p->lSize = l; \
p->tblName = t; \
}while(0);
#define stringsetv(p,s,f,...) vSetCodField(&p->stCond, sizeof((s).f), (char *)(s).f - (char *)&(s)); \ #define stringsetv(p,s,f,...) vSetCodField(&p->stCond, sizeof((s).f), (char *)(s).f - (char *)&(s)); \
snprintf((s).f, sizeof((s).f), __VA_ARGS__); snprintf((s).f, sizeof((s).f), __VA_ARGS__);

View File

@ -1,5 +1,5 @@
INCDIR= -I/usr/include -I$(HOME)/include -I./ -I./include -I../include INCDIR= -I/usr/include -I$(HOME)/include -I./ -I./include -I../include
LIBDIR= -L$(HOME)/lib -L../lib -lstvm -lreadline -lm -lc -ldl -lpthread LIBDIR= -L$(HOME)/lib -L../lib -lstvm -lreadline -lm -lc -ldl -lrt -lpthread
AR=ar AR=ar
LD=ld LD=ld
LN=ln LN=ln

View File

@ -137,6 +137,52 @@ long _lPop(SATvm *pstSavm, void *pvAddr, void *pvOut, Timesp *tm)
return RC_SUCC; return RC_SUCC;
} }
/*************************************************************************************************
descriptionpop more data from queue
parameters:
tm --left time
tb --last record time
return:
true --success
false --time out
*************************************************************************************************/
bool bIsTimeOut(Timesp *tm, Timesp *tb)
{
Timesp tms;
clock_gettime(CLOCK_REALTIME, &tms);
if(tms.tv_nsec < tb->tv_nsec)
{
tb->tv_sec = tms.tv_sec - tb->tv_sec - 1;
tb->tv_nsec = 1000000000 + tms.tv_nsec - tb->tv_nsec;
}
else
{
tb->tv_sec = tms.tv_sec - tb->tv_sec;
tb->tv_nsec = tms.tv_nsec - tb->tv_nsec;
}
if(tb->tv_sec > tm->tv_sec)
return false;
if(tm->tv_nsec < tb->tv_nsec)
{
tm->tv_sec = tm->tv_sec - tb->tv_sec - 1;
tm->tv_nsec = 1000000000 + tm->tv_nsec - tb->tv_nsec;
}
else
{
tm->tv_sec = tm->tv_sec - tb->tv_sec;
tm->tv_nsec = tm->tv_nsec - tb->tv_nsec;
}
if((long)tm->tv_sec < 0)
return false;
memcpy(tb, &tms, sizeof(Timesp));
return true;
}
/************************************************************************************************* /*************************************************************************************************
descriptionpop more data from queue descriptionpop more data from queue
parameters: parameters:
@ -153,6 +199,7 @@ long _lPop(SATvm *pstSavm, void *pvAddr, void *pvOut, Timesp *tm)
long _lPops(SATvm *pstSavm, void *pvAddr, size_t lExpect, Timesp *tm, size_t *plOut, long _lPops(SATvm *pstSavm, void *pvAddr, size_t lExpect, Timesp *tm, size_t *plOut,
void **ppsvOut) void **ppsvOut)
{ {
Timesp tms;
int nPos; int nPos;
SHTruck *ps = NULL; SHTruck *ps = NULL;
extern int errno; extern int errno;
@ -164,13 +211,27 @@ long _lPops(SATvm *pstSavm, void *pvAddr, size_t lExpect, Timesp *tm, size_t
return RC_FAIL; return RC_FAIL;
} }
for (*plOut = 0; *plOut < lExpect; ) for (*plOut = 0, clock_gettime(CLOCK_REALTIME, &tms); *plOut < lExpect; )
{ {
if(!bIsTimeOut(tm, &tms))
{
pstSavm->m_lEffect = *plOut;
if(0 == pstSavm->m_lEffect)
{
TFree(*ppsvOut);
pstSavm->m_lErrno = NO_DATA_FOUND;
}
else
pstSavm->m_lErrno = MQUE_WAIT_TMO;
return RC_FAIL;
}
if(0 != Futex(&pv->m_lValid, FUTEX_WAIT, 0, tm)) if(0 != Futex(&pv->m_lValid, FUTEX_WAIT, 0, tm))
{ {
if(ETIMEDOUT == errno) if(ETIMEDOUT == errno)
{ {
if(0 == *plOut) pstSavm->m_lEffect = *plOut;
if(0 == pstSavm->m_lEffect)
{ {
TFree(*ppsvOut); TFree(*ppsvOut);
pstSavm->m_lErrno = NO_DATA_FOUND; pstSavm->m_lErrno = NO_DATA_FOUND;

View File

@ -1239,7 +1239,7 @@ long lShowTables(SATvm *pstSavm)
parameters parameters
return return
**************************************************************************************************/ **************************************************************************************************/
void vPrintAmount(int t, char *pszTable, int nValid, int nMax) void vPrintAmount(int t, uint uType, char *pszTable, int nValid, int nMax)
{ {
double dPer; double dPer;
int i, nPer; int i, nPer;
@ -1249,6 +1249,11 @@ void vPrintAmount(int t, char *pszTable, int nValid, int nMax)
dPer = nValid * 100.0 / nMax; dPer = nValid * 100.0 / nMax;
nPer = nValid * 50 / nMax > 0 ? nValid * 50 / nMax : 1; nPer = nValid * 50 / nMax > 0 ? nValid * 50 / nMax : 1;
if(SYS_TVM_SEQUE == t)
fprintf(stdout, "SEQUE:[%3d][%-20s]: [", t, pszTable);
else if(TYPE_MQUEUE == uType)
fprintf(stdout, "QUEUE:[%3d][%-20s]: [", t, pszTable);
else
fprintf(stdout, "TABLE:[%3d][%-20s]: [", t, pszTable); fprintf(stdout, "TABLE:[%3d][%-20s]: [", t, pszTable);
if(dPer < 60.00) if(dPer < 60.00)
fprintf(stdout, "\033[42;32m"); fprintf(stdout, "\033[42;32m");
@ -1318,8 +1323,8 @@ void vTableAmount()
else else
snprintf(szTable, sizeof(szTable), "%s@%s", pstIndex[i].m_szPart, pstIndex[i].m_szTable); snprintf(szTable, sizeof(szTable), "%s@%s", pstIndex[i].m_szPart, pstIndex[i].m_szTable);
vPrintAmount(pstIndex[i].m_table, szTable, lGetTblValid(pstIndex[i].m_table), vPrintAmount(pstIndex[i].m_table, pstIndex[i].m_lType, szTable,
lGetTblRow(pstIndex[i].m_table)); lGetTblValid(pstIndex[i].m_table), lGetTblRow(pstIndex[i].m_table));
vTblDisconnect(pstSavm, pstIndex[i].m_table); vTblDisconnect(pstSavm, pstIndex[i].m_table);
} }
TFree(pstIndex); TFree(pstIndex);

View File

@ -1420,6 +1420,13 @@ long lEventOperate(SATvm *pstSavm, SKCon *pstCon, TFace *pstFace, char *pvDat
if(RC_SUCC == lDelete(pstSavm)) if(RC_SUCC == lDelete(pstSavm))
pstCon->m_pstWork = pstSavm->m_pstWork; pstCon->m_pstWork = pstSavm->m_pstWork;
return RC_SUCC; return RC_SUCC;
case OPERAYS_QUEPUSH:
if(RC_SUCC != lPush(pstSavm))
{
Tlog("Asypush error, %d, %s", pstSavm->m_lErrno, sGetTError(pstSavm->m_lErrno));
pstFace->m_lRows = pstSavm->m_lEffect;
}
return RC_SUCC;
case OPERAYS_INSERT: case OPERAYS_INSERT:
pstSavm->m_bWork = pstCon->m_bWork; pstSavm->m_bWork = pstCon->m_bWork;
pstSavm->m_pstWork = pstCon->m_pstWork; pstSavm->m_pstWork = pstCon->m_pstWork;
@ -1427,13 +1434,8 @@ long lEventOperate(SATvm *pstSavm, SKCon *pstCon, TFace *pstFace, char *pvDat
pstCon->m_pstWork = pstSavm->m_pstWork; pstCon->m_pstWork = pstSavm->m_pstWork;
return RC_SUCC; return RC_SUCC;
case OPERATE_QUEPOPS: case OPERATE_QUEPOPS:
if(RC_SUCC == lPopup(pstSavm, pstFace->m_lFind, pstFace->m_lErrno, lPopup(pstSavm, pstFace->m_lFind, pstFace->m_lErrno, (size_t *)&pstFace->m_lRows,
(size_t *)&pstFace->m_lRows, (void *)&pvOut)) (void *)&pvOut);
{
pstSavm->m_lErrno = TVM_DONE_SUCC;
lData = pstFace->m_lDLen * pstFace->m_lRows;
}
pstFace->m_lErrno = pstSavm->m_lErrno; pstFace->m_lErrno = pstSavm->m_lErrno;
if(sizeof(TFace) != lSendBuffer(pstCon->m_skSock, (void *)pstFace, sizeof(TFace))) if(sizeof(TFace) != lSendBuffer(pstCon->m_skSock, (void *)pstFace, sizeof(TFace)))
{ {
@ -1441,6 +1443,7 @@ long lEventOperate(SATvm *pstSavm, SKCon *pstCon, TFace *pstFace, char *pvDat
return RC_SUCC; return RC_SUCC;
} }
lData = pstFace->m_lDLen * pstFace->m_lRows;
lSendBuffer(pstCon->m_skSock, pvOut, lData); lSendBuffer(pstCon->m_skSock, pvOut, lData);
TFree(pvOut); TFree(pvOut);
return RC_SUCC; return RC_SUCC;
@ -2240,7 +2243,7 @@ long lCacheDomain(SATvm *pstSavm, Benum eMode, long lPort)
return RC_FAIL; return RC_FAIL;
} }
conditnull(pstSavm, TDomain, SYS_TVM_DOMAIN); conditnull(pstSavm, sizeof(TDomain), SYS_TVM_DOMAIN);
decorate(pstSavm, TDomain, m_szIp, GROUP_BY | ORDER_ASC); decorate(pstSavm, TDomain, m_szIp, GROUP_BY | ORDER_ASC);
decorate(pstSavm, TDomain, m_lPort, GROUP_BY | ORDER_ASC); decorate(pstSavm, TDomain, m_lPort, GROUP_BY | ORDER_ASC);
decorate(pstSavm, TDomain, m_lGroup, GROUP_BY); decorate(pstSavm, TDomain, m_lGroup, GROUP_BY);
@ -2274,7 +2277,7 @@ long lCacheDomain(SATvm *pstSavm, Benum eMode, long lPort)
} }
TFree(pstDom); TFree(pstDom);
conditnull(pstSavm, TDomain, SYS_TVM_DOMAIN); conditnull(pstSavm, sizeof(TDomain), SYS_TVM_DOMAIN);
decorate(pstSavm, TDomain, m_table, GROUP_BY | ORDER_ASC); decorate(pstSavm, TDomain, m_table, GROUP_BY | ORDER_ASC);
if(RC_SUCC != lGroup(pstSavm, &lOut, (void *)&pstDom)) if(RC_SUCC != lGroup(pstSavm, &lOut, (void *)&pstDom))
{ {
@ -2470,6 +2473,7 @@ long lBootLocal(SATvm *pstSavm, TBoot *pstBoot, Benum eMode)
} }
} }
fflush(stdout);
fprintf(stdout, " process %s id=%d ... success\n", TVM_LOCAL_SERV, getpid()); fprintf(stdout, " process %s id=%d ... success\n", TVM_LOCAL_SERV, getpid());
fflush(stdout); fflush(stdout);
@ -4100,6 +4104,7 @@ void* pProtocaJava(SATvm *pstSavm, void *pstVoid, TFace *pstFace, void *pvBuf
switch(pstFace->m_enum) switch(pstFace->m_enum)
{ {
case OPERAYS_QUEPUSH:
case OPERATE_QUEPUSH: case OPERATE_QUEPUSH:
case OPERATE_INSERT: case OPERATE_INSERT:
return pvBuffer; return pvBuffer;
@ -4235,6 +4240,7 @@ void* pParsePacket(SATvm *pstSavm, void *pstVoid, TFace *pstFace, void *pvBuf
{ {
case OPERAYS_INSERT: case OPERAYS_INSERT:
case OPERATE_INSERT: case OPERATE_INSERT:
case OPERAYS_QUEPUSH:
case OPERATE_QUEPUSH: case OPERATE_QUEPUSH:
return memcpy(pstVoid, pvData, pstFace->m_lDLen); return memcpy(pstVoid, pvData, pstFace->m_lDLen);
case OPERAYS_UPDATE: case OPERAYS_UPDATE:
@ -4385,6 +4391,9 @@ long lTvmPopup(SATvm *pstSavm, size_t lExpect, time_t lTime, size_t *plOut, v
return RC_FAIL; return RC_FAIL;
} }
// longest waiting time is 10 min
lTime = lTime > 600 ? 600 : lTime;
pstRun = (RunTime *)pGetRunTime(pstSavm, 0); pstRun = (RunTime *)pGetRunTime(pstSavm, 0);
if(!pstRun->pstVoid) if(!pstRun->pstVoid)
{ {
@ -4413,7 +4422,7 @@ long lTvmPopup(SATvm *pstSavm, size_t lExpect, time_t lTime, size_t *plOut, v
} }
pstSavm->m_lErrno = pstFace->m_lErrno; pstSavm->m_lErrno = pstFace->m_lErrno;
if(0 != pstSavm->m_lErrno) if(0 != pstSavm->m_lErrno && 0 == pstFace->m_lRows)
return RC_FAIL; return RC_FAIL;
pstRun->m_lRowSize = pstSavm->lSize * pstFace->m_lRows; pstRun->m_lRowSize = pstSavm->lSize * pstFace->m_lRows;
@ -4848,6 +4857,54 @@ long lAsyInsert(SATvm *pstSavm)
return RC_SUCC; return RC_SUCC;
} }
/*************************************************************************************************
descriptionAPI - push by asynch
parameters:
pstSavm --stvm handle
return:
RC_SUCC --success
RC_FAIL --failure
*************************************************************************************************/
long lAsyPush(SATvm *pstSavm)
{
RunTime *pstRun;
TFace *pstFace;
uint lWrite = sizeof(TFace);
if(!pstSavm || !pstSavm->pstVoid)
{
pstSavm->m_lErrno = CONDIT_IS_NIL;
return RC_FAIL;
}
pstRun = (RunTime *)pGetRunTime(pstSavm, 0);
if(!pstRun->pstVoid)
{
pstSavm->m_lErrno = DOM_NOT_INITL;
return RC_FAIL;
}
pstFace = (TFace *)pstRun->pstVoid;
pstFace->m_lFind = pstSavm->lFind;
pstFace->m_lDLen = pstSavm->lSize;
pstFace->m_lErrno = TVM_DONE_SUCC;
pstFace->m_enum = OPERAYS_QUEPUSH;
pstFace->m_table = pstSavm->tblName;
pstFace->m_lRows = pstSavm->lSize;
lWrite = pstFace->m_lRows + sizeof(TFace);
checkbuffer(pstSavm, pstRun, 1);
memcpy(pstRun->pstVoid + sizeof(TFace), pstSavm->pstVoid, pstSavm->lSize);
if(lWrite != lSendBuffer(pstSavm->m_skSock, (void *)pstRun->pstVoid, lWrite))
{
pstSavm->m_lErrno = SOCK_COM_EXCP;
return RC_FAIL;
}
return RC_SUCC;
}
/************************************************************************************************* /*************************************************************************************************
descriptionAPI - push descriptionAPI - push
parameters: parameters:

View File

@ -4,8 +4,8 @@ MAXTABLE=255
MAXFILED=3000 MAXFILED=3000
MAXDOMAIN=1024 MAXDOMAIN=1024
MAXSEQUE=1024 MAXSEQUE=1024
#SERVER_EXEC=4 SERVER_EXEC=4
SERVER_EXEC=1 #SERVER_EXEC=1
DEPLOY=cluster DEPLOY=cluster
#DEPLOY=local #DEPLOY=local
SERVER_PORT=5050 SERVER_PORT=5050