forked from apache/flink
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FLINK-9377] [core] (part 6) Introduce TypeSerializerSnapshot for a s…
…moother upgrade path This commit deprecates TypeSerializerConfigSnapshot, and introduces a TypeSerializerSnapshot interface which will eventually be the new replacement. The now-deprecated TypeSerializerConfigSnapshot differentiates in that when being written, it wil still write along with it the prior serializer and return that when attempting to restore the prior serializer. Implementations which are upgraded to directly implement the new TypeSerializerSnapshot interface are strictly required to implement the restoreSerializer() method. Therefore, once upgraded, the prior serializer is no longer written.
- Loading branch information
Showing
59 changed files
with
1,134 additions
and
699 deletions.
There are no files selected for viewing
134 changes: 0 additions & 134 deletions
134
...rc/main/java/org/apache/flink/api/common/typeutils/BackwardsCompatibleConfigSnapshot.java
This file was deleted.
Oops, something went wrong.
99 changes: 99 additions & 0 deletions
99
...ain/java/org/apache/flink/api/common/typeutils/BackwardsCompatibleSerializerSnapshot.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,99 @@ | ||
/* | ||
* 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 | ||
* | ||
* 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.api.common.typeutils; | ||
|
||
import org.apache.flink.annotation.Internal; | ||
import org.apache.flink.core.memory.DataInputView; | ||
import org.apache.flink.core.memory.DataOutputView; | ||
import org.apache.flink.util.Preconditions; | ||
|
||
import javax.annotation.Nonnull; | ||
import java.io.IOException; | ||
|
||
/** | ||
* A utility {@link TypeSerializerConfigSnapshot} that is used for backwards compatibility purposes. | ||
* | ||
* <p>In older versions of Flink (<= 1.2), we only wrote serializers and not their corresponding snapshots. | ||
* This class serves as a wrapper around the restored serializer instances. | ||
* | ||
* @param <T> the data type that the wrapped serializer instance serializes. | ||
*/ | ||
@Internal | ||
public class BackwardsCompatibleSerializerSnapshot<T> implements TypeSerializerSnapshot<T> { | ||
|
||
/** | ||
* The serializer instance written in savepoints. | ||
*/ | ||
@Nonnull | ||
private TypeSerializer<T> serializerInstance; | ||
|
||
public BackwardsCompatibleSerializerSnapshot(TypeSerializer<T> serializerInstance) { | ||
this.serializerInstance = Preconditions.checkNotNull(serializerInstance); | ||
} | ||
|
||
@Override | ||
public void write(DataOutputView out) throws IOException { | ||
throw new UnsupportedOperationException( | ||
"This is a dummy config snapshot used only for backwards compatibility."); | ||
} | ||
|
||
@Override | ||
public void read(int version, DataInputView in, ClassLoader userCodeClassLoader) throws IOException { | ||
throw new UnsupportedOperationException( | ||
"This is a dummy config snapshot used only for backwards compatibility."); | ||
} | ||
|
||
@Override | ||
public int getCurrentVersion() { | ||
throw new UnsupportedOperationException( | ||
"This is a dummy config snapshot used only for backwards compatibility."); | ||
} | ||
|
||
@Override | ||
public TypeSerializer<T> restoreSerializer() { | ||
return serializerInstance; | ||
} | ||
|
||
@Override | ||
public <NS extends TypeSerializer<T>> TypeSerializerSchemaCompatibility<T, NS> resolveSchemaCompatibility(NS newSerializer) { | ||
// if there is no configuration snapshot to check against, | ||
// then we can only assume that the new serializer is compatible as is | ||
return TypeSerializerSchemaCompatibility.compatibleAsIs(); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return serializerInstance.hashCode(); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
|
||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
|
||
BackwardsCompatibleSerializerSnapshot<?> that = (BackwardsCompatibleSerializerSnapshot<?>) o; | ||
|
||
return that.serializerInstance.equals(serializerInstance); | ||
} | ||
} |
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
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
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
Oops, something went wrong.