예제 #1
0
  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();
  }
예제 #2
0
  void start() {
    nodeEngine.start();
    connectionManager.start();
    if (config.getNetworkConfig().getJoin().getMulticastConfig().isEnabled()) {
      final Thread multicastServiceThread =
          new Thread(
              hazelcastThreadGroup.getInternalThreadGroup(),
              multicastService,
              hazelcastThreadGroup.getThreadNamePrefix("MulticastThread"));
      multicastServiceThread.start();
    }
    if (groupProperties.getBoolean(GroupProperty.DISCOVERY_SPI_ENABLED)) {
      discoveryService.start();
    }

    if (groupProperties.getBoolean(GroupProperty.SHUTDOWNHOOK_ENABLED)) {
      logger.finest("Adding ShutdownHook");
      Runtime.getRuntime().addShutdownHook(shutdownHookThread);
    }
    state = NodeState.ACTIVE;

    join();
    int clusterSize = clusterService.getSize();
    if (config.getNetworkConfig().isPortAutoIncrement()
        && address.getPort() >= config.getNetworkConfig().getPort() + clusterSize) {
      StringBuilder sb = new StringBuilder("Config seed port is ");
      sb.append(config.getNetworkConfig().getPort());
      sb.append(" and cluster size is ");
      sb.append(clusterSize);
      sb.append(". Some of the ports seem occupied!");
      logger.warning(sb.toString());
    }
    try {
      managementCenterService = new ManagementCenterService(hazelcastInstance);
    } catch (Exception e) {
      logger.warning("ManagementCenterService could not be constructed!", e);
    }
    nodeExtension.afterStart(this);
    versionCheck.check(this, getBuildInfo().getVersion(), buildInfo.isEnterprise());
  }