List of usage examples for org.apache.commons.lang SystemUtils IS_OS_LINUX
boolean IS_OS_LINUX
To view the source code for org.apache.commons.lang SystemUtils IS_OS_LINUX.
Click Source Link
Is true
if this is Linux.
The field will return false
if OS_NAME
is null
.
From source file:com.yahoo.pulsar.client.api.MockBrokerService.java
public void startMockBrokerService() throws Exception { ThreadFactory threadFactory = new ThreadFactoryBuilder().setNameFormat("mock-pulsar-%s").build(); final int numThreads = 2; final int MaxMessageSize = 5 * 1024 * 1024; EventLoopGroup eventLoopGroup;/* w w w . j a v a2 s. c om*/ try { if (SystemUtils.IS_OS_LINUX) { try { eventLoopGroup = new EpollEventLoopGroup(numThreads, threadFactory); } catch (UnsatisfiedLinkError e) { eventLoopGroup = new NioEventLoopGroup(numThreads, threadFactory); } } else { eventLoopGroup = new NioEventLoopGroup(numThreads, threadFactory); } workerGroup = eventLoopGroup; ServerBootstrap bootstrap = new ServerBootstrap(); bootstrap.group(workerGroup, workerGroup); if (workerGroup instanceof EpollEventLoopGroup) { bootstrap.channel(EpollServerSocketChannel.class); } else { bootstrap.channel(NioServerSocketChannel.class); } bootstrap.childHandler(new ChannelInitializer<SocketChannel>() { @Override public void initChannel(SocketChannel ch) throws Exception { ch.pipeline().addLast("frameDecoder", new LengthFieldBasedFrameDecoder(MaxMessageSize, 0, 4, 0, 4)); ch.pipeline().addLast("handler", new MockServerCnx()); } }); // Bind and start to accept incoming connections. bootstrap.bind(brokerServicePort).sync(); } catch (Exception e) { throw e; } }
From source file:com.yahoo.pulsar.testclient.LoadSimulationClient.java
public LoadSimulationClient(final MainArguments arguments) throws Exception { payloadCache = new ConcurrentHashMap<>(); topicsToTradeUnits = new ConcurrentHashMap<>(); final EventLoopGroup eventLoopGroup = SystemUtils.IS_OS_LINUX ? new EpollEventLoopGroup(Runtime.getRuntime().availableProcessors(), new DefaultThreadFactory("pulsar-test-client")) : new NioEventLoopGroup(Runtime.getRuntime().availableProcessors(), new DefaultThreadFactory("pulsar-test-client")); clientConf = new ClientConfiguration(); clientConf.setConnectionsPerBroker(4); // Disable stats on the clients to reduce CPU/memory usage. clientConf.setStatsInterval(0, TimeUnit.SECONDS); producerConf = new ProducerConfiguration(); // Disable timeout. producerConf.setSendTimeout(0, TimeUnit.SECONDS); producerConf.setMessageRoutingMode(ProducerConfiguration.MessageRoutingMode.RoundRobinPartition); // Enable batching. producerConf.setBatchingMaxPublishDelay(1, TimeUnit.MILLISECONDS); producerConf.setBatchingEnabled(true); consumerConf = new ConsumerConfiguration(); consumerConf.setMessageListener(ackListener); client = new PulsarClientImpl(arguments.serviceURL, clientConf, eventLoopGroup); port = arguments.port;//from ww w.j a v a2 s. c o m executor = Executors.newCachedThreadPool(new DefaultThreadFactory("test-client")); }
From source file:configuration.Config.java
/** * This set the default configuration properties *//*from w w w . j av a2 s .c o m*/ public void setDefaultProperties() { //--Ask to set Email and other helpfull //--Path set("Name", "Configuration file (config.dat)"); set("currentPath", currentPath); //== //==Note: //==This databasePath represent the default project filename set("databasePath", currentPath + File.separator + "projects" + File.separator + "New_Untitled.db"); set("propertiesPath", currentPath + File.separator + "data" + File.separator + "properties"); // Reflect armadillo properties path set("classPath", currentPath + File.separator + "build" + File.separator + "classes" + File.separator + "programs"); //Running program class set("editorPath", currentPath + File.separator + "build" + File.separator + "classes" + File.separator + "editors"); //editor class set("dataPath", currentPath + File.separator + "data"); set("ExecutableDir", currentPath + File.separator + "Executable"); set("tmpDir", currentPath + File.separator + "tmp"); set("temporaryDir", currentPath + File.separator + "tmp" + File.separator + "temporary"); set("resultsDir", currentPath + File.separator + "results"); set("testDir", currentPath + File.separator + "test"); set("iconsPath", currentPath + File.separator + "data" + File.separator + "icons"); set("projectsDir", currentPath + File.separator + "projects"); // Projects Directory set("hgncDataPath", dataPath() + File.separator + "hgnc.txt"); //default hgnc database... set("hgncWebDownload", "http://www.genenames.org/cgi-bin/hgnc_downloads.cgi?title=HGNC+output+data&hgnc_dbtag=on&preset=all&status=Approved&status=Entry+Withdrawn&status_opt=2&level=pri&=on&where=&order_by=gd_app_sym_sort&limit=&format=text&submit=submit&.cgifields=&.cgifields=level&.cgifields=chr&.cgifields=status&.cgifields=hgnc_dbtag"); set("log", currentPath + File.separator + "armadillo.log"); //--Try to create the tempDir (temporary file directory) if doesn't exists Util.CreateDir(get("tmpDir")); Util.CreateDir(get("resultsDir")); Util.CreateDir(get("projectsDir")); try { if (Util.FileExists(dataPath("New_Untitled_default.db"))) { Util.copy(dataPath("New_Untitled_default.db"), this.projectsDir() + File.separator + "New_Untitled.db"); } else { log("Unable to find the default project file..."); } } catch (Exception e) { } Util.CreateDir(get("temporaryDir")); //--Version and Other set("authorArmadillo", "Etienne Lord, Mickael Leclercq, Alix Boc, Abdoulaye Banir Diallo, Vladimir Makarenkov"); set("version", "2.0"); set("applicationName", "Armadillo Workflow Platform"); set("webpageArmadillo", "http://adn.bioinfo.uqam.ca/armadillo/"); //--Armadillo default webpage set("webserverArmadillo", "http://trex.uqam.ca/armadillo/"); //--Armadillo webserver set("helpArmadillo", "http://adn.bioinfo.uqam.ca/armadillo/wiki/index.php/Main_Page"); //--Armadillo default help page set("getting_startedArmadillo", dataPath() + File.separator + "Documents" + File.separator + "getting_started.html"); //--Getting started page shown at start up set("splashIconPath", currentPath + File.separator + "data" + File.separator + "splash1.png"); set("smallIconPath", currentPath + File.separator + "data" + File.separator + "armadillo.png"); set("imagePath", currentPath + File.separator + "data" + File.separator + "images"); set("imageNcbiLoading", currentPath + File.separator + "data" + File.separator + "LoadingNcbi.jpg"); set("imageEnsemblLoading", currentPath + File.separator + "data" + File.separator + "LoadingEnsembl.jpg"); set("imageSequenceLoading", currentPath + File.separator + "data" + File.separator + "LoadingSequence.jpg"); //--Editor version and name set("editorApplicationName", "Armadillo Editor"); set("editorVersion", "0.1"); set("editorAuthor", "Etienne Lord, Mickael Leclercq"); set("workflow_w", 2000); //Initial workflow size set("workflow_h", 600); set("font_size_adjuster", 0); //--Increase of decrease workflow font size; set("FirstTime", 1); //--Special (Tree Editor, etc...) set("LoadPhyloWidget", false); //--By default, display the Start page set("DisplayStartPage", true); //--Programs currentPath = new File("").getAbsolutePath(); //Databases used set("HGNCData", currentPath + File.separator + "data" + File.separator + "hgnc.txt"); set("Tooltip", currentPath + File.separator + "data" + File.separator + "tooltips.csv"); //set("iso",currentPath+"//data//iso.txt"); set("EnsemblDb", currentPath + File.separator + "data" + File.separator + "EnsemblDB.tsv"); //Others set("defaultSplashPath", currentPath + File.separator + "data" + File.separator + "splash" + File.separator); set("urlToModelTest", "http://www.hiv.lanl.gov/content/sequence/findmodel/findmodel.html"); set("download_genbank", false); set("debugEditor", false); //--System environment specific options if (SystemUtils.IS_OS_MAC_OSX || SystemUtils.IS_OS_MAC) { set("MacOSX", true); set("font_size_adjuster", -1); } else if (SystemUtils.IS_OS_LINUX || SystemUtils.IS_OS_UNIX) { set("Linux", true); } else if (SystemUtils.IS_OS_WINDOWS) { set("Windows", true); } Save(); }
From source file:com.igormaznitsa.mindmap.model.MMapURITest.java
@Test public void testAsURI_Linux_CreatedAsFile() throws Exception { if (SystemUtils.IS_OS_LINUX) { final Properties props = new Properties(); props.put("Kik vi", "tere"); final MMapURI uri = new MMapURI(null, new File("/Kik/vi/mitte/midagi.txt"), props); assertEquals(new URI("file:///K%C3%B5ik/v%C3%B5i/mitte/midagi.txt?K%C3%B5ik+v%C3%B5i=tere"), uri.asURI());/* ww w . j av a 2s. co m*/ assertEquals("tere", uri.getParameters().getProperty("Kik vi")); assertEquals(new File("/Kik/vi/mitte/midagi.txt"), uri.asFile(null)); } }
From source file:com.vmware.identity.idm.server.config.IdmServerConfig.java
private void getServiceProviderConnParams(IRegistryAdapter regAdapter, IRegistryKey rootKey) { String portValueName = _useSSL ? PlatformUtils.CONFIG_DIRECTORY_LDAPS_PORT_KEY : PlatformUtils.CONFIG_DIRECTORY_LDAP_PORT_KEY; Integer port = null;/*from ww w . j a v a 2 s. c o m*/ if (SystemUtils.IS_OS_LINUX) { port = pollIntValue(regAdapter, rootKey, CONFIG_DIRECTORY_PARAMETERS_KEY, portValueName); } else { port = regAdapter.getIntValue(rootKey, CONFIG_DIRECTORY_PARAMETERS_KEY, portValueName, true); } // fall back to lotus default port if (port == null || port == 0) { port = LdapConstants.LDAP_PORT_LOTUS; } _directoryConfigStorePort = _useSSL ? LdapConstants.LDAP_SSL_PORT : port; }
From source file:com.houghtonassociates.bamboo.plugins.GerritRepositoryAdapter.java
public synchronized File prepareSSHKeyFile(String strRelativePath, String sshKey) { String filePath = getBaseBuildWorkingDirectory() + File.separator + strRelativePath; File f = new File(filePath); f.setReadable(true, true);//from www .ja v a 2s . co m f.setWritable(true, true); f.setExecutable(false, false); try { FileUtils.writeStringToFile(f, sshKey); } catch (IOException e) { log.error(e.getMessage()); return null; } try { if (SystemUtils.IS_OS_UNIX || SystemUtils.IS_OS_LINUX || SystemUtils.IS_OS_MAC_OSX) Runtime.getRuntime().exec("chmod 700 " + filePath); } catch (IOException e) { log.warn(e.getMessage()); } return f; }
From source file:com.cloud.hypervisor.kvm.resource.LibvirtComputingResourceTest.java
@Test public void testGetNicStats() { //this test is only working on linux because of the loopback interface name //also the tested code seems to work only on linux Assume.assumeTrue(SystemUtils.IS_OS_LINUX); final LibvirtComputingResource libvirtComputingResource = new LibvirtComputingResource(); final Pair<Double, Double> stats = libvirtComputingResource.getNicStats("lo"); assertNotNull(stats);/*from w ww. ja v a 2 s . c o m*/ }
From source file:com.cloud.hypervisor.kvm.resource.LibvirtComputingResourceTest.java
@Test public void getCpuSpeed() { Assume.assumeTrue(SystemUtils.IS_OS_LINUX); final NodeInfo nodeInfo = Mockito.mock(NodeInfo.class); LibvirtComputingResource.getCpuSpeed(nodeInfo); }
From source file:com.vmware.identity.idm.server.LocalOsIdentityProviderTest.java
private static ISecurityAccountsLibrary getSamLib() { if (_lib == null) { if (SystemUtils.IS_OS_WINDOWS) { _lib = new WinSecurityAccountsLibrary(); } else if (SystemUtils.IS_OS_LINUX) { _lib = new LinuxSecurityAccountsLibrary(); } else {/* ww w.j a va2 s. c om*/ throw new RuntimeException("Only Linux and Windows os's are suported."); } } return _lib; }
From source file:com.amazonaws.services.kinesis.producer.KinesisProducer.java
private void extractBinaries() { synchronized (EXTRACT_BIN_MUTEX) { final List<File> watchFiles = new ArrayList<>(2); String os = SystemUtils.OS_NAME; if (SystemUtils.IS_OS_WINDOWS) { os = "windows"; } else if (SystemUtils.IS_OS_LINUX) { os = "linux"; } else if (SystemUtils.IS_OS_MAC_OSX) { os = "osx"; } else {// www. j a va2s. c o m throw new RuntimeException("Your operation system is not supported (" + os + "), the KPL only supports Linux, OSX and Windows"); } String root = "amazon-kinesis-producer-native-binaries"; String tmpDir = config.getTempDirectory(); if (tmpDir.trim().length() == 0) { tmpDir = System.getProperty("java.io.tmpdir"); } tmpDir = Paths.get(tmpDir, root).toString(); pathToTmpDir = tmpDir; String binPath = config.getNativeExecutable(); if (binPath != null && !binPath.trim().isEmpty()) { pathToExecutable = binPath.trim(); log.warn("Using non-default native binary at " + pathToExecutable); pathToLibDir = ""; } else { log.info("Extracting binaries to " + tmpDir); try { File tmpDirFile = new File(tmpDir); if (!tmpDirFile.exists() && !tmpDirFile.mkdirs()) { throw new IOException("Could not create tmp dir " + tmpDir); } String extension = os.equals("windows") ? ".exe" : ""; String executableName = "kinesis_producer" + extension; byte[] bin = IOUtils.toByteArray(this.getClass().getClassLoader() .getResourceAsStream(root + "/" + os + "/" + executableName)); MessageDigest md = MessageDigest.getInstance("SHA1"); String mdHex = DatatypeConverter.printHexBinary(md.digest(bin)).toLowerCase(); pathToExecutable = Paths.get(pathToTmpDir, "kinesis_producer_" + mdHex + extension).toString(); File extracted = new File(pathToExecutable); watchFiles.add(extracted); if (extracted.exists()) { try (FileInputStream fis = new FileInputStream(extracted); FileLock lock = fis.getChannel().lock(0, Long.MAX_VALUE, true)) { boolean contentEqual = false; if (extracted.length() == bin.length) { byte[] existingBin = IOUtils.toByteArray(new FileInputStream(extracted)); contentEqual = Arrays.equals(bin, existingBin); } if (!contentEqual) { throw new SecurityException("The contents of the binary " + extracted.getAbsolutePath() + " is not what it's expected to be."); } } } else { try (FileOutputStream fos = new FileOutputStream(extracted); FileLock lock = fos.getChannel().lock()) { IOUtils.write(bin, fos); } extracted.setExecutable(true); } String certFileName = "b204d74a.0"; File certFile = new File(pathToTmpDir, certFileName); if (!certFile.exists()) { try (FileOutputStream fos = new FileOutputStream(certFile); FileLock lock = fos.getChannel().lock()) { byte[] certs = IOUtils.toByteArray(this.getClass().getClassLoader() .getResourceAsStream("cacerts/" + certFileName)); IOUtils.write(certs, fos); } } watchFiles.add(certFile); pathToLibDir = pathToTmpDir; FileAgeManager.instance().registerFiles(watchFiles); } catch (Exception e) { throw new RuntimeException("Could not copy native binaries to temp directory " + tmpDir, e); } } } }