Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* 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.gemini.engine.snapshot;
import org.apache.flink.api.common.typeutils.base.MapSerializer;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.core.fs.FileSystem;
import org.apache.flink.core.fs.Path;
import org.apache.flink.core.memory.DataOutputView;
import org.apache.flink.core.memory.DataOutputViewStreamWrapper;
import org.apache.flink.runtime.state.gemini.engine.GRegionID;
import org.apache.flink.runtime.state.gemini.engine.dbms.GContext;
import org.apache.flink.runtime.state.gemini.engine.fs.FileManager;
import org.apache.flink.runtime.state.gemini.engine.fs.FileMeta;
import org.apache.flink.util.Preconditions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nullable;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import static org.apache.flink.runtime.state.gemini.engine.snapshot.SnapshotMetaFile.writerFunc;
/**
* Base snapshot operation.
*/
public abstract class SnapshotOperation {
private static final Logger LOG = LoggerFactory.getLogger(SnapshotOperation.class);
protected final GContext gContext;
protected final SnapshotManager snapshotManager;
/**
* Whether to force flush page when snapshotting, mainly used when rescale.
*/
private boolean forceFlushPage = false;
SnapshotOperation(GContext gContext, SnapshotManager snapshotManager) {
this.gContext = Preconditions.checkNotNull(gContext);
this.snapshotManager = Preconditions.checkNotNull(snapshotManager);
}
public abstract SnapshotManager.PendingSnapshot createPendingSnapshot(
BackendSnapshotMeta backendSnapshotMeta,
long accessNumber);
public abstract SnapshotManager.PendingSnapshot getPendingSnapshot();
public abstract DBSnapshotResult getSnapshotResult() throws Exception;
public void setForceFlushPage(boolean forceFlushPage) {
this.forceFlushPage = forceFlushPage;
}
public boolean isForceFlushPage() {
return forceFlushPage;
}
/**
* Write region snapshot meta and snapshot page index, this method would also update file mapping.
*
* @param fileMappings each file mapping is {groupId -> fileId, (reference, size)}
* @return The offsets of regions.
* @throws IOException
*/
List writeRegionMetaAndPageIndex(
Map> tableRegionMap,
List regionSnapshots,
List