Search in sources :

Example 16 with ServiceConfig

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

the class PartitionReplicaStateCheckerTest method shouldNotBeSafe_whenReplicasAreNotSync.

@Test
public void shouldNotBeSafe_whenReplicasAreNotSync() {
    Config config = new Config();
    ServiceConfig serviceConfig = TestMigrationAwareService.createServiceConfig(1);
    config.getServicesConfig().addServiceConfig(serviceConfig);
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory();
    HazelcastInstance hz = factory.newHazelcastInstance(config);
    HazelcastInstance hz2 = factory.newHazelcastInstance(config);
    InternalPartitionServiceImpl partitionService1 = getNode(hz).partitionService;
    InternalPartitionServiceImpl partitionService2 = getNode(hz2).partitionService;
    drainAllReplicaSyncPermits(partitionService1);
    drainAllReplicaSyncPermits(partitionService2);
    warmUpPartitions(hz, hz2);
    setBackupPacketDropFilter(hz, 100);
    setBackupPacketDropFilter(hz2, 100);
    NodeEngine nodeEngine = getNode(hz).nodeEngine;
    for (int i = 0; i < nodeEngine.getPartitionService().getPartitionCount(); i++) {
        Operation op = new TestPutOperationWithAsyncBackup(i);
        nodeEngine.getOperationService().invokeOnPartition(null, op, i).join();
    }
    final PartitionReplicaStateChecker replicaStateChecker1 = partitionService1.getPartitionReplicaStateChecker();
    final PartitionReplicaStateChecker replicaStateChecker2 = partitionService2.getPartitionReplicaStateChecker();
    assertEquals(PartitionServiceState.REPLICA_NOT_SYNC, replicaStateChecker1.getPartitionServiceState());
    assertEquals(PartitionServiceState.REPLICA_NOT_SYNC, replicaStateChecker2.getPartitionServiceState());
    addReplicaSyncPermits(partitionService1, 100);
    addReplicaSyncPermits(partitionService2, 100);
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            assertEquals(PartitionServiceState.SAFE, replicaStateChecker1.getPartitionServiceState());
            assertEquals(PartitionServiceState.SAFE, replicaStateChecker2.getPartitionServiceState());
        }
    });
}
Also used : Config(com.hazelcast.config.Config) ServiceConfig(com.hazelcast.config.ServiceConfig) Operation(com.hazelcast.spi.Operation) TestPutOperation(com.hazelcast.internal.partition.service.TestPutOperation) UnknownHostException(java.net.UnknownHostException) NodeEngine(com.hazelcast.spi.NodeEngine) HazelcastInstance(com.hazelcast.core.HazelcastInstance) ServiceConfig(com.hazelcast.config.ServiceConfig) AssertTask(com.hazelcast.test.AssertTask) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 17 with ServiceConfig

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

the class ServiceManagerImplTest method setup.

@Before
public void setup() {
    Config config = new Config();
    ServiceConfig serviceConfig = new ServiceConfig().setClassName(FooService.class.getName()).setEnabled(true).setName("fooService");
    config.getServicesConfig().addServiceConfig(serviceConfig);
    HazelcastInstance hz = createHazelcastInstance(config);
    NodeEngineImpl nodeEngine = getNodeEngineImpl(hz);
    serviceManager = (ServiceManagerImpl) nodeEngine.getServiceManager();
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) HazelcastInstance(com.hazelcast.core.HazelcastInstance) ServiceConfig(com.hazelcast.config.ServiceConfig) Config(com.hazelcast.config.Config) ServiceConfig(com.hazelcast.config.ServiceConfig) Before(org.junit.Before)

Aggregations

ServiceConfig (com.hazelcast.config.ServiceConfig)17 Config (com.hazelcast.config.Config)15 QuickTest (com.hazelcast.test.annotation.QuickTest)8 Test (org.junit.Test)8 ParallelTest (com.hazelcast.test.annotation.ParallelTest)7 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)6 HazelcastInstance (com.hazelcast.core.HazelcastInstance)4 Before (org.junit.Before)3 ServicesConfig (com.hazelcast.config.ServicesConfig)2 Operation (com.hazelcast.spi.Operation)2 AssertTask (com.hazelcast.test.AssertTask)2 ClientConfig (com.hazelcast.client.config.ClientConfig)1 ProxyFactoryConfig (com.hazelcast.client.config.ProxyFactoryConfig)1 Node (com.hazelcast.instance.Node)1 TestPutOperation (com.hazelcast.internal.partition.service.TestPutOperation)1 NodeEngine (com.hazelcast.spi.NodeEngine)1 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)1 ProxyServiceImpl (com.hazelcast.spi.impl.proxyservice.impl.ProxyServiceImpl)1 MigrationEndpoint (com.hazelcast.spi.partition.MigrationEndpoint)1 UnknownHostException (java.net.UnknownHostException)1