/** * @see NativeCalls#isProcessActive(int) */ @Override public boolean isProcessActive(final int processId) { try { return kill(processId, 0) == 0; } catch (LastErrorException le) { if (le.getErrorCode() == EPERM) { // Process exists; it probably belongs to another user (bug 27698). return true; } } return false; }
public static void tryMunlockall() { try { if(isOperatingSystem("windows")) return; munlockall(); logger.info("munlockall() on JVM Heap successful"); } catch(Exception e) { if(!(e instanceof LastErrorException)) logger.error("Unexpected error during mlock of server heap", e); LastErrorException le = (LastErrorException) e; logger.warn("Error unlocking JVM heap " + le.getErrorCode()); } }
public static void tryMlockall() { try { if(isOperatingSystem("windows")) return; // Since we demand-zero every page of the heap while bringing up the // jvm, MCL_FUTURE is not needed mlockall(MCL_CURRENT); logger.info("mlockall() on JVM Heap successful"); } catch(Exception e) { if(!(e instanceof LastErrorException)) logger.error("Unexpected error during mlock of server heap", e); LastErrorException le = (LastErrorException) e; if(le.getErrorCode() == ENOMEM && isOperatingSystem("linux")) { logger.warn("Unable to lock JVM memory (ENOMEM)." + " This can result in part of the JVM being swapped out with higher Young gen stalls" + " Increase RLIMIT_MEMLOCK or run Voldemort as root."); } else if(!isOperatingSystem("mac")) { // fixes a OS X oddity, where it still throws an error, even // though mlockall succeeds logger.warn("Unknown mlockall error " + le.getErrorCode()); } } }
@Override protected int setPlatformSocketOption(int sockfd, int level, int optName, TCPSocketOptions opt, Integer optVal, int optSize) throws NativeErrorException { try { return setsockopt(sockfd, level, optName, new IntByReference(optVal.intValue()), optSize); } catch (LastErrorException le) { throw new NativeErrorException(le.getMessage(), le.getErrorCode(), le.getCause()); } }
if (logger.isDebugEnabled()) { logger.debug("DEBUG preBlow posix_fallocate called for path = " + path + " and ret = " + le.getErrorCode() + " maxsize = " + maxSize); if (le.getErrorCode() == ENOSPC) { unknownError = false; throw new IOException("Not enough space left on device");
@Override protected int setPlatformSocketOption(int sockfd, int level, int optName, TCPSocketOptions opt, Integer optVal, int optSize) throws NativeErrorException { try { switch (optName) { case OPT_TCP_KEEPALIVE_THRESHOLD: // value required is in millis final IntByReference timeout = new IntByReference(optVal.intValue() * 1000); int result = setsockopt(sockfd, level, optName, timeout, optSize); if (result == 0) { // setting ABORT_THRESHOLD to be same as KEEPALIVE_THRESHOLD return setsockopt(sockfd, level, OPT_TCP_KEEPALIVE_ABORT_THRESHOLD, timeout, optSize); } else { return result; } default: throw new UnsupportedOperationException("unsupported option " + opt); } } catch (LastErrorException le) { throw new NativeErrorException(le.getMessage(), le.getErrorCode(), le.getCause()); } }
if (le.getErrorCode() == WSAENOPROTOOPT) { error = new UnsupportedOperationException(getUnsupportedSocketOptionMessage(errorOpt), new NativeErrorException(le.getMessage(), le.getErrorCode(), le.getCause())); } else { final SocketException se =
} catch (LastErrorException le) { if (le.getErrorCode() != EPERM) { err = new UnsupportedOperationException("Failed in setsid() in daemonize() due to " + le.getMessage() + " (errno=" + le.getErrorCode() + ')');
private static String formatError(LastErrorException lee) { try { return strerror(lee.getErrorCode()); } catch (Throwable t) { return lee.getMessage(); } }
static public HANDLE CreateFile(String name, int access, int sharing, SECURITY_ATTRIBUTES security, int create, int attribs, Pointer template) { log = log && log(5, "> CreateFileA(%s, 0x%08X, 0x%08X, %s, 0x%08X, 0x%08X,%s)\n", name, access, sharing, security, create, attribs, template); HANDLE h; try { h = m_K32lib.CreateFile(name, access, sharing, security, create, attribs, template); LastError.get()[0] = 0; } catch (LastErrorException le) { h = INVALID_HANDLE_VALUE; LastError.get()[0] = le.getErrorCode(); } log = log && log(4, "< CreateFileA(%s, 0x%08X, 0x%08X, %s, 0x%08X, 0x%08X,%s) => %s\n", name, access, sharing, security, create, attribs, template, h); return h; }
static public boolean EscapeCommFunction(HANDLE hFile, int func) { log = log && log(5, "> EscapeCommFunction(%s,0x%08X)\n", hFile, func); boolean res; try { res = m_K32lib.EscapeCommFunction(hFile, func); LastError.get()[0] = 0; } catch (LastErrorException le) { res = false; LastError.get()[0] = le.getErrorCode(); } log = log && log(4, "< EscapeCommFunction(%s,0x%08X) => %s\n", hFile, func, res); return res; }
@Override public void setAffinity(final long affinity) { final CLibrary lib = CLibrary.INSTANCE; WinDef.DWORD aff = new WinDef.DWORD(affinity); try { lib.SetThreadAffinityMask(lib.GetCurrentThread(), aff); } catch (LastErrorException e) { throw new IllegalStateException("sched_getaffinity((" + Long.SIZE / 8 + ") , &(" + affinity + ") ) errorNo=" + e.getErrorCode(), e); } } }
private void closeFD() { if (allocationMode == AllocationMode.DESCRIPTOR && fd > 0) { try { ONative.instance().close(fd); } catch (final LastErrorException e) { OLogManager.instance() .warnNoDb(this, "Can not close Linux descriptor of file %s, error %d", osFile.toAbsolutePath().toString(), e.getErrorCode()); } allocationMode = null; fd = 0; } }
public void allowFragmentation(final int level, final int option_name, final boolean frag) throws IOException { final int socket = getSock(); if (socket < 0) { throw new IOException("Invalid socket!"); } final IntByReference dontfragment = new IntByReference(frag == true? 0 : 1); try { setsockopt(socket, level, option_name, dontfragment.getPointer(), Pointer.SIZE); } catch (final LastErrorException e) { throw new IOException("setsockopt: " + strerror(e.getErrorCode())); } }
@Override public void setTrafficClass(final int tc) throws IOException { final IntByReference tc_ptr = new IntByReference(tc); try { setsockopt(getSock(), IPPROTO_IP, IP_TOS, tc_ptr.getPointer(), Pointer.SIZE); } catch (final LastErrorException e) { throw new IOException("setsockopt: " + strerror(e.getErrorCode())); } }
@Override public void setTrafficClass(final int tc) throws LastErrorException { final IntByReference tc_ptr = new IntByReference(tc); try { setsockopt(getSock(), IPPROTO_IPV6, IPV6_TCLASS, tc_ptr.getPointer(), Pointer.SIZE); } catch (final LastErrorException e) { throw new RuntimeException("setsockopt: " + strerror(e.getErrorCode())); } }
@Override public void setTrafficClass(final int tc) throws IOException { final IntByReference tc_ptr = new IntByReference(tc); try { setsockopt(getSock(), IPPROTO_IP, IP_TOS, tc_ptr.getPointer(), Pointer.SIZE); } catch (final LastErrorException e) { throw new IOException("setsockopt: " + strerror(e.getErrorCode())); } }
@Override public void setTrafficClass(final int tc) throws LastErrorException { final IntByReference tc_ptr = new IntByReference(tc); try { setsockopt(getSock(), IPPROTO_IPV6, IPV6_TCLASS, tc_ptr.getPointer(), Pointer.SIZE); } catch (final LastErrorException e) { throw new RuntimeException("setsockopt: " + strerror(e.getErrorCode())); } }
@Override public void setTrafficClass(final int tc) throws LastErrorException { final IntByReference tc_ptr = new IntByReference(tc); try { setsockopt(getSock(), IPPROTO_IPV6, IPV6_TCLASS, tc_ptr.getPointer(), Pointer.SIZE); } catch (final LastErrorException e) { throw new RuntimeException("setsockopt: " + strerror(e.getErrorCode())); } }
@Override public void setTrafficClass(final int tc) throws IOException { final IntByReference tc_ptr = new IntByReference(tc); try { setsockopt(getSock(), IPPROTO_IP, IP_TOS, tc_ptr.getPointer(), Pointer.SIZE); } catch (final LastErrorException e) { throw new IOException("setsockopt: " + strerror(e.getErrorCode())); } }