Repository navigation
Conversation
LMCROSSITXSADEPLOY-3312
|
| String region = ((String) credentials.get(CredentialKeys.REGION)).substring( | ||
| 4); // so we can remove the "oss-" part, because it does not work with V4 signing |
There was a problem hiding this comment.
If we receive something other than oss- this will break. Can you use replace("oss-", "")
There was a problem hiding this comment.
actually yes, so thank you :)
| 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()); |
| 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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
throw FileStorageException
| ObjectMetadata metadata = new ObjectMetadata(); | ||
| metadata.setContentLength(fileSize); | ||
| metadata.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE); | ||
| metadata.setContentDisposition(fileEntry.getName()); | ||
| metadata.setUserMetadata(ObjectStoreMapper.createFileEntryMetadata(fileEntry)); |
There was a problem hiding this comment.
i would separate it to a new method because this a long method
| .map(objectSummary -> CompletableFuture.supplyAsync(() -> fetchMetadataAndFilter(objectSummary.getKey(), predicate), | ||
| executor)) | ||
| .toList() | ||
| .stream() | ||
| .map(CompletableFuture::join) | ||
| .filter(Objects::nonNull) | ||
| .toList(); |
There was a problem hiding this comment.
why dont you do the second map right after the first one instead calling toList?
There was a problem hiding this comment.
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.
| try { | ||
| do { | ||
| listing = ossClient.listObjects(request); | ||
| pageConsumer.accept(listing.getObjectSummaries()); | ||
| request.setMarker(listing.getNextMarker()); | ||
| } while (listing.isTruncated()); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
even changed it now with a while, since with the refactor I think it is the better approach now :)
| public static final int ZERO_DELETED_FILES_FROM_OBJECT_STORE = 0; | ||
|
|
There was a problem hiding this comment.
Is this constant really needed?
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
| requests.forEach(request -> assertTrue(request.getKeys() | ||
| .size() <= 1000)); |
There was a problem hiding this comment.
Is there anywhere this ceiling is stated? We should use it here if it is.
There was a problem hiding this comment.
yes it is the limit of the batch size, just changed it with the constant we already use
LMCROSSITXSADEPLOY-3312
LMCROSSITXSADEPLOY-3312


Migrating from JClouds OS to AliCloud OS
LMCROSSITXSADEPLOY-3312