org.apache.flink.runtime.state.gemini.engine.filecompaction.FileCompactionPageTransfer Maven / Gradle / Ivy
/*
*
* * 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.filecompaction;
import org.apache.flink.runtime.state.gemini.engine.GRegionContext;
import org.apache.flink.runtime.state.gemini.engine.fs.FileManager;
import org.apache.flink.runtime.state.gemini.engine.page.PageAddress;
import org.apache.flink.shaded.netty4.io.netty.util.concurrent.EventExecutor;
import javax.annotation.Nullable;
import java.io.Closeable;
import java.util.function.BiConsumer;
/**
* Transfer pages to a new place, used for file compaction.
*/
public interface FileCompactionPageTransfer extends Closeable {
/**
* Return the file manager used to manage files used by DB Runtime.
*
* @return the file manager.
*/
FileManager getDbFileManager();
/**
* Whether the page has a valid file address.
*
* @param pageAddress the page.
* @return whether the page has a valid file address
*/
boolean hasDbFileAddress(PageAddress pageAddress);
/**
* Return the id of file used by the given page for DB Runtime.
* It's up to the implementation whether to use the local address
* or dfs address. If file address is not valid, the returned file
* id may be meaningless.
*
* @param pageAddress the page.
* @return id of the file used by the page for DB Runtime.
*/
int getDbFileId(PageAddress pageAddress);
/**
* Transfer the page to a new place.
*
* @param pageAddress address of page to transfer.
* @param gRegionContext context of region this page belongs to.
* @param eventExecutor executor used to transfer.
* @param callBack code to execute after page is transferred.
*/
void transferPage(
PageAddress pageAddress,
GRegionContext gRegionContext,
EventExecutor eventExecutor,
@Nullable BiConsumer callBack);
}