Skip to content

Commit

Permalink
Merge pull request #41582 from Thevakumar-Luheerathan/fix-timeout-issue
Browse files Browse the repository at this point in the history
Introduce configurable timeouts for CentralClient
  • Loading branch information
Thevakumar-Luheerathan authored Nov 7, 2023
2 parents 3e17306 + c003263 commit 98d7a9d
Show file tree
Hide file tree
Showing 14 changed files with 265 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,9 @@ private static void pullPackageFromRemote(String orgName, String packageName, St
CentralAPIClient client = new CentralAPIClient(RepoUtils.getRemoteRepoURL(),
initializeProxy(settings.getProxy()), settings.getProxy().username(),
settings.getProxy().password(),
getAccessTokenOfCLI(settings));
getAccessTokenOfCLI(settings), settings.getCentral().getConnectTimeout(),
settings.getCentral().getReadTimeout(), settings.getCentral().getWriteTimeout(),
settings.getCentral().getCallTimeout());
try {
client.pullPackage(orgName, packageName, version, destination, supportedPlatform,
RepoUtils.getBallerinaVersion(), false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,9 @@ private void deprecateInCentral(String packageInfo) {
CentralAPIClient client = new CentralAPIClient(RepoUtils.getRemoteRepoURL(),
initializeProxy(settings.getProxy()), settings.getProxy().username(),
settings.getProxy().password(),
getAccessTokenOfCLI(settings));
getAccessTokenOfCLI(settings), settings.getCentral().getConnectTimeout(),
settings.getCentral().getReadTimeout(), settings.getCentral().getWriteTimeout(),
settings.getCentral().getCallTimeout());
client.deprecatePackage(packageValue, deprecationMsg,
JvmTarget.JAVA_17.code(),
RepoUtils.getBallerinaVersion(), this.undoFlag);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,10 @@ public void execute() {
try {
CentralAPIClient client = new CentralAPIClient(RepoUtils.getRemoteRepoURL(),
initializeProxy(settings.getProxy()), settings.getProxy().username(),
settings.getProxy().password(), getAccessTokenOfCLI(settings));
settings.getProxy().password(), getAccessTokenOfCLI(settings),
settings.getCentral().getConnectTimeout(),
settings.getCentral().getReadTimeout(), settings.getCentral().getWriteTimeout(),
settings.getCentral().getCallTimeout());
client.pullPackage(orgName, packageName, version, packagePathInBalaCache, supportedPlatform,
RepoUtils.getBallerinaVersion(), false);
if (version.equals(Names.EMPTY.getValue())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,10 @@ public void execute() {
}
CentralAPIClient client = new CentralAPIClient(RepoUtils.getRemoteRepoURL(),
initializeProxy(settings.getProxy()), settings.getProxy().username(),
settings.getProxy().password(), getAccessTokenOfCLI(settings));
settings.getProxy().password(), getAccessTokenOfCLI(settings),
settings.getCentral().getConnectTimeout(),
settings.getCentral().getReadTimeout(), settings.getCentral().getWriteTimeout(),
settings.getCentral().getCallTimeout());
if (balaPath == null) {
pushPackage(project, client);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,11 @@ private void searchInCentral(String query) {
initializeProxy(settings.getProxy()),
settings.getProxy().username(),
settings.getProxy().password(),
getAccessTokenOfCLI(settings));
getAccessTokenOfCLI(settings),
settings.getCentral().getConnectTimeout(),
settings.getCentral().getReadTimeout(),
settings.getCentral().getWriteTimeout(),
settings.getCentral().getCallTimeout());
boolean foundSearch = false;
String supportedPlatform = Arrays.stream(JvmTarget.values())
.map(target -> target.code())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,10 @@ private void pullToolFromCentral(String supportedPlatform, Path balaCacheDirPath
System.setProperty(CentralClientConstants.ENABLE_OUTPUT_STREAM, "true");
CentralAPIClient client = new CentralAPIClient(RepoUtils.getRemoteRepoURL(),
initializeProxy(settings.getProxy()), settings.getProxy().username(),
settings.getProxy().password(), getAccessTokenOfCLI(settings));
settings.getProxy().password(), getAccessTokenOfCLI(settings),
settings.getCentral().getConnectTimeout(),
settings.getCentral().getReadTimeout(), settings.getCentral().getWriteTimeout(),
settings.getCentral().getCallTimeout());
String[] toolInfo = client.pullTool(toolId, version, balaCacheDirPath, supportedPlatform,
RepoUtils.getBallerinaVersion(), false);
boolean isPulled = Boolean.parseBoolean(toolInfo[0]);
Expand Down Expand Up @@ -574,7 +577,10 @@ private void searchToolsInCentral(String keyword) {
}
CentralAPIClient client = new CentralAPIClient(RepoUtils.getRemoteRepoURL(),
initializeProxy(settings.getProxy()), settings.getProxy().username(),
settings.getProxy().password(), getAccessTokenOfCLI(settings));
settings.getProxy().password(), getAccessTokenOfCLI(settings),
settings.getCentral().getConnectTimeout(),
settings.getCentral().getReadTimeout(), settings.getCentral().getWriteTimeout(),
settings.getCentral().getCallTimeout());
boolean foundTools = false;
String supportedPlatform = Arrays.stream(JvmTarget.values())
.map(JvmTarget::code)
Expand Down Expand Up @@ -726,7 +732,10 @@ private String getLatestVersionForUpdateCommand(String supportedPlatforms, BalTo
System.setProperty(CentralClientConstants.ENABLE_OUTPUT_STREAM, "true");
CentralAPIClient client = new CentralAPIClient(RepoUtils.getRemoteRepoURL(),
initializeProxy(settings.getProxy()), settings.getProxy().username(),
settings.getProxy().password(), getAccessTokenOfCLI(settings));
settings.getProxy().password(), getAccessTokenOfCLI(settings),
settings.getCentral().getConnectTimeout(),
settings.getCentral().getReadTimeout(), settings.getCentral().getWriteTimeout(),
settings.getCentral().getCallTimeout());
List<String> versions = client.getPackageVersions(tool.org(), tool.name(), supportedPlatforms,
RepoUtils.getBallerinaVersion());
return getLatestVersion(versions, tool.version());
Expand Down
Loading

0 comments on commit 98d7a9d

Please sign in to comment.