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


Java DiscoveryStrategyConfig类代码示例

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


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

示例1: testIntegration

import com.hazelcast.config.DiscoveryStrategyConfig; //导入依赖的package包/类
@Test
public void testIntegration() {
    String zookeeperURL = zkTestServer.getConnectString();
    Config config = new Config();
    config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
    config.setProperty("hazelcast.discovery.enabled", "true");

    DiscoveryStrategyConfig discoveryStrategyConfig = new DiscoveryStrategyConfig(new ZookeeperDiscoveryStrategyFactory());
    discoveryStrategyConfig.addProperty(ZookeeperDiscoveryProperties.ZOOKEEPER_URL.key(), zookeeperURL);
    config.getNetworkConfig().getJoin().getDiscoveryConfig().addDiscoveryStrategyConfig(discoveryStrategyConfig);

    HazelcastInstance instance1 = Hazelcast.newHazelcastInstance(config);
    HazelcastInstance instance2 = Hazelcast.newHazelcastInstance(config);

    int instance1Size = instance1.getCluster().getMembers().size();
    assertEquals(2, instance1Size);
    int instance2Size = instance2.getCluster().getMembers().size();
    assertEquals(2, instance2Size);
}
 
开发者ID:hazelcast,项目名称:hazelcast-zookeeper,代码行数:20,代码来源:HazelcastIntegrationTest.java

示例2: testIntegration_urlNotConfigured

import com.hazelcast.config.DiscoveryStrategyConfig; //导入依赖的package包/类
@Test
public void testIntegration_urlNotConfigured() {
    exception.expect(IllegalStateException.class);
    exception.expectMessage("Zookeeper URL cannot be null.");

    Config config = new Config();
    config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
    config.setProperty("hazelcast.discovery.enabled", "true");

    DiscoveryStrategyConfig discoveryStrategyConfig = new DiscoveryStrategyConfig(new ZookeeperDiscoveryStrategyFactory());
    config.getNetworkConfig().getJoin().getDiscoveryConfig().addDiscoveryStrategyConfig(discoveryStrategyConfig);

    HazelcastInstance instance1 = Hazelcast.newHazelcastInstance(config);
    HazelcastInstance instance2 = Hazelcast.newHazelcastInstance(config);

    int instance1Size = instance1.getCluster().getMembers().size();
    assertEquals(2, instance1Size);
    int instance2Size = instance2.getCluster().getMembers().size();
    assertEquals(2, instance2Size);
}
 
开发者ID:hazelcast,项目名称:hazelcast-zookeeper,代码行数:21,代码来源:HazelcastIntegrationTest.java

示例3: hazelcastConfig

import com.hazelcast.config.DiscoveryStrategyConfig; //导入依赖的package包/类
@Bean
public Config hazelcastConfig () {
    val config = new Config();
    config.setProperty("hazelcast.discovery.enabled", "true");

    val networkingConfig = config.getNetworkConfig();
    networkingConfig.setPort(hazelcastPort);
    networkingConfig.setPortAutoIncrement(false);

    val joinConfig = networkingConfig.getJoin();

    joinConfig.getMulticastConfig().setEnabled(false);
    joinConfig.getTcpIpConfig().setEnabled(false);
    joinConfig.getAwsConfig().setEnabled(false);
    joinConfig.getDiscoveryConfig()
            .addDiscoveryStrategyConfig(new DiscoveryStrategyConfig(discoveryStrategyFactory()));

    return config;
}
 
开发者ID:xxlabaza,项目名称:hazelcast_eureka,代码行数:20,代码来源:HazelcastMemberConfiguration.java

示例4: testExternalRegistration

import com.hazelcast.config.DiscoveryStrategyConfig; //导入依赖的package包/类
@Test
public void testExternalRegistration(){
    EurekaHttpResponse<Applications> response = generateMockResponse(Collections.<InstanceInfo>emptyList());
    when(requestHandler.getApplications()).thenReturn(response);

    Config config = new XmlConfigBuilder().build();
    DiscoveryConfig discoveryConfig = config.getNetworkConfig().getJoin().getDiscoveryConfig();
    DiscoveryStrategyConfig strategyConfig = discoveryConfig.getDiscoveryStrategyConfigs().iterator().next();
    strategyConfig.addProperty("self-registration", "false");

    HazelcastInstance hz1 = factory.newHazelcastInstance(config);
    HazelcastInstance hz2 = factory.newHazelcastInstance(config);

    assertClusterSizeEventually(2, hz1);
    assertClusterSizeEventually(2, hz2);

    verify(requestHandler, after(5000).never()).register(any(InstanceInfo.class));

}
 
