private static int getProcessId() {
        String value = "";
        try {
            final RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
            value = runtime.getName();
        } catch (final Throwable t) {
            if (logger.isDebugEnabled()) {
                logger.debug("Could not invoke ManagementFactory.getRuntimeMXBean().getName(), {}.",
                    StackTraceUtil.stackTrace(t));
            }
        }

        // something like '<pid>@<hostname>', at least in SUN / Oracle JVMs
        final int atIndex = value.indexOf('@');
        if (atIndex >= 0) {
            value = value.substring(0, atIndex);
        }

        int pid = -1;
        try {
            pid = Integer.parseInt(value);
        } catch (final NumberFormatException ignored) {
            // value did not contain an integer
        }

        if (pid < 0 || pid > MAX_PROCESS_ID) {
            pid = ThreadLocalRandom.current().nextInt(MAX_PROCESS_ID + 1);

            logger.warn("Failed to find the current process ID from '{}'; using a random value: {}.", value, pid);
        }

        return pid;
    }
Gets current pid, max pid 32 bit systems 32768, for 64 bit 4194304
http://unix.stackexchange.com/questions/16883/what-is-the-maximum-value-of-the-pid-of-a-process
http://stackoverflow.com/questions/35842/how-can-a-java-program-get-its-own-process-id
jraft-rheakv/rheakv-core/src/main/java/com/alipay/sofa/jraft/rhea/util/UniqueIdUtil.java