Search in sources :

Example 26 with XmlConfigBuilder

use of com.hazelcast.config.XmlConfigBuilder in project hazelcast by hazelcast.

the class ClientMapStoreTest method buildConfig.

private Config buildConfig(String xml) {
    ByteArrayInputStream bis = new ByteArrayInputStream(xml.getBytes());
    XmlConfigBuilder configBuilder = new XmlConfigBuilder(bis);
    return configBuilder.build();
}
Also used : XmlConfigBuilder(com.hazelcast.config.XmlConfigBuilder) ByteArrayInputStream(java.io.ByteArrayInputStream)

Example 27 with XmlConfigBuilder

use of com.hazelcast.config.XmlConfigBuilder in project hazelcast by hazelcast.

the class ClientExecutorServiceCancelTest method setup.

@Before
public void setup() {
    Config config = new XmlConfigBuilder(getClass().getClassLoader().getResourceAsStream("hazelcast-test-executor.xml")).build();
    server1 = hazelcastFactory.newHazelcastInstance(config);
    server2 = hazelcastFactory.newHazelcastInstance(config);
}
Also used : XmlConfigBuilder(com.hazelcast.config.XmlConfigBuilder) ClientConfig(com.hazelcast.client.config.ClientConfig) Config(com.hazelcast.config.Config) Before(org.junit.Before)

Example 28 with XmlConfigBuilder

use of com.hazelcast.config.XmlConfigBuilder in project hazelcast by hazelcast.

the class ClientExecutorServiceTest method setup.

@Before
public void setup() throws IOException {
    Config config = new XmlConfigBuilder(getClass().getClassLoader().getResourceAsStream("hazelcast-test-executor.xml")).build();
    ClientConfig clientConfig = new XmlClientConfigBuilder("classpath:hazelcast-client-test-executor.xml").build();
    instance = hazelcastFactory.newHazelcastInstance(config);
    hazelcastFactory.newHazelcastInstance(config);
    hazelcastFactory.newHazelcastInstance(config);
    hazelcastFactory.newHazelcastInstance(config);
    client = hazelcastFactory.newHazelcastClient(clientConfig);
}
Also used : XmlConfigBuilder(com.hazelcast.config.XmlConfigBuilder) XmlClientConfigBuilder(com.hazelcast.client.config.XmlClientConfigBuilder) ClientConfig(com.hazelcast.client.config.ClientConfig) Config(com.hazelcast.config.Config) ClientConfig(com.hazelcast.client.config.ClientConfig) Before(org.junit.Before)

Example 29 with XmlConfigBuilder

use of com.hazelcast.config.XmlConfigBuilder in project hazelcast by hazelcast.

the class ClientMapWithIndexCreationTest method test_createMapWithIndexes_whenProxyCreatedOnMemberOtherThanClientOwner.

/**
 * Given a two members (A, B) cluster, a non-smart client connected to B attempts to create a map proxy targeting member A.
 */
@Test
public void test_createMapWithIndexes_whenProxyCreatedOnMemberOtherThanClientOwner() {
    Config config = new XmlConfigBuilder().build();
    MapConfig mapConfig = config.getMapConfig("test");
    List<IndexConfig> indexConfigs = mapConfig.getIndexConfigs();
    IndexConfig indexConfig = new IndexConfig();
    indexConfig.addAttribute("name");
    indexConfig.setType(IndexType.SORTED);
    indexConfigs.add(indexConfig);
    HazelcastInstance hz1 = factory.newHazelcastInstance(config);
    HazelcastInstance hz2 = factory.newHazelcastInstance(config);
    ClientConfig clientConfig = new ClientConfig();
    // ProxyManager#findNextAddressToSendCreateRequest uses the configured load balancer to find the next address
    // to which proxy creation request will be sent. We want this to be member hz1.
    clientConfig.setLoadBalancer(new StaticLB((Member) hz1.getLocalEndpoint()));
    clientConfig.getNetworkConfig().setSmartRouting(false);
    // the client only connects to member hz2.
    clientConfig.getNetworkConfig().addAddress(hz2.getCluster().getLocalMember().getAddress().getHost() + ":" + hz2.getCluster().getLocalMember().getAddress().getPort());
    HazelcastInstance client = factory.newHazelcastClient(clientConfig);
    IMap<String, SampleTestObjects.Employee> test = client.getMap("test");
    test.put("foo", new SampleTestObjects.Employee(1, "name", "age", 32, true, 230));
}
Also used : XmlConfigBuilder(com.hazelcast.config.XmlConfigBuilder) Config(com.hazelcast.config.Config) IndexConfig(com.hazelcast.config.IndexConfig) MapConfig(com.hazelcast.config.MapConfig) ClientConfig(com.hazelcast.client.config.ClientConfig) StaticLB(com.hazelcast.client.util.StaticLB) IndexConfig(com.hazelcast.config.IndexConfig) HazelcastInstance(com.hazelcast.core.HazelcastInstance) SampleTestObjects(com.hazelcast.query.SampleTestObjects) MapConfig(com.hazelcast.config.MapConfig) ClientConfig(com.hazelcast.client.config.ClientConfig) Member(com.hazelcast.cluster.Member) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 30 with XmlConfigBuilder

use of com.hazelcast.config.XmlConfigBuilder in project hazelcast by hazelcast.

the class GcpDiscoveryStrategyFactoryTest method createStrategy.

private static DiscoveryStrategy createStrategy(String xmlFileName) {
    final InputStream xmlResource = GcpDiscoveryStrategyFactoryTest.class.getClassLoader().getResourceAsStream(xmlFileName);
    Config config = new XmlConfigBuilder(xmlResource).build();
    DiscoveryConfig discoveryConfig = config.getNetworkConfig().getJoin().getDiscoveryConfig();
    DiscoveryServiceSettings settings = new DiscoveryServiceSettings().setDiscoveryConfig(discoveryConfig);
    DefaultDiscoveryService service = new DefaultDiscoveryService(settings);
    Iterator<DiscoveryStrategy> strategies = service.getDiscoveryStrategies().iterator();
    return strategies.next();
}
Also used : XmlConfigBuilder(com.hazelcast.config.XmlConfigBuilder) InputStream(java.io.InputStream) WireMockConfiguration.wireMockConfig(com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig) Config(com.hazelcast.config.Config) DiscoveryConfig(com.hazelcast.config.DiscoveryConfig) DefaultDiscoveryService(com.hazelcast.spi.discovery.impl.DefaultDiscoveryService) DiscoveryConfig(com.hazelcast.config.DiscoveryConfig) DiscoveryServiceSettings(com.hazelcast.spi.discovery.integration.DiscoveryServiceSettings) DiscoveryStrategy(com.hazelcast.spi.discovery.DiscoveryStrategy)

Aggregations

XmlConfigBuilder (com.hazelcast.config.XmlConfigBuilder)51 Config (com.hazelcast.config.Config)44 InputStream (java.io.InputStream)18 ClientConfig (com.hazelcast.client.config.ClientConfig)15 Test (org.junit.Test)14 XmlClientConfigBuilder (com.hazelcast.client.config.XmlClientConfigBuilder)13 DiscoveryConfig (com.hazelcast.config.DiscoveryConfig)12 Before (org.junit.Before)11 DiscoveryStrategyConfig (com.hazelcast.config.DiscoveryStrategyConfig)10 HazelcastInstance (com.hazelcast.core.HazelcastInstance)9 QuickTest (com.hazelcast.test.annotation.QuickTest)9 JoinConfig (com.hazelcast.config.JoinConfig)7 File (java.io.File)7 AwsConfig (com.hazelcast.config.AwsConfig)6 InterfacesConfig (com.hazelcast.config.InterfacesConfig)6 MapConfig (com.hazelcast.config.MapConfig)6 MulticastConfig (com.hazelcast.config.MulticastConfig)6 TcpIpConfig (com.hazelcast.config.TcpIpConfig)6 Member (com.hazelcast.cluster.Member)4 MapStoreConfig (com.hazelcast.config.MapStoreConfig)4