Search in sources :

Example 21 with XmlConfigBuilder

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

the class AbstractClientMapReduceJobTest method buildConfig.

protected Config buildConfig() {
    Config config = new XmlConfigBuilder().build();
    config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
    config.getNetworkConfig().getJoin().getTcpIpConfig().setEnabled(true).addMember("127.0.0.1");
    return config;
}
Also used : XmlConfigBuilder(com.hazelcast.config.XmlConfigBuilder) Config(com.hazelcast.config.Config)

Example 22 with XmlConfigBuilder

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

the class CacheQuorumConfigTest method cacheConfigXmlTest.

@Test
public void cacheConfigXmlTest() throws IOException {
    final String cacheName = "configtestCache" + randomString();
    Config config = new XmlConfigBuilder(configUrl).build();
    CacheSimpleConfig cacheConfig1 = config.getCacheConfig(cacheName);
    final String quorumName = cacheConfig1.getQuorumName();
    assertEquals("cache-quorum", quorumName);
    QuorumConfig quorumConfig = config.getQuorumConfig(quorumName);
    assertEquals(3, quorumConfig.getSize());
    assertEquals(QuorumType.READ_WRITE, quorumConfig.getType());
}
Also used : QuorumConfig(com.hazelcast.config.QuorumConfig) CacheSimpleConfig(com.hazelcast.config.CacheSimpleConfig) XmlConfigBuilder(com.hazelcast.config.XmlConfigBuilder) Config(com.hazelcast.config.Config) CacheSimpleConfig(com.hazelcast.config.CacheSimpleConfig) QuorumConfig(com.hazelcast.config.QuorumConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 23 with XmlConfigBuilder

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

the class CacheCreationTest method init.

@BeforeClass
public static void init() throws Exception {
    final URL configUrl = CacheCreationTest.class.getClassLoader().getResource("test-hazelcast-real-jcache.xml");
    XmlConfigBuilder configBuilder = new XmlConfigBuilder(configUrl.getFile());
    hzConfig = configBuilder.build();
}
Also used : XmlConfigBuilder(com.hazelcast.config.XmlConfigBuilder) URL(java.net.URL) BeforeClass(org.junit.BeforeClass)

Example 24 with XmlConfigBuilder

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

the class ResourceCacheImpl method getHazelcastConfig.

private Config getHazelcastConfig(BundleContext context, String xmlConfigFilename) {
    Config cfg = null;
    Bundle bundle = context.getBundle();
    URL xmlConfigFileUrl = null;
    if (StringUtils.isNotBlank(xmlConfigFilename)) {
        xmlConfigFileUrl = bundle.getResource(xmlConfigFilename);
    }
    XmlConfigBuilder xmlConfigBuilder = null;
    if (xmlConfigFileUrl != null) {
        try {
            xmlConfigBuilder = new XmlConfigBuilder(xmlConfigFileUrl.openStream());
            cfg = xmlConfigBuilder.build();
            LOGGER.debug("Successfully built hazelcast config from XML config file {}", xmlConfigFilename);
        } catch (FileNotFoundException e) {
            LOGGER.info("FileNotFoundException trying to build hazelcast config from XML file " + xmlConfigFilename, e);
            cfg = null;
        } catch (IOException e) {
            LOGGER.info("IOException trying to build hazelcast config from XML file " + xmlConfigFilename, e);
            cfg = null;
        }
    }
    if (cfg == null) {
        LOGGER.info("Falling back to using generic Config for hazelcast");
        cfg = new Config();
    } else if (LOGGER.isDebugEnabled()) {
        MapConfig mapConfig = cfg.getMapConfig("Product_Cache");
        if (mapConfig == null) {
            LOGGER.debug("mapConfig is NULL for persistentNotifications - try persistent*");
            mapConfig = cfg.getMapConfig("persistent*");
            if (mapConfig == null) {
                LOGGER.debug("mapConfig is NULL for persistent*");
            }
        } else {
            MapStoreConfig mapStoreConfig = mapConfig.getMapStoreConfig();
            if (null != mapStoreConfig) {
                LOGGER.debug("mapStoreConfig factoryClassName = {}", mapStoreConfig.getFactoryClassName());
            }
        }
    }
    return cfg;
}
Also used : XmlConfigBuilder(com.hazelcast.config.XmlConfigBuilder) MapConfig(com.hazelcast.config.MapConfig) Config(com.hazelcast.config.Config) MapStoreConfig(com.hazelcast.config.MapStoreConfig) Bundle(org.osgi.framework.Bundle) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) MapConfig(com.hazelcast.config.MapConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) URL(java.net.URL)

Example 25 with XmlConfigBuilder

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

the class HazelcastNotificationStore method getHazelcastConfig.

private Config getHazelcastConfig(BundleContext context, String xmlConfigFilename) {
    Config cfg = null;
    Bundle bundle = context.getBundle();
    URL xmlConfigFileUrl = null;
    if (StringUtils.isNotBlank(xmlConfigFilename)) {
        xmlConfigFileUrl = bundle.getResource(xmlConfigFilename);
    }
    XmlConfigBuilder xmlConfigBuilder = null;
    if (xmlConfigFileUrl != null) {
        try {
            xmlConfigBuilder = new XmlConfigBuilder(xmlConfigFileUrl.openStream());
            cfg = xmlConfigBuilder.build();
            LOGGER.debug("Successfully built hazelcast config from XML config file {}", xmlConfigFilename);
        } catch (FileNotFoundException e) {
            LOGGER.info("FileNotFoundException trying to build hazelcast config from XML file " + xmlConfigFilename, e);
            cfg = null;
        } catch (IOException e) {
            LOGGER.info("IOException trying to build hazelcast config from XML file " + xmlConfigFilename, e);
            cfg = null;
        }
    }
    if (cfg == null) {
        LOGGER.info("Falling back to using generic Config for hazelcast");
        cfg = new Config();
    } else if (LOGGER.isDebugEnabled()) {
        MapConfig mapConfig = cfg.getMapConfig("persistentNotifications");
        if (mapConfig == null) {
            LOGGER.debug("mapConfig is NULL for persistentNotifications - try persistent*");
            mapConfig = cfg.getMapConfig("persistent*");
            if (mapConfig == null) {
                LOGGER.debug("mapConfig is NULL for persistent*");
            }
        } else {
            MapStoreConfig mapStoreConfig = mapConfig.getMapStoreConfig();
            if (mapStoreConfig != null) {
                LOGGER.debug("mapStoreConfig factoryClassName = {}", mapStoreConfig.getFactoryClassName());
            } else {
                LOGGER.debug("mapStoreConfig is null");
            }
        }
    }
    return cfg;
}
Also used : XmlConfigBuilder(com.hazelcast.config.XmlConfigBuilder) Config(com.hazelcast.config.Config) MapConfig(com.hazelcast.config.MapConfig) NetworkConfig(com.hazelcast.config.NetworkConfig) JoinConfig(com.hazelcast.config.JoinConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) Bundle(org.osgi.framework.Bundle) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) MapConfig(com.hazelcast.config.MapConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) URL(java.net.URL)

Aggregations

XmlConfigBuilder (com.hazelcast.config.XmlConfigBuilder)25 Config (com.hazelcast.config.Config)20 Test (org.junit.Test)10 InputStream (java.io.InputStream)9 QuickTest (com.hazelcast.test.annotation.QuickTest)8 MapConfig (com.hazelcast.config.MapConfig)7 JoinConfig (com.hazelcast.config.JoinConfig)6 HazelcastInstance (com.hazelcast.core.HazelcastInstance)6 URL (java.net.URL)6 MapStoreConfig (com.hazelcast.config.MapStoreConfig)5 MulticastConfig (com.hazelcast.config.MulticastConfig)5 TcpIpConfig (com.hazelcast.config.TcpIpConfig)5 AwsConfig (com.hazelcast.config.AwsConfig)4 DiscoveryConfig (com.hazelcast.config.DiscoveryConfig)4 DiscoveryStrategyConfig (com.hazelcast.config.DiscoveryStrategyConfig)4 InterfacesConfig (com.hazelcast.config.InterfacesConfig)4 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)3 ParallelTest (com.hazelcast.test.annotation.ParallelTest)3 ClientConfig (com.hazelcast.client.config.ClientConfig)2 CacheSimpleConfig (com.hazelcast.config.CacheSimpleConfig)2