Skip to content

Commit ef91cfe

Browse files
committed
concurrent resume upload add reporter
1 parent 74d7cbf commit ef91cfe

File tree

15 files changed

+247
-172
lines changed

15 files changed

+247
-172
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1100"
4+
version = "1.3">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "YES"
13+
buildForArchiving = "YES"
14+
buildForAnalyzing = "YES">
15+
<BuildableReference
16+
BuildableIdentifier = "primary"
17+
BlueprintIdentifier = "93D2301E1C86D7F700434F6D"
18+
BuildableName = "QiniuDemo.app"
19+
BlueprintName = "QiniuDemo"
20+
ReferencedContainer = "container:QiniuDemo.xcodeproj">
21+
</BuildableReference>
22+
</BuildActionEntry>
23+
</BuildActionEntries>
24+
</BuildAction>
25+
<TestAction
26+
buildConfiguration = "Debug"
27+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
28+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
shouldUseLaunchSchemeArgsEnv = "YES">
30+
<Testables>
31+
</Testables>
32+
</TestAction>
33+
<LaunchAction
34+
buildConfiguration = "Debug"
35+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
36+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
37+
launchStyle = "0"
38+
useCustomWorkingDirectory = "NO"
39+
ignoresPersistentStateOnLaunch = "NO"
40+
debugDocumentVersioning = "YES"
41+
debugServiceExtension = "internal"
42+
allowLocationSimulation = "YES">
43+
<BuildableProductRunnable
44+
runnableDebuggingMode = "0">
45+
<BuildableReference
46+
BuildableIdentifier = "primary"
47+
BlueprintIdentifier = "93D2301E1C86D7F700434F6D"
48+
BuildableName = "QiniuDemo.app"
49+
BlueprintName = "QiniuDemo"
50+
ReferencedContainer = "container:QiniuDemo.xcodeproj">
51+
</BuildableReference>
52+
</BuildableProductRunnable>
53+
</LaunchAction>
54+
<ProfileAction
55+
buildConfiguration = "Release"
56+
shouldUseLaunchSchemeArgsEnv = "YES"
57+
savedToolIdentifier = ""
58+
useCustomWorkingDirectory = "NO"
59+
debugDocumentVersioning = "YES">
60+
<BuildableProductRunnable
61+
runnableDebuggingMode = "0">
62+
<BuildableReference
63+
BuildableIdentifier = "primary"
64+
BlueprintIdentifier = "93D2301E1C86D7F700434F6D"
65+
BuildableName = "QiniuDemo.app"
66+
BlueprintName = "QiniuDemo"
67+
ReferencedContainer = "container:QiniuDemo.xcodeproj">
68+
</BuildableReference>
69+
</BuildableProductRunnable>
70+
</ProfileAction>
71+
<AnalyzeAction
72+
buildConfiguration = "Debug">
73+
</AnalyzeAction>
74+
<ArchiveAction
75+
buildConfiguration = "Release"
76+
revealArchiveInOrganizer = "YES">
77+
</ArchiveAction>
78+
</Scheme>

QiniuSDK.xcodeproj/project.pbxproj

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,9 @@
1717
93D01E661C7065C200E7F47C /* QNPHAssetResource.m in Sources */ = {isa = PBXBuildFile; fileRef = 93D01E631C7065C200E7F47C /* QNPHAssetResource.m */; };
1818
A31ADA71DBBF1F4D8A065061 /* libPods-QiniuSDK_Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 73B66D8E78B0B3A0BEEA45A6 /* libPods-QiniuSDK_Mac.a */; };
1919
BA8408541BE251010093B013 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BA8408521BE250C80093B013 /* SystemConfiguration.framework */; };
20-
CC3F321C22C0CC3700F23681 /* QNReportConfig.h in Headers */ = {isa = PBXBuildFile; fileRef = CC3F321A22C0CC3700F23681 /* QNReportConfig.h */; };
21-
CC3F321D22C0CC3700F23681 /* QNReportConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = CC3F321B22C0CC3700F23681 /* QNReportConfig.m */; };
22-
CC3F321F22C0CC3700F23681 /* QNReportConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = CC3F321B22C0CC3700F23681 /* QNReportConfig.m */; };
2320
CC3F322322C0CCDF00F23681 /* QNUploadInfoReporter.h in Headers */ = {isa = PBXBuildFile; fileRef = CC3F322122C0CCDF00F23681 /* QNUploadInfoReporter.h */; };
2421
CC3F322422C0CCDF00F23681 /* QNUploadInfoReporter.m in Sources */ = {isa = PBXBuildFile; fileRef = CC3F322222C0CCDF00F23681 /* QNUploadInfoReporter.m */; };
2522
CC3F322622C0CCDF00F23681 /* QNUploadInfoReporter.m in Sources */ = {isa = PBXBuildFile; fileRef = CC3F322222C0CCDF00F23681 /* QNUploadInfoReporter.m */; };
26-
CC4B347522C496A800130D51 /* QNReporterTest.m in Sources */ = {isa = PBXBuildFile; fileRef = CC4B347422C496A800130D51 /* QNReporterTest.m */; };
27-
CC4B347622C496A800130D51 /* QNReporterTest.m in Sources */ = {isa = PBXBuildFile; fileRef = CC4B347422C496A800130D51 /* QNReporterTest.m */; };
2823
CCC3A50822DC10CB00D835B1 /* QNConcurrentResumeUpload.h in Headers */ = {isa = PBXBuildFile; fileRef = CCC3A50622DC10CB00D835B1 /* QNConcurrentResumeUpload.h */; };
2924
CCC3A50922DC10CB00D835B1 /* QNConcurrentResumeUpload.m in Sources */ = {isa = PBXBuildFile; fileRef = CCC3A50722DC10CB00D835B1 /* QNConcurrentResumeUpload.m */; };
3025
CCC3A50A22DC10CB00D835B1 /* QNConcurrentResumeUpload.m in Sources */ = {isa = PBXBuildFile; fileRef = CCC3A50722DC10CB00D835B1 /* QNConcurrentResumeUpload.m */; };
@@ -152,8 +147,6 @@
152147
B62E937FF4E75CDD482C35E8 /* Pods-QiniuSDK_MacTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-QiniuSDK_MacTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-QiniuSDK_MacTests/Pods-QiniuSDK_MacTests.release.xcconfig"; sourceTree = "<group>"; };
153148
BA8408521BE250C80093B013 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.0.sdk/System/Library/Frameworks/SystemConfiguration.framework; sourceTree = DEVELOPER_DIR; };
154149
C1D8890E270C769A9E798A8E /* libPods-QiniuSDK_iOS.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-QiniuSDK_iOS.a"; sourceTree = BUILT_PRODUCTS_DIR; };
155-
CC3F321A22C0CC3700F23681 /* QNReportConfig.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = QNReportConfig.h; sourceTree = "<group>"; };
156-
CC3F321B22C0CC3700F23681 /* QNReportConfig.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = QNReportConfig.m; sourceTree = "<group>"; };
157150
CC3F322122C0CCDF00F23681 /* QNUploadInfoReporter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = QNUploadInfoReporter.h; sourceTree = "<group>"; };
158151
CC3F322222C0CCDF00F23681 /* QNUploadInfoReporter.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = QNUploadInfoReporter.m; sourceTree = "<group>"; };
159152
CCC3A50622DC10CB00D835B1 /* QNConcurrentResumeUpload.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = QNConcurrentResumeUpload.h; sourceTree = "<group>"; };
@@ -400,8 +393,6 @@
400393
DF609A041A58E39D00AC7297 /* QNFormUpload.m */,
401394
DF482FD61B0DA8A2000DAD98 /* QNConfiguration.h */,
402395
DF482FD71B0DA8A2000DAD98 /* QNConfiguration.m */,
403-
CC3F321A22C0CC3700F23681 /* QNReportConfig.h */,
404-
CC3F321B22C0CC3700F23681 /* QNReportConfig.m */,
405396
CC3F322122C0CCDF00F23681 /* QNUploadInfoReporter.h */,
406397
CC3F322222C0CCDF00F23681 /* QNUploadInfoReporter.m */,
407398
DF437CD71B2429E10099587B /* QNUpToken.h */,
@@ -428,7 +419,6 @@
428419
DF437CDE1B243A2C0099587B /* QNUpTokenTest.m */,
429420
FDEA88651DAC10D000D037E5 /* QNAutoZoneTest.m */,
430421
FD4FEE431F298D58003A38B8 /* QNPipelineTest.m */,
431-
CC4B347422C496A800130D51 /* QNReporterTest.m */,
432422
);
433423
path = QiniuSDKTests;
434424
sourceTree = SOURCE_ROOT;
@@ -463,7 +453,6 @@
463453
FDEA5BFE1F27A21900D9D731 /* QNPipeline.h in Headers */,
464454
DFBF63711BCCE2A600A771D8 /* QNSystem.h in Headers */,
465455
DFF126F61B63ABED0005C39C /* QNALAssetFile.h in Headers */,
466-
CC4B347722C4995100130D51 /* QiniuSDK.h in Headers */,
467456
DF437CD21B2426270099587B /* QN_GTM_Base64.h in Headers */,
468457
DF293C9E19DBC2AE00799011 /* QNUserAgent.h in Headers */,
469458
DF2CDE6719DAC6A400CE01FB /* QNVersion.h in Headers */,
@@ -480,7 +469,6 @@
480469
DFF126F11B639F3B0005C39C /* QNFile.h in Headers */,
481470
CCF661082355C5120018A41E /* QiniuSDK.h in Headers */,
482471
DFA9B63B19DF904000A15FD1 /* QNEtag.h in Headers */,
483-
CC3F321C22C0CC3700F23681 /* QNReportConfig.h in Headers */,
484472
DF2CDE5C19DAC6A400CE01FB /* QNUrlSafeBase64.h in Headers */,
485473
93D01E641C7065C200E7F47C /* QNPHAssetResource.h in Headers */,
486474
DFA9B64919E0018800A15FD1 /* QNUploadOption.h in Headers */,
@@ -710,7 +698,6 @@
710698
files = (
711699
DF2CDE5D19DAC6A400CE01FB /* QNUrlSafeBase64.m in Sources */,
712700
DFBF636E1BCCE28300A771D8 /* QNSystem.m in Sources */,
713-
CC3F321D22C0CC3700F23681 /* QNReportConfig.m in Sources */,
714701
DF0D23CF19DCE6E500D6B68F /* QNResponseInfo.m in Sources */,
715702
DFA9B63C19DF904000A15FD1 /* QNEtag.m in Sources */,
716703
DF437CD31B2426270099587B /* QN_GTM_Base64.m in Sources */,
@@ -760,7 +747,6 @@
760747
files = (
761748
DF24DDA11B63FF1800EF57E6 /* QNALAssetFile.m in Sources */,
762749
DFBF636F1BCCE28300A771D8 /* QNSystem.m in Sources */,
763-
CC3F321F22C0CC3700F23681 /* QNReportConfig.m in Sources */,
764750
DF24DDA01B63FF0E00EF57E6 /* QNFile.m in Sources */,
765751
DF2CDE5E19DAC6A400CE01FB /* QNUrlSafeBase64.m in Sources */,
766752
DF0D23D019DCE6E500D6B68F /* QNResponseInfo.m in Sources */,

QiniuSDK/Http/QNHttpDelegate.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,6 @@ typedef void (^QNInternalProgressBlock)(long long totalBytesWritten, long long t
66
typedef void (^QNCompleteBlock)(QNResponseInfo *info, NSDictionary *resp);
77
typedef BOOL (^QNCancelBlock)(void);
88

9-
typedef NS_ENUM(NSUInteger, QNUploadRequestType) {
10-
RequestType_mkblk,
11-
RequestType_bput,
12-
RequestType_mkfile,
13-
RequestType_form,
14-
};
15-
169
/**
1710
* Http 客户端接口
1811
*/

QiniuSDK/Http/QNResponseInfo.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
//
88

99
#import <Foundation/Foundation.h>
10-
#import "QNHttpDelegate.h"
1110

1211
/**
1312
* 中途取消的状态码
@@ -204,17 +203,4 @@ extern const int kQNFileError;
204203
withDuration:(double)duration
205204
withBody:(NSData *)body;
206205

207-
/**
208-
* 上报信息字符串生成api
209-
*
210-
* @param requestType 请求类型
211-
* @param bytesSent 已发送的字节数
212-
* @param fileSize 总字节数
213-
*
214-
* @return 上报信息字符串
215-
*/
216-
- (NSString *)buildUploadInfoWithRequestType:(QNUploadRequestType)requestType
217-
bytesSent:(UInt32)bytesSent
218-
fileSize:(UInt32)fileSize;
219-
220206
@end

QiniuSDK/Http/QNResponseInfo.m

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -207,23 +207,4 @@ - (BOOL)couldRetry {
207207
return (_statusCode >= 500 && _statusCode < 600 && _statusCode != 579) || _statusCode == kQNNetworkError || _statusCode == 996 || _statusCode == 406 || (_statusCode == 200 && _error != nil) || _statusCode < -1000 || self.isNotQiniu;
208208
}
209209

210-
- (NSString *)buildUploadInfoWithRequestType:(QNUploadRequestType)requestType bytesSent:(UInt32)bytesSent fileSize:(UInt32)fileSize {
211-
212-
NSArray *requestTypeItems = @[@"mkblk", @"bput", @"mkfile", @"form"];
213-
NSString *nullString = @"";
214-
NSArray *reportItems = @[
215-
[NSString stringWithFormat:@"%d", _statusCode] ? [NSString stringWithFormat:@"%d", _statusCode] : nullString,
216-
_reqId ? _reqId : nullString,
217-
_host ? _host : nullString,
218-
_serverIp ? _serverIp : nullString,
219-
nullString,
220-
[NSString stringWithFormat:@"%.1f", _duration * 1000] ? [NSString stringWithFormat:@"%.1f", _duration * 1000] : nullString,
221-
[NSString stringWithFormat:@"%llu", _timeStamp] ? [NSString stringWithFormat:@"%llu", _timeStamp] : nullString,
222-
[NSString stringWithFormat:@"%d", bytesSent] ? [NSString stringWithFormat:@"%d", bytesSent] : nullString,
223-
requestTypeItems[requestType],
224-
[NSString stringWithFormat:@"%d", fileSize] ? [NSString stringWithFormat:@"%d", fileSize] : nullString
225-
];
226-
return [reportItems componentsJoinedByString:@","];
227-
}
228-
229210
@end

QiniuSDK/QiniuSDK.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,3 @@
1616
#import "QNUploadOption.h"
1717
#import "QNUrlSafeBase64.h"
1818
#import "QNUploadInfoReporter.h"
19-
#import "QNReportConfig.h"

QiniuSDK/Storage/QNConcurrentResumeUpload.m

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#import "QNResponseInfo.h"
1414
#import "QNUrlSafeBase64.h"
1515
#import "QNCrc32.h"
16+
#import "QNUploadInfoReporter.h"
1617

1718
@interface QNConcurrentTask: NSObject
1819

@@ -325,6 +326,11 @@ - (void)putBlockWithHost:(NSString *)uphost taskQueue:(QNConcurrentTask *)task r
325326
};
326327

327328
QNCompleteBlock completionHandler = ^(QNResponseInfo *info, NSDictionary *resp) {
329+
[UploadInfoReporter recordWithRequestType:ReportType_mkblk
330+
responseInfo:info
331+
bytesSent:task.size
332+
fileSize:self.size
333+
token:self.token.token];
328334
if (info.error != nil) {
329335
if (retried >= self.config.retryMax || !info.couldRetry) {
330336
[self invalidateTasksWithErrorInfo:info resp:resp];
@@ -391,6 +397,11 @@ - (void)makeFileWithHost:(NSString *)uphost retriedTimes:(int)retried {
391397
[postData appendData:[bodyStr dataUsingEncoding:NSUTF8StringEncoding]];
392398

393399
QNCompleteBlock completionHandler = ^(QNResponseInfo *info, NSDictionary *resp) {
400+
[UploadInfoReporter recordWithRequestType:ReportType_mkfile
401+
responseInfo:info
402+
bytesSent:self.size
403+
fileSize:self.size
404+
token:self.token.token];
394405
if (info.isOK) {
395406
[self removeRecord];
396407
self.option.progressHandler(self.key, 1.0);

QiniuSDK/Storage/QNConfiguration.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
//
88

99
#import <Foundation/Foundation.h>
10-
1110
#import "QNRecorderDelegate.h"
12-
#import "QNReportConfig.h"
1311

1412
/**
1513
* 断点上传时的分块大小
@@ -27,6 +25,7 @@ typedef NSString * (^QNUrlConvert)(NSString *url);
2725

2826
@class QNConfigurationBuilder;
2927
@class QNZone;
28+
@class QNReportConfig;
3029
/**
3130
* Builder block
3231
*

QiniuSDK/Storage/QNConfiguration.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#import "QNSessionManager.h"
1212
#import "QNSystem.h"
1313
#import "QNUpToken.h"
14+
#import "QNUploadInfoReporter.h"
1415

1516
const UInt32 kQNBlockSize = 4 * 1024 * 1024;
1617

QiniuSDK/Storage/QNFormUpload.m

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,11 @@ - (void)put {
8282
};
8383
__block NSString *upHost = [_config.zone up:_token isHttps:_config.useHttps frozenDomain:nil];
8484
QNCompleteBlock complete = ^(QNResponseInfo *info, NSDictionary *resp) {
85-
[UploadInfoReporter recordWithUploadResult:[info buildUploadInfoWithRequestType:RequestType_form bytesSent:(UInt32)_data.length fileSize:(UInt32)_data.length] uploadToken:_token.token];
85+
[UploadInfoReporter recordWithRequestType:ReportType_form
86+
responseInfo:info
87+
bytesSent:(UInt32)_data.length
88+
fileSize:(UInt32)_data.length
89+
token:_token.token];
8690
if (info.isOK) {
8791
_option.progressHandler(_key, 1.0);
8892
}
@@ -99,7 +103,11 @@ - (void)put {
99103
nextHost = [_config.zone up:_token isHttps:_config.useHttps frozenDomain:nextHost];
100104
}
101105
QNCompleteBlock retriedComplete = ^(QNResponseInfo *info, NSDictionary *resp) {
102-
[UploadInfoReporter recordWithUploadResult:[info buildUploadInfoWithRequestType:RequestType_form bytesSent:(UInt32)_data.length fileSize:(UInt32)_data.length] uploadToken:_token.token];
106+
[UploadInfoReporter recordWithRequestType:ReportType_form
107+
responseInfo:info
108+
bytesSent:(UInt32)_data.length
109+
fileSize:(UInt32)_data.length
110+
token:_token.token];
103111
if (info.isOK) {
104112
_option.progressHandler(_key, 1.0);
105113
}
@@ -116,7 +124,11 @@ - (void)put {
116124
thirdHost = [_config.zone up:_token isHttps:_config.useHttps frozenDomain:nextHost];
117125
}
118126
QNCompleteBlock thirdComplete = ^(QNResponseInfo *info, NSDictionary *resp) {
119-
[UploadInfoReporter recordWithUploadResult:[info buildUploadInfoWithRequestType:RequestType_form bytesSent:(UInt32)_data.length fileSize:(UInt32)_data.length] uploadToken:_token.token];
127+
[UploadInfoReporter recordWithRequestType:ReportType_form
128+
responseInfo:info
129+
bytesSent:(UInt32)_data.length
130+
fileSize:(UInt32)_data.length
131+
token:_token.token];
120132
if (info.isOK) {
121133
_option.progressHandler(_key, 1.0);
122134
}

0 commit comments

Comments
 (0)