Search in sources :

Example 1 with IAtomicLong

use of com.hazelcast.core.IAtomicLong in project hazelcast by hazelcast.

the class ProxyManager method init.

public void init(ClientConfig config) {
    // register defaults
    register(MapService.SERVICE_NAME, createServiceProxyFactory(MapService.class));
    if (JCacheDetector.isJCacheAvailable(config.getClassLoader())) {
        register(ICacheService.SERVICE_NAME, new ClientCacheProxyFactory(client));
    }
    register(QueueService.SERVICE_NAME, ClientQueueProxy.class);
    register(MultiMapService.SERVICE_NAME, ClientMultiMapProxy.class);
    register(ListService.SERVICE_NAME, ClientListProxy.class);
    register(SetService.SERVICE_NAME, ClientSetProxy.class);
    register(SemaphoreService.SERVICE_NAME, ClientSemaphoreProxy.class);
    register(TopicService.SERVICE_NAME, ClientTopicProxy.class);
    register(AtomicLongService.SERVICE_NAME, ClientAtomicLongProxy.class);
    register(AtomicReferenceService.SERVICE_NAME, ClientAtomicReferenceProxy.class);
    register(DistributedExecutorService.SERVICE_NAME, ClientExecutorServiceProxy.class);
    register(DistributedDurableExecutorService.SERVICE_NAME, ClientDurableExecutorServiceProxy.class);
    register(LockServiceImpl.SERVICE_NAME, ClientLockProxy.class);
    register(CountDownLatchService.SERVICE_NAME, ClientCountDownLatchProxy.class);
    register(MapReduceService.SERVICE_NAME, ClientMapReduceProxy.class);
    register(ReplicatedMapService.SERVICE_NAME, ClientReplicatedMapProxy.class);
    register(XAService.SERVICE_NAME, XAResourceProxy.class);
    register(RingbufferService.SERVICE_NAME, ClientRingbufferProxy.class);
    register(ReliableTopicService.SERVICE_NAME, new ClientProxyFactory() {

        public ClientProxy create(String id) {
            return new ClientReliableTopicProxy(id, client);
        }
    });
    register(IdGeneratorService.SERVICE_NAME, new ClientProxyFactory() {

        public ClientProxy create(String id) {
            IAtomicLong atomicLong = client.getAtomicLong(IdGeneratorService.ATOMIC_LONG_NAME + id);
            return new ClientIdGeneratorProxy(IdGeneratorService.SERVICE_NAME, id, atomicLong);
        }
    });
    register(CardinalityEstimatorService.SERVICE_NAME, ClientCardinalityEstimatorProxy.class);
    register(DistributedScheduledExecutorService.SERVICE_NAME, ClientScheduledExecutorProxy.class);
    for (ProxyFactoryConfig proxyFactoryConfig : config.getProxyFactoryConfigs()) {
        try {
            ClassLoader classLoader = config.getClassLoader();
            ClientProxyFactory clientProxyFactory = proxyFactoryConfig.getFactoryImpl();
            if (clientProxyFactory == null) {
                String className = proxyFactoryConfig.getClassName();
                clientProxyFactory = ClassLoaderUtil.newInstance(classLoader, className);
            }
            register(proxyFactoryConfig.getService(), clientProxyFactory);
        } catch (Exception e) {
            throw ExceptionUtil.rethrow(e);
        }
    }
    readProxyDescriptors();
}
Also used : ProxyFactoryConfig(com.hazelcast.client.config.ProxyFactoryConfig) ClientCacheProxyFactory(com.hazelcast.client.cache.impl.ClientCacheProxyFactory) ClientReliableTopicProxy(com.hazelcast.client.proxy.ClientReliableTopicProxy) MultiMapService(com.hazelcast.multimap.impl.MultiMapService) ReplicatedMapService(com.hazelcast.replicatedmap.impl.ReplicatedMapService) MapService(com.hazelcast.map.impl.MapService) IAtomicLong(com.hazelcast.core.IAtomicLong) HazelcastException(com.hazelcast.core.HazelcastException) ClientServiceNotFoundException(com.hazelcast.client.spi.impl.ClientServiceNotFoundException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) ClientIdGeneratorProxy(com.hazelcast.client.proxy.ClientIdGeneratorProxy)

Example 2 with IAtomicLong

use of com.hazelcast.core.IAtomicLong in project hazelcast by hazelcast.

the class ClientAtomicLongTest method alter_whenCalledWithNullFunction.

@Test(expected = IllegalArgumentException.class)
public void alter_whenCalledWithNullFunction() {
    IAtomicLong ref = client.getAtomicLong("alter_whenCalledWithNullFunction");
    ref.alter(null);
}
Also used : IAtomicLong(com.hazelcast.core.IAtomicLong) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 3 with IAtomicLong

use of com.hazelcast.core.IAtomicLong in project hazelcast by hazelcast.

the class ClientAtomicLongTest method apply_whenCalledWithNullFunction.

@Test(expected = IllegalArgumentException.class)
public void apply_whenCalledWithNullFunction() {
    IAtomicLong ref = client.getAtomicLong("apply_whenCalledWithNullFunction");
    ref.apply(null);
}
Also used : IAtomicLong(com.hazelcast.core.IAtomicLong) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 4 with IAtomicLong

use of com.hazelcast.core.IAtomicLong in project hazelcast by hazelcast.

the class ClientAtomicLongTest method getAndAlter_whenCalledWithNullFunction.

@Test(expected = IllegalArgumentException.class)
public void getAndAlter_whenCalledWithNullFunction() {
    IAtomicLong ref = client.getAtomicLong("getAndAlter_whenCalledWithNullFunction");
    ref.getAndAlter(null);
}
Also used : IAtomicLong(com.hazelcast.core.IAtomicLong) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 5 with IAtomicLong

use of com.hazelcast.core.IAtomicLong in project hazelcast by hazelcast.

the class ClientAtomicLongTest method alterAndGet.

@Test
public void alterAndGet() {
    IAtomicLong ref = client.getAtomicLong("alterAndGet");
    ref.set(10);
    assertEquals(11, ref.alterAndGet(new AddOneFunction()));
    assertEquals(11, ref.get());
}
Also used : IAtomicLong(com.hazelcast.core.IAtomicLong) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

IAtomicLong (com.hazelcast.core.IAtomicLong)49 ParallelTest (com.hazelcast.test.annotation.ParallelTest)45 Test (org.junit.Test)45 QuickTest (com.hazelcast.test.annotation.QuickTest)44 HazelcastInstance (com.hazelcast.core.HazelcastInstance)21 IExecutorService (com.hazelcast.core.IExecutorService)10 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)9 UndefinedErrorCodeException (com.hazelcast.client.UndefinedErrorCodeException)8 Random (java.util.Random)8 Config (com.hazelcast.config.Config)6 Member (com.hazelcast.core.Member)6 CountDownLatch (java.util.concurrent.CountDownLatch)6 ExecutionException (java.util.concurrent.ExecutionException)6 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)6 ExecutorConfig (com.hazelcast.config.ExecutorConfig)5 MultiExecutionCallback (com.hazelcast.core.MultiExecutionCallback)3 Map (java.util.Map)3 ICountDownLatch (com.hazelcast.core.ICountDownLatch)2 ClientCacheProxyFactory (com.hazelcast.client.cache.impl.ClientCacheProxyFactory)1 ProxyFactoryConfig (com.hazelcast.client.config.ProxyFactoryConfig)1