Search in sources :

Example 26 with ServiceConfig

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

the class MembershipUpdateTest method getConfigWithService.

private Config getConfigWithService(Object service, String serviceName) {
    Config config = new Config();
    ServiceConfig serviceConfig = new ServiceConfig().setEnabled(true).setName(serviceName).setImplementation(service);
    ConfigAccessor.getServicesConfig(config).addServiceConfig(serviceConfig);
    return config;
}
Also used : ServiceConfig(com.hazelcast.config.ServiceConfig) TestHazelcastInstanceFactory.initOrCreateConfig(com.hazelcast.test.TestHazelcastInstanceFactory.initOrCreateConfig) Config(com.hazelcast.config.Config) ServiceConfig(com.hazelcast.config.ServiceConfig)

Example 27 with ServiceConfig

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

the class MapIndexLifecycleTest method whenIndexAddedProgrammatically_existsOnAllMembers.

@Test
public void whenIndexAddedProgrammatically_existsOnAllMembers() {
    // GIVEN indexes are configured before Hazelcast starts
    int clusterSize = 3;
    TestHazelcastInstanceFactory instanceFactory = createHazelcastInstanceFactory(clusterSize);
    HazelcastInstance[] instances = new HazelcastInstance[clusterSize];
    Config config = getConfig().setProperty(ClusterProperty.PARTITION_COUNT.getName(), "4");
    config.getMapConfig(mapName);
    ConfigAccessor.getServicesConfig(config).addServiceConfig(new ServiceConfig().setName("SlowPostJoinAwareService").setEnabled(true).setImplementation(new SlowPostJoinAwareService()));
    instances[0] = instanceFactory.newHazelcastInstance(config);
    IMap<Integer, Book> bookMap = instances[0].getMap(mapName);
    fillMap(bookMap);
    bookMap.addIndex(getIndexConfig("author", false));
    bookMap.addIndex(getIndexConfig("year", true));
    assertEquals(BOOK_COUNT, bookMap.size());
    // THEN indexes are migrated and populated on all members
    for (int i = 1; i < clusterSize; i++) {
        instances[i] = instanceFactory.newHazelcastInstance(config);
        waitAllForSafeState(copyOfRange(instances, 0, i + 1));
        bookMap = instances[i].getMap(mapName);
        assertEquals(BOOK_COUNT, bookMap.keySet().size());
        assertAllPartitionContainersAreInitialized(instances[i]);
        assertGlobalIndexesAreInitialized(instances[i]);
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) HazelcastInstance(com.hazelcast.core.HazelcastInstance) ServiceConfig(com.hazelcast.config.ServiceConfig) Config(com.hazelcast.config.Config) ServiceConfig(com.hazelcast.config.ServiceConfig) IndexConfig(com.hazelcast.config.IndexConfig) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 28 with ServiceConfig

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

the class PartitionIndexingTest method getConfig.

@Override
protected Config getConfig() {
    Config config = smallInstanceConfig();
    config.setProperty(ClusterProperty.PARTITION_COUNT.getName(), "101");
    config.getMapConfig(MAP_NAME).setInMemoryFormat(inMemoryFormat);
    ServiceConfig serviceConfig = new ServiceConfig().setEnabled(true).setImplementation(migrationFailingService).setName(MigrationFailingService.class.getName());
    ConfigAccessor.getServicesConfig(config).addServiceConfig(serviceConfig);
    return config;
}
Also used : ServiceConfig(com.hazelcast.config.ServiceConfig) Config(com.hazelcast.config.Config) ServiceConfig(com.hazelcast.config.ServiceConfig) IndexConfig(com.hazelcast.config.IndexConfig)

Example 29 with ServiceConfig

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

the class LockInterceptorServiceTest method testLockingInterceptor.

private void testLockingInterceptor(LockInterceptingService implementation) {
    Config config = new Config();
    ConfigAccessor.getServicesConfig(config).addServiceConfig(new ServiceConfig().setEnabled(true).setName(LockInterceptingService.SERVICE_NAME).setImplementation(implementation));
    HazelcastInstance member = createHazelcastInstance(config);
    NodeEngine nodeEngine = getNodeEngineImpl(member);
    implementation.serializationService = getSerializationService(member);
    LockProxySupport lockProxySupport = new LockProxySupport(new DistributedObjectNamespace(LockInterceptingService.SERVICE_NAME, "test-object"), 10000);
    for (int i = 0; i < 100; i++) {
        try {
            Data key = getSerializationService(member).toData("key" + i);
            lockProxySupport.lock(nodeEngine, key);
        } catch (RuntimeException e) {
            ignore(e);
        }
    }
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) HazelcastInstance(com.hazelcast.core.HazelcastInstance) ServiceConfig(com.hazelcast.config.ServiceConfig) Config(com.hazelcast.config.Config) ServiceConfig(com.hazelcast.config.ServiceConfig) LockProxySupport(com.hazelcast.internal.locksupport.LockProxySupport) DistributedObjectNamespace(com.hazelcast.internal.services.DistributedObjectNamespace) Data(com.hazelcast.internal.serialization.Data)

Example 30 with ServiceConfig

use of com.hazelcast.config.ServiceConfig in project hazelcast-jet by hazelcast.

the class Jet method configureJetService.

static void configureJetService(JetConfig jetConfig) {
    if (!(jetConfig.getHazelcastConfig().getConfigPatternMatcher() instanceof MatchingPointConfigPatternMatcher)) {
        throw new UnsupportedOperationException("Custom config pattern matcher is not supported in Jet");
    }
    jetConfig.getHazelcastConfig().getServicesConfig().addServiceConfig(new ServiceConfig().setEnabled(true).setName(JetService.SERVICE_NAME).setClassName(JetService.class.getName()).setConfigObject(jetConfig));
    jetConfig.getHazelcastConfig().addMapConfig(new MapConfig(INTERNAL_JET_OBJECTS_PREFIX + "*").setBackupCount(jetConfig.getInstanceConfig().getBackupCount()).setStatisticsEnabled(false).setMergePolicy(IgnoreMergingEntryMapMergePolicy.class.getName()));
}
Also used : JetService(com.hazelcast.jet.impl.JetService) ServiceConfig(com.hazelcast.config.ServiceConfig) MapConfig(com.hazelcast.config.MapConfig) MatchingPointConfigPatternMatcher(com.hazelcast.config.matcher.MatchingPointConfigPatternMatcher)

Aggregations

ServiceConfig (com.hazelcast.config.ServiceConfig)30 Config (com.hazelcast.config.Config)27 QuickTest (com.hazelcast.test.annotation.QuickTest)11 Test (org.junit.Test)11 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)10 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)8 HazelcastInstance (com.hazelcast.core.HazelcastInstance)7 Before (org.junit.Before)6 NodeEngine (com.hazelcast.spi.impl.NodeEngine)4 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)3 ClientConfig (com.hazelcast.client.config.ClientConfig)2 ProxyFactoryConfig (com.hazelcast.client.config.ProxyFactoryConfig)2 IndexConfig (com.hazelcast.config.IndexConfig)2 Operation (com.hazelcast.spi.impl.operationservice.Operation)2 ProxyServiceImpl (com.hazelcast.spi.impl.proxyservice.impl.ProxyServiceImpl)2 Accessors.getNodeEngineImpl (com.hazelcast.test.Accessors.getNodeEngineImpl)2 UUID (java.util.UUID)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 MapConfig (com.hazelcast.config.MapConfig)1 ServicesConfig (com.hazelcast.config.ServicesConfig)1