forked from apache/flink
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FLINK-5041] Savepoint backwards compatibility 1.1 -> 1.2
This addresses Savepoint, TaskState, StateHandels, KeyedStateBackends. This closes apache#2781.
- Loading branch information
1 parent
a6e80da
commit af3bf83
Showing
57 changed files
with
3,823 additions
and
227 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
...src/main/java/org/apache/flink/migration/contrib/streaming/state/RocksDBStateBackend.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* 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:https://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.migration.contrib.streaming.state; | ||
|
||
import org.apache.flink.api.common.state.ValueState; | ||
import org.apache.flink.api.common.state.ValueStateDescriptor; | ||
import org.apache.flink.core.memory.DataInputView; | ||
import org.apache.flink.migration.runtime.state.AbstractStateBackend; | ||
import org.apache.flink.migration.runtime.state.KvStateSnapshot; | ||
import org.apache.flink.migration.runtime.state.StateHandle; | ||
|
||
import java.io.IOException; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
@Deprecated | ||
public class RocksDBStateBackend extends AbstractStateBackend { | ||
private static final long serialVersionUID = 1L; | ||
|
||
/** | ||
* Dummy {@link KvStateSnapshot} that holds the state of our one RocksDB data base. | ||
*/ | ||
public static class FinalFullyAsyncSnapshot implements KvStateSnapshot<Object, Object, ValueState<Object>, ValueStateDescriptor<Object>> { | ||
private static final long serialVersionUID = 1L; | ||
|
||
public final StateHandle<DataInputView> stateHandle; | ||
final long checkpointId; | ||
|
||
/** | ||
* Creates a new snapshot from the given state parameters. | ||
*/ | ||
private FinalFullyAsyncSnapshot(StateHandle<DataInputView> stateHandle, long checkpointId) { | ||
this.stateHandle = requireNonNull(stateHandle); | ||
this.checkpointId = checkpointId; | ||
} | ||
|
||
@Override | ||
public final void discardState() throws Exception { | ||
stateHandle.discardState(); | ||
} | ||
|
||
@Override | ||
public final long getStateSize() throws Exception { | ||
return stateHandle.getStateSize(); | ||
} | ||
|
||
@Override | ||
public void close() throws IOException { | ||
stateHandle.close(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 changes: 113 additions & 0 deletions
113
flink-core/src/main/java/org/apache/flink/core/fs/AbstractMultiFSDataInputStream.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
/* | ||
* 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:https://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.core.fs; | ||
|
||
import org.apache.flink.util.IOUtils; | ||
import org.apache.flink.util.Preconditions; | ||
|
||
import java.io.EOFException; | ||
import java.io.IOException; | ||
|
||
/** | ||
* Abstract base class for wrappers over multiple {@link FSDataInputStream}, which gives a contiguous view on all inner | ||
* streams and makes them look like a single stream, in which we can read, seek, etc. | ||
*/ | ||
public abstract class AbstractMultiFSDataInputStream extends FSDataInputStream { | ||
|
||
/** Inner stream for the currently accessed segment of the virtual global stream */ | ||
protected FSDataInputStream delegate; | ||
|
||
/** Position in the virtual global stream */ | ||
protected long totalPos; | ||
|
||
/** Total available bytes in the virtual global stream */ | ||
protected long totalAvailable; | ||
|
||
public AbstractMultiFSDataInputStream() { | ||
this.totalPos = 0L; | ||
} | ||
|
||
@Override | ||
public void seek(long desired) throws IOException { | ||
|
||
if(desired == totalPos) { | ||
return; | ||
} | ||
|
||
Preconditions.checkArgument(desired >= 0L); | ||
|
||
if (desired > totalAvailable) { | ||
throw new EOFException(); | ||
} | ||
|
||
IOUtils.closeQuietly(delegate); | ||
delegate = getSeekedStreamForOffset(desired); | ||
|
||
this.totalPos = desired; | ||
} | ||
|
||
@Override | ||
public long getPos() throws IOException { | ||
return totalPos; | ||
} | ||
|
||
@Override | ||
public int read() throws IOException { | ||
|
||
if (null == delegate) { | ||
return -1; | ||
} | ||
|
||
int val = delegate.read(); | ||
|
||
if (-1 == val) { | ||
IOUtils.closeQuietly(delegate); | ||
if (totalPos < totalAvailable) { | ||
delegate = getSeekedStreamForOffset(totalPos); | ||
} else { | ||
delegate = null; | ||
} | ||
return read(); | ||
} | ||
|
||
++totalPos; | ||
return val; | ||
} | ||
|
||
@Override | ||
public void close() throws IOException { | ||
IOUtils.closeQuietly(delegate); | ||
} | ||
|
||
@Override | ||
public long skip(long n) throws IOException { | ||
seek(totalPos + n); | ||
return n; | ||
} | ||
|
||
/** | ||
* Delivers a the right stream for the given global stream offset. The returned stream is already seeked to the | ||
* right local offset that correctly reflects the global offset. | ||
* | ||
* @param globalStreamOffset the global offset to which we seek | ||
* @return a sub-stream, seeked to the correct local offset w.r.t. the global offset. | ||
* @throws IOException | ||
*/ | ||
protected abstract FSDataInputStream getSeekedStreamForOffset(long globalStreamOffset) throws IOException; | ||
} |
Oops, something went wrong.