热门标签 | 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;
}


推荐阅读
  • 本文分享了一个关于在C#中使用异步代码的问题,作者在控制台中运行时代码正常工作,但在Windows窗体中却无法正常工作。作者尝试搜索局域网上的主机,但在窗体中计数器没有减少。文章提供了相关的代码和解决思路。 ... [详细]
  • HDU 2372 El Dorado(DP)的最长上升子序列长度求解方法
    本文介绍了解决HDU 2372 El Dorado问题的一种动态规划方法,通过循环k的方式求解最长上升子序列的长度。具体实现过程包括初始化dp数组、读取数列、计算最长上升子序列长度等步骤。 ... [详细]
  • 阿,里,云,物,联网,net,core,客户端,czgl,aliiotclient, ... [详细]
  • [大整数乘法] java代码实现
    本文介绍了使用java代码实现大整数乘法的过程,同时也涉及到大整数加法和大整数减法的计算方法。通过分治算法来提高计算效率,并对算法的时间复杂度进行了研究。详细代码实现请参考文章链接。 ... [详细]
  • Java学习笔记之面向对象编程(OOP)
    本文介绍了Java学习笔记中的面向对象编程(OOP)内容,包括OOP的三大特性(封装、继承、多态)和五大原则(单一职责原则、开放封闭原则、里式替换原则、依赖倒置原则)。通过学习OOP,可以提高代码复用性、拓展性和安全性。 ... [详细]
  • C++字符字符串处理及字符集编码方案
    本文介绍了C++中字符字符串处理的问题,并详细解释了字符集编码方案,包括UNICODE、Windows apps采用的UTF-16编码、ASCII、SBCS和DBCS编码方案。同时说明了ANSI C标准和Windows中的字符/字符串数据类型实现。文章还提到了在编译时需要定义UNICODE宏以支持unicode编码,否则将使用windows code page编译。最后,给出了相关的头文件和数据类型定义。 ... [详细]
  • Go GUIlxn/walk 学习3.菜单栏和工具栏的具体实现
    本文介绍了使用Go语言的GUI库lxn/walk实现菜单栏和工具栏的具体方法,包括消息窗口的产生、文件放置动作响应和提示框的应用。部分代码来自上一篇博客和lxn/walk官方示例。文章提供了学习GUI开发的实际案例和代码示例。 ... [详细]
  • 先看官方文档TheJavaTutorialshavebeenwrittenforJDK8.Examplesandpracticesdescribedinthispagedontta ... [详细]
  • 大数据Hadoop生态(20)MapReduce框架原理OutputFormat的开发笔记
    本文介绍了大数据Hadoop生态(20)MapReduce框架原理OutputFormat的开发笔记,包括outputFormat接口实现类、自定义outputFormat步骤和案例。案例中将包含nty的日志输出到nty.log文件,其他日志输出到other.log文件。同时提供了一些相关网址供参考。 ... [详细]
  • Java如何导入和导出Excel文件的方法和步骤详解
    本文详细介绍了在SpringBoot中使用Java导入和导出Excel文件的方法和步骤,包括添加操作Excel的依赖、自定义注解等。文章还提供了示例代码,并将代码上传至GitHub供访问。 ... [详细]
  • 本文介绍了解决java开源项目apache commons email简单使用报错的方法,包括使用正确的JAR包和正确的代码配置,以及相关参数的设置。详细介绍了如何使用apache commons email发送邮件。 ... [详细]
  • 对于开源的东东,尤其是刚出来不久,我认为最好的学习方式就是能够看源代码和doc,測试它的样例为了方便查看源代码,关联导入源代 ... [详细]
  • MapReduce工作流程最详细解释
    MapReduce是我们再进行离线大数据处理的时候经常要使用的计算模型,MapReduce的计算过程被封装的很好,我们只用使用Map和Reduce函数,所以对其整体的计算过程不是太 ... [详细]
  • 本文介绍了OC学习笔记中的@property和@synthesize,包括属性的定义和合成的使用方法。通过示例代码详细讲解了@property和@synthesize的作用和用法。 ... [详细]
  • Android日历提醒软件开源项目分享及使用教程
    本文介绍了一款名为Android日历提醒软件的开源项目,作者分享了该项目的代码和使用教程,并提供了GitHub项目地址。文章详细介绍了该软件的主界面风格、日程信息的分类查看功能,以及添加日程提醒和查看详情的界面。同时,作者还提醒了读者在使用过程中可能遇到的Android6.0权限问题,并提供了解决方法。 ... [详细]
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社区 版权所有