当前位置: 首页>>代码示例>>Java>>正文


Java GroupConfig类代码示例

本文整理汇总了Java中com.hazelcast.config.GroupConfig的典型用法代码示例。如果您正苦于以下问题:Java GroupConfig类的具体用法?Java GroupConfig怎么用?Java GroupConfig使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


GroupConfig类属于com.hazelcast.config包,在下文中一共展示了GroupConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTimedMemberState

import com.hazelcast.config.GroupConfig; //导入依赖的package包/类
public TimedMemberState getTimedMemberState() {
    if (latestThisMemberState == null) {
        updateLocalState();
    }
    GroupConfig groupConfig = factory.getConfig().getGroupConfig();
    TimedMemberState timedMemberState = new TimedMemberState();
    timedMemberState.setMaster(factory.node.isMaster());


    if (timedMemberState.getMaster()) {
        timedMemberState.setMemberList(new ArrayList<String>());
        for (Address addr : addresses) {
            timedMemberState.getMemberList().add(addr.getHost() + ":" + addr.getPort());
        }
    }
    timedMemberState.setMemberState(latestThisMemberState);
    timedMemberState.setClusterName(groupConfig.getName());
    timedMemberState.setInstanceNames(getLongInstanceNames());
    return timedMemberState;
}
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:21,代码来源:ManagementCenterService.java

示例2: connect

import com.hazelcast.config.GroupConfig; //导入依赖的package包/类
private void connect(String[] args) {
    String ip = "localhost";
    String groupName = "dev";
    String pass = "dev-pass";
    if (args.length > 0) {
        ip = args[0];
    }
    if (args.length > 2) {
        groupName = args[1];
        pass = args[2];
    }
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.setGroupConfig(new GroupConfig(groupName, pass));
    System.out.println("Connecting to " + ip);
    String[] ips = null;
    if (ip.indexOf(':') == -1) {
        ips = new String[]{ip + ":5701", ip + ":5702", ip + ":5703"};
    } else {
        ips = new String[]{ip};
    }
    clientConfig.addAddress(ips);
    this.hz = HazelcastClient.newHazelcastClient(clientConfig);
    System.out.println(hz.getCluster().getMembers());
}
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:25,代码来源:TestClientApp.java

示例3: Config

import com.hazelcast.config.GroupConfig; //导入依赖的package包/类
@Test
public void testAuthenticate
        () {
    String grName = "dev";
    String grPass = "pass";
    Config conf = new Config();
    conf.setProperty(GroupProperties.PROP_WAIT_SECONDS_BEFORE_JOIN, "1");
    GroupConfig gc = new GroupConfig();
    gc.setName(grName);
    gc.setPassword(grPass);
    conf.setGroupConfig(gc);
    HazelcastInstance h = Hazelcast.newHazelcastInstance(conf);
    client = newHazelcastClient(grName, grPass, h);
    Map map = client.getMap("aasd");
    client.shutdown();
    h.shutdown();
}
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:18,代码来源:DynamicClusterTest.java

示例4: twoClientsAndTransaction

import com.hazelcast.config.GroupConfig; //导入依赖的package包/类
@Test
public void twoClientsAndTransaction() {
    Config config1 = new XmlConfigBuilder().build();
    config1.setProperty(GroupProperties.PROP_WAIT_SECONDS_BEFORE_JOIN, "1");
    Config config2 = new XmlConfigBuilder().build();
    config2.setProperty(GroupProperties.PROP_WAIT_SECONDS_BEFORE_JOIN, "1");
    GroupConfig gConfig1 = new GroupConfig("g1", "pg1");
    GroupConfig gConfig2 = new GroupConfig("g2", "pg2");
    config1.setGroupConfig(gConfig1);
    config2.setGroupConfig(gConfig2);
    HazelcastInstance h1 = Hazelcast.newHazelcastInstance(config1);
    HazelcastInstance h2 = Hazelcast.newHazelcastInstance(config2);
    HazelcastInstance client1 = TestUtility.newHazelcastClient(h1);
    HazelcastInstance client2 = TestUtility.newHazelcastClient(h2);
    Transaction t1 = client1.getTransaction();
    Transaction t2 = client2.getTransaction();
    t1.begin();
    client1.getMap("map").put(1, 4);
    t1.commit();
    client1.shutdown();
    client2.shutdown();
    h1.shutdown();
    h2.shutdown();
}
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:25,代码来源:DynamicClusterTest.java

