Skip to content

Commit

Permalink
add sdk max connections count configuration (#121)
Browse files Browse the repository at this point in the history
fix l5 update route report inside of java sdk

update

Co-authored-by: “vintmd” <[email protected]>
  • Loading branch information
vintmd and vintmd authored Apr 28, 2023
1 parent 50db453 commit 3073028
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
10 changes: 9 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@
<organizationUrl>https://cloud.tencent.com/</organizationUrl>
<url>https://github.com/yuyang733</url>
</developer>
<developer>
<id>alantong</id>
<name>Mingda Tong</name>
<email>[email protected]</email>
<organization>Tencent Cloud</organization>
<organizationUrl>https://cloud.tencent.com/</organizationUrl>
<url>https://github.com/vintmd</url>
</developer>
</developers>

<scm>
Expand All @@ -45,7 +53,7 @@
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<hadoop.version>3.3.0</hadoop.version>
<cos_api.version>5.6.112</cos_api.version>
<cos_api.version>5.6.137.2</cos_api.version>
<google.guava.version>24.1.1-jre</google.guava.version>
<commons_lang3.version>3.1</commons_lang3.version>
<junit.version>4.8</junit.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ private void initCOSClient(URI uri, Configuration conf) throws IOException {
throw new IOException("The current version does not support L5 resolver.", e);
}
config.setEndpointResolver(l5EndpointResolver);
// used by cos java sdk to handle
config.turnOnRefreshEndpointAddrSwitch();
config.setHandlerAfterProcess(l5EndpointResolver);
}
}
} else {
Expand All @@ -217,6 +220,7 @@ private void initCOSClient(URI uri, Configuration conf) throws IOException {
CosNConfigKeys.COSN_CLIENT_SOCKET_TIMEOUTSEC,
CosNConfigKeys.DEFAULT_CLIENT_SOCKET_TIMEOUTSEC);
config.setSocketTimeout(socketTimeoutSec * 1000);

this.crc32cEnabled = conf.getBoolean(CosNConfigKeys.CRC32C_CHECKSUM_ENABLED,
CosNConfigKeys.DEFAULT_CRC32C_CHECKSUM_ENABLED);
this.completeMPUCheckEnabled = conf.getBoolean(CosNConfigKeys.COSN_COMPLETE_MPU_CHECK,
Expand Down Expand Up @@ -1817,7 +1821,7 @@ private <X> Object callCOSClientWithRetry(X request) throws CosServiceException,
if (useL5Id) {
if (l5ErrorCodeRetryIndex >= this.l5UpdateMaxRetryTimes) {
// L5上报,进行重试
l5EndpointResolver.updateRouteResult(-1);
l5EndpointResolver.handle(-1, 0);
l5ErrorCodeRetryIndex = 1;
} else {
l5ErrorCodeRetryIndex = l5ErrorCodeRetryIndex + 1;
Expand Down Expand Up @@ -1883,7 +1887,7 @@ private <X> Object callCOSClientWithRetry(X request) throws CosServiceException,
if (useL5Id) {
if (l5ErrorCodeRetryIndex >= this.l5UpdateMaxRetryTimes) {
// L5上报,进行重试
l5EndpointResolver.updateRouteResult(-1);
l5EndpointResolver.handle(-1, 0);
l5ErrorCodeRetryIndex = 1;
} else {
l5ErrorCodeRetryIndex = l5ErrorCodeRetryIndex + 1;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package org.apache.hadoop.fs.cosn;

import com.qcloud.cos.endpoint.EndpointResolver;
import com.qcloud.cos.http.HandlerAfterProcess;

public interface TencentCloudL5EndpointResolver extends EndpointResolver {
public interface TencentCloudL5EndpointResolver extends EndpointResolver, HandlerAfterProcess {
public void setModId(int modId);
public void setCmdId(int cmdId);
public void updateRouteResult(int status);
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,23 @@ public void setCmdId(int cmdId) {
}

@Override
public void updateRouteResult(int status) {
public void handle(int status, long costMs) {
// which is used by cos java sdk to refresh
if (null != l5IP && l5Port > 0) {
int startUsec = (int)(System.currentTimeMillis() - costMs);
L5API.L5QOSPacket packet = new L5API.L5QOSPacket();
packet.ip = this.l5IP;
packet.port = l5Port;
packet.cmdid = this.cmdId;
packet.modid = this.modId;
packet.start = this.l5Start;
packet.start = startUsec;

for (int i = 0; i < 5; ++i) {
L5API.updateRoute(packet, status);
}
// because inner already retry many times, give the control into the java sdk.
L5API.updateRoute(packet, status);
} else {
LOG.error("Update l5 modid: {} cmdid: {} ip: {} port {} failed.",
this.modId, this.cmdId, this.l5IP, this.l5Port);
LOG.error("Update l5 modid: {} cmdid: {} ip: {} port {}, " +
"status {}, costMs {} failed.",
this.modId, this.cmdId, this.l5IP, this.l5Port, status, costMs);
}
}

Expand Down

0 comments on commit 3073028

Please sign in to comment.