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


推荐阅读
  • 本文介绍了如何通过 Maven 依赖引入 SQLiteJDBC 和 HikariCP 包,从而在 Java 应用中高效地连接和操作 SQLite 数据库。文章提供了详细的代码示例,并解释了每个步骤的实现细节。 ... [详细]
  • 本文介绍了在Windows环境下使用pydoc工具的方法,并详细解释了如何通过命令行和浏览器查看Python内置函数的文档。此外,还提供了关于raw_input和open函数的具体用法和功能说明。 ... [详细]
  • 本文介绍如何使用阿里云的fastjson库解析包含时间戳、IP地址和参数等信息的JSON格式文本,并进行数据处理和保存。 ... [详细]
  • 本文介绍了如何在C#中启动一个应用程序,并通过枚举窗口来获取其主窗口句柄。当使用Process类启动程序时,我们通常只能获得进程的句柄,而主窗口句柄可能为0。因此,我们需要使用API函数和回调机制来准确获取主窗口句柄。 ... [详细]
  • 本文详细解析了Python中的os和sys模块,介绍了它们的功能、常用方法及其在实际编程中的应用。 ... [详细]
  • 扫描线三巨头 hdu1928hdu 1255  hdu 1542 [POJ 1151]
    学习链接:http:blog.csdn.netlwt36articledetails48908031学习扫描线主要学习的是一种扫描的思想,后期可以求解很 ... [详细]
  • 本文详细分析了Hive在启动过程中遇到的权限拒绝错误,并提供了多种解决方案,包括调整文件权限、用户组设置以及环境变量配置等。 ... [详细]
  • 本文介绍如何使用 NSTimer 实现倒计时功能,详细讲解了初始化方法、参数配置以及具体实现步骤。通过示例代码展示如何创建和管理定时器,确保在指定时间间隔内执行特定任务。 ... [详细]
  • 本文探讨了如何优化和正确配置Kafka Streams应用程序以确保准确的状态存储查询。通过调整配置参数和代码逻辑,可以有效解决数据不一致的问题。 ... [详细]
  • 从 .NET 转 Java 的自学之路:IO 流基础篇
    本文详细介绍了 Java 中的 IO 流,包括字节流和字符流的基本概念及其操作方式。探讨了如何处理不同类型的文件数据,并结合编码机制确保字符数据的正确读写。同时,文中还涵盖了装饰设计模式的应用,以及多种常见的 IO 操作实例。 ... [详细]
  • andr ... [详细]
  • RecyclerView初步学习(一)
    RecyclerView初步学习(一)ReCyclerView提供了一种插件式的编程模式,除了提供ViewHolder缓存模式,还可以自定义动画,分割符,布局样式,相比于传统的ListVi ... [详细]
  • ServiceStack与Swagger的无缝集成指南
    本文详细介绍了如何在ServiceStack项目中集成Swagger,以实现API文档的自动生成和在线测试。通过本指南,您将了解从配置到部署的完整流程,并掌握如何优化API接口的开发和维护。 ... [详细]
  • 本文详细介绍了如何在 Spring Boot 应用中通过 @PropertySource 注解读取非默认配置文件,包括配置文件的创建、映射类的设计以及确保 Spring 容器能够正确加载这些配置的方法。 ... [详细]
  • 本教程涵盖OpenGL基础操作及直线光栅化技术,包括点的绘制、简单图形绘制、直线绘制以及DDA和中点画线算法。通过逐步实践,帮助读者掌握OpenGL的基本使用方法。 ... [详细]
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社区 版权所有