示例5: changeWebServerUrlOverCluster

import com.hazelcast.config.GroupConfig; //导入依赖的package包/类
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;
}
 
开发者ID:health-and-care-developer-network,项目名称:health-and-care-developer-network,代码行数:18,代码来源:ManagementCenterService.java

示例6: getTimedMemberState

import com.hazelcast.config.GroupConfig; //导入依赖的package包/类
private 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.setExecutorList(getExecutorNames());
        timedMemberState.setMemberState(memberState);
        timedMemberState.setClusterName(groupConfig.getName());
        timedMemberState.setInstanceNames(getLongInstanceNames());
        return timedMemberState;
    }
    return null;
}
 
开发者ID:health-and-care-developer-network,项目名称:health-and-care-developer-network,代码行数:26,代码来源:ManagementCenterService.java

示例7: HazelcastSessionDao

import com.hazelcast.config.GroupConfig; //导入依赖的package包/类
public HazelcastSessionDao() {
    log.info("Initializing Hazelcast Shiro session persistence..");

    // configure Hazelcast instance
    final Config cfg = new Config();
    cfg.setInstanceName(hcInstanceName);
    // group configuration
    cfg.setGroupConfig(new GroupConfig(HC_GROUP_NAME, HC_GROUP_PASSWORD));
    // network configuration initialization
    final NetworkConfig netCfg = new NetworkConfig();
    netCfg.setPortAutoIncrement(true);
    netCfg.setPort(HC_PORT);
    // multicast
    final MulticastConfig mcCfg = new MulticastConfig();
    mcCfg.setEnabled(false);
    mcCfg.setMulticastGroup(HC_MULTICAST_GROUP);
    mcCfg.setMulticastPort(HC_MULTICAST_PORT);
    // tcp
    final TcpIpConfig tcpCfg = new TcpIpConfig();
    tcpCfg.addMember("127.0.0.1");
    tcpCfg.setEnabled(false);
    // network join configuration
    final JoinConfig joinCfg = new JoinConfig();
    joinCfg.setMulticastConfig(mcCfg);
    joinCfg.setTcpIpConfig(tcpCfg);
    netCfg.setJoin(joinCfg);
    // ssl
    netCfg.setSSLConfig(new SSLConfig().setEnabled(false));

    // get map
    map = Hazelcast.newHazelcastInstance(cfg).getMap(HC_MAP);
    log.info("Hazelcast Shiro session persistence initialized.");
}
 
开发者ID:summerDp,项目名称:dpCms,代码行数:34,代码来源:HazelcastSessionDao.java

示例8: getConfig

import com.hazelcast.config.GroupConfig; //导入依赖的package包/类
private ClientConfig getConfig() {
  final ClientConfig clientConfig = new ClientConfig();
  clientConfig.setGroupConfig(new GroupConfig(Constants.HC_GROUP_NAME,
      Constants.HC_GROUP_PASSWORD));
  clientConfig.setClassLoader(getClass().getClassLoader());

  return clientConfig;
}
 
开发者ID:FlavioF,项目名称:docker-hazelcast-mapstore-cassandra,代码行数:9,代码来源:HazelcastWorker.java

示例9: SerializableClientConfig

import com.hazelcast.config.GroupConfig; //导入依赖的package包/类
SerializableClientConfig(ClientConfig clientConfig) {
    GroupConfig groupConfig = clientConfig.getGroupConfig();
    List<String> addresses = clientConfig.getNetworkConfig().getAddresses();
    this.groupName = groupConfig.getName();
    this.groupPass = groupConfig.getPassword();
    this.addresses = addresses;
}
 
开发者ID:hazelcast,项目名称:hazelcast-jet,代码行数:8,代码来源:SerializableClientConfig.java

示例10: HazelcastSessionDao