开发者ID:hazelcast,项目名称:hazelcast-eureka,代码行数:20,代码来源:HazelcastClientTestCase.java

示例5: testNamespaceRegistration

import com.hazelcast.config.DiscoveryStrategyConfig; //导入依赖的package包/类
@Test
public void testNamespaceRegistration(){
    final String appName = "other";
    final String namespace = "hz";
    configure(namespace, appName);

    EurekaHttpResponse<Applications> response = generateMockResponse(Collections.<InstanceInfo>emptyList(), appName);
    when(requestHandler.getApplications()).thenReturn(response);

    Config config = new XmlConfigBuilder().build();
    DiscoveryConfig discoveryConfig = config.getNetworkConfig().getJoin().getDiscoveryConfig();
    DiscoveryStrategyConfig strategyConfig = discoveryConfig.getDiscoveryStrategyConfigs().iterator().next();
    strategyConfig.addProperty("namespace", namespace);

    HazelcastInstance hz1 = factory.newHazelcastInstance(config);

    assertClusterSizeEventually(1, hz1);

    ArgumentCaptor<InstanceInfo> captor = ArgumentCaptor.forClass(InstanceInfo.class);
    verify(requestHandler, timeout(5000).atLeastOnce()).register(captor.capture());

    String actual = captor.getValue().getAppName().toLowerCase();
    assertThat(actual, is(appName));

}
 
开发者ID:hazelcast,项目名称:hazelcast-eureka,代码行数:26,代码来源:HazelcastClientTestCase.java

示例6: discoveryStrategyFactoryTest

import com.hazelcast.config.DiscoveryStrategyConfig; //导入依赖的package包/类
@Test
public void discoveryStrategyFactoryTest() {
    JCloudsDiscoveryStrategyFactory jCloudsDiscoveryStrategyFactory = new JCloudsDiscoveryStrategyFactory();
    String xmlFileName = "test-jclouds-config.xml";
    InputStream xmlResource = JCloudsDiscoveryFactoryTest.class.getClassLoader().getResourceAsStream(xmlFileName);
    Config config = new XmlConfigBuilder(xmlResource).build();

    JoinConfig joinConfig = config.getNetworkConfig().getJoin();
    DiscoveryConfig discoveryConfig = joinConfig.getDiscoveryConfig();
    DiscoveryStrategyConfig providerConfig = discoveryConfig.getDiscoveryStrategyConfigs().iterator().next();

    assertEquals(jCloudsDiscoveryStrategyFactory.getDiscoveryStrategyType(), JCloudsDiscoveryStrategy.class);
    assertEquals(JCloudsDiscoveryStrategy.class.getName(), providerConfig.getClassName());
    assertEquals(jCloudsDiscoveryStrategyFactory.getConfigurationProperties().size(), providerConfig.getProperties().size());
    assertTrue(jCloudsDiscoveryStrategyFactory.
            newDiscoveryStrategy(null, null, new HashMap<String, Comparable>()) instanceof DiscoveryStrategy);
}
 
开发者ID:hazelcast,项目名称:hazelcast-jclouds,代码行数:18,代码来源:JCloudsDiscoveryFactoryTest.java

示例7: testIntegration

import com.hazelcast.config.DiscoveryStrategyConfig; //导入依赖的package包/类
@Test
public void testIntegration() {
    String zookeeperURL = zkTestServer.getConnectString();

    Config config = new Config();
    config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
    config.setProperty(GroupProperty.DISCOVERY_SPI_ENABLED, "true");

    DiscoveryStrategyConfig dicoveryStrategyConfig = new DiscoveryStrategyConfig(new ZookeeperDiscoveryStrategyFactory());
    dicoveryStrategyConfig.addProperty(ZookeeperDiscoveryProperties.ZOOKEEPER_URL.key(), zookeeperURL);
    config.getNetworkConfig().getJoin().getDiscoveryConfig().addDiscoveryProviderConfig(dicoveryStrategyConfig);

    HazelcastInstance instance1 = Hazelcast.newHazelcastInstance(config);
    HazelcastInstance instance2 = Hazelcast.newHazelcastInstance(config);

    int instance1Size = instance1.getCluster().getMembers().size();
    assertEquals(2, instance1Size);
    int instance2Size = instance2.getCluster().getMembers().size();
    assertEquals(2, instance2Size);
}
 
