Search in sources :

Example 1 with LockProxySupport

use of com.hazelcast.internal.locksupport.LockProxySupport 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)

Aggregations

Config (com.hazelcast.config.Config)1 ServiceConfig (com.hazelcast.config.ServiceConfig)1 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 LockProxySupport (com.hazelcast.internal.locksupport.LockProxySupport)1 Data (com.hazelcast.internal.serialization.Data)1 DistributedObjectNamespace (com.hazelcast.internal.services.DistributedObjectNamespace)1 NodeEngine (com.hazelcast.spi.impl.NodeEngine)1