import com.hazelcast.config.GroupConfig; //导入依赖的package包/类
public HazelcastSessionDao() {
  log.info("Initializating Hazelcast Shiro session persistence..");

  // configure Hazelcast instance
  hcInstanceName = UUID.randomUUID().toString();
  Config cfg = new Config();
  cfg.setInstanceName(hcInstanceName);
  // group configuration
  cfg.setGroupConfig(new GroupConfig(HC_GROUP_NAME, HC_GROUP_PASSWORD));

  // network configuration initialization
  NetworkConfig netCfg = new NetworkConfig();
  netCfg.setPortAutoIncrement(true);
  netCfg.setPort(HC_PORT);
  // multicast
  MulticastConfig mcCfg = new MulticastConfig();
  mcCfg.setEnabled(true);
  mcCfg.setMulticastGroup(HC_MULTICAST_GROUP);
  mcCfg.setMulticastPort(HC_MULTICAST_PORT);
  // tcp
  TcpIpConfig tcpCfg = new TcpIpConfig();
  tcpCfg.setEnabled(false);
  // network join configuration
  JoinConfig joinCfg = new JoinConfig();
  joinCfg.setMulticastConfig(mcCfg);
  joinCfg.setTcpIpConfig(tcpCfg);
  netCfg.setJoin(joinCfg);
  // ssl
  netCfg.setSSLConfig(new SSLConfig().setEnabled(false));

  // get map
  map = Hazelcast.newHazelcastInstance(cfg).getMap(HC_MAP);

  log.info("Hazelcast Shiro session persistence initialized.");
}
 
开发者ID:pires,项目名称:fabric8-cxf-shiro,代码行数:36,代码来源:HazelcastSessionDao.java

示例11: loadInstance

import com.hazelcast.config.GroupConfig; //导入依赖的package包/类
public HazelcastInstance loadInstance() throws CacheException {
    if (props == null) {
        throw new NullPointerException("Hibernate environment properties is null!");
    }
    if (client != null && client.getLifecycleService().isRunning()) {
        logger.log(Level.WARNING, "Current HazelcastClient is already active! Shutting it down...");
        unloadInstance();
    }
    String address = PropertiesHelper.getString(CacheEnvironment.NATIVE_CLIENT_ADDRESS, props, null);
    if (address == null) {
        String[] hosts = PropertiesHelper.toStringArray(CacheEnvironment.NATIVE_CLIENT_HOSTS, ",", props);
        if (hosts != null && hosts.length > 0) {
            address = hosts[0];
            logger.log(Level.WARNING, "Hibernate property '" + CacheEnvironment.NATIVE_CLIENT_HOSTS + "' " +
                    "is deprecated, use '" + CacheEnvironment.NATIVE_CLIENT_ADDRESS + "' instead!");
        }
    }
    String group = PropertiesHelper.getString(CacheEnvironment.NATIVE_CLIENT_GROUP, props, null);
    String pass = PropertiesHelper.getString(CacheEnvironment.NATIVE_CLIENT_PASSWORD, props, null);
    if (address == null || group == null || pass == null) {
        throw new CacheException("Configuration properties " + CacheEnvironment.NATIVE_CLIENT_ADDRESS + ", "
                + CacheEnvironment.NATIVE_CLIENT_GROUP + " and " + CacheEnvironment.NATIVE_CLIENT_PASSWORD
                + " are mandatory to use native client!");
    }
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.setGroupConfig(new GroupConfig(group, pass)).addAddress(address);
    clientConfig.setUpdateAutomatic(true);
    return (client = HazelcastClient.newHazelcastClient(clientConfig));
}
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:30,代码来源:HazelcastClientLoader.java

示例12: SpringXmlBuilder

import com.hazelcast.config.GroupConfig; //导入依赖的package包/类
public SpringXmlBuilder(ParserContext parserContext) {
    this.parserContext = parserContext;
    this.builder = BeanDefinitionBuilder.rootBeanDefinition(HazelcastClient.class);
    this.builder.setFactoryMethod("newHazelcastClient");
    this.builder.setDestroyMethodName("shutdown");
    this.members = new ManagedList();
    this.configBuilder = createBeanBuilder(ClientConfig.class, "client-config");
    this.groupConfigBuilder = createBeanBuilder(GroupConfig.class, "client-group-config");
    configBuilder.addPropertyValue("groupConfig", groupConfigBuilder.getBeanDefinition());
}
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:11,代码来源:HazelcastClientBeanDefinitionParser.java

