資源簡介
NativeIO.java 的源文件
代碼片段和文件信息
/**
?*?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.hadoop.io.nativeio;
import?java.io.File;
import?java.io.FileDescriptor;
import?java.io.FileInputStream;
import?java.io.FileOutputStream;
import?java.io.IOException;
import?java.io.RandomAccessFile;
import?java.lang.reflect.Field;
import?java.nio.ByteBuffer;
import?java.nio.MappedByteBuffer;
import?java.nio.channels.FileChannel;
import?java.util.Map;
import?java.util.concurrent.ConcurrentHashMap;
import?org.apache.hadoop.classification.InterfaceAudience;
import?org.apache.hadoop.classification.InterfaceStability;
import?org.apache.hadoop.conf.Configuration;
import?org.apache.hadoop.fs.CommonConfigurationKeys;
import?org.apache.hadoop.fs.Hardlink;
import?org.apache.hadoop.io.IOUtils;
import?org.apache.hadoop.io.SecureIOUtils.AlreadyExistsException;
import?org.apache.hadoop.util.NativeCodeLoader;
import?org.apache.hadoop.util.Shell;
import?org.apache.hadoop.util.PerformanceAdvisory;
import?org.apache.commons.logging.Log;
import?org.apache.commons.logging.LogFactory;
import?sun.misc.Unsafe;
import?com.google.common.annotations.VisibleForTesting;
/**
?*?JNI?wrappers?for?various?native?IO-related?calls?not?available?in?Java.?These
?*?functions?should?generally?be?used?alongside?a?fallback?to?another?more
?*?portable?mechanism.
?*/
@InterfaceAudience.Private
@InterfaceStability.Unstable
public?class?NativeIO?{
public?static?class?POSIX?{
//?Flags?for?open()?call?from?bits/fcntl.h
public?static?final?int?O_RDONLY?=?00;
public?static?final?int?O_WRONLY?=?01;
public?static?final?int?O_RDWR?=?02;
public?static?final?int?O_CREAT?=?0100;
public?static?final?int?O_EXCL?=?0200;
public?static?final?int?O_NOCTTY?=?0400;
public?static?final?int?O_TRUNC?=?01000;
public?static?final?int?O_APPEND?=?02000;
public?static?final?int?O_NONBLOCK?=?04000;
public?static?final?int?O_SYNC?=?010000;
public?static?final?int?O_ASYNC?=?020000;
public?static?final?int?O_FSYNC?=?O_SYNC;
public?static?final?int?O_NDELAY?=?O_NONBLOCK;
//?Flags?for?posix_fadvise()?from?bits/fcntl.h
/*?No?further?special?treatment.?*/
public?static?final?int?POSIX_FADV_NORMAL?=?0;
/*?Expect?random?page?references.?*/
public?static?final?int?POSIX_FA
評論
共有 條評論