io.netty.util.internal.SystemPropertyUtil Java Examples
The following examples show how to use
io.netty.util.internal.SystemPropertyUtil.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ResourceLeakDetectorFactory.java From netty-4.1.22 with Apache License 2.0 | 6 votes |
DefaultResourceLeakDetectorFactory() { String customLeakDetector; try { customLeakDetector = AccessController.doPrivileged(new PrivilegedAction<String>() { @Override public String run() { return SystemPropertyUtil.get("io.netty.customResourceLeakDetector"); } }); } catch (Throwable cause) { logger.error("Could not access System property: io.netty.customResourceLeakDetector", cause); customLeakDetector = null; } if (customLeakDetector == null) { obsoleteCustomClassConstructor = customClassConstructor = null; } else { obsoleteCustomClassConstructor = obsoleteCustomClassConstructor(customLeakDetector); customClassConstructor = customClassConstructor(customLeakDetector); } }
Example #2
Source File: AbstractBootstrapServer.java From InChat with Apache License 2.0 | 6 votes |
private void initSsl(InitNetty serverBean){ ExecutorService executorService = Executors.newCachedThreadPool(); executorService.submit(() -> {}); String algorithm = SystemPropertyUtil.get("ssl.KeyManagerFactory.algorithm"); if (algorithm == null) { algorithm = "SunX509"; } SSLContext serverContext; try { // KeyStore ks = KeyStore.getInstance("JKS"); ks.load( SecureSocketSslContextFactory.class.getResourceAsStream(serverBean.getJksFile()), serverBean.getJksStorePassword().toCharArray()); KeyManagerFactory kmf = KeyManagerFactory.getInstance(algorithm); kmf.init(ks,serverBean.getJksCertificatePassword().toCharArray()); serverContext = SSLContext.getInstance(PROTOCOL); serverContext.init(kmf.getKeyManagers(), null, null); } catch (Exception e) { throw new Error( "Failed to initialize the server-side SSLContext", e); } SERVER_CONTEXT = serverContext; }
Example #3
Source File: RecycleTest.java From sailfish with Apache License 2.0 | 6 votes |
@Test public void testRecycleInSyncThread() throws Exception{ //recycle Resource2 resource1 = Resource2.newInstance(); resource1.recycle(); //don't recycle resource1 = Resource2.newInstance(); Resource2 temp =null; // By default we allow one push to a Recycler for each 8th try on handles that were never recycled before. // This should help to slowly increase the capacity of the recycler while not be too sensitive to allocation // bursts. int stackDefaultRatioMask = SystemPropertyUtil.getInt("io.netty.recycler.ratio", 8) - 1; for(int i =0; i< stackDefaultRatioMask; i++){ temp = Resource2.newInstance(); temp.recycle(); Assert.assertTrue(temp != Resource2.newInstance()); } temp = Resource2.newInstance(); temp.recycle(); Assert.assertTrue(temp == Resource2.newInstance()); }
Example #4
Source File: NettySocketSslContext.java From openzaly with Apache License 2.0 | 6 votes |
private NettySocketSslContext() { String algorithm = SystemPropertyUtil.get("ssl.KeyManagerFactory.algorithm"); if (algorithm == null) { algorithm = "SunX509"; } try { // KeyStore keystore = KeyStore.getInstance("JKS"); keystore.load(SslKeyStore.asInputStream(), SslKeyStore.getKeyStorePassword()); // Set up key manager factory to use our key store KeyManagerFactory kmf = KeyManagerFactory.getInstance(algorithm); kmf.init(keystore, SslKeyStore.getCertificatePassword()); // Initialize the SSLContext to work with our key managers. serverContext = SSLContext.getInstance(PROTOCOL); serverContext.init(kmf.getKeyManagers(), null, null); } catch (Exception e) { throw new Error("Failed to initialize the server-side SSLContext", e); } }
Example #5
Source File: NettySocketSslContext.java From openzaly with Apache License 2.0 | 6 votes |
private NettySocketSslContext() { String algorithm = SystemPropertyUtil.get("ssl.KeyManagerFactory.algorithm"); if (algorithm == null) { algorithm = "SunX509"; } try { // KeyStore keystore = KeyStore.getInstance("JKS"); keystore.load(SslKeyStore.asInputStream(), SslKeyStore.getKeyStorePassword()); // Set up key manager factory to use our key store KeyManagerFactory kmf = KeyManagerFactory.getInstance(algorithm); kmf.init(keystore, SslKeyStore.getCertificatePassword()); // Initialize the SSLContext to work with our key managers. serverContext = SSLContext.getInstance(PROTOCOL); serverContext.init(kmf.getKeyManagers(), null, null); } catch (Exception e) { throw new Error("Failed to initialize the server-side SSLContext", e); } }
Example #6
Source File: Native.java From netty-4.1.22 with Apache License 2.0 | 6 votes |
private static void loadNativeLibrary() { String name = SystemPropertyUtil.get("os.name").toLowerCase(Locale.UK).trim(); if (!name.startsWith("linux")) { throw new IllegalStateException("Only supported on Linux"); } String staticLibName = "netty_transport_native_epoll"; String sharedLibName = staticLibName + '_' + PlatformDependent.normalizedArch(); ClassLoader cl = PlatformDependent.getClassLoader(Native.class); try { NativeLibraryLoader.load(sharedLibName, cl); } catch (UnsatisfiedLinkError e1) { try { NativeLibraryLoader.load(staticLibName, cl); logger.debug("Failed to load {}", sharedLibName, e1); } catch (UnsatisfiedLinkError e2) { ThrowableUtil.addSuppressed(e1, e2); throw e1; } } }
Example #7
Source File: Native.java From netty-4.1.22 with Apache License 2.0 | 6 votes |
private static void loadNativeLibrary() { String name = SystemPropertyUtil.get("os.name").toLowerCase(Locale.UK).trim(); if (!name.startsWith("mac") && !name.contains("bsd") && !name.startsWith("darwin")) { throw new IllegalStateException("Only supported on BSD"); } String staticLibName = "netty_transport_native_kqueue"; String sharedLibName = staticLibName + '_' + PlatformDependent.normalizedArch(); ClassLoader cl = PlatformDependent.getClassLoader(Native.class); try { NativeLibraryLoader.load(sharedLibName, cl); } catch (UnsatisfiedLinkError e1) { try { NativeLibraryLoader.load(staticLibName, cl); logger.debug("Failed to load {}", sharedLibName, e1); } catch (UnsatisfiedLinkError e2) { ThrowableUtil.addSuppressed(e1, e2); throw e1; } } }
Example #8
Source File: NettyRuntimeTests.java From netty-4.1.22 with Apache License 2.0 | 6 votes |
@Test @SuppressForbidden(reason = "testing fallback to Runtime#availableProcessors") public void testGet() { final String availableProcessorsSystemProperty = SystemPropertyUtil.get("io.netty.availableProcessors"); try { System.clearProperty("io.netty.availableProcessors"); final NettyRuntime.AvailableProcessorsHolder holder = new NettyRuntime.AvailableProcessorsHolder(); assertThat(holder.availableProcessors(), equalTo(Runtime.getRuntime().availableProcessors())); } finally { if (availableProcessorsSystemProperty != null) { System.setProperty("io.netty.availableProcessors", availableProcessorsSystemProperty); } else { System.clearProperty("io.netty.availableProcessors"); } } }
Example #9
Source File: HttpStaticFileServerHandler.java From timely with Apache License 2.0 | 6 votes |
private static String sanitizeUri(String uri) { // Decode the path. try { uri = URLDecoder.decode(uri, "UTF-8"); } catch (UnsupportedEncodingException e) { throw new Error(e); } if (uri.isEmpty() || uri.charAt(0) != '/') { return null; } // Convert file separators. uri = uri.replace('/', File.separatorChar); // Simplistic dumb security check. // You will have to do something serious in the production environment. if (uri.contains(File.separator + '.') || uri.contains('.' + File.separator) || uri.charAt(0) == '.' || uri.charAt(uri.length() - 1) == '.' || INSECURE_URI.matcher(uri).matches()) { return null; } // Convert to absolute path. return SystemPropertyUtil.get("user.dir") + File.separator + uri; }
Example #10
Source File: NettySocketSslContext.java From wind-im with Apache License 2.0 | 6 votes |
private NettySocketSslContext() { String algorithm = SystemPropertyUtil.get("ssl.KeyManagerFactory.algorithm"); if (algorithm == null) { algorithm = "SunX509"; } try { // KeyStore keystore = KeyStore.getInstance("JKS"); keystore.load(SslKeyStore.asInputStream(), SslKeyStore.getKeyStorePassword()); // Set up key manager factory to use our key store KeyManagerFactory kmf = KeyManagerFactory.getInstance(algorithm); kmf.init(keystore, SslKeyStore.getCertificatePassword()); // Initialize the SSLContext to work with our key managers. serverContext = SSLContext.getInstance(PROTOCOL); serverContext.init(kmf.getKeyManagers(), null, null); } catch (Exception e) { throw new Error("Failed to initialize the server-side SSLContext", e); } }
Example #11
Source File: GrafanaAuth.java From timely with Apache License 2.0 | 5 votes |
private static boolean useEpoll() { // Should we just return true if this is Linux and if we get an error // during Epoll // setup handle it there? final String os = SystemPropertyUtil.get(OS_NAME).toLowerCase().trim(); final String[] version = SystemPropertyUtil.get(OS_VERSION).toLowerCase().trim().split("\\."); if (os.startsWith("linux") && version.length >= 3) { final int major = Integer.parseInt(version[0]); if (major > EPOLL_MIN_MAJOR_VERSION) { return true; } else if (major == EPOLL_MIN_MAJOR_VERSION) { final int minor = Integer.parseInt(version[1]); if (minor > EPOLL_MIN_MINOR_VERSION) { return true; } else if (minor == EPOLL_MIN_MINOR_VERSION) { final int patch = Integer.parseInt(version[2].substring(0, 2)); return patch >= EPOLL_MIN_PATCH_VERSION; } else { return false; } } else { return false; } } else { return false; } }
Example #12
Source File: HttpStaticFileServerHandler.java From netty-4.1.22 with Apache License 2.0 | 5 votes |
private static String sanitizeUri(String uri) { // Decode the path. try { uri = URLDecoder.decode(uri, "UTF-8"); } catch (UnsupportedEncodingException e) { throw new Error(e); } if (uri.isEmpty() || uri.charAt(0) != '/') { return null; } // Convert file separators. uri = uri.replace('/', File.separatorChar); // Simplistic dumb security check. // You will have to do something serious in the production environment. if (uri.contains(File.separator + '.') || uri.contains('.' + File.separator) || uri.charAt(0) == '.' || uri.charAt(uri.length() - 1) == '.' || INSECURE_URI.matcher(uri).matches()) { return null; } // Convert to absolute path. return SystemPropertyUtil.get("user.dir") + File.separator + uri; }
Example #13
Source File: Balancer.java From timely with Apache License 2.0 | 5 votes |
private static boolean useEpoll() { // Should we just return true if this is Linux and if we get an error // during Epoll // setup handle it there? final String os = SystemPropertyUtil.get(OS_NAME).toLowerCase().trim(); final String[] version = SystemPropertyUtil.get(OS_VERSION).toLowerCase().trim().split("\\."); if (os.startsWith("linux") && version.length >= 3) { final int major = Integer.parseInt(version[0]); if (major > EPOLL_MIN_MAJOR_VERSION) { return true; } else if (major == EPOLL_MIN_MAJOR_VERSION) { final int minor = Integer.parseInt(version[1]); if (minor > EPOLL_MIN_MINOR_VERSION) { return true; } else if (minor == EPOLL_MIN_MINOR_VERSION) { final int patch = Integer.parseInt(version[2].substring(0, 2)); return patch >= EPOLL_MIN_PATCH_VERSION; } else { return false; } } else { return false; } } else { return false; } }
Example #14
Source File: Server.java From timely with Apache License 2.0 | 5 votes |
private static boolean useEpoll() { // Should we just return true if this is Linux and if we get an error // during Epoll // setup handle it there? final String os = SystemPropertyUtil.get(OS_NAME).toLowerCase().trim(); final String[] version = SystemPropertyUtil.get(OS_VERSION).toLowerCase().trim().split("\\."); if (os.startsWith("linux") && version.length >= 3) { final int major = Integer.parseInt(version[0]); if (major > EPOLL_MIN_MAJOR_VERSION) { return true; } else if (major == EPOLL_MIN_MAJOR_VERSION) { final int minor = Integer.parseInt(version[1]); if (minor > EPOLL_MIN_MINOR_VERSION) { return true; } else if (minor == EPOLL_MIN_MINOR_VERSION) { final int patch = Integer.parseInt(version[2].substring(0, 2)); return patch >= EPOLL_MIN_PATCH_VERSION; } else { return false; } } else { return false; } } else { return false; } }
Example #15
Source File: HttpStaticFileServerHandler.java From netty4.0.27Learn with Apache License 2.0 | 5 votes |
private static String sanitizeUri(String uri) { // Decode the path. try { uri = URLDecoder.decode(uri, "UTF-8"); } catch (UnsupportedEncodingException e) { throw new Error(e); } if (uri.isEmpty() || uri.charAt(0) != '/') { return null; } // Convert file separators. uri = uri.replace('/', File.separatorChar); // Simplistic dumb security check. // You will have to do something serious in the production environment. if (uri.contains(File.separator + '.') || uri.contains('.' + File.separator) || uri.charAt(0) == '.' || uri.charAt(uri.length() - 1) == '.' || INSECURE_URI.matcher(uri).matches()) { return null; } // Convert to absolute path. return SystemPropertyUtil.get("user.dir") + File.separator + uri; }
Example #16
Source File: Holder.java From blynk-server with GNU General Public License v3.0 | 5 votes |
private static void disableNettyLeakDetector() { String leakProperty = SystemPropertyUtil.get("io.netty.leakDetection.level"); //we do not pass any with JVM option if (leakProperty == null) { System.setProperty("io.netty.leakDetection.level", "disabled"); } }
Example #17
Source File: ThriftSerializer.java From tchannel-java with MIT License | 5 votes |
@VisibleForTesting static void init() { // We should always prefer direct buffers by default if Netty prefers it and not explicitly prohibited. DIRECT_BUFFER_PREFERRED = PlatformDependent.directBufferPreferred() && !SystemPropertyUtil.getBoolean("com.uber.tchannel.thrift_serializer.noPreferDirect", false); if (logger.isDebugEnabled()) { logger.debug("-Dcom.uber.tchannel.thrift_serializer.noPreferDirect: {}", !DIRECT_BUFFER_PREFERRED); } }
Example #18
Source File: HttpStaticFileServerHandler.java From netty-cookbook with Apache License 2.0 | 5 votes |
private static String sanitizeUri(String uri) { // Decode the path. try { uri = URLDecoder.decode(uri, "UTF-8"); } catch (UnsupportedEncodingException e) { throw new Error(e); } if (uri.isEmpty() || uri.charAt(0) != '/') { return null; } // Convert file separators. uri = uri.replace('/', File.separatorChar); // Simplistic dumb security check. // You will have to do something serious in the production environment. if (uri.contains(File.separator + '.') || uri.contains('.' + File.separator) || uri.charAt(0) == '.' || uri.charAt(uri.length() - 1) == '.' || INSECURE_URI.matcher(uri).matches()) { return null; } // Convert to absolute path. return SystemPropertyUtil.get("user.dir") + File.separator + uri; }
Example #19
Source File: NettyRuntimeTests.java From netty-4.1.22 with Apache License 2.0 | 5 votes |
@Test public void testGetWithSystemProperty() { final String availableProcessorsSystemProperty = SystemPropertyUtil.get("io.netty.availableProcessors"); try { System.setProperty("io.netty.availableProcessors", "2048"); final NettyRuntime.AvailableProcessorsHolder holder = new NettyRuntime.AvailableProcessorsHolder(); assertThat(holder.availableProcessors(), equalTo(2048)); } finally { if (availableProcessorsSystemProperty != null) { System.setProperty("io.netty.availableProcessors", availableProcessorsSystemProperty); } else { System.clearProperty("io.netty.availableProcessors"); } } }
Example #20
Source File: Server.java From qonduit with Apache License 2.0 | 5 votes |
private static boolean useEpoll() { // Should we just return true if this is Linux and if we get an error // during Epoll // setup handle it there? final String os = SystemPropertyUtil.get(OS_NAME).toLowerCase().trim(); final String[] version = SystemPropertyUtil.get(OS_VERSION).toLowerCase().trim().split("\\."); if (os.startsWith("linux") && version.length >= 3) { final int major = Integer.parseInt(version[0]); if (major > EPOLL_MIN_MAJOR_VERSION) { return true; } else if (major == EPOLL_MIN_MAJOR_VERSION) { final int minor = Integer.parseInt(version[1]); if (minor > EPOLL_MIN_MINOR_VERSION) { return true; } else if (minor == EPOLL_MIN_MINOR_VERSION) { final int patch = Integer.parseInt(version[2].substring(0, 2)); return patch >= EPOLL_MIN_PATCH_VERSION; } else { return false; } } else { return false; } } else { return false; } }
Example #21
Source File: AbstractMicrobenchmark.java From netty4.0.27Learn with Apache License 2.0 | 4 votes |
protected int getWarmupIterations() { return SystemPropertyUtil.getInt("warmupIterations", -1); }
Example #22
Source File: NettyByteBufLeakHelper.java From ambry with Apache License 2.0 | 4 votes |
/** * Constructor to create a {@link NettyByteBufLeakHelper}. */ public NettyByteBufLeakHelper() { // The allocator cache is enabled by default if this property is not set. The default value of 32k comes from // PooledByteBufAllocator.DEFAULT_MAX_CACHED_BUFFER_CAPACITY (private constant) cachedEnabled = SystemPropertyUtil.getInt("io.netty.allocator.maxCachedBufferCapacity", 32 * 1024) != 0; }
Example #23
Source File: AbstractMicrobenchmark.java From netty-4.1.22 with Apache License 2.0 | 4 votes |
protected int getForks() { return SystemPropertyUtil.getInt("forks", -1); }
Example #24
Source File: AbstractMicrobenchmarkBase.java From netty-4.1.22 with Apache License 2.0 | 4 votes |
protected int getWarmupIterations() { return SystemPropertyUtil.getInt("warmupIterations", -1); }
Example #25
Source File: AbstractMicrobenchmarkBase.java From netty-4.1.22 with Apache License 2.0 | 4 votes |
protected int getMeasureIterations() { return SystemPropertyUtil.getInt("measureIterations", -1); }
Example #26
Source File: UnixDomainSocketTest.java From spinach with Apache License 2.0 | 4 votes |
private void linuxOnly() { String osName = SystemPropertyUtil.get("os.name").toLowerCase(Locale.UK).trim(); assumeTrue("Only supported on Linux, your os is " + osName, osName.startsWith("linux")); }
Example #27
Source File: AbstractMicrobenchmark.java From netty4.0.27Learn with Apache License 2.0 | 4 votes |
protected String getReportDir() { return SystemPropertyUtil.get("perfReportDir"); }
Example #28
Source File: AbstractMicrobenchmark.java From netty4.0.27Learn with Apache License 2.0 | 4 votes |
protected int getForks() { return SystemPropertyUtil.getInt("forks", -1); }
Example #29
Source File: AbstractMicrobenchmark.java From netty4.0.27Learn with Apache License 2.0 | 4 votes |
protected int getMeasureIterations() { return SystemPropertyUtil.getInt("measureIterations", -1); }
Example #30
Source File: AbstractMicrobenchmarkBase.java From netty-4.1.22 with Apache License 2.0 | 4 votes |
protected String getReportDir() { return SystemPropertyUtil.get("perfReportDir"); }