示例13: run

import com.hazelcast.config.GroupConfig; //导入依赖的package包/类
public void run() {
    if (host == 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) {
            try {
                URL url = new URL(host + "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, "Web Management Center will be closed due to exception.", throwable);
    }
}
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:34,代码来源:ManagementCenterService.java

示例14: testFailingClientSocketInterceptor

import com.hazelcast.config.GroupConfig; //导入依赖的package包/类
@Test(expected = RuntimeException.class, timeout = 120000)
public void testFailingClientSocketInterceptor() {
    Config config = new Config();
    SocketInterceptorConfig sic = new SocketInterceptorConfig();
    MySocketInterceptor mySocketInterceptor = new MySocketInterceptor(true);
    sic.setImplementation(mySocketInterceptor);
    config.getNetworkConfig().setSocketInterceptorConfig(sic);
    HazelcastInstance h1 = Hazelcast.newHazelcastInstance(config);
    HazelcastInstance h2 = Hazelcast.newHazelcastInstance(config);
    int count = 1000;
    for (int i = 0; i < count; i++) {
        h1.getMap("default").put(i, "value" + i);
        h2.getMap("default").put(i, "value" + i);
    }
    assertEquals(2, h2.getCluster().getMembers().size());
    assertTrue(mySocketInterceptor.getAcceptCallCount() >= 1);
    assertTrue(mySocketInterceptor.getConnectCallCount() >= 1);
    assertEquals(2, mySocketInterceptor.getInitCallCount());
    assertEquals(0, mySocketInterceptor.getAcceptFailureCount());
    assertEquals(0, mySocketInterceptor.getConnectFailureCount());
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.setGroupConfig(new GroupConfig("dev", "dev-pass")).addAddress("localhost");
    MySocketInterceptor myClientSocketInterceptor = new MySocketInterceptor(false);
    clientConfig.setSocketInterceptor(myClientSocketInterceptor);
    HazelcastInstance client = HazelcastClient.newHazelcastClient(clientConfig);
    for (int i = 0; i < count; i++) {
        client.getMap("default").put(i, "value" + i);
    }
    assertTrue(mySocketInterceptor.getAcceptCallCount() >= 2);
    assertTrue(mySocketInterceptor.getConnectCallCount() >= 1);
    assertEquals(1, myClientSocketInterceptor.getConnectCallCount());
    assertEquals(0, myClientSocketInterceptor.getAcceptCallCount());
    assertEquals(1, mySocketInterceptor.getAcceptFailureCount());
    assertEquals(0, myClientSocketInterceptor.getAcceptFailureCount());
    assertEquals(1, myClientSocketInterceptor.getConnectFailureCount());
}
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:37,代码来源:SocketInterceptorTest.java

示例15: toClientConfig

import com.hazelcast.config.GroupConfig; //导入依赖的package包/类
public static ClientConfig toClientConfig(ClientProperties properties) {
    String groupName = properties.getProperty(ClientProperties.ClientPropertyName.GROUP_NAME);
    String groupPassword = properties.getProperty(ClientProperties.ClientPropertyName.GROUP_PASSWORD);
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.setGroupConfig(new GroupConfig(groupName, groupPassword));
    clientConfig.setConnectionTimeout(properties.getInteger(ClientProperties.ClientPropertyName.CONNECTION_TIMEOUT));
    clientConfig.setInitialConnectionAttemptLimit(properties.getInteger(ClientProperties.ClientPropertyName.INIT_CONNECTION_ATTEMPTS_LIMIT));
    clientConfig.setReconnectionAttemptLimit(properties.getInteger(ClientProperties.ClientPropertyName.RECONNECTION_ATTEMPTS_LIMIT));
    clientConfig.setReConnectionTimeOut(properties.getInteger(ClientProperties.ClientPropertyName.RECONNECTION_TIMEOUT));
    return clientConfig;
}
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:12,代码来源:TestUtility.java


注:本文中的com.hazelcast.config.GroupConfig类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。