Search in sources :

Example 1 with Config

use of com.hazelcast.config.Config in project cas by apereo.

the class ProvidedHazelcastInstanceConfigurationTests method hazelcastInstanceIsCreatedNormally.

@Test
public void hazelcastInstanceIsCreatedNormally() throws Exception {
    assertNotNull(this.hzInstance);
    final Config config = this.hzInstance.getConfig();
    assertTrue(config.getNetworkConfig().getJoin().getMulticastConfig().isEnabled());
    assertEquals(Arrays.asList("127.0.0.1"), config.getNetworkConfig().getJoin().getTcpIpConfig().getMembers());
    assertFalse(config.getNetworkConfig().isPortAutoIncrement());
    assertEquals(5801, config.getNetworkConfig().getPort());
    final MapConfig mapConfig = config.getMapConfig("tickets-from-external-config");
    assertNotNull(mapConfig);
    assertEquals(20000, mapConfig.getMaxIdleSeconds());
    assertEquals(EvictionPolicy.LFU, mapConfig.getEvictionPolicy());
    assertEquals(99, mapConfig.getEvictionPercentage());
}
Also used : MapConfig(com.hazelcast.config.MapConfig) Config(com.hazelcast.config.Config) MapConfig(com.hazelcast.config.MapConfig) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with Config

use of com.hazelcast.config.Config in project Openfire by igniterealtime.

the class ClusteredCacheFactory method startCluster.

public boolean startCluster() {
    state = State.starting;
    // Set the serialization strategy to use for transmitting objects between node clusters
    serializationStrategy = ExternalizableUtil.getInstance().getStrategy();
    ExternalizableUtil.getInstance().setStrategy(new ClusterExternalizableUtil());
    // Set session locator to use when in a cluster
    XMPPServer.getInstance().setRemoteSessionLocator(new RemoteSessionLocator());
    // Set packet router to use to deliver packets to remote cluster nodes
    XMPPServer.getInstance().getRoutingTable().setRemotePacketRouter(new ClusterPacketRouter());
    ClassLoader oldLoader = null;
    // Store previous class loader (in case we change it)
    oldLoader = Thread.currentThread().getContextClassLoader();
    ClassLoader loader = new ClusterClassLoader();
    Thread.currentThread().setContextClassLoader(loader);
    int retry = 0;
    do {
        try {
            Config config = new ClasspathXmlConfig(HAZELCAST_CONFIG_FILE);
            config.setInstanceName("openfire");
            config.setClassLoader(loader);
            if (JMXManager.isEnabled() && HAZELCAST_JMX_ENABLED) {
                config.setProperty("hazelcast.jmx", "true");
                config.setProperty("hazelcast.jmx.detailed", "true");
            }
            hazelcast = Hazelcast.newHazelcastInstance(config);
            cluster = hazelcast.getCluster();
            // Update the running state of the cluster
            state = cluster != null ? State.started : State.stopped;
            // Set the ID of this cluster node
            XMPPServer.getInstance().setNodeID(NodeID.getInstance(getClusterMemberID()));
            // CacheFactory is now using clustered caches. We can add our listeners.
            clusterListener = new ClusterListener(cluster);
            lifecycleListener = hazelcast.getLifecycleService().addLifecycleListener(clusterListener);
            membershipListener = cluster.addMembershipListener(clusterListener);
            break;
        } catch (Exception e) {
            if (retry < CLUSTER_STARTUP_RETRY_COUNT) {
                logger.warn("Failed to start clustering (" + e.getMessage() + "); " + "will retry in " + CLUSTER_STARTUP_RETRY_TIME + " seconds");
                try {
                    Thread.sleep(CLUSTER_STARTUP_RETRY_TIME * 1000);
                } catch (InterruptedException ie) {
                /* ignore */
                }
            } else {
                logger.error("Unable to start clustering - continuing in local mode", e);
                state = State.stopped;
            }
        }
    } while (retry++ < CLUSTER_STARTUP_RETRY_COUNT);
    if (oldLoader != null) {
        // Restore previous class loader
        Thread.currentThread().setContextClassLoader(oldLoader);
    }
    return cluster != null;
}
Also used : ClusterPacketRouter(org.jivesoftware.openfire.plugin.util.cluster.ClusterPacketRouter) RemoteSessionLocator(org.jivesoftware.openfire.plugin.session.RemoteSessionLocator) Config(com.hazelcast.config.Config) ClasspathXmlConfig(com.hazelcast.config.ClasspathXmlConfig) ClasspathXmlConfig(com.hazelcast.config.ClasspathXmlConfig) TimeoutException(java.util.concurrent.TimeoutException)