开发者ID:jerrinot,项目名称:hzkeeper,代码行数:21,代码来源:HazelcastIT.java

示例8: addZkConfig

import com.hazelcast.config.DiscoveryStrategyConfig; //导入依赖的package包/类
private void addZkConfig(Config config) {
    config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
    config.setProperty(GroupProperty.DISCOVERY_SPI_ENABLED.getName(), Boolean.TRUE.toString());
    DiscoveryStrategyConfig discoveryStrategyConfig = new DiscoveryStrategyConfig(new ZookeeperDiscoveryStrategyFactory());
    discoveryStrategyConfig.addProperty(ZookeeperDiscoveryProperties.ZOOKEEPER_URL.key(), zkUrl);
    discoveryStrategyConfig.addProperty(ZookeeperDiscoveryProperties.ZOOKEEPER_PATH.key(), zkDir);
    discoveryStrategyConfig.addProperty(ZookeeperDiscoveryProperties.GROUP.key(), HAZELCAST_CLUSTER_NAME);
    config.getNetworkConfig().getJoin().getDiscoveryConfig().addDiscoveryStrategyConfig(discoveryStrategyConfig);
}
 
开发者ID:osswangxining,项目名称:iotplatform,代码行数:10,代码来源:ServiceCacheConfiguration.java

示例9: createClientConfig

import com.hazelcast.config.DiscoveryStrategyConfig; //导入依赖的package包/类
private ClientConfig createClientConfig(String zookeeperURL) {
    DiscoveryStrategyConfig discoveryStrategyConfig = createDiscoveryConfig(zookeeperURL);
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.setProperty("hazelcast.discovery.enabled", "true");
    clientConfig.getNetworkConfig().getDiscoveryConfig().addDiscoveryStrategyConfig(discoveryStrategyConfig);
    return clientConfig;
}
 
开发者ID:hazelcast,项目名称:hazelcast-zookeeper,代码行数:8,代码来源:ClientSmokeTest.java

示例10: createMemberConfig

import com.hazelcast.config.DiscoveryStrategyConfig; //导入依赖的package包/类
private Config createMemberConfig(String zookeeperURL) {
    Config config = new Config();
    config.getNetworkConfig().setPort(HAZELCAST_BASE_PORT);
    config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
    config.setProperty("hazelcast.discovery.enabled", "true");

    DiscoveryStrategyConfig discoveryStrategyConfig = createDiscoveryConfig(zookeeperURL);
    config.getNetworkConfig().getJoin().getDiscoveryConfig().addDiscoveryStrategyConfig(discoveryStrategyConfig);
    return config;
}
 
开发者ID:hazelcast,项目名称:hazelcast-zookeeper,代码行数:11,代码来源:ClientSmokeTest.java

示例11: parseDiscoveryStrategyConfigPasses

