Skip to content

Commit 439deaf

Browse files
committed
added:auto now bucket size Calculate
1 parent a7f36f1 commit 439deaf

File tree

6 files changed

+82
-0
lines changed

6 files changed

+82
-0
lines changed

XEngine_Source/StorageModule_APIHelp/APIHelp_Define.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,30 @@ extern "C" bool APIHelp_Distributed_GetPathKey(list<XENGINE_STORAGEBUCKET>* pStl
180180
备注:
181181
*********************************************************************/
182182
extern "C" __int64u APIHelp_Distributed_GetSize(LPCXSTR lpszMsgBuffer);
183+
/********************************************************************
184+
函数名称:APIHelp_Distributed_SetSize
185+
函数功能:设置指定BUCKET当前大小
186+
参数.一:pStl_ListBucket
187+
In/Out:In
188+
类型:STL容器
189+
可空:N
190+
意思:输入BUCKET列表
191+
参数.二:lpszBuckKey
192+
In/Out:In
193+
类型:常量字符指针
194+
可空:N
195+
意思:输入要查询的BUCKET名称
196+
参数.三:nSize
197+
In/Out:In
198+
类型:整数型
199+
可空:N
200+
意思:支持+ - 操作
201+
返回值
202+
类型:逻辑型
203+
意思:是否成功
204+
备注:
205+
*********************************************************************/
206+
extern "C" bool APIHelp_Distributed_SetSize(list<XENGINE_STORAGEBUCKET>* pStl_ListBucket, LPCXSTR lpszBuckKey, __int64x nSize);
183207
/************************************************************************/
184208
/* 帮助函数 */
185209
/************************************************************************/

XEngine_Source/StorageModule_APIHelp/APIHelp_Distributed/APIHelp_Distributed.cpp

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,57 @@ __int64u CAPIHelp_Distributed::APIHelp_Distributed_GetSize(LPCXSTR lpszMsgBuffer
523523

524524
return nllSize;
525525
}
526+
/********************************************************************
527+
函数名称:APIHelp_Distributed_SetSize
528+
函数功能:设置指定BUCKET当前大小
529+
参数.一:pStl_ListBucket
530+
In/Out:In
531+
类型:STL容器
532+
可空:N
533+
意思:输入BUCKET列表
534+
参数.二:lpszBuckKey
535+
In/Out:In
536+
类型:常量字符指针
537+
可空:N
538+
意思:输入要查询的BUCKET名称
539+
参数.三:nSize
540+
In/Out:In
541+
类型:整数型
542+
可空:N
543+
意思:支持+ - 操作
544+
返回值
545+
类型:逻辑型
546+
意思:是否成功
547+
备注:
548+
*********************************************************************/
549+
bool CAPIHelp_Distributed::APIHelp_Distributed_SetSize(list<XENGINE_STORAGEBUCKET>* pStl_ListBucket, LPCXSTR lpszBuckKey, __int64x nSize)
550+
{
551+
APIHelp_IsErrorOccur = false;
552+
553+
if ((NULL == pStl_ListBucket) || (NULL == lpszBuckKey))
554+
{
555+
APIHelp_IsErrorOccur = true;
556+
APIHelp_dwErrorCode = ERROR_STORAGE_MODULE_APIHELP_PARAMENT;
557+
return false;
558+
}
559+
bool bFound = false;
560+
for (auto stl_ListIterator = pStl_ListBucket->begin(); stl_ListIterator != pStl_ListBucket->end(); stl_ListIterator++)
561+
{
562+
if (0 == _tcsxncmp(lpszBuckKey, stl_ListIterator->tszBuckKey, _tcsxlen(stl_ListIterator->tszBuckKey)))
563+
{
564+
stl_ListIterator->nBuckSize += nSize;
565+
bFound = true;
566+
break;
567+
}
568+
}
569+
if (!bFound)
570+
{
571+
APIHelp_IsErrorOccur = true;
572+
APIHelp_dwErrorCode = ERROR_STORAGE_MODULE_APIHELP_NOTFOUND;
573+
return false;
574+
}
575+
return true;
576+
}
526577
//////////////////////////////////////////////////////////////////////////
527578
// 保护函数
528579
//////////////////////////////////////////////////////////////////////////

XEngine_Source/StorageModule_APIHelp/APIHelp_Distributed/APIHelp_Distributed.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class CAPIHelp_Distributed
2525
bool APIHelp_Distributed_UPStorage(list<XENGINE_STORAGEBUCKET>* pStl_ListBucket, XENGINE_STORAGEBUCKET* pSt_StorageBucket, int nMode);
2626
bool APIHelp_Distributed_GetPathKey(list<XENGINE_STORAGEBUCKET>* pStl_ListBucket, LPCXSTR lpszBuckKey, XCHAR* ptszFilePath);
2727
__int64u APIHelp_Distributed_GetSize(LPCXSTR lpszMsgBuffer);
28+
bool APIHelp_Distributed_SetSize(list<XENGINE_STORAGEBUCKET>* pStl_ListBucket, LPCXSTR lpszBuckKey, __int64x nSize);
2829
protected:
2930
bool APIHelp_Distributed_FileListParse(LPCXSTR lpszMsgBuffer, int nMsgLen, XSTORAGECORE_DBFILE* pSt_DBFile);
3031
private:

XEngine_Source/StorageModule_APIHelp/StorageModule_APIHelp.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ EXPORTS
1010
APIHelp_Distributed_UPStorage
1111
APIHelp_Distributed_GetPathKey
1212
APIHelp_Distributed_GetSize
13+
APIHelp_Distributed_SetSize
1314

1415
APIHelp_Api_RangeFile
1516
APIHelp_Api_VerHash

XEngine_Source/StorageModule_APIHelp/pch.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ extern "C" __int64u APIHelp_Distributed_GetSize(LPCXSTR lpszMsgBuffer)
5959
{
6060
return m_APIDistributed.APIHelp_Distributed_GetSize(lpszMsgBuffer);
6161
}
62+
extern "C" bool APIHelp_Distributed_SetSize(list<XENGINE_STORAGEBUCKET>* pStl_ListBucket, LPCXSTR lpszBuckKey, __int64x nSize)
63+
{
64+
return m_APIDistributed.APIHelp_Distributed_SetSize(pStl_ListBucket, lpszBuckKey, nSize);
65+
}
6266
/************************************************************************/
6367
/* 帮助函数 */
6468
/************************************************************************/

XEngine_Source/XEngine_StorageApp/StorageApp_UPLoader.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,7 @@ bool XEngine_Task_HttpUPLoader(LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, in
541541
XEngine_Net_SendMsg(lpszClientAddr, tszSDBuffer, nSDLen, nNetType);
542542
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_WARN, _X("上传客户端:%s,请求上传文件成功,文件名:%s,大小:%d,数据库没有启用,不插入数据库"), lpszClientAddr, tszFileDir, nRVCount);
543543
}
544+
APIHelp_Distributed_SetSize(st_LoadbalanceCfg.st_LoadBalance.pStl_ListBucket, st_StorageBucket.tszBuckKey, st_ProtocolFile.st_ProtocolFile.nFileSize);
544545
}
545546
else
546547
{

0 commit comments

Comments
 (0)