Skip to content

Migrating from JClouds OS to AliCloud OS - #1956

Open
karrgov wants to merge 3 commits into
masterfrom
alicloud_migration
Open

karrgov wants to merge 3 commits into
masterfrom
alicloud_migration

Conversation

@karrgov

@karrgov karrgov commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Migrating from JClouds OS to AliCloud OS

LMCROSSITXSADEPLOY-3312

@sonarqubecloud

sonarqubecloud Bot commented Nov 9, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
75.4% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

Comment on lines +70 to +71
String region = ((String) credentials.get(CredentialKeys.REGION)).substring(
4); // so we can remove the "oss-" part, because it does not work with V4 signing

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we receive something other than oss- this will break. Can you use replace("oss-", "")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually yes, so thank you :)

Comment on lines +76 to +79
config.setConnectionTimeout((int) ObjectStoreConstants.ALI_OBJECT_STORE_CONNECTION_TIMEOUT_CONFIG_IN_SECONDS.toMillis());
config.setSocketTimeout((int) ObjectStoreConstants.ALI_OBJECT_STORE_SOCKET_TIMEOUT_CONFIG_IN_MINUTES.toMillis());
config.setRequestTimeoutEnabled(true);
config.setRequestTimeout((int) ObjectStoreConstants.ALI_OBJECT_STORE_REQUEST_TIMEOUT_CONFIG_IN_MINUTES.toMillis());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MiscUtil.cast

LOGGER.debug(MessageFormat.format(Messages.DELETED_FILE_WITH_ID_0_AND_SPACE_1, id, space));
} catch (OSSException | ClientException e) {
LOGGER.error(MessageFormat.format(Messages.ALI_OBJECT_STORE_OPERATION_0_FAILED_FOR_KEY_1, "deleteObject", id, describe(e)));
throw e;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Throw FileStorageException not the incomming one

} catch (OSSException | ClientException e) {
LOGGER.error(MessageFormat.format(Messages.ALI_OBJECT_STORE_CONNECTION_TEST_FAILED_FOR_BUCKET_0_ENDPOINT_1, bucketName,
endpoint, describe(e)));
throw e;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

throw FileStorageException

ossObject = ossClient.getObject(request);
} catch (OSSException | ClientException e) {
LOGGER.error(MessageFormat.format(Messages.ALI_OBJECT_STORE_OPERATION_0_FAILED_FOR_KEY_1, "getObject", id, describe(e)));
throw e;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

throw FileStorageException

} while (listing.isTruncated());
} catch (OSSException | ClientException e) {
LOGGER.error(MessageFormat.format(Messages.ALI_OBJECT_STORE_LISTING_FAILED_FOR_BUCKET_0, bucketName, describe(e)));
throw e;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

throw FileStorageException

Comment on lines +115 to +119
ObjectMetadata metadata = new ObjectMetadata();
metadata.setContentLength(fileSize);
metadata.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
metadata.setContentDisposition(fileEntry.getName());
metadata.setUserMetadata(ObjectStoreMapper.createFileEntryMetadata(fileEntry));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would separate it to a new method because this a long method

Comment on lines +276 to +282
.map(objectSummary -> CompletableFuture.supplyAsync(() -> fetchMetadataAndFilter(objectSummary.getKey(), predicate),
executor))
.toList()
.stream()
.map(CompletableFuture::join)
.filter(Objects::nonNull)
.toList();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why dont you do the second map right after the first one instead calling toList?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because since the streams in java are lazy, if I have the maps one after another then the whole thing is going to sequentially go through each element while also joining it before starting the next one - all if this because there is not going to be a termination call like a collect or toList between the maps. Thats why now when we do a termination task between the maps, the concurrent gets are all started at the same time and then we go into the "stream" where we wait for their results.

I could ve separated them into two separate streams but this seemed like was showing the intention better.

Comment on lines +337 to +342
try {
do {
listing = ossClient.listObjects(request);
pageConsumer.accept(listing.getObjectSummaries());
request.setMarker(listing.getNextMarker());
} while (listing.isTruncated());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Separate the do-while in a new method because there are nested structures.

P.S wow, haven't seen do-while in a while. no pun intended :D

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

even changed it now with a while, since with the refactor I think it is the better approach now :)

Comment on lines +26 to +27
public static final int ZERO_DELETED_FILES_FROM_OBJECT_STORE = 0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this constant really needed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think yes, since otherwise I would have a magic number and it will be not so "clean-code"

public static final String BYTES_RANGE_FORMAT = "bytes=%d-%d";

// AliCloud OSS
public static final Duration ALI_OBJECT_STORE_REQUEST_TIMEOUT_CONFIG_IN_MINUTES = Duration.ofMinutes(30);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this timeout functionally identical to AWS's AWS_OBJECT_STORE_TOTAL_TIMEOUT_CONFIG_IN_MINUTES. If so keep the naming consistency and rename it to ALI_OBJECT_STORE_TOTAL_TIMEOUT_CONFIG_IN_MINUTES.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is not actually - this is the per request timeout , while in the aws I think this is total timeout when talking about a request + its retries if there are any at all

Comment on lines +185 to +186
requests.forEach(request -> assertTrue(request.getKeys()
.size() <= 1000));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there anywhere this ceiling is stated? We should use it here if it is.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes it is the limit of the batch size, just changed it with the constant we already use

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants