Beispiel #1
0
  public Node(HazelcastInstanceImpl hazelcastInstance, Config config, NodeContext nodeContext) {
    this.hazelcastInstance = hazelcastInstance;
    this.config = config;
    this.configClassLoader = config.getClassLoader();
    this.groupProperties = new GroupProperties(config);
    this.buildInfo = BuildInfoProvider.getBuildInfo();

    String loggingType = groupProperties.getString(GroupProperty.LOGGING_TYPE);
    loggingService =
        new LoggingServiceImpl(config.getGroupConfig().getName(), loggingType, buildInfo);
    final AddressPicker addressPicker = nodeContext.createAddressPicker(this);
    try {
      addressPicker.pickAddress();
    } catch (Throwable e) {
      throw ExceptionUtil.rethrow(e);
    }

    final ServerSocketChannel serverSocketChannel = addressPicker.getServerSocketChannel();
    try {
      address = addressPicker.getPublicAddress();
      final Map<String, Object> memberAttributes =
          findMemberAttributes(config.getMemberAttributeConfig().asReadOnly());
      localMember =
          new MemberImpl(
              address, true, createMemberUuid(address), hazelcastInstance, memberAttributes);
      loggingService.setThisMember(localMember);
      logger = loggingService.getLogger(Node.class.getName());
      hazelcastThreadGroup =
          new HazelcastThreadGroup(hazelcastInstance.getName(), logger, configClassLoader);
      nodeExtension = NodeExtensionFactory.create(configClassLoader);
      nodeExtension.beforeStart(this);

      serializationService = nodeExtension.createSerializationService();
      securityContext =
          config.getSecurityConfig().isEnabled() ? nodeExtension.getSecurityContext() : null;

      nodeEngine = new NodeEngineImpl(this);

      clientEngine = new ClientEngineImpl(this);
      connectionManager = nodeContext.createConnectionManager(this, serverSocketChannel);
      partitionService = new InternalPartitionServiceImpl(this);
      clusterService = new ClusterServiceImpl(this);
      textCommandService = new TextCommandServiceImpl(this);
      nodeExtension.printNodeInfo(this);
      multicastService =
          createMulticastService(addressPicker.getBindAddress(), this, config, logger);
      discoveryService = createDiscoveryService(config);
      initializeListeners(config);
      joiner = nodeContext.createJoiner(this);
    } catch (Throwable e) {
      try {
        serverSocketChannel.close();
      } catch (Throwable ignored) {
      }
      throw ExceptionUtil.rethrow(e);
    }
  }
 @Test
 public void testMemberAttributesConfig() {
   MemberAttributeConfig memberAttributeConfig = config.getMemberAttributeConfig();
   assertNotNull(memberAttributeConfig);
   assertEquals("spring-group", memberAttributeConfig.getStringAttribute("cluster.group.name"));
   assertEquals(new Integer(5700), memberAttributeConfig.getIntAttribute("cluster.port.int"));
   assertEquals(new Long(5700), memberAttributeConfig.getLongAttribute("cluster.port.long"));
   assertEquals(new Short("5700"), memberAttributeConfig.getShortAttribute("cluster.port.short"));
   assertEquals(new Byte("111"), memberAttributeConfig.getByteAttribute("attribute.byte"));
   assertTrue(memberAttributeConfig.getBooleanAttribute("attribute.boolean"));
   assertEquals(0.0d, memberAttributeConfig.getDoubleAttribute("attribute.double"), 0.0001d);
   assertEquals(1234.5678, memberAttributeConfig.getFloatAttribute("attribute.float"), 0.0001);
 }
Beispiel #3
0
  public JoinRequest createJoinRequest(boolean withCredentials) {
    final Credentials credentials =
        (withCredentials && securityContext != null)
            ? securityContext.getCredentialsFactory().newCredentials()
            : null;

    return new JoinRequest(
        Packet.VERSION,
        buildInfo.getBuildNumber(),
        address,
        localMember.getUuid(),
        createConfigCheck(),
        credentials,
        config.getMemberAttributeConfig().getAttributes());
  }