import com.hazelcast.config.DiscoveryStrategyConfig; //导入依赖的package包/类
@Test
public void parseDiscoveryStrategyConfigPasses() {
    final AwsDiscoveryStrategyFactory factory = new AwsDiscoveryStrategyFactory();
    final Config config = createConfig("test-aws-config.xml");
    final JoinConfig joinConfig = config.getNetworkConfig().getJoin();

    assertFalse(joinConfig.getAwsConfig().isEnabled());
    assertFalse(joinConfig.getTcpIpConfig().isEnabled());
    assertFalse(joinConfig.getMulticastConfig().isEnabled());

    final DiscoveryConfig discoveryConfig = joinConfig.getDiscoveryConfig();

    assertTrue(discoveryConfig.isEnabled());
    assertEquals(1, discoveryConfig.getDiscoveryStrategyConfigs().size());

    final DiscoveryStrategyConfig providerConfig = discoveryConfig.getDiscoveryStrategyConfigs().iterator().next();
    final Map<String, Comparable> providerProperties = providerConfig.getProperties();
    final Collection<PropertyDefinition> factoryConfigProperties = factory.getConfigurationProperties();

    assertEquals(factory.getDiscoveryStrategyType(), AwsDiscoveryStrategy.class);
    assertEquals(AwsDiscoveryStrategy.class.getName(), providerConfig.getClassName());
    assertEquals(factoryConfigProperties.size(), providerProperties.size());
    for (AwsProperties prop : AwsProperties.values()) {
        assertTrue(factoryConfigProperties.contains(prop.getDefinition()));
    }

    assertEquals("test-access-key", providerProperties.get("access-key"));
    assertEquals("test-secret-key", providerProperties.get("secret-key"));
    assertEquals("test-region", providerProperties.get("region"));
    assertEquals("test-iam-role", providerProperties.get("iam-role"));
    assertEquals("ec2.test-host-header", providerProperties.get("host-header"));
    assertEquals("test-security-group-name", providerProperties.get("security-group-name"));
    assertEquals("test-tag-key", providerProperties.get("tag-key"));
    assertEquals("test-tag-value", providerProperties.get("tag-value"));
    assertEquals("10", providerProperties.get("connection-timeout-seconds"));
    assertEquals("5702", providerProperties.get("hz-port"));
}
 
开发者ID:hazelcast,项目名称:hazelcast-aws,代码行数:38,代码来源:AwsDiscoveryStrategyFactoryTest.java

示例12: testParsing

import com.hazelcast.config.DiscoveryStrategyConfig; //导入依赖的package包/类
@Test
public void testParsing() {
    String xmlFileName = "test-jclouds-config.xml";
    InputStream xmlResource = JCloudsDiscoveryFactoryTest.class.getClassLoader().getResourceAsStream(xmlFileName);
    Config config = new XmlConfigBuilder(xmlResource).build();

    JoinConfig joinConfig = config.getNetworkConfig().getJoin();

    AwsConfig awsConfig = joinConfig.getAwsConfig();
    assertFalse(awsConfig.isEnabled());

    TcpIpConfig tcpIpConfig = joinConfig.getTcpIpConfig();
    assertFalse(tcpIpConfig.isEnabled());

    MulticastConfig multicastConfig = joinConfig.getMulticastConfig();
    assertFalse(multicastConfig.isEnabled());

    DiscoveryConfig discoveryConfig = joinConfig.getDiscoveryConfig();
    assertTrue(discoveryConfig.isEnabled());

    assertEquals(1, discoveryConfig.getDiscoveryStrategyConfigs().size());

    DiscoveryStrategyConfig providerConfig = discoveryConfig.getDiscoveryStrategyConfigs().iterator().next();

    assertEquals(12, providerConfig.getProperties().size());
    assertEquals("aws-ec2", providerConfig.getProperties().get("provider"));
    assertEquals("test", providerConfig.getProperties().get("identity"));
    assertEquals("test", providerConfig.getProperties().get("credential"));
    assertEquals("zone1,zone2", providerConfig.getProperties().get("zones"));
    assertEquals("region1,region2", providerConfig.getProperties().get("regions"));
    assertEquals("zone1,zone2", providerConfig.getProperties().get("zones"));
    assertEquals("tag1,tag2", providerConfig.getProperties().get("tag-keys"));
    assertEquals("tagvalue1,tagvalue2", providerConfig.getProperties().get("tag-values"));
    assertEquals("group", providerConfig.getProperties().get("group"));
    assertEquals("5702", providerConfig.getProperties().get("hz-port"));
    assertEquals("myfile.json", providerConfig.getProperties().get("credentialPath"));
    assertEquals("myRole", providerConfig.getProperties().get("role-name"));
    assertEquals("http://foo/bar", providerConfig.getProperties().get("endpoint"));
}
 
开发者ID:hazelcast,项目名称:hazelcast-jclouds,代码行数:40,代码来源:JCloudsDiscoveryFactoryTest.java

示例13: createDiscoveryConfig

import com.hazelcast.config.DiscoveryStrategyConfig; //导入依赖的package包/类
private DiscoveryStrategyConfig createDiscoveryConfig(String zookeeperURL) {
    DiscoveryStrategyConfig discoveryStrategyConfig = new DiscoveryStrategyConfig(new ZookeeperDiscoveryStrategyFactory());
    discoveryStrategyConfig.addProperty(ZookeeperDiscoveryProperties.ZOOKEEPER_URL.key(), zookeeperURL);
    return discoveryStrategyConfig;
}
 
开发者ID:hazelcast,项目名称:hazelcast-zookeeper,代码行数:6,代码来源:ClientSmokeTest.java

示例14: newInstance

import com.hazelcast.config.DiscoveryStrategyConfig; //导入依赖的package包/类
public HazelcastInstance newInstance() {
    String name = NAME.get();
    String password = PASS.get();

    if (StringUtils.isBlank(name)) {
        name = hazelcastDao.getGroupName();
    }

    if (StringUtils.isBlank(password)) {
        password = hazelcastDao.getGroupPassword();
    }

    Config config = new Config();
    if (JMX.get()) {
        config.setProperty("hazelcast.jmx", "true");
    }

    config.setProperty("hazelcast.logging.type", LOGGING.get());
    config.setProperty("hazelcast.discovery.enabled", "true");


    GroupConfig groupConfig = new GroupConfig();
    groupConfig.setName(name);
    groupConfig.setPassword(password);
    config.setGroupConfig(groupConfig);

    DiscoveryStrategyConfig dsc = new DiscoveryStrategyConfig(dbDiscoveryFactory);

    DiscoveryConfig dc = new DiscoveryConfig();
    dc.setDiscoveryStrategyConfigs(Arrays.asList(dsc));

    JoinConfig joinConfig = new JoinConfig();
    joinConfig.setDiscoveryConfig(dc);
    joinConfig.getTcpIpConfig().setEnabled(false);
    joinConfig.getMulticastConfig().setEnabled(false);
    joinConfig.getAwsConfig().setEnabled(false);

    NetworkConfig nc = new NetworkConfig();
    nc.setPort(DBDiscovery.DEFAULT_PORT.get());
    nc.setJoin(joinConfig);
    nc.setPublicAddress(dbDiscovery.getLocalConfig().getAdvertiseAddress());

    config.setNetworkConfig(nc);

    HazelcastInstance hi = Hazelcast.newHazelcastInstance(config);
    while (!hi.getPartitionService().isClusterSafe()) {
        log.info("Waiting for cluster to be in a steady state");
        try {
            Thread.sleep(2000L);
        } catch (InterruptedException e) {
            throw new IllegalStateException("Waiting for cluster to be in a steady state", e);
        }
    }

    return hi;
}
 
开发者ID:rancher,项目名称:cattle,代码行数:57,代码来源:HazelcastFactory.java

示例15: test

import com.hazelcast.config.DiscoveryStrategyConfig; //导入依赖的package包/类
@Test
public void test() {
    Config config = new XmlConfigBuilder().build();
    config.setProperty("hazelcast.discovery.enabled", "true");

    JoinConfig joinConfig = config.getNetworkConfig().getJoin();

    joinConfig.getMulticastConfig().setEnabled(false);
    joinConfig.getTcpIpConfig().setEnabled(false);

    DiscoveryConfig discoveryConfig = joinConfig.getDiscoveryConfig();

    DiscoveryStrategyFactory discoveryStrategyFactory = new SomeRestServiceDiscoveryStrategyFactory();
    DiscoveryStrategyConfig discoveryStrategyConfig = new DiscoveryStrategyConfig(discoveryStrategyFactory);

    discoveryConfig.addDiscoveryStrategyConfig(discoveryStrategyConfig);

    config.getNetworkConfig().setPort(55667);
    HazelcastInstance hazelcastInstance1 = Hazelcast.newHazelcastInstance(config);

    config.getNetworkConfig().setPort(1122);
    HazelcastInstance hazelcastInstance2 = Hazelcast.newHazelcastInstance(config);

    assertEquals(2, hazelcastInstance1.getCluster().getMembers().size());
    assertEquals(2, hazelcastInstance2.getCluster().getMembers().size());

    Hazelcast.shutdownAll();
}
 
开发者ID:noctarius,项目名称:hazelcast-discovery-spi-demonstration,代码行数:29,代码来源:DiscoveryTest.java


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