org.apache.flink.runtime.state.gemini.engine.vm.EvictablePagePool 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.vm;
import org.apache.flink.runtime.state.gemini.engine.GRegion;
import org.apache.flink.runtime.state.gemini.engine.page.PageAddress;
import java.util.List;
import java.util.Set;
/**
* valid page pool contains pages which could be evicted.
*/
public interface EvictablePagePool {
/**
* remove page from this pool.
*
* @param pageAddress The actual PageAddress, either PageAddressCompositeImpl or PageAddressSingleImpl.
* @return true if exist.
*/
boolean remove(PageAddress pageAddress);
/**
* add page to this pool.
*
* @param pageAddress The actual PageAddress, either PageAddressCompositeImpl or PageAddressSingleImpl.
* @param gRegion gRegion instance.
*/
void add(PageAddress pageAddress, GRegion gRegion);
/**
* check if this page is in this pool.
*
* @param pageAddress The actual PageAddress, either PageAddressCompositeImpl or PageAddressSingleImpl.
* @return true if exist.
*/
boolean containsPage(PageAddress pageAddress);
/**
* get sorted list from this pool. coldest page is first.
*
* @return a sorted list.
*/
List getSortedList();
/**
* the total pages count in this pool.
*
* @return total number of pages in this pool.
*/
int size();
/**
* the total pages size in this pool.
*
* @return total size of pages in this pool.
*/
long dataSize();
/**
* fill pool.
*
* @param regions all regions.
* @return whether launch a worker to fill pool.
*/
boolean tryFillPool(Set regions);
void shutdown();
/**
* subPage has flushed, call this method to let pool reduce the related size.
* must ensure invoke is thread safe.
*
* @param pageAddress pageAddressComposite
* @param curFlushedSize subPage size belong to this pageAddressComposite.
*/
void partialSubPageFlush(PageAddress pageAddress, int curFlushedSize);
/**
* resolve Comparison method violates its general contract.
*/
class SortedEntry {
final PageAddress pageAddress;
final double score;
final GRegion region;
public SortedEntry(PageAddress pa, GRegion region, double score) {
this.pageAddress = pa;
this.region = region;
this.score = score;
}
public double getScore() {
return score;
}
}
}