Example usage for org.apache.lucene.util Constants SUN_OS

List of usage examples for org.apache.lucene.util Constants SUN_OS

Introduction

In this page you can find the example usage for org.apache.lucene.util Constants SUN_OS.

Prototype

boolean SUN_OS

To view the source code for org.apache.lucene.util Constants SUN_OS.

Click Source Link

Document

True iff running on SunOS.

Usage

From source file:com.b2international.index.lucene.Directories.java

License:Apache License

/**
 * Just like {@link #openFile(File)}, but allows you to also specify a custom {@link LockFactory}.
 *///from w ww.  ja  v a 2  s  .com
public static FSDirectory openFile(final Path path, final LockFactory lockFactory) throws IOException {
    if ((Constants.WINDOWS || Constants.SUN_OS || Constants.LINUX || Constants.MAC_OS_X)
            && Constants.JRE_IS_64BIT && MMapDirectory.UNMAP_SUPPORTED) {

        return new MMapDirectory(path, lockFactory);
    } else if (Constants.WINDOWS) {
        return new SimpleFSDirectory(path, lockFactory);
    } else {
        return new NIOFSDirectory(path, lockFactory);
    }
}

From source file:org.apache.jackrabbit.core.integration.InterruptedQueryTest.java

License:Apache License

@Test
public void testQuery() throws Exception {
    if (Constants.WINDOWS) {
        return;//from   w w  w  .j av  a 2  s.co m
    }
    for (int i = 0; i < 100; i++) {
        session.getRootNode().addNode("node" + i, "nt:unstructured");
    }
    session.save();
    final QueryManager qm = session.getWorkspace().getQueryManager();
    final AtomicBoolean stop = new AtomicBoolean(false);
    final List<Exception> exceptions = Collections.synchronizedList(new ArrayList<Exception>());
    Thread t = new Thread(new Runnable() {
        @Override
        public void run() {
            while (!stop.get() && exceptions.isEmpty()) {
                try {
                    // execute query
                    String stmt = "//*[@jcr:primaryType='nt:unstructured']";
                    qm.createQuery(stmt, Query.XPATH).execute();
                } catch (RepositoryException e) {
                    if (Constants.SUN_OS) {
                        // on Solaris it's OK when the root cause
                        // of the exception is an InterruptedIOException
                        // the underlying file is not closed
                        Throwable t = e;
                        while (t.getCause() != null) {
                            t = t.getCause();
                        }
                        if (!(t instanceof InterruptedIOException)) {
                            exceptions.add(e);
                        }
                    } else {
                        exceptions.add(e);
                    }
                }
            }
        }
    });
    t.start();
    for (int i = 0; i < 200 && t.isAlive(); i++) {
        t.interrupt();
        Thread.sleep((long) (100.0 * Math.random()));
    }
    stop.set(true);
    t.join();
    if (!exceptions.isEmpty()) {
        throw exceptions.get(0);
    }
}

From source file:org.elasticsearch.bootstrap.Seccomp.java

License:Apache License

static void solarisImpl() {
    // first be defensive: we can give nice errors this way, at the very least.
    boolean supported = Constants.SUN_OS;
    if (supported == false) {
        throw new IllegalStateException(
                "bug: should not be trying to initialize priv_set for an unsupported OS");
    }/*from ww  w  .ja va 2s. c o m*/

    // we couldn't link methods, could be some really ancient Solaris or some bug
    if (libc_solaris == null) {
        throw new UnsupportedOperationException(
                "priv_set unavailable: could not link methods. requires Solaris 10+");
    }

    // drop a null-terminated list of privileges 
    if (libc_solaris.priv_set(PRIV_OFF, PRIV_ALLSETS, PRIV_PROC_FORK, PRIV_PROC_EXEC, null) != 0) {
        throw new UnsupportedOperationException(
                "priv_set unavailable: priv_set(): " + JNACLibrary.strerror(Native.getLastError()));
    }

    logger.debug("Solaris priv_set initialization successful");
}

From source file:org.elasticsearch.bootstrap.Seccomp.java

License:Apache License

/**
 * Attempt to drop the capability to execute for the process.
 * <p>//from w w w  .  j av a2 s  . co  m
 * This is best effort and OS and architecture dependent. It may throw any Throwable.
 * @return 0 if we can do this for application threads, 1 for the entire process
 */
static int init(Path tmpFile) throws Throwable {
    if (Constants.LINUX) {
        return linuxImpl();
    } else if (Constants.MAC_OS_X) {
        // try to enable both mechanisms if possible
        bsdImpl();
        macImpl(tmpFile);
        return 1;
    } else if (Constants.SUN_OS) {
        solarisImpl();
        return 1;
    } else if (Constants.FREE_BSD || OPENBSD) {
        bsdImpl();
        return 1;
    } else if (Constants.WINDOWS) {
        windowsImpl();
        return 1;
    } else {
        throw new UnsupportedOperationException(
                "syscall filtering not supported for OS: '" + Constants.OS_NAME + "'");
    }
}

From source file:org.elasticsearch.bootstrap.SystemCallFilter.java

License:Apache License

static void solarisImpl() {
    // first be defensive: we can give nice errors this way, at the very least.
    boolean supported = Constants.SUN_OS;
    if (supported == false) {
        throw new IllegalStateException(
                "bug: should not be trying to initialize priv_set for an unsupported OS");
    }/*w  ww. j  a v  a 2 s . co m*/

    // we couldn't link methods, could be some really ancient Solaris or some bug
    if (libc_solaris == null) {
        throw new UnsupportedOperationException(
                "priv_set unavailable: could not link methods. requires Solaris 10+");
    }

    // drop a null-terminated list of privileges
    if (libc_solaris.priv_set(PRIV_OFF, PRIV_ALLSETS, PRIV_PROC_FORK, PRIV_PROC_EXEC, null) != 0) {
        throw new UnsupportedOperationException(
                "priv_set unavailable: priv_set(): " + JNACLibrary.strerror(Native.getLastError()));
    }

    logger.debug("Solaris priv_set initialization successful");
}

From source file:org.elasticsearch.bootstrap.SystemCallFilter.java

License:Apache License

/**
 * Attempt to drop the capability to execute for the process.
 * <p>/*from   w w w  .  ja va2 s  . com*/
 * This is best effort and OS and architecture dependent. It may throw any Throwable.
 * @return 0 if we can do this for application threads, 1 for the entire process
 */
static int init(Path tmpFile) throws Exception {
    if (Constants.LINUX) {
        return linuxImpl();
    } else if (Constants.MAC_OS_X) {
        // try to enable both mechanisms if possible
        bsdImpl();
        macImpl(tmpFile);
        return 1;
    } else if (Constants.SUN_OS) {
        solarisImpl();
        return 1;
    } else if (Constants.FREE_BSD || OPENBSD) {
        bsdImpl();
        return 1;
    } else if (Constants.WINDOWS) {
        windowsImpl();
        return 1;
    } else {
        throw new UnsupportedOperationException(
                "syscall filtering not supported for OS: '" + Constants.OS_NAME + "'");
    }
}

From source file:org.elasticsearch.common.compress.lzf.LZFCompressor.java

License:Apache License

public LZFCompressor() {
    if (Constants.SUN_OS) {
        this.decoder = ChunkDecoderFactory.safeInstance();
    } else {//from  w w w.  j  ava  2  s .c o m
        this.decoder = ChunkDecoderFactory.optimalInstance();
    }
    Loggers.getLogger(LZFCompressor.class).debug("using [{}] decoder", this.decoder.getClass().getSimpleName());
}

From source file:org.elasticsearch.index.store.IndexStoreModule.java

License:Apache License

@Override
public Iterable<? extends Module> spawnModules() {
    Class<? extends Module> indexStoreModule = NioFsIndexStoreModule.class;
    // Same logic as FSDirectory#open ...
    if ((Constants.WINDOWS || Constants.SUN_OS || Constants.LINUX) && Constants.JRE_IS_64BIT
            && MMapDirectory.UNMAP_SUPPORTED) {
        indexStoreModule = MmapFsIndexStoreModule.class;
    } else if (Constants.WINDOWS) {
        indexStoreModule = SimpleFsIndexStoreModule.class;
    }/*  w w w .j a  v a 2s  .  co  m*/
    String storeType = settings.get("index.store.type");
    if ("ram".equalsIgnoreCase(storeType)) {
        indexStoreModule = RamIndexStoreModule.class;
    } else if ("memory".equalsIgnoreCase(storeType)) {
        indexStoreModule = RamIndexStoreModule.class;
    } else if ("fs".equalsIgnoreCase(storeType)) {
        // nothing to set here ... (we default to fs)
    } else if ("simplefs".equalsIgnoreCase(storeType) || "simple_fs".equals(storeType)) {
        indexStoreModule = SimpleFsIndexStoreModule.class;
    } else if ("niofs".equalsIgnoreCase(storeType) || "nio_fs".equalsIgnoreCase(storeType)) {
        indexStoreModule = NioFsIndexStoreModule.class;
    } else if ("mmapfs".equalsIgnoreCase(storeType) || "mmap_fs".equalsIgnoreCase(storeType)) {
        indexStoreModule = MmapFsIndexStoreModule.class;
    } else if (storeType != null) {
        indexStoreModule = settings.getAsClass("index.store.type", indexStoreModule,
                "org.elasticsearch.index.store.", "IndexStoreModule");
    }
    return ImmutableList.of(Modules.createModule(indexStoreModule, settings));
}

From source file:org.elasticsearch.index.store.mock.MockDirectoryHelper.java

License:Apache License

public FsDirectoryService randomDirectorService(IndexStore indexStore) {
    if ((Constants.WINDOWS || Constants.SUN_OS) && Constants.JRE_IS_64BIT && MMapDirectory.UNMAP_SUPPORTED) {
        return new MmapFsDirectoryService(shardId, indexSettings, indexStore);
    } else if (Constants.WINDOWS) {
        return new SimpleFsDirectoryService(shardId, indexSettings, indexStore);
    }/*from   w w  w.  jav  a  2 s.  c  om*/
    switch (random.nextInt(3)) {
    case 1:
        return new MmapFsDirectoryService(shardId, indexSettings, indexStore);
    case 0:
        return new SimpleFsDirectoryService(shardId, indexSettings, indexStore);
    default:
        return new NioFsDirectoryService(shardId, indexSettings, indexStore);
    }
}