Ejemplo n.º 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();
  }
Ejemplo n.º 2
0
  private void registerServices(
      Map<String, Properties> serviceProps, Map<String, Object> serviceConfigObjects) {
    registerCoreServices();

    Node node = nodeEngine.getNode();
    ServicesConfig servicesConfig = node.getConfig().getServicesConfig();
    if (servicesConfig != null) {
      registerDefaultServices(servicesConfig);
      registerUserServices(servicesConfig, serviceProps, serviceConfigObjects);
    }
  }
Ejemplo n.º 3
0
  public MulticastService(Node node, MulticastSocket multicastSocket) throws Exception {
    this.node = node;
    logger = node.getLogger(MulticastService.class.getName());
    Config config = node.getConfig();
    this.multicastSocket = multicastSocket;

    sendOutput = node.getSerializationService().createObjectDataOutput(1024);
    datagramPacketReceive =
        new DatagramPacket(new byte[DATAGRAM_BUFFER_SIZE], DATAGRAM_BUFFER_SIZE);
    final MulticastConfig multicastConfig =
        config.getNetworkConfig().getJoin().getMulticastConfig();
    datagramPacketSend =
        new DatagramPacket(
            new byte[0],
            0,
            InetAddress.getByName(multicastConfig.getMulticastGroup()),
            multicastConfig.getMulticastPort());
    running = true;
  }
Ejemplo n.º 4
0
 @Override
 public Collection<Integer> getOutboundPorts() {
   final NetworkConfig networkConfig = node.getConfig().getNetworkConfig();
   final Collection<String> portDefinitions = getPortDefinitions(networkConfig);
   final Set<Integer> ports = getPorts(networkConfig);
   if (portDefinitions.isEmpty() && ports.isEmpty()) {
     // means any port
     return Collections.emptySet();
   }
   if (portDefinitions.contains("*") || portDefinitions.contains("0")) {
     // means any port
     return Collections.emptySet();
   }
   transformPortDefinitionsToPorts(portDefinitions, ports);
   if (ports.contains(0)) {
     // means any port
     return Collections.emptySet();
   }
   return ports;
 }
Ejemplo n.º 5
0
 @Override
 public Config getConfig() {
   return node.getConfig();
 }
Ejemplo n.º 6
0
 public Config getConfig() {
   return node.getConfig();
 }
Ejemplo n.º 7
0
 @Override
 public SymmetricEncryptionConfig getSymmetricEncryptionConfig() {
   return node.getConfig().getNetworkConfig().getSymmetricEncryptionConfig();
 }
Ejemplo n.º 8
0
 @Override
 public SocketInterceptorConfig getSocketInterceptorConfig() {
   return node.getConfig().getNetworkConfig().getSocketInterceptorConfig();
 }
Ejemplo n.º 9
0
 @Override
 public SSLConfig getSSLConfig() {
   return node.getConfig().getNetworkConfig().getSSLConfig();
 }
Ejemplo n.º 10
0
 public TcpIpJoinerOverAWS(Node node) {
   super(node);
   logger = node.getLogger(getClass());
   AwsConfig awsConfig = node.getConfig().getNetworkConfig().getJoin().getAwsConfig();
   aws = new AWSClient(awsConfig);
 }