/** * @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; }
@Override protected void fallocateFD(int fd, long offset, long len) throws LastErrorException { int errno = posix_fallocate64(fd, offset, len); if (errno != 0) { throw new LastErrorException(errno); } } }
@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()); } }
} catch (LastErrorException le) { if (le.getErrorCode() != EPERM) { err = new UnsupportedOperationException("Failed in setsid() in daemonize() due to " + le.getMessage() + " (errno=" + le.getErrorCode() + ')');
public void connect(SocketAddress endpoint, int timeout) throws IOException { try { is = new SharedMemoryInputStream(); os = new SharedMemoryOutputStream(); String prefix = memoryName + "_" + getConnectNumber(); clientRead = openEvent(prefix + "_CLIENT_READ"); serverRead = openEvent(prefix + "_SERVER_READ"); serverWrote = openEvent(prefix + "_SERVER_WROTE"); clientWrote = openEvent(prefix + "_CLIENT_WROTE"); connectionClosed = openEvent(prefix + "_CONNECTION_CLOSED"); view = mapMemory(prefix + "_DATA", Kernel32.FILE_MAP_WRITE, BUFFERLEN); Kernel32.INSTANCE.SetEvent(serverRead); } catch (LastErrorException lee) { throw new IOException(lee.getMessage(), lee.getCause()); } }
logger.debug("DEBUG isOnLocalFileSystem got ex = " + le + " msg = " + le.getMessage());
/** * <p>Put the display to a state where it is ready for returning.</p> * * <p>Keyboard mode is restored, text mode is set and VT autoswitch is enabled. * Then, console file descriptor is closed.</p> */ private void deinitialize() { LOGGER.trace("Closing system console"); try { ttyfd.setKeyboardMode(old_kbmode); ttyfd.setConsoleMode(KD_TEXT); NativeTTY.vt_mode vtm = new NativeTTY.vt_mode(); vtm.mode = VT_AUTO; vtm.relsig = 0; vtm.acqsig = 0; ttyfd.setVTmode(vtm); ttyfd.close(); } catch (LastErrorException e) { System.err.println("Error occured during console shutdown: " + e.getMessage()); e.printStackTrace(); } // free objects closeFramebuffer(); ttyfd = null; libc = null; }
public LastErrorException(int code) { this(code, formatMessage(code)); }
private static String formatError(LastErrorException lee) { try { return strerror(lee.getErrorCode()); } catch (Throwable t) { return lee.getMessage(); } }
public void connect(SocketAddress endpoint, int timeout) throws IOException { try { is = new SharedMemoryInputStream(); os = new SharedMemoryOutputStream(); String prefix = memoryName + "_" + getConnectNumber(); clientRead = openEvent(prefix + "_CLIENT_READ"); serverRead = openEvent(prefix + "_SERVER_READ"); serverWrote = openEvent(prefix + "_SERVER_WROTE"); clientWrote = openEvent(prefix + "_CLIENT_WROTE"); connectionClosed = openEvent(prefix + "_CONNECTION_CLOSED"); view = mapMemory(prefix + "_DATA", Kernel32.FILE_MAP_WRITE, BUFFERLEN); Kernel32.INSTANCE.SetEvent(serverRead); } catch (LastErrorException lee) { throw new IOException(lee.getMessage(), lee.getCause()); } }
memoryName = "Global\\" + memoryName; } catch (LastErrorException lee2) { throw new IOException("getConnectNumber() fails : " + lee2.getMessage() + " " + memoryName);
private static String parseMessage(String m) { try { return formatMessage(Integer.parseInt(m)); } catch(NumberFormatException e) { return m; } }
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()); } }
@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()); } }
private static String formatError(LastErrorException lee) { try { return strerror(lee.getErrorCode()); } catch (Throwable t) { return lee.getMessage(); } }
@Override protected void fallocateFD(int fd, long offset, long len) throws LastErrorException { int errno = posix_fallocate64(fd, offset, len); if (errno != 0) { throw new LastErrorException(errno); } } }
memoryName = "Global\\" + memoryName; } catch (LastErrorException lee2) { throw new IOException("getConnectNumber() fails : " + lee2.getMessage() + " " + memoryName);
public LastErrorException(int code) { this(code, formatMessage(code)); }
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()); } } }
if (le.getErrorCode() == WSAENOPROTOOPT) { error = new UnsupportedOperationException(getUnsupportedSocketOptionMessage(errorOpt), new NativeErrorException(le.getMessage(), le.getErrorCode(), le.getCause())); } else { final SocketException se =