Samrat002 commented on code in PR #27187: URL: https://github.com/apache/flink/pull/27187#discussion_r2808903196
########## flink-filesystems/flink-s3-fs-native/src/main/java/org/apache/flink/fs/s3native/writer/NativeS3Recoverable.java: ########## @@ -0,0 +1,126 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.fs.s3native.writer; + +import org.apache.flink.core.fs.RecoverableWriter; + +import javax.annotation.Nullable; + +import java.util.ArrayList; +import java.util.List; + +import static org.apache.flink.util.Preconditions.checkArgument; +import static org.apache.flink.util.Preconditions.checkNotNull; + +public final class NativeS3Recoverable + implements RecoverableWriter.ResumeRecoverable, RecoverableWriter.CommitRecoverable { + + private final String uploadId; + private final String objectName; + private final List<PartETag> parts; + @Nullable private final String lastPartObject; + private long numBytesInParts; + private long lastPartObjectLength; + + public NativeS3Recoverable( + String objectName, String uploadId, List<PartETag> parts, long numBytesInParts) { + this(objectName, uploadId, parts, numBytesInParts, null, -1L); + } + + public NativeS3Recoverable( + String objectName, + String uploadId, + List<PartETag> parts, + long numBytesInParts, + @Nullable String lastPartObject, + long lastPartObjectLength) { + checkArgument(numBytesInParts >= 0L); + checkArgument(lastPartObject == null || lastPartObjectLength > 0L); Review Comment: Good catch on the mutability concern. I've made both numBytesInParts and lastPartObjectLength final . To clarify the valid states: 1. `lastPartObject == null` — Yes, this is valid. It means all data has been uploaded as complete multipart parts with no trailing data pending. In this case lastPartObjectLength is set to -1 (by the convenience constructor) and is ignored. 2. `lastPartObject != null && lastPartObjectLength > 0` — Valid. There's a temporary S3 object holding data smaller than the minimum part size, waiting to be included in the final commit. 3. `lastPartObject != null && lastPartObjectLength == 0` — Invalid, rejected by the precondition. A trailing S3 object with zero bytes would be meaningless. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
