Skip to content

Commit be6e35b

Browse files
author
jordanqin
committed
update qcloud sdk to 1.5.69
1 parent 458762d commit be6e35b

40 files changed

+1924
-4
lines changed

QCloudFoundation/.idea/gradle.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

QCloudFoundation/foundation/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ android {
77
minSdkVersion 15
88
targetSdkVersion 28
99

10-
versionCode 10568
11-
versionName "1.5.68"
10+
versionCode 10569
11+
versionName "1.5.69"
1212

1313
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
1414

QCloudFoundation/foundation/src/main/java/com/tencent/qcloud/core/http/HttpTask.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ protected HttpResult<T> execute() throws QCloudClientException, QCloudServiceExc
260260
metrics.onHttpTaskEnd();
261261
return httpResult;
262262
} else {
263+
metrics.onHttpTaskEnd();
263264
throw serviceException;
264265
}
265266
} catch (QCloudClientException clientException) {
@@ -283,6 +284,7 @@ protected HttpResult<T> execute() throws QCloudClientException, QCloudServiceExc
283284
metrics.onHttpTaskEnd();
284285
return httpResult;
285286
} else {
287+
metrics.onHttpTaskEnd();
286288
throw clientException;
287289
}
288290
} finally {

QCloudFoundation/foundation/src/main/java/com/tencent/qcloud/core/http/HttpTaskMetrics.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ void onHttpTaskStart() {
8787
}
8888

8989
void onHttpTaskEnd() {
90-
httpTaskTookTime = System.nanoTime() - httpTaskStartTime;
90+
if(httpTaskStartTime != 0){
91+
httpTaskTookTime = System.nanoTime() - httpTaskStartTime;
92+
}
9193
}
9294

9395
void onCalculateMD5Start() {
@@ -265,7 +267,8 @@ public static HttpTaskMetrics createMetricsWithHost(String host) {
265267

266268
public void recordConnectAddress(InetAddress address) {
267269
if (address != null) {
268-
domainName = address.getHostName();
270+
// 耗时操作 要去掉
271+
// domainName = address.getHostName();
269272
connectAddress = address;
270273
}
271274
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
apply plugin: 'com.android.library'
2+
3+
android {
4+
compileSdkVersion 28
5+
6+
defaultConfig {
7+
minSdkVersion 15
8+
targetSdkVersion 28
9+
10+
versionCode 10000
11+
versionName "1.0.0"
12+
13+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
14+
consumerProguardFiles "consumer-rules.pro"
15+
}
16+
17+
buildTypes {
18+
release {
19+
minifyEnabled false
20+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
21+
}
22+
}
23+
compileOptions {
24+
sourceCompatibility JavaVersion.VERSION_1_8
25+
targetCompatibility JavaVersion.VERSION_1_8
26+
}
27+
}
28+
29+
dependencies {
30+
testImplementation 'junit:junit:4.13.2'
31+
androidTestImplementation 'com.android.support.test:runner:1.0.2'
32+
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
33+
34+
androidTestCompileOnly project(path: ':network-sonar')
35+
36+
implementation "org.minidns:minidns-hla:1.0.5"
37+
}
38+
39+
project.extensions.add('artifactId', 'qcloud-network-sonar')
40+
project.extensions.add('artifactDesc', 'the network sonar for tencent cloud sdk')
41+
project.extensions.add('archiveFilePath', 'outputs/aar/qcloud-network-sonar-release.aar')
42+
43+
44+
apply from: '../../publishMavenCentral.gradle'

QCloudFoundation/network-sonar/consumer-rules.pro

Whitespace-only changes.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
package com.tencent.qcloud.network.sonar;
2+
3+
import android.content.Context;
4+
import android.support.test.InstrumentationRegistry;
5+
import android.support.test.runner.AndroidJUnit4;
6+
import android.util.Log;
7+
8+
import com.tencent.qcloud.network.sonar.dns.DnsResult;
9+
import com.tencent.qcloud.network.sonar.ping.PingResult;
10+
import com.tencent.qcloud.network.sonar.traceroute.TracerouteResult;
11+
12+
import org.junit.Test;
13+
import org.junit.runner.RunWith;
14+
15+
import java.util.ArrayList;
16+
import java.util.List;
17+
import java.util.concurrent.LinkedBlockingQueue;
18+
import java.util.concurrent.ThreadPoolExecutor;
19+
import java.util.concurrent.TimeUnit;
20+
21+
/**
22+
* Instrumented test, which will execute on an Android device.
23+
*
24+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
25+
*/
26+
@RunWith(AndroidJUnit4.class)
27+
public class ExampleInstrumentedTest {
28+
private static ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 1, 5L, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(Integer.MAX_VALUE));
29+
static {
30+
threadPoolExecutor.allowCoreThreadTimeOut(true);
31+
}
32+
33+
@Test
34+
public void sonar() {
35+
// Context of the app under test.
36+
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
37+
38+
String url = "harmony-cos-1258344699.cos.ap-guangzhou.myqcloud.com";
39+
// String url = "taobao.com";
40+
List<SonarType> types = new ArrayList<>();
41+
types.add(SonarType.DNS);
42+
types.add(SonarType.PING);
43+
types.add(SonarType.TRACEROUTE);
44+
final TestLocker testLocker = new TestLocker();
45+
threadPoolExecutor.execute(new Runnable() {
46+
@Override
47+
public void run() {
48+
NetworkSonar.sonar(appContext, new SonarRequest(url), types, new NetworkSonarCallback() {
49+
@Override
50+
public void onSuccess(SonarResult result) {
51+
Log.d("sonar", "onSuccess: " + result.getType().toString());
52+
switch (result.getType()) {
53+
case DNS:
54+
DnsResult dnsResult = (DnsResult) result.getResult();
55+
Log.d("sonar", dnsResult.toString());
56+
break;
57+
case PING:
58+
PingResult pingResult = (PingResult) result.getResult();
59+
Log.d("sonar", pingResult.toString());
60+
break;
61+
case TRACEROUTE:
62+
TracerouteResult tracerouteResult = (TracerouteResult) result.getResult();
63+
Log.d("sonar", tracerouteResult.toString());
64+
break;
65+
}
66+
}
67+
68+
@Override
69+
public void onFail(SonarResult result) {
70+
Log.d("sonar", "onFail: " + result.getType().toString());
71+
Log.e("sonar", result.getException().getMessage(), result.getException());
72+
}
73+
74+
@Override
75+
public void onFinish(List<SonarResult> results) {
76+
Log.d("sonar", "Finish");
77+
testLocker.release();
78+
}
79+
});
80+
}
81+
});
82+
testLocker.lock();
83+
}
84+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Copyright (c) 2010-2020 Tencent Cloud. All rights reserved.
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in all
12+
* copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
* SOFTWARE.
21+
*/
22+
23+
package com.tencent.qcloud.network.sonar;
24+
25+
import java.util.concurrent.CountDownLatch;
26+
import java.util.concurrent.TimeUnit;
27+
28+
public class TestLocker {
29+
30+
private CountDownLatch locker;
31+
32+
public TestLocker(int count) {
33+
locker = new CountDownLatch(count);
34+
}
35+
36+
public TestLocker() {
37+
locker = new CountDownLatch(1);
38+
}
39+
40+
public void lock() {
41+
try {
42+
locker.await(50000, TimeUnit.MILLISECONDS);
43+
// locker.await();
44+
} catch (InterruptedException e) {
45+
e.printStackTrace();
46+
}
47+
}
48+
49+
public void lock(long timeout) {
50+
try {
51+
locker.await(timeout, TimeUnit.MILLISECONDS);
52+
} catch (InterruptedException e) {
53+
e.printStackTrace();
54+
}
55+
}
56+
57+
synchronized public void release() {
58+
59+
if (locker != null && locker.getCount() > 0) {
60+
locker.countDown();
61+
}
62+
}
63+
64+
}

0 commit comments

Comments
 (0)