public static void deleteQuiet(File file) { try { delete(file); } catch (IOException ignored) { EmptyStatement.ignore(ignored); } }
public Map<String, String> phoneHome(Node hazelcastNode, String version, boolean isEnterprise) { String downloadId = "source"; InputStream is = null; try { is = getClass().getClassLoader().getResourceAsStream("hazelcast-download.properties"); if (is != null) { final Properties properties = new Properties(); properties.load(is); downloadId = properties.getProperty("hazelcastDownloadId"); } } catch (IOException ignored) { EmptyStatement.ignore(ignored); } finally { IOUtil.closeResource(is); } // Calculate native memory usage from native memory config NativeMemoryConfig memoryConfig = hazelcastNode.getConfig().getNativeMemoryConfig(); final ClusterServiceImpl clusterService = hazelcastNode.getClusterService(); long totalNativeMemorySize = clusterService.getSize(DATA_MEMBER_SELECTOR) * memoryConfig.getSize().bytes(); String nativeMemoryParameter = (isEnterprise) ? Long.toString(MemoryUnit.BYTES.toGigaBytes(totalNativeMemorySize)) : "0"; // Calculate connected clients to the cluster. Map<ClientType, Integer> clusterClientStats = hazelcastNode.clientEngine.getConnectedClientStats(); RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean(); Long clusterUpTime = clusterService.getClusterClock().getClusterUpTime(); PhoneHomeParameterCreator parameterCreator = new PhoneHomeParameterCreator(); parameterCreator.addParam("version", version); parameterCreator.addParam("m", hazelcastNode.getLocalMember().getUuid()); parameterCreator.addParam("e", Boolean.toString(isEnterprise)); parameterCreator.addParam("l", MD5Util.toMD5String(hazelcastNode.getConfig().getLicenseKey())); parameterCreator.addParam("p", downloadId); parameterCreator.addParam("c", clusterService.getClusterId()); parameterCreator.addParam("crsz", convertToLetter(clusterService.getMembers().size())); parameterCreator.addParam( "cssz", convertToLetter(hazelcastNode.clientEngine.getClientEndpointCount())); parameterCreator.addParam("hdgb", nativeMemoryParameter); parameterCreator.addParam("ccpp", Integer.toString(clusterClientStats.get(ClientType.CPP))); parameterCreator.addParam("cdn", Integer.toString(clusterClientStats.get(ClientType.CSHARP))); parameterCreator.addParam("cjv", Integer.toString(clusterClientStats.get(ClientType.JAVA))); parameterCreator.addParam("cuptm", Long.toString(clusterUpTime)); parameterCreator.addParam("nuptm", Long.toString(runtimeMxBean.getUptime())); String urlStr = BASE_PHONE_HOME_URL + parameterCreator.build(); fetchWebService(urlStr); return parameterCreator.getParameters(); }
private void fetchWebService(String urlStr) { InputStream in = null; try { URL url = new URL(urlStr); URLConnection conn = url.openConnection(); conn.setRequestProperty("User-Agent", "Mozilla/5.0"); conn.setConnectTimeout(TIMEOUT * 2); conn.setReadTimeout(TIMEOUT * 2); in = new BufferedInputStream(conn.getInputStream()); } catch (IOException ignored) { EmptyStatement.ignore(ignored); } finally { IOUtil.closeResource(in); } }
static List<ClassLoader> selectClassLoaders(ClassLoader classLoader) { // List prevents reordering! List<ClassLoader> classLoaders = new ArrayList<ClassLoader>(); if (classLoader != null) { classLoaders.add(classLoader); } // Is TCCL same as given classLoader ClassLoader tccl = Thread.currentThread().getContextClassLoader(); if (tccl != classLoader) { classLoaders.add(tccl); } // Hazelcast core classLoader ClassLoader coreClassLoader = ServiceLoader.class.getClassLoader(); if (coreClassLoader != classLoader && coreClassLoader != tccl) { classLoaders.add(coreClassLoader); } // Hazelcast client classLoader try { Class<?> hzClientClass = Class.forName("com.hazelcast.client.HazelcastClient"); ClassLoader clientClassLoader = hzClientClass.getClassLoader(); if (clientClassLoader != classLoader && clientClassLoader != tccl && clientClassLoader != coreClassLoader) { classLoaders.add(clientClassLoader); } } catch (ClassNotFoundException ignore) { EmptyStatement.ignore(ignore); // ignore since we does not have HazelcastClient in classpath } return classLoaders; }