@Test
 public void testGroupConfig() {
   GroupConfig groupConfig = config.getGroupConfig();
   assertNotNull(groupConfig);
   assertEquals("spring-group", groupConfig.getName());
   assertEquals("spring-group-pass", groupConfig.getPassword());
 }
Пример #2
0
 private HazelcastClient(ClientConfig config) {
   this.config = config;
   final GroupConfig groupConfig = config.getGroupConfig();
   instanceName = "hz.client_" + id + (groupConfig != null ? "_" + groupConfig.getName() : "");
   threadGroup = new ThreadGroup(instanceName);
   lifecycleService = new LifecycleServiceImpl(this);
   clientProperties = new ClientProperties(config);
   serializationService = initSerializationService(config);
   proxyManager = new ProxyManager(this);
   executionService =
       new ClientExecutionServiceImpl(
           instanceName,
           threadGroup,
           Thread.currentThread().getContextClassLoader(),
           config.getExecutorPoolSize());
   transactionManager = new ClientTransactionManager(this);
   LoadBalancer lb = config.getLoadBalancer();
   if (lb == null) {
     lb = new RoundRobinLB();
   }
   loadBalancer = lb;
   connectionManager = createClientConnectionManager();
   clusterService = new ClientClusterServiceImpl(this);
   invocationService = new ClientInvocationServiceImpl(this);
   userContext = new ConcurrentHashMap<String, Object>();
   proxyManager.init(config);
   partitionService = new ClientPartitionServiceImpl(this);
 }
 private boolean authenticateWithUserNameAndPassword() {
   GroupConfig groupConfig = nodeEngine.getConfig().getGroupConfig();
   String nodeGroupName = groupConfig.getName();
   String nodeGroupPassword = groupConfig.getPassword();
   boolean usernameMatch = nodeGroupName.equals(parameters.username);
   boolean passwordMatch = nodeGroupPassword.equals(parameters.password);
   return usernameMatch && passwordMatch;
 }
 private boolean authenticate(UsernamePasswordCredentials credentials) {
   GroupConfig groupConfig = nodeEngine.getConfig().getGroupConfig();
   String nodeGroupName = groupConfig.getName();
   String nodeGroupPassword = groupConfig.getPassword();
   boolean usernameMatch = nodeGroupName.equals(credentials.getUsername());
   boolean passwordMatch = nodeGroupPassword.equals(credentials.getPassword());
   return usernameMatch && passwordMatch;
 }
 @Override
 public void run() {
   GroupConfig groupConfig = getNodeEngine().getConfig().getGroupConfig();
   if (!groupName.equals(groupConfig.getName())) {
     response = Boolean.FALSE;
   } else if (!groupPassword.equals(groupConfig.getPassword())) {
     response = Boolean.FALSE;
   }
 }
 public byte[] changeWebServerUrlOverCluster(String groupName, String groupPass, String newUrl) {
   try {
     GroupConfig groupConfig = factory.getConfig().getGroupConfig();
     if (!(groupConfig.getName().equals(groupName) && groupConfig.getPassword().equals(groupPass)))
       return HttpCommand.RES_403;
     ManagementCenterConfigCallable callable = new ManagementCenterConfigCallable(newUrl);
     callable.setHazelcastInstance(factory);
     Set<Member> members = factory.getCluster().getMembers();
     MultiTask<Void> task = new MultiTask<Void>(callable, members);
     ExecutorService executorService = factory.getExecutorService();
     executorService.execute(task);
   } catch (Throwable throwable) {
     logger.log(Level.WARNING, "New web server url cannot be assigned.", throwable);
     return HttpCommand.RES_500;
   }
   return HttpCommand.RES_204;
 }
Пример #7
0
  public ConfigCheck createConfigCheck() {
    final ConfigCheck configCheck = new ConfigCheck();
    final GroupConfig groupConfig = config.getGroupConfig();
    final PartitionGroupConfig partitionGroupConfig = config.getPartitionGroupConfig();
    final boolean partitionGroupEnabled =
        partitionGroupConfig != null && partitionGroupConfig.isEnabled();

    PartitionGroupConfig.MemberGroupType memberGroupType =
        partitionGroupEnabled
            ? partitionGroupConfig.getGroupType()
            : PartitionGroupConfig.MemberGroupType.PER_MEMBER;
    configCheck
        .setGroupName(groupConfig.getName())
        .setGroupPassword(groupConfig.getPassword())
        .setJoinerType(joiner != null ? joiner.getType() : "")
        .setPartitionGroupEnabled(partitionGroupEnabled)
        .setMemberGroupType(memberGroupType);
    return configCheck;
  }
    public void run() {
      if (webServerUrl == null) {
        logger.log(Level.WARNING, "Web server url is null!");
        return;
      }
      try {
        Random rand = new Random();
        Address address =
            ((MemberImpl) factory.node.getClusterImpl().getLocalMember()).getAddress();
        GroupConfig groupConfig = factory.getConfig().getGroupConfig();
        while (running.get()) {
          try {
            URL url =
                new URL(
                    webServerUrl
                        + "getTask.do?member="
                        + address.getHost()
                        + ":"
                        + address.getPort()
                        + "&cluster="
                        + groupConfig.getName());
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            connection.setRequestProperty("Connection", "keep-alive");
            InputStream inputStream = connection.getInputStream();
            DataInputStream input = new DataInputStream(inputStream);

            int taskId = input.readInt();
            if (taskId > 0) {
              int requestType = input.readInt();
              ConsoleRequest request = consoleRequests[requestType];
              request.readData(input);
              sendResponse(taskId, request);
            }
          } catch (Exception e) {
            logger.log(Level.FINEST, e.getMessage(), e);
          }
          Thread.sleep(700 + rand.nextInt(300));
        }
      } catch (Throwable throwable) {
        logger.log(Level.FINEST, "Problem on management center while polling task.", throwable);
      }
    }
 private Credentials initCredentials(ClientConfig config) {
   final GroupConfig groupConfig = config.getGroupConfig();
   final ClientSecurityConfig securityConfig = config.getSecurityConfig();
   Credentials c = securityConfig.getCredentials();
   if (c == null) {
     final String credentialsClassname = securityConfig.getCredentialsClassname();
     // todo: Should be moved to a reflection utility.
     if (credentialsClassname != null) {
       try {
         c = ClassLoaderUtil.newInstance(config.getClassLoader(), credentialsClassname);
       } catch (Exception e) {
         throw ExceptionUtil.rethrow(e);
       }
     }
   }
   if (c == null) {
     c = new UsernamePasswordCredentials(groupConfig.getName(), groupConfig.getPassword());
   }
   return c;
 }
 public TimedMemberState getTimedMemberState() {
   if (running.get()) {
     final MemberStateImpl memberState = new MemberStateImpl();
     createMemberState(memberState);
     GroupConfig groupConfig = factory.getConfig().getGroupConfig();
     TimedMemberState timedMemberState = new TimedMemberState();
     timedMemberState.setMaster(factory.node.isMaster());
     if (timedMemberState.getMaster()) {
       timedMemberState.setMemberList(new ArrayList<String>());
       Set<Member> memberSet = factory.getCluster().getMembers();
       for (Member member : memberSet) {
         MemberImpl memberImpl = (MemberImpl) member;
         Address address = memberImpl.getAddress();
         timedMemberState.getMemberList().add(address.getHost() + ":" + address.getPort());
       }
     }
     timedMemberState.setMemberState(memberState);
     timedMemberState.setClusterName(groupConfig.getName());
     timedMemberState.setInstanceNames(getLongInstanceNames());
     return timedMemberState;
   }
   return null;
 }
 public Boolean call() throws Exception {
   GroupConfig groupConfig = node.getConfig().getGroupConfig();
   if (!groupName.equals(groupConfig.getName())) return Boolean.FALSE;
   if (!groupPassword.equals(groupConfig.getPassword())) return Boolean.FALSE;
   return Boolean.TRUE;
 }
 @Test
 public void testGroupConfig() {
   final GroupConfig groupConfig = clientConfig.getGroupConfig();
   assertEquals("dev", groupConfig.getName());
   assertEquals("dev-pass", groupConfig.getPassword());
 }
Пример #13
0
 public XAResourceImpl(NodeEngine nodeEngine, XAService service) {
   super(nodeEngine, service);
   GroupConfig groupConfig = nodeEngine.getConfig().getGroupConfig();
   groupName = groupConfig.getName();
 }