zuston commented on a change in pull request #18157: URL: https://github.com/apache/flink/pull/18157#discussion_r790244517
########## File path: flink-runtime/src/main/java/org/apache/flink/runtime/state/filesystem/MetadataOutputStreamWrapper.java ########## @@ -0,0 +1,78 @@ +/* + * 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.runtime.state.filesystem; + +import org.apache.flink.annotation.Internal; +import org.apache.flink.core.fs.FSDataOutputStream; + +import java.io.IOException; + +/** The wrapper manages metadata output stream close and commit. */ +@Internal +public abstract class MetadataOutputStreamWrapper { + private volatile boolean closed = false; + + /** Return {@link FSDataOutputStream} to write and other operations. */ + abstract FSDataOutputStream getOutput(); + + /** + * The abstract function of once closing output stream and committing operation. It will throw + * {@link IOException} when failed and should be invoked by {@code closeForCommit()} indirectly + * instead of this function. + */ + protected abstract void closeForCommitAction() throws IOException; Review comment: Make sense. ########## File path: flink-runtime/src/main/java/org/apache/flink/runtime/state/filesystem/MetadataOutputStreamWrapper.java ########## @@ -0,0 +1,78 @@ +/* + * 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.runtime.state.filesystem; + +import org.apache.flink.annotation.Internal; +import org.apache.flink.core.fs.FSDataOutputStream; + +import java.io.IOException; + +/** The wrapper manages metadata output stream close and commit. */ +@Internal +public abstract class MetadataOutputStreamWrapper { + private volatile boolean closed = false; + + /** Return {@link FSDataOutputStream} to write and other operations. */ + abstract FSDataOutputStream getOutput(); + + /** + * The abstract function of once closing output stream and committing operation. It will throw + * {@link IOException} when failed and should be invoked by {@code closeForCommit()} indirectly + * instead of this function. + */ + protected abstract void closeForCommitAction() throws IOException; + + /** + * The abstract function of once closing output stream operation. It will throw {@link + * IOException} when failed and should be invoked by {@code close()} indirectly instead of this + * function. + */ + protected abstract void closeAction() throws IOException; + + /** + * The abstract function of aborting temporary files or doing nothing, which depends on the + * different output stream implementations. It will throw {@link IOException} when failed. + */ + abstract void abort() throws IOException; + + /** + * The function will check output stream valid. If it has been closed before, it will throw + * {@link IOException}. If not, it will invoke {@code closeForCommitAction()} and mark it + * closed. + */ + void closeForCommit() throws IOException { Review comment: Got it. ########## File path: flink-runtime/src/main/java/org/apache/flink/runtime/state/filesystem/MetadataOutputStreamWrapper.java ########## @@ -0,0 +1,78 @@ +/* + * 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.runtime.state.filesystem; + +import org.apache.flink.annotation.Internal; +import org.apache.flink.core.fs.FSDataOutputStream; + +import java.io.IOException; + +/** The wrapper manages metadata output stream close and commit. */ +@Internal +public abstract class MetadataOutputStreamWrapper { + private volatile boolean closed = false; + + /** Return {@link FSDataOutputStream} to write and other operations. */ Review comment: Got it. -- 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]