Example 3 with Config

use of com.hazelcast.config.Config 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 4 with Config

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

the class DefaultNodeExtension method createSerializationService.

public InternalSerializationService createSerializationService() {
    InternalSerializationService ss;
    try {
        Config config = node.getConfig();
        ClassLoader configClassLoader = node.getConfigClassLoader();
        HazelcastInstanceImpl hazelcastInstance = node.hazelcastInstance;
        PartitioningStrategy partitioningStrategy = getPartitioningStrategy(configClassLoader);
        SerializationServiceBuilder builder = new DefaultSerializationServiceBuilder();
        SerializationConfig serializationConfig = config.getSerializationConfig() != null ? config.getSerializationConfig() : new SerializationConfig();
        byte version = (byte) node.getProperties().getInteger(GroupProperty.SERIALIZATION_VERSION);
        ss = (InternalSerializationService) builder.setClassLoader(configClassLoader).setConfig(serializationConfig).setManagedContext(hazelcastInstance.managedContext).setPartitioningStrategy(partitioningStrategy).setHazelcastInstance(hazelcastInstance).setVersion(version).build();
    } catch (Exception e) {
        throw ExceptionUtil.rethrow(e);
    }
    return ss;
}
Also used : DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) SerializationServiceBuilder(com.hazelcast.internal.serialization.SerializationServiceBuilder) DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) SerializationConfig(com.hazelcast.config.SerializationConfig) Config(com.hazelcast.config.Config) SerializationConfig(com.hazelcast.config.SerializationConfig) DefaultPartitioningStrategy(com.hazelcast.partition.strategy.DefaultPartitioningStrategy) PartitioningStrategy(com.hazelcast.core.PartitioningStrategy) InternalSerializationService(com.hazelcast.internal.serialization.InternalSerializationService) VersionMismatchException(com.hazelcast.internal.cluster.impl.VersionMismatchException)

Example 5 with Config

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

the class MemberConfigRequest method writeResponse.

@Override
public void writeResponse(ManagementCenterService mcs, JsonObject root) {
    final JsonObject result = new JsonObject();
    ConfigXmlGenerator configXmlGenerator = new ConfigXmlGenerator(true);
    Config config = mcs.getHazelcastInstance().getConfig();
    String configXmlString = configXmlGenerator.generate(config);
    result.add("configXmlString", configXmlString);
    root.add("result", result);
}
Also used : Config(com.hazelcast.config.Config) JsonObject(com.eclipsesource.json.JsonObject) ConfigXmlGenerator(com.hazelcast.config.ConfigXmlGenerator)

Aggregations

Config (com.hazelcast.config.Config)2458 Test (org.junit.Test)1570 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1465 QuickTest (com.hazelcast.test.annotation.QuickTest)1286 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)1003 MapConfig (com.hazelcast.config.MapConfig)599 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)497 MapStoreConfig (com.hazelcast.config.MapStoreConfig)300 NearCacheConfig (com.hazelcast.config.NearCacheConfig)270 Before (org.junit.Before)242 ClientConfig (com.hazelcast.client.config.ClientConfig)228 SlowTest (com.hazelcast.test.annotation.SlowTest)204 NightlyTest (com.hazelcast.test.annotation.NightlyTest)186 CountDownLatch (java.util.concurrent.CountDownLatch)182 IndexConfig (com.hazelcast.config.IndexConfig)162 JoinConfig (com.hazelcast.config.JoinConfig)142 ParallelTest (com.hazelcast.test.annotation.ParallelTest)141 AssertTask (com.hazelcast.test.AssertTask)131 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)126 CacheSimpleConfig (com.hazelcast.config.CacheSimpleConfig)125