1 /** 2 * Copyright The Apache Software Foundation 3 * 4 * Licensed to the Apache Software Foundation (ASF) under one or more 5 * contributor license agreements. See the NOTICE file distributed with this 6 * work for additional information regarding copyright ownership. The ASF 7 * licenses this file to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance with the License. 9 * You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, software 14 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 15 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 16 * License for the specific language governing permissions and limitations 17 * under the License. 18 */ 19 package org.apache.hadoop.hbase.io.hfile.bucket; 20 21 import java.io.IOException; 22 import java.nio.ByteBuffer; 23 24 import org.apache.hadoop.classification.InterfaceAudience; 25 26 /** 27 * A class implementing IOEngine interface could support data services for 28 * {@link BucketCache}. 29 */ 30 @InterfaceAudience.Private 31 public interface IOEngine { 32 33 /** 34 * @return true if persistent storage is supported for the cache when shutdown 35 */ 36 boolean isPersistent(); 37 38 /** 39 * Transfers data from IOEngine to the given byte buffer 40 * @param dstBuffer the given byte buffer into which bytes are to be written 41 * @param offset The offset in the IO engine where the first byte to be read 42 * @return number of bytes read 43 * @throws IOException 44 */ 45 int read(ByteBuffer dstBuffer, long offset) throws IOException; 46 47 /** 48 * Transfers data from the given byte buffer to IOEngine 49 * @param srcBuffer the given byte buffer from which bytes are to be read 50 * @param offset The offset in the IO engine where the first byte to be 51 * written 52 * @throws IOException 53 */ 54 void write(ByteBuffer srcBuffer, long offset) throws IOException; 55 56 /** 57 * Sync the data to IOEngine after writing 58 * @throws IOException 59 */ 60 void sync() throws IOException; 61 62 /** 63 * Shutdown the IOEngine 64 */ 65 void shutdown(); 66 }