热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

java.lang.UnsatisfiedLinkError:…….io.nativeio.NativeIO$Windows.access0(Ljava/lang/String;I)Z

在利用hadoop运行MapReduce项目时,提示报错(注意最后是Z):Exceptioninthreadmainj

  在利用 hadoop 运行 MapReduce 项目时,提示报错(注意最后是Z):

Exception in thread "main" java.lang.UnsatisfiedLinkError:
org.apache.hadoop.io.nativeio.NativeIO$Windows.access0(Ljava/lang/String;I)Z

  这个主要是因为本地启动运行,需要更改源代码中的对应配置。
  在项目的根目录下(本项目为WordCount,根目录也就是java)新建包 org.apache.hadoop.io.nativeio ,添加类 NativeIO 即可。
在这里插入图片描述

package org.apache.hadoop.io.nativeio;/*** 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.*/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.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.io.SecureIOUtils.AlreadyExistsException;
import org.apache.hadoop.util.NativeCodeLoader;
import org.apache.hadoop.util.Shell;
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.hpublic static final int O_RDONLY &#61; 00;public static final int O_WRONLY &#61; 01;public static final int O_RDWR &#61; 02;public static final int O_CREAT &#61; 0100;public static final int O_EXCL &#61; 0200;public static final int O_NOCTTY &#61; 0400;public static final int O_TRUNC &#61; 01000;public static final int O_APPEND &#61; 02000;public static final int O_NONBLOCK &#61; 04000;public static final int O_SYNC &#61; 010000;public static final int O_ASYNC &#61; 020000;public static final int O_FSYNC &#61; O_SYNC;public static final int O_NDELAY &#61; O_NONBLOCK;// Flags for posix_fadvise() from bits/fcntl.h/* No further special treatment. */public static final int POSIX_FADV_NORMAL &#61; 0;/* Expect random page references. */public static final int POSIX_FADV_RANDOM &#61; 1;/* Expect sequential page references. */public static final int POSIX_FADV_SEQUENTIAL &#61; 2;/* Will need these pages. */public static final int POSIX_FADV_WILLNEED &#61; 3;/* Don&#39;t need these pages. */public static final int POSIX_FADV_DONTNEED &#61; 4;/* Data will be accessed once. */public static final int POSIX_FADV_NOREUSE &#61; 5;/** Wait upon writeout of all pages in the range before performing the* write.*/public static final int SYNC_FILE_RANGE_WAIT_BEFORE &#61; 1;/** Initiate writeout of all those dirty pages in the range which are not* presently under writeback.*/public static final int SYNC_FILE_RANGE_WRITE &#61; 2;/** Wait upon writeout of all pages in the range after performing the* write.*/public static final int SYNC_FILE_RANGE_WAIT_AFTER &#61; 4;private static final Log LOG &#61; LogFactory.getLog(NativeIO.class);private static boolean nativeLoaded &#61; false;private static boolean fadvisePossible &#61; true;private static boolean syncFileRangePossible &#61; true;static final String WORKAROUND_NON_THREADSAFE_CALLS_KEY &#61; "hadoop.workaround.non.threadsafe.getpwuid";static final boolean WORKAROUND_NON_THREADSAFE_CALLS_DEFAULT &#61; true;private static long cacheTimeout &#61; -1;private static CacheManipulator cacheManipulator &#61; new CacheManipulator();public static CacheManipulator getCacheManipulator() {return cacheManipulator;}public static void setCacheManipulator(CacheManipulator cacheManipulator) {POSIX.cacheManipulator &#61; cacheManipulator;}/*** Used to manipulate the operating system cache.*/&#64;VisibleForTestingpublic static class CacheManipulator {public void mlock(String identifier, ByteBuffer buffer, long len) throws IOException {POSIX.mlock(buffer, len);}public long getMemlockLimit() {return NativeIO.getMemlockLimit();}public long getOperatingSystemPageSize() {return NativeIO.getOperatingSystemPageSize();}public void posixFadviseIfPossible(String identifier, FileDescriptor fd, long offset, long len, int flags)throws NativeIOException {POSIX.posixFadviseIfPossible(identifier, fd, offset, len, flags);}public boolean verifyCanMlock() {return NativeIO.isAvailable();}}/*** A CacheManipulator used for testing which does not actually call* mlock. This allows many tests to be run even when the operating* system does not allow mlock, or only allows limited mlocking.*/&#64;VisibleForTestingpublic static class NoMlockCacheManipulator extends CacheManipulator {public void mlock(String identifier, ByteBuffer buffer, long len) throws IOException {LOG.info("mlocking " &#43; identifier);}public long getMemlockLimit() {return 1125899906842624L;}public long getOperatingSystemPageSize() {return 4096;}public boolean verifyCanMlock() {return true;}}static {if (NativeCodeLoader.isNativeCodeLoaded()) {try {Configuration conf &#61; new Configuration();workaroundNonThreadSafePasswdCalls &#61; conf.getBoolean(WORKAROUND_NON_THREADSAFE_CALLS_KEY,WORKAROUND_NON_THREADSAFE_CALLS_DEFAULT);initNative();nativeLoaded &#61; true;cacheTimeout &#61; conf.getLong(CommonConfigurationKeys.HADOOP_SECURITY_UID_NAME_CACHE_TIMEOUT_KEY,CommonConfigurationKeys.HADOOP_SECURITY_UID_NAME_CACHE_TIMEOUT_DEFAULT) * 1000;LOG.debug("Initialized cache for IDs to User/Group mapping with a " &#43; " cache timeout of "&#43; cacheTimeout / 1000 &#43; " seconds.");} catch (Throwable t) {// This can happen if the user has an older version of// libhadoop.so// installed - in this case we can continue without native// IO// after warningLOG.error("Unable to initialize NativeIO libraries", t);}}}/*** Return true if the JNI-based native IO extensions are available.*/public static boolean isAvailable() {return NativeCodeLoader.isNativeCodeLoaded() && nativeLoaded;}private static void assertCodeLoaded() throws IOException {if (!isAvailable()) {throw new IOException("NativeIO was not loaded");}}/** Wrapper around open(2) */public static native FileDescriptor open(String path, int flags, int mode) throws IOException;/** Wrapper around fstat(2) */private static native Stat fstat(FileDescriptor fd) throws IOException;/*** Native chmod implementation. On UNIX, it is a wrapper around chmod(2)*/private static native void chmodImpl(String path, int mode) throws IOException;public static void chmod(String path, int mode) throws IOException {if (!Shell.WINDOWS) {chmodImpl(path, mode);} else {try {chmodImpl(path, mode);} catch (NativeIOException nioe) {if (nioe.getErrorCode() &#61;&#61; 3) {throw new NativeIOException("No such file or directory", Errno.ENOENT);} else {LOG.warn(String.format("NativeIO.chmod error (%d): %s", nioe.getErrorCode(), nioe.getMessage()));throw new NativeIOException("Unknown error", Errno.UNKNOWN);}}}}/** Wrapper around posix_fadvise(2) */static native void posix_fadvise(FileDescriptor fd, long offset, long len, int flags) throws NativeIOException;/** Wrapper around sync_file_range(2) */static native void sync_file_range(FileDescriptor fd, long offset, long nbytes, int flags)throws NativeIOException;/*** Call posix_fadvise on the given file descriptor. See the manpage for* this syscall for more information. On systems where this call is not* available, does nothing.** &#64;throws NativeIOException* if there is an error with the syscall*/static void posixFadviseIfPossible(String identifier, FileDescriptor fd, long offset, long len, int flags)throws NativeIOException {if (nativeLoaded && fadvisePossible) {try {posix_fadvise(fd, offset, len, flags);} catch (UnsupportedOperationException uoe) {fadvisePossible &#61; false;} catch (UnsatisfiedLinkError ule) {fadvisePossible &#61; false;}}}/*** Call sync_file_range on the given file descriptor. See the manpage* for this syscall for more information. On systems where this call is* not available, does nothing.** &#64;throws NativeIOException* if there is an error with the syscall*/public static void syncFileRangeIfPossible(FileDescriptor fd, long offset, long nbytes, int flags)throws NativeIOException {if (nativeLoaded && syncFileRangePossible) {try {sync_file_range(fd, offset, nbytes, flags);} catch (UnsupportedOperationException uoe) {syncFileRangePossible &#61; false;} catch (UnsatisfiedLinkError ule) {syncFileRangePossible &#61; false;}}}static native void mlock_native(ByteBuffer buffer, long len) throws NativeIOException;static native void munlock_native(ByteBuffer buffer, long len) throws NativeIOException;/*** Locks the provided direct ByteBuffer into memory, preventing it from* swapping out. After a buffer is locked, future accesses will not* incur a page fault.** See the mlock(2) man page for more information.** &#64;throws NativeIOException*/static void mlock(ByteBuffer buffer, long len) throws IOException {assertCodeLoaded();if (!buffer.isDirect()) {throw new IOException("Cannot mlock a non-direct ByteBuffer");}mlock_native(buffer, len);}/*** Unlocks a locked direct ByteBuffer, allowing it to swap out of* memory. This is a no-op if the ByteBuffer was not previously locked.** See the munlock(2) man page for more information.** &#64;throws NativeIOException*/public static void munlock(ByteBuffer buffer, long len) throws IOException {assertCodeLoaded();if (!buffer.isDirect()) {throw new IOException("Cannot munlock a non-direct ByteBuffer");}munlock_native(buffer, len);}/*** Unmaps the block from memory. See munmap(2).** There isn&#39;t any portable way to unmap a memory region in Java. So we* use the sun.nio method here. Note that unmapping a memory region* could cause crashes if code continues to reference the unmapped code.* However, if we don&#39;t manually unmap the memory, we are dependent on* the finalizer to do it, and we have no idea when the finalizer will* run.** &#64;param buffer* The buffer to unmap.*/public static void munmap(MappedByteBuffer buffer) {if (buffer instanceof sun.nio.ch.DirectBuffer) {sun.misc.Cleaner cleaner &#61; ((sun.nio.ch.DirectBuffer) buffer).cleaner();cleaner.clean();}}/** Linux only methods used for getOwner() implementation */private static native long getUIDforFDOwnerforOwner(FileDescriptor fd) throws IOException;private static native String getUserName(long uid) throws IOException;/*** Result type of the fstat call*/public static class Stat {private int ownerId, groupId;private String owner, group;private int mode;// Mode constantspublic static final int S_IFMT &#61; 0170000; /* type of file */public static final int S_IFIFO &#61; 0010000; /* named pipe (fifo) */public static final int S_IFCHR &#61; 0020000; /* character special */public static final int S_IFDIR &#61; 0040000; /* directory */public static final int S_IFBLK &#61; 0060000; /* block special */public static final int S_IFREG &#61; 0100000; /* regular */public static final int S_IFLNK &#61; 0120000; /* symbolic link */public static final int S_IFSOCK &#61; 0140000; /* socket */public static final int S_IFWHT &#61; 0160000; /* whiteout */public static final int S_ISUID &#61; 0004000; /** set user id on* execution*/public static final int S_ISGID &#61; 0002000; /** set group id on* execution*/public static final int S_ISVTX &#61; 0001000; /** save swapped text even* after use*/public static final int S_IRUSR &#61; 0000400; /** read permission, owner*/public static final int S_IWUSR &#61; 0000200; /** write permission,* owner*/public static final int S_IXUSR &#61; 0000100; /** execute/search* permission, owner*/Stat(int ownerId, int groupId, int mode) {this.ownerId &#61; ownerId;this.groupId &#61; groupId;this.mode &#61; mode;}Stat(String owner, String group, int mode) {if (!Shell.WINDOWS) {this.owner &#61; owner;} else {this.owner &#61; stripDomain(owner);}if (!Shell.WINDOWS) {this.group &#61; group;} else {this.group &#61; stripDomain(group);}this.mode &#61; mode;}&#64;Overridepublic String toString() {return "Stat(owner&#61;&#39;" &#43; owner &#43; "&#39;, group&#61;&#39;" &#43; group &#43; "&#39;" &#43; ", mode&#61;" &#43; mode &#43; ")";}public String getOwner() {return owner;}public String getGroup() {return group;}public int getMode() {return mode;}}/*** Returns the file stat for a file descriptor.** &#64;param fd* file descriptor.* &#64;return the file descriptor file stat.* &#64;throws IOException* thrown if there was an IO error while obtaining the file* stat.*/public static Stat getFstat(FileDescriptor fd) throws IOException {Stat stat &#61; null;if (!Shell.WINDOWS) {stat &#61; fstat(fd);stat.owner &#61; getName(IdCache.USER, stat.ownerId);stat.group &#61; getName(IdCache.GROUP, stat.groupId);} else {try {stat &#61; fstat(fd);} catch (NativeIOException nioe) {if (nioe.getErrorCode() &#61;&#61; 6) {throw new NativeIOException("The handle is invalid.", Errno.EBADF);} else {LOG.warn(String.format("NativeIO.getFstat error (%d): %s", nioe.getErrorCode(),nioe.getMessage()));throw new NativeIOException("Unknown error", Errno.UNKNOWN);}}}return stat;}private static String getName(IdCache domain, int id) throws IOException {Map idNameCache &#61; (domain &#61;&#61; IdCache.USER) ? USER_ID_NAME_CACHE : GROUP_ID_NAME_CACHE;String name;CachedName cachedName &#61; idNameCache.get(id);long now &#61; System.currentTimeMillis();if (cachedName !&#61; null && (cachedName.timestamp &#43; cacheTimeout) > now) {name &#61; cachedName.name;} else {name &#61; (domain &#61;&#61; IdCache.USER) ? getUserName(id) : getGroupName(id);if (LOG.isDebugEnabled()) {String type &#61; (domain &#61;&#61; IdCache.USER) ? "UserName" : "GroupName";LOG.debug("Got " &#43; type &#43; " " &#43; name &#43; " for ID " &#43; id &#43; " from the native implementation");}cachedName &#61; new CachedName(name, now);idNameCache.put(id, cachedName);}return name;}static native String getUserName(int uid) throws IOException;static native String getGroupName(int uid) throws IOException;private static class CachedName {final long timestamp;final String name;public CachedName(String name, long timestamp) {this.name &#61; name;this.timestamp &#61; timestamp;}}private static final Map USER_ID_NAME_CACHE &#61; new ConcurrentHashMap();private static final Map GROUP_ID_NAME_CACHE &#61; new ConcurrentHashMap();private enum IdCache {USER, GROUP}public final static int MMAP_PROT_READ &#61; 0x1;public final static int MMAP_PROT_WRITE &#61; 0x2;public final static int MMAP_PROT_EXEC &#61; 0x4;public static native long mmap(FileDescriptor fd, int prot, boolean shared, long length) throws IOException;public static native void munmap(long addr, long length) throws IOException;}private static boolean workaroundNonThreadSafePasswdCalls &#61; false;public static class Windows {// Flags for CreateFile() call on Windowspublic static final long GENERIC_READ &#61; 0x80000000L;public static final long GENERIC_WRITE &#61; 0x40000000L;public static final long FILE_SHARE_READ &#61; 0x00000001L;public static final long FILE_SHARE_WRITE &#61; 0x00000002L;public static final long FILE_SHARE_DELETE &#61; 0x00000004L;public static final long CREATE_NEW &#61; 1;public static final long CREATE_ALWAYS &#61; 2;public static final long OPEN_EXISTING &#61; 3;public static final long OPEN_ALWAYS &#61; 4;public static final long TRUNCATE_EXISTING &#61; 5;public static final long FILE_BEGIN &#61; 0;public static final long FILE_CURRENT &#61; 1;public static final long FILE_END &#61; 2;/** Wrapper around CreateFile() on Windows */public static native FileDescriptor createFile(String path, long desiredAccess, long shareMode,long creationDisposition) throws IOException;/** Wrapper around SetFilePointer() on Windows */public static native long setFilePointer(FileDescriptor fd, long distanceToMove, long moveMethod)throws IOException;/** Windows only methods used for getOwner() implementation */private static native String getOwner(FileDescriptor fd) throws IOException;/** Supported list of Windows access right flags */public static enum AccessRight {ACCESS_READ(0x0001), // FILE_READ_DATAACCESS_WRITE(0x0002), // FILE_WRITE_DATAACCESS_EXECUTE(0x0020); // FILE_EXECUTEprivate final int accessRight;AccessRight(int access) {accessRight &#61; access;}public int accessRight() {return accessRight;}};/*** Windows only method used to check if the current process has* requested access rights on the given path.*/private static native boolean access0(String path, int requestedAccess);/*** Checks whether the current process has desired access rights on the* given path.** Longer term this native function can be substituted with JDK7* function Files#isReadable, isWritable, isExecutable.** &#64;param path* input path* &#64;param desiredAccess* ACCESS_READ, ACCESS_WRITE or ACCESS_EXECUTE* &#64;return true if access is allowed* &#64;throws IOException* I/O exception on error*/public static boolean access(String path, AccessRight desiredAccess) throws IOException {return true;// return access0(path, desiredAccess.accessRight());}static {if (NativeCodeLoader.isNativeCodeLoaded()) {try {initNative();nativeLoaded &#61; true;} catch (Throwable t) {// This can happen if the user has an older version of// libhadoop.so// installed - in this case we can continue without native// IO// after warningLOG.error("Unable to initialize NativeIO libraries", t);}}}}private static final Log LOG &#61; LogFactory.getLog(NativeIO.class);private static boolean nativeLoaded &#61; false;static {if (NativeCodeLoader.isNativeCodeLoaded()) {try {initNative();nativeLoaded &#61; true;} catch (Throwable t) {// This can happen if the user has an older version of// libhadoop.so// installed - in this case we can continue without native IO// after warningLOG.error("Unable to initialize NativeIO libraries", t);}}}/*** Return true if the JNI-based native IO extensions are available.*/public static boolean isAvailable() {return NativeCodeLoader.isNativeCodeLoaded() && nativeLoaded;}/** Initialize the JNI method ID and class ID cache */private static native void initNative();/*** Get the maximum number of bytes that can be locked into memory at any* given point.** &#64;return 0 if no bytes can be locked into memory; Long.MAX_VALUE if there* is no limit; The number of bytes that can be locked into memory* otherwise.*/static long getMemlockLimit() {return isAvailable() ? getMemlockLimit0() : 0;}private static native long getMemlockLimit0();/*** &#64;return the operating system&#39;s page size.*/static long getOperatingSystemPageSize() {try {Field f &#61; Unsafe.class.getDeclaredField("theUnsafe");f.setAccessible(true);Unsafe unsafe &#61; (Unsafe) f.get(null);return unsafe.pageSize();} catch (Throwable e) {LOG.warn("Unable to get operating system page size. Guessing 4096.", e);return 4096;}}private static class CachedUid {final long timestamp;final String username;public CachedUid(String username, long timestamp) {this.timestamp &#61; timestamp;this.username &#61; username;}}private static final Map<Long, CachedUid> uidCache &#61; new ConcurrentHashMap<Long, CachedUid>();private static long cacheTimeout;private static boolean initialized &#61; false;/*** The Windows logon name has two part, NetBIOS domain name and user account* name, of the format DOMAIN\UserName. This method will remove the domain* part of the full logon name.** &#64;param //the* full principal name containing the domain* &#64;return name with domain removed*/private static String stripDomain(String name) {int i &#61; name.indexOf(&#39;\\&#39;);if (i !&#61; -1)name &#61; name.substring(i &#43; 1);return name;}public static String getOwner(FileDescriptor fd) throws IOException {ensureInitialized();if (Shell.WINDOWS) {String owner &#61; Windows.getOwner(fd);owner &#61; stripDomain(owner);return owner;} else {long uid &#61; POSIX.getUIDforFDOwnerforOwner(fd);CachedUid cUid &#61; uidCache.get(uid);long now &#61; System.currentTimeMillis();if (cUid !&#61; null && (cUid.timestamp &#43; cacheTimeout) > now) {return cUid.username;}String user &#61; POSIX.getUserName(uid);LOG.info("Got UserName " &#43; user &#43; " for UID " &#43; uid &#43; " from the native implementation");cUid &#61; new CachedUid(user, now);uidCache.put(uid, cUid);return user;}}/*** Create a FileInputStream that shares delete permission on the file* opened, i.e. other process can delete the file the FileInputStream is* reading. Only Windows implementation uses the native interface.*/public static FileInputStream getShareDeleteFileInputStream(File f) throws IOException {if (!Shell.WINDOWS) {// On Linux the default FileInputStream shares delete permission// on the file opened.//return new FileInputStream(f);} else {// Use Windows native interface to create a FileInputStream that// shares delete permission on the file opened.//FileDescriptor fd &#61; Windows.createFile(f.getAbsolutePath(), Windows.GENERIC_READ,Windows.FILE_SHARE_READ | Windows.FILE_SHARE_WRITE | Windows.FILE_SHARE_DELETE,Windows.OPEN_EXISTING);return new FileInputStream(fd);}}/*** Create a FileInputStream that shares delete permission on the file opened* at a given offset, i.e. other process can delete the file the* FileInputStream is reading. Only Windows implementation uses the native* interface.*/public static FileInputStream getShareDeleteFileInputStream(File f, long seekOffset) throws IOException {if (!Shell.WINDOWS) {RandomAccessFile rf &#61; new RandomAccessFile(f, "r");if (seekOffset > 0) {rf.seek(seekOffset);}return new FileInputStream(rf.getFD());} else {// Use Windows native interface to create a FileInputStream that// shares delete permission on the file opened, and set it to the// given offset.//FileDescriptor fd &#61; Windows.createFile(f.getAbsolutePath(), Windows.GENERIC_READ, Windows.FILE_SHARE_READ| Windows.FILE_SHARE_WRITE | Windows.FILE_SHARE_DELETE,Windows.OPEN_EXISTING);if (seekOffset > 0)Windows.setFilePointer(fd, seekOffset, Windows.FILE_BEGIN);return new FileInputStream(fd);}}/*** Create the specified File for write access, ensuring that it does not* exist.** &#64;param f* the file that we want to create* &#64;param permissions* we want to have on the file (if security is enabled)** &#64;throws AlreadyExistsException* if the file already exists* &#64;throws IOException* if any other error occurred*/public static FileOutputStream getCreateForWriteFileOutputStream(File f, int permissions) throws IOException {if (!Shell.WINDOWS) {// Use the native wrapper around open(2)try {FileDescriptor fd &#61; POSIX.open(f.getAbsolutePath(),POSIX.O_WRONLY | POSIX.O_CREAT | POSIX.O_EXCL, permissions);return new FileOutputStream(fd);} catch (NativeIOException nioe) {if (nioe.getErrno() &#61;&#61; Errno.EEXIST) {throw new AlreadyExistsException(nioe);}throw nioe;}} else {// Use the Windows native APIs to create equivalent FileOutputStreamtry {FileDescriptor fd &#61; Windows.createFile(f.getCanonicalPath(),Windows.GENERIC_WRITE, Windows.FILE_SHARE_DELETE| Windows.FILE_SHARE_READ | Windows.FILE_SHARE_WRITE,Windows.CREATE_NEW);POSIX.chmod(f.getCanonicalPath(), permissions);return new FileOutputStream(fd);} catch (NativeIOException nioe) {if (nioe.getErrorCode() &#61;&#61; 80) {// ERROR_FILE_EXISTS// 80 (0x50)// The file existsthrow new AlreadyExistsException(nioe);}throw nioe;}}}private synchronized static void ensureInitialized() {if (!initialized) {cacheTimeout &#61; new Configuration().getLong("hadoop.security.uid.cache.secs", 4 * 60 * 60) * 1000;LOG.info("Initialized cache for UID to User mapping with a cache" &#43; " timeout of " &#43; cacheTimeout / 1000&#43; " seconds.");initialized &#61; true;}}/*** A version of renameTo that throws a descriptive exception when it fails.** &#64;param src* The source path* &#64;param dst* The destination path** &#64;throws NativeIOException* On failure.*/public static void renameTo(File src, File dst) throws IOException {if (!nativeLoaded) {if (!src.renameTo(dst)) {throw new IOException("renameTo(src&#61;" &#43; src &#43; ", dst&#61;" &#43; dst &#43; ") failed.");}} else {renameTo0(src.getAbsolutePath(), dst.getAbsolutePath());}}/*** A version of renameTo that throws a descriptive exception when it fails.** &#64;param src* The source path* &#64;param dst* The destination path** &#64;throws NativeIOException* On failure.*/private static native void renameTo0(String src, String dst) throws NativeIOException;
}


推荐阅读
  • Android与JUnit集成测试实践
    本文探讨了如何在Android项目中集成JUnit进行单元测试,并详细介绍了修改AndroidManifest.xml文件以支持测试的方法。 ... [详细]
  • Hadoop的文件操作位于包org.apache.hadoop.fs里面,能够进行新建、删除、修改等操作。比较重要的几个类:(1)Configurati ... [详细]
  • 使用TabActivity实现Android顶部选项卡功能
    本文介绍如何通过继承TabActivity来创建Android应用中的顶部选项卡。通过简单的步骤,您可以轻松地添加多个选项卡,并实现基本的界面切换功能。 ... [详细]
  • JUC并发编程——线程的基本方法使用
    目录一、线程名称设置和获取二、线程的sleep()三、线程的interrupt四、join()五、yield()六、wait(),notify(),notifyAll( ... [详细]
  • 本文详细介绍了在 CentOS 7 系统中配置 fstab 文件以实现开机自动挂载 NFS 共享目录的方法,并解决了常见的配置失败问题。 ... [详细]
  • 二维码的实现与应用
    本文介绍了二维码的基本概念、分类及其优缺点,并详细描述了如何使用Java编程语言结合第三方库(如ZXing和qrcode.jar)来实现二维码的生成与解析。 ... [详细]
  • JUnit下的测试和suite
    nsitionalENhttp:www.w3.orgTRxhtml1DTDxhtml1-transitional.dtd ... [详细]
  • 一、Advice执行顺序二、Advice在同一个Aspect中三、Advice在不同的Aspect中一、Advice执行顺序如果多个Advice和同一个JointPoint连接& ... [详细]
  • 本文深入探讨了Go语言中的接口型函数,通过实例分析其灵活性和强大功能,帮助开发者更好地理解和运用这一特性。 ... [详细]
  • spring boot使用jetty无法启动 ... [详细]
  • 本文探讨了如何通过Service Locator模式来简化和优化在B/S架构中的服务命名访问,特别是对于需要频繁访问的服务,如JNDI和XMLNS。该模式通过缓存机制减少了重复查找的成本,并提供了对多种服务的统一访问接口。 ... [详细]
  • 本文介绍了如何在 MapReduce 作业中使用 SequenceFileOutputFormat 生成 SequenceFile 文件,并详细解释了 SequenceFile 的结构和用途。 ... [详细]
  • 在项目需要国际化处理时,即支持多种语言切换的功能,通常有两种方案:单个包和多个包。本文将重点讨论单个包的实现方法。 ... [详细]
  • vsftpd配置(虚拟用户、匿名用户登录)
    一、ftp服务搭建(一)概述1.ftp连接及传输模式(1)控制连接TCP21,用于发送FTP命令信息 ... [详细]
  • 本文将介绍如何在混合开发(Hybrid)应用中实现Native与HTML5的交互,包括基本概念、学习目标以及具体的实现步骤。 ... [详细]
author-avatar
手机用户2502856053
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有