Skip to content

Commit 1445628

Browse files
authored
Merge pull request #17 from libxengine/develop
MergeV3.3
2 parents fef136f + c42cf13 commit 1445628

38 files changed

+523
-249
lines changed

XEngine_Docment/Docment_en.docx

92.4 KB
Binary file not shown.

XEngine_Docment/Docment_zh.docx

92.7 KB
Binary file not shown.

XEngine_Release/XEngine_Config/XEngine_Config.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@
3838
"XStorage":{
3939
"bResumable":1,
4040
"bUPHash":0,
41-
"nHashMode":2,
42-
"tszFileDir":"./XEngine_File"
41+
"nHashMode":2
4342
},
4443
"XProxy":{
4544
"XProxyAuth":{
@@ -76,7 +75,8 @@
7675
},
7776
"XVer":{
7877
"StorageVersion":[
79-
"3.2.0.1001 Build20211210",
78+
"3.3.0.1001 Build20220106",
79+
"3.2.0.1001 Build20211211",
8080
"3.1.0.1001 Build20211109",
8181
"3.0.0.1001 Build20211029",
8282
"2.5.0.1001 Build20210930",
Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,36 @@
11
{
2-
"tszIPAddr": "127.0.0.1",
3-
"bDistributed": 1,
4-
"LBConfig": {
5-
"nServerMode": 1
2+
"bDistributed":1,
3+
"LBConfig":{
4+
"nServerMode":1
65
},
7-
"LoadBalance": {
8-
"nUseMode": [
9-
0
10-
],
11-
"CenterAddr": [
12-
"http://192.168.1.9:5100"
13-
],
14-
"DownloadAddr": [
15-
"http://192.168.1.9:5010"
16-
],
17-
"UPLoaderAddr": [
18-
"http://192.168.1.9:5102"
19-
]
6+
"LoadBalance":{
7+
"nUseMode":[
8+
0
9+
],
10+
"CenterAddr":[
11+
"http://192.168.1.9:5100"
12+
],
13+
"DownloadAddr":[
14+
"http://192.168.1.9:5010"
15+
],
16+
"UPLoaderAddr":[
17+
"http://192.168.1.9:5102"
18+
],
19+
"StorageAddr":[
20+
{
21+
"bEnable":1,
22+
"nLevel":1,
23+
"Size":"1024MB",
24+
"XEngine_Key":"storagekey1",
25+
"XEngine_Path":"./XEngine_File"
26+
},
27+
{
28+
"bEnable":1,
29+
"nLevel":1,
30+
"Size":"1024MB",
31+
"XEngine_Key":"storagekey2",
32+
"XEngine_Path":"./XEngine_File2"
33+
}
34+
]
2035
}
2136
}
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
/*
22
Navicat Premium Data Transfer
33
4-
Source Server : 192.168.1.9
4+
Source Server : 192.168.1.12
55
Source Server Type : MySQL
6-
Source Server Version : 80025
7-
Source Host : 192.168.1.9:3306
6+
Source Server Version : 80027
7+
Source Host : 192.168.1.12:3306
88
Source Schema : XEngine_Storage
99
1010
Target Server Type : MySQL
11-
Target Server Version : 80025
11+
Target Server Version : 80027
1212
File Encoding : 65001
1313
14-
Date: 17/06/2021 17:19:07
14+
Date: 06/01/2022 10:45:33
1515
*/
1616

1717
SET NAMES utf8mb4;
@@ -23,13 +23,14 @@ SET FOREIGN_KEY_CHECKS = 0;
2323
DROP TABLE IF EXISTS `XStorage_File`;
2424
CREATE TABLE `XStorage_File` (
2525
`ID` int NOT NULL AUTO_INCREMENT COMMENT 'ID序号',
26+
`BuckKey` varchar(260) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '路径KEY',
2627
`FilePath` varchar(260) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '文件路径',
2728
`FileName` varchar(260) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '文件名称',
2829
`FileHash` varchar(260) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '文件HASH',
2930
`FileUser` varchar(260) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '文件所属用户',
3031
`FileSize` bigint NOT NULL COMMENT '文件大小',
3132
`FileTime` datetime NOT NULL COMMENT '插入时间',
3233
PRIMARY KEY (`ID`) USING BTREE
33-
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = DYNAMIC;
34+
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = DYNAMIC;
3435

3536
SET FOREIGN_KEY_CHECKS = 1;

XEngine_Source/StorageModule_APIHelp/APIHelp_Define.h

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,47 @@ extern "C" BOOL APIHelp_Distributed_RandomAddr(list<string>* pStl_ListAddr, TCHA
8383
意思:是否成功
8484
备注:
8585
*********************************************************************/
86-
extern "C" BOOL APIHelp_Distributed_FileList(list<APIHELP_LBFILEINFO>* pStl_ListParse, XSTORAGECORE_DBFILE*** pppSt_ListPacket, int* pInt_ListCount);
86+
extern "C" BOOL APIHelp_Distributed_FileList(list<APIHELP_LBFILEINFO>* pStl_ListParse, XSTORAGECORE_DBFILE*** pppSt_ListPacket, int* pInt_ListCount);
87+
/********************************************************************
88+
函数名称:APIHelp_Distributed_DLStorage
89+
函数功能:通过URLKEY得到一个对应下载地址
90+
参数.一:lpszMsgBuffer
91+
In/Out:In
92+
类型:常量字符指针
93+
可空:N
94+
意思:输入要解析的URL
95+
参数.二:pStl_ListBucket
96+
In/Out:In
97+
类型:容器指针
98+
可空:N
99+
意思:输入要解析的列表
100+
参数.三:pSt_StorageBucket
101+
In/Out:Out
102+
类型:数据结构指针
103+
可空:N
104+
意思:输出获取到的可用存储
105+
返回值
106+
类型:逻辑型
107+
意思:是否成功
108+
备注:
109+
*********************************************************************/
110+
extern "C" BOOL APIHelp_Distributed_DLStorage(LPCTSTR lpszMsgBuffer, list<XENGINE_STORAGEBUCKET>* pStl_ListBucket, XENGINE_STORAGEBUCKET* pSt_StorageBucket);
111+
/********************************************************************
112+
函数名称:APIHelp_Distributed_UPStorage
113+
函数功能:通过分布式存储列表获得一个存储地址
114+
参数.一:pStl_ListBucket
115+
In/Out:In
116+
类型:容器指针
117+
可空:N
118+
意思:输入要解析的列表
119+
参数.二:pSt_StorageBucket
120+
In/Out:Out
121+
类型:数据结构指针
122+
可空:N
123+
意思:输出获取到的可用存储
124+
返回值
125+
类型:逻辑型
126+
意思:是否成功
127+
备注:
128+
*********************************************************************/
129+
extern "C" BOOL APIHelp_Distributed_UPStorage(list<XENGINE_STORAGEBUCKET>* pStl_ListBucket, XENGINE_STORAGEBUCKET* pSt_StorageBucket);

XEngine_Source/StorageModule_APIHelp/APIHelp_Distributed/APIHelp_Distributed.cpp

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,148 @@ BOOL CAPIHelp_Distributed::APIHelp_Distributed_FileList(list<APIHELP_LBFILEINFO>
141141
*pInt_ListCount = pStl_ListParse->size();
142142
return TRUE;
143143
}
144+
/********************************************************************
145+
函数名称:APIHelp_Distributed_DLStorage
146+
函数功能:通过URLKEY得到一个对应下载地址
147+
参数.一:lpszMsgBuffer
148+
In/Out:In
149+
类型:常量字符指针
150+
可空:N
151+
意思:输入要解析的URL
152+
参数.二:pStl_ListBucket
153+
In/Out:In
154+
类型:容器指针
155+
可空:N
156+
意思:输入要解析的列表
157+
参数.三:pSt_StorageBucket
158+
In/Out:Out
159+
类型:数据结构指针
160+
可空:N
161+
意思:输出获取到的可用存储
162+
返回值
163+
类型:逻辑型
164+
意思:是否成功
165+
备注:
166+
*********************************************************************/
167+
BOOL CAPIHelp_Distributed::APIHelp_Distributed_DLStorage(LPCTSTR lpszMsgBuffer, list<XENGINE_STORAGEBUCKET>* pStl_ListBucket, XENGINE_STORAGEBUCKET* pSt_StorageBucket)
168+
{
169+
APIHelp_IsErrorOccur = FALSE;
170+
171+
if ((NULL == lpszMsgBuffer) || (NULL == pSt_StorageBucket))
172+
{
173+
APIHelp_IsErrorOccur = TRUE;
174+
APIHelp_dwErrorCode = ERROR_STORAGE_MODULE_APIHELP_PARAMENT;
175+
return FALSE;
176+
}
177+
BOOL bFound = FALSE;
178+
TCHAR tszKeyStr[128];
179+
memset(tszKeyStr, '\0', sizeof(tszKeyStr));
180+
//获得key
181+
int i = 1;
182+
int nLen = _tcslen(lpszMsgBuffer);
183+
for (; i < nLen; i++)
184+
{
185+
if ('/' == lpszMsgBuffer[i])
186+
{
187+
bFound = TRUE;
188+
memcpy(tszKeyStr, lpszMsgBuffer + 1, i - 1);
189+
break;
190+
}
191+
}
192+
if (!bFound)
193+
{
194+
APIHelp_IsErrorOccur = TRUE;
195+
APIHelp_dwErrorCode = ERROR_STORAGE_MODULE_APIHELP_NOTFOUND;
196+
return FALSE;
197+
}
198+
bFound = FALSE;
199+
//获得对应存储
200+
for (auto stl_ListIterator = pStl_ListBucket->begin(); stl_ListIterator != pStl_ListBucket->end(); stl_ListIterator++)
201+
{
202+
if (0 == _tcsncmp(tszKeyStr, stl_ListIterator->tszBuckKey, _tcslen(tszKeyStr)))
203+
{
204+
bFound = TRUE;
205+
*pSt_StorageBucket = *stl_ListIterator;
206+
break;
207+
}
208+
}
209+
if (!bFound)
210+
{
211+
APIHelp_IsErrorOccur = TRUE;
212+
APIHelp_dwErrorCode = ERROR_STORAGE_MODULE_APIHELP_NOTFOUND;
213+
return FALSE;
214+
}
215+
_tcscpy(pSt_StorageBucket->tszFileName, lpszMsgBuffer + i);
216+
return TRUE;
217+
}
218+
/********************************************************************
219+
函数名称:APIHelp_Distributed_UPStorage
220+
函数功能:通过分布式存储列表获得一个存储地址
221+
参数.一:pStl_ListBucket
222+
In/Out:In
223+
类型:容器指针
224+
可空:N
225+
意思:输入要解析的列表
226+
参数.二:pSt_StorageBucket
227+
In/Out:Out
228+
类型:数据结构指针
229+
可空:N
230+
意思:输出获取到的可用存储
231+
返回值
232+
类型:逻辑型
233+
意思:是否成功
234+
备注:
235+
*********************************************************************/
236+
BOOL CAPIHelp_Distributed::APIHelp_Distributed_UPStorage(list<XENGINE_STORAGEBUCKET>* pStl_ListBucket, XENGINE_STORAGEBUCKET* pSt_StorageBucket)
237+
{
238+
APIHelp_IsErrorOccur = FALSE;
239+
240+
if ((NULL == pStl_ListBucket) || (NULL == pSt_StorageBucket))
241+
{
242+
APIHelp_IsErrorOccur = TRUE;
243+
APIHelp_dwErrorCode = ERROR_STORAGE_MODULE_APIHELP_PARAMENT;
244+
return FALSE;
245+
}
246+
BOOL bFound = FALSE;
247+
int nLastLevel = 9999;
248+
for (auto stl_ListIterator = pStl_ListBucket->begin(); stl_ListIterator != pStl_ListBucket->end(); stl_ListIterator++)
249+
{
250+
//只处理启用的
251+
if (stl_ListIterator->bEnable)
252+
{
253+
//处理优先级
254+
if (stl_ListIterator->nLevel < nLastLevel)
255+
{
256+
int nListCount = 0;
257+
__int64u nDirCount = 0; //当前目录大小
258+
CHAR** ppListFile;
259+
SystemApi_File_EnumFile(stl_ListIterator->tszFilePath, &ppListFile, &nListCount, NULL, NULL, TRUE, 1);
260+
for (int j = 0; j < nListCount; j++)
261+
{
262+
struct __stat64 st_FStat;
263+
_stat64(ppListFile[j], &st_FStat);
264+
nDirCount += st_FStat.st_size;
265+
}
266+
BaseLib_OperatorMemory_Free((XPPPMEM)&ppListFile, nListCount);
267+
//如果当前目录大小大于设定的大小.那么忽略
268+
if (nDirCount >= APIHelp_Distributed_GetSize(stl_ListIterator->tszBuckSize))
269+
{
270+
continue;
271+
}
272+
bFound = TRUE;
273+
nLastLevel = stl_ListIterator->nLevel;
274+
*pSt_StorageBucket = *stl_ListIterator;
275+
}
276+
}
277+
}
278+
if (!bFound)
279+
{
280+
APIHelp_IsErrorOccur = TRUE;
281+
APIHelp_dwErrorCode = ERROR_STORAGE_MODULE_APIHELP_NOTFOUND;
282+
return FALSE;
283+
}
284+
return TRUE;
285+
}
144286
//////////////////////////////////////////////////////////////////////////
145287
// 保护函数
146288
//////////////////////////////////////////////////////////////////////////
@@ -199,4 +341,47 @@ BOOL CAPIHelp_Distributed::APIHelp_Distributed_FileListParse(LPCTSTR lpszMsgBuff
199341
break;
200342
}
201343
return TRUE;
344+
}
345+
/********************************************************************
346+
函数名称:APIHelp_Distributed_GetSize
347+
函数功能:获取存储设置大小
348+
参数.一:lpszMsgBuffer
349+
In/Out:In
350+
类型:常量字符指针
351+
可空:N
352+
意思:输入要获取的缓冲区
353+
返回值
354+
类型:整数型
355+
意思:获取到的大小字节
356+
备注:
357+
*********************************************************************/
358+
__int64u CAPIHelp_Distributed::APIHelp_Distributed_GetSize(LPCTSTR lpszMsgBuffer)
359+
{
360+
APIHelp_IsErrorOccur = FALSE;
361+
362+
TCHAR tszSizeStr[64];
363+
TCHAR tszUnitStr[4];
364+
365+
memset(tszSizeStr, '\0', sizeof(tszSizeStr));
366+
memset(tszUnitStr, '\0', sizeof(tszUnitStr));
367+
//分别得到数字和单位
368+
memcpy(tszSizeStr, lpszMsgBuffer, _tcslen(lpszMsgBuffer) - 2);
369+
BaseLib_OperatorString_GetLastString(lpszMsgBuffer, 2, tszUnitStr);
370+
371+
__int64u nllSize = _ttoi64(tszSizeStr);
372+
//得到单位大小
373+
if (0 == _tcsncmp(tszUnitStr, _T("KB"), 2))
374+
{
375+
nllSize = nllSize * 1024;
376+
}
377+
else if (0 == _tcsncmp(tszUnitStr, _T("MB"), 2))
378+
{
379+
nllSize = nllSize * 1024 * 1024;
380+
}
381+
else if (0 == _tcsncmp(tszUnitStr, _T("GB"), 2))
382+
{
383+
nllSize = nllSize * 1024 * 1024 * 1024;
384+
}
385+
386+
return nllSize;
202387
}

XEngine_Source/StorageModule_APIHelp/APIHelp_Distributed/APIHelp_Distributed.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ class CAPIHelp_Distributed
2121
BOOL APIHelp_Distributed_IsMode(list<int>* pStl_ListMode, int nMode);
2222
BOOL APIHelp_Distributed_RandomAddr(list<string>* pStl_ListAddr, TCHAR* ptszAddr);
2323
BOOL APIHelp_Distributed_FileList(list<APIHELP_LBFILEINFO>* pStl_ListParse, XSTORAGECORE_DBFILE*** pppSt_ListPacket, int* pInt_ListCount);
24+
BOOL APIHelp_Distributed_DLStorage(LPCTSTR lpszMsgBuffer, list<XENGINE_STORAGEBUCKET>* pStl_ListBucket, XENGINE_STORAGEBUCKET* pSt_StorageBucket);
25+
BOOL APIHelp_Distributed_UPStorage(list<XENGINE_STORAGEBUCKET>* pStl_ListBucket, XENGINE_STORAGEBUCKET* pSt_StorageBucket);
2426
protected:
2527
BOOL APIHelp_Distributed_FileListParse(LPCTSTR lpszMsgBuffer, int nMsgLen, XSTORAGECORE_DBFILE* pSt_DBFile);
28+
__int64u APIHelp_Distributed_GetSize(LPCTSTR lpszMsgBuffer);
2629
private:
2730
};

XEngine_Source/StorageModule_APIHelp/APIHelp_Error.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@
1111
// History:
1212
*********************************************************************/
1313
#define ERROR_STORAGE_MODULE_APIHELP_PARAMENT 0x0030001
14-
#define ERROR_STORAGE_MODULE_APIHELP_PARSE 0x0030002
14+
#define ERROR_STORAGE_MODULE_APIHELP_PARSE 0x0030002
15+
#define ERROR_STORAGE_MODULE_APIHELP_NOTFOUND 0x0030003

XEngine_Source/StorageModule_APIHelp/StorageModule_APIHelp.def

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ EXPORTS
55

66
APIHelp_Distributed_IsMode
77
APIHelp_Distributed_RandomAddr
8-
APIHelp_Distributed_FileList
8+
APIHelp_Distributed_FileList
9+
APIHelp_Distributed_DLStorage
10+
APIHelp_Distributed_UPStorage

0 commit comments

Comments
 (0)