|
| 1 | +/* |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one or more |
| 3 | + * contributor license agreements. See the NOTICE file distributed with |
| 4 | + * this work for additional information regarding copyright ownership. |
| 5 | + * The ASF licenses this file to You under the Apache License, Version 2.0 |
| 6 | + * (the "License"); you may not use this file except in compliance with |
| 7 | + * the License. You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * See the License for the specific language governing permissions and |
| 15 | + * limitations under the License. |
| 16 | + */ |
| 17 | + |
| 18 | +package org.apache.flink.runtime.checkpoint.channel; |
| 19 | + |
| 20 | +import org.apache.flink.api.common.JobID; |
| 21 | +import org.apache.flink.runtime.jobgraph.JobVertexID; |
| 22 | +import org.apache.flink.runtime.state.CheckpointStateOutputStream; |
| 23 | +import org.apache.flink.runtime.state.CheckpointStorageLocationReference; |
| 24 | +import org.apache.flink.runtime.state.CheckpointStorageWorkerView; |
| 25 | +import org.apache.flink.runtime.state.StreamStateHandle; |
| 26 | + |
| 27 | +import java.io.IOException; |
| 28 | + |
| 29 | +/** |
| 30 | + * The manager of ChannelStateCheckpointStream. Its responsibilities are as follows: 1. Create a new |
| 31 | + * output stream or get an old output stream for each task 2. Close the channel state output stream |
| 32 | + * and callback the success method of all tasks when all shared tasks completed checkpoint 3. Close |
| 33 | + * the channel state output stream and callback the fail method of all tasks when any tasks failed |
| 34 | + * checkpoint. |
| 35 | + */ |
| 36 | +public interface ChannelStateCheckpointStreamManager { |
| 37 | + |
| 38 | + void registerTask(JobID jobID, JobVertexID jobVertexID, int subtaskIndex); |
| 39 | + |
| 40 | + void unregisterTask(JobID jobID, JobVertexID jobVertexID, int subtaskIndex); |
| 41 | + |
| 42 | + /** Create or get a channel state output stream, and register callback. */ |
| 43 | + CheckpointStateOutputStream getOutputStream( |
| 44 | + JobID jobID, |
| 45 | + JobVertexID jobVertexID, |
| 46 | + int subtaskIndex, |
| 47 | + long checkpointId, |
| 48 | + CheckpointStorageLocationReference locationReference, |
| 49 | + CheckpointStorageWorkerView streamFactoryResolver, |
| 50 | + ChannelStateCallback callback) |
| 51 | + throws IOException; |
| 52 | + |
| 53 | + void completeCheckpoint( |
| 54 | + JobID jobID, long checkpointId, JobVertexID jobVertexID, long subtaskIndex) |
| 55 | + throws IOException; |
| 56 | + |
| 57 | + void failCheckpoint( |
| 58 | + JobID jobID, |
| 59 | + long checkpointId, |
| 60 | + JobVertexID jobVertexID, |
| 61 | + long subtaskIndex, |
| 62 | + Throwable e); |
| 63 | + |
| 64 | + /** The channel state callback. */ |
| 65 | + interface ChannelStateCallback { |
| 66 | + |
| 67 | + /** It will be called when the channel state file has been written. */ |
| 68 | + void success(StreamStateHandle stateHandle) throws IOException; |
| 69 | + |
| 70 | + /** |
| 71 | + * It will be called when any problems are encountered during the writing of the channel |
| 72 | + * state file. |
| 73 | + */ |
| 74 | + void fail(Throwable e); |
| 75 | + } |
| 76 | +} |
0 commit comments