Search in sources :

Example 1 with XmlConfigBuilder

use of com.hazelcast.config.XmlConfigBuilder in project spring-boot by spring-projects.

the class HazelcastInstanceFactory method getConfig.

private Config getConfig(Resource configLocation) throws IOException {
    URL configUrl = configLocation.getURL();
    Config config = new XmlConfigBuilder(configUrl).build();
    if (ResourceUtils.isFileURL(configUrl)) {
        config.setConfigurationFile(configLocation.getFile());
    } else {
        config.setConfigurationUrl(configUrl);
    }
    return config;
}
Also used : XmlConfigBuilder(com.hazelcast.config.XmlConfigBuilder) Config(com.hazelcast.config.Config) URL(java.net.URL)

Example 2 with XmlConfigBuilder

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

the class HazelcastServerCachingProvider method getConfig.

private Config getConfig(URL configURL, ClassLoader theClassLoader, String instanceName) throws IOException {
    Config config = new XmlConfigBuilder(configURL).build();
    config.setClassLoader(theClassLoader);
    if (instanceName != null) {
        // If instance name is specified via properties use it
        // even though instance name is specified in the config.
        config.setInstanceName(instanceName);
    } else if (config.getInstanceName() == null) {
        // Use config url as instance name if instance name is not specified.
        config.setInstanceName(configURL.toString());
    }
    return config;
}
Also used : XmlConfigBuilder(com.hazelcast.config.XmlConfigBuilder) Config(com.hazelcast.config.Config)

Example 3 with XmlConfigBuilder

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

the class ClientToMemberDiscoveryTest method setup.

@Before
public void setup() {
    String serverXmlFileName = "hazelcast-multicast-plugin.xml";
    String clientXmlFileName = "hazelcast-client-multicast-plugin.xml";
    InputStream xmlResource = MulticastDiscoveryStrategy.class.getClassLoader().getResourceAsStream(serverXmlFileName);
    serverConfig = new XmlConfigBuilder(xmlResource).build();
    InputStream xmlClientResource = MulticastDiscoveryStrategy.class.getClassLoader().getResourceAsStream(clientXmlFileName);
    clientConfig = new XmlClientConfigBuilder(xmlClientResource).build();
}
Also used : XmlConfigBuilder(com.hazelcast.config.XmlConfigBuilder) XmlClientConfigBuilder(com.hazelcast.client.config.XmlClientConfigBuilder) InputStream(java.io.InputStream) MulticastDiscoveryStrategy(com.hazelcast.spi.discovery.multicast.MulticastDiscoveryStrategy) Before(org.junit.Before)

Example 4 with XmlConfigBuilder

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

the class HazelcastComponent method getOrCreateHzInstance.

private HazelcastInstance getOrCreateHzInstance(CamelContext context, Map<String, Object> parameters) throws Exception {
    HazelcastInstance hzInstance = null;
    Config config = null;
    // Query param named 'hazelcastInstance' (if exists) overrides the instance that was set
    hzInstance = resolveAndRemoveReferenceParameter(parameters, HAZELCAST_INSTANCE_PARAM, HazelcastInstance.class);
    // Check if an already created instance is given then just get instance by its name.
    if (hzInstance == null && parameters.get(HAZELCAST_INSTANCE_NAME_PARAM) != null) {
        hzInstance = Hazelcast.getHazelcastInstanceByName((String) parameters.get(HAZELCAST_INSTANCE_NAME_PARAM));
    }
    // as reference or as xml configuration file.
    if (hzInstance == null) {
        config = resolveAndRemoveReferenceParameter(parameters, HAZELCAST_CONFIGU_PARAM, Config.class);
        if (config == null) {
            String configUri = getAndRemoveParameter(parameters, HAZELCAST_CONFIGU_URI_PARAM, String.class);
            if (configUri != null) {
                configUri = getCamelContext().resolvePropertyPlaceholders(configUri);
            }
            if (configUri != null) {
                InputStream is = ResourceHelper.resolveMandatoryResourceAsInputStream(context, configUri);
                config = new XmlConfigBuilder(is).build();
            }
        }
        if (hazelcastInstance == null && config == null) {
            config = new XmlConfigBuilder().build();
            // Disable the version check
            config.getProperties().setProperty("hazelcast.version.check.enabled", "false");
            config.getProperties().setProperty("hazelcast.phone.home.enabled", "false");
            hzInstance = Hazelcast.newHazelcastInstance(config);
        } else if (config != null) {
            if (ObjectHelper.isNotEmpty(config.getInstanceName())) {
                hzInstance = Hazelcast.getOrCreateHazelcastInstance(config);
            } else {
                hzInstance = Hazelcast.newHazelcastInstance(config);
            }
        }
        if (hzInstance != null) {
            if (this.customHazelcastInstances.add(hzInstance)) {
                LOGGER.debug("Add managed HZ instance {}", hzInstance.getName());
            }
        }
    }
    return hzInstance == null ? hazelcastInstance : hzInstance;
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) XmlConfigBuilder(com.hazelcast.config.XmlConfigBuilder) ClientConfig(com.hazelcast.client.config.ClientConfig) Config(com.hazelcast.config.Config) InputStream(java.io.InputStream)

Example 5 with XmlConfigBuilder

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

the class HazelcastUtil method newInstance.

public static HazelcastInstance newInstance() {
    Config cfg = new XmlConfigBuilder().build();
    // hazelcast.version.check.enabled is deprecated
    cfg.setProperty("hazelcast.phone.home.enabled", System.getProperty("hazelcast.phone.home.enabled", "false"));
    cfg.setProperty("hazelcast.logging.type", System.getProperty("hazelcast.logging.type", "slf4j"));
    return newInstance(cfg);
}
Also used : XmlConfigBuilder(com.hazelcast.config.XmlConfigBuilder) Config(com.hazelcast.config.Config)

Aggregations

XmlConfigBuilder (com.hazelcast.config.XmlConfigBuilder)43 Config (com.hazelcast.config.Config)36 InputStream (java.io.InputStream)15 ClientConfig (com.hazelcast.client.config.ClientConfig)12 Test (org.junit.Test)12 Before (org.junit.Before)11 XmlClientConfigBuilder (com.hazelcast.client.config.XmlClientConfigBuilder)10 DiscoveryConfig (com.hazelcast.config.DiscoveryConfig)10 QuickTest (com.hazelcast.test.annotation.QuickTest)9 DiscoveryStrategyConfig (com.hazelcast.config.DiscoveryStrategyConfig)8 JoinConfig (com.hazelcast.config.JoinConfig)7 HazelcastInstance (com.hazelcast.core.HazelcastInstance)7 AwsConfig (com.hazelcast.config.AwsConfig)6 InterfacesConfig (com.hazelcast.config.InterfacesConfig)6 MulticastConfig (com.hazelcast.config.MulticastConfig)6 TcpIpConfig (com.hazelcast.config.TcpIpConfig)6 MapConfig (com.hazelcast.config.MapConfig)5 MapStoreConfig (com.hazelcast.config.MapStoreConfig)4 URL (java.net.URL)4 Member (com.hazelcast.cluster.Member)3