Search in sources :

Example 51 with NodeEngine

use of com.hazelcast.spi.impl.NodeEngine in project hazelcast by hazelcast.

the class QueueReplicationOperation method run.

@Override
public void run() {
    QueueService service = getService();
    NodeEngine nodeEngine = getNodeEngine();
    Config config = nodeEngine.getConfig();
    for (Map.Entry<String, QueueContainer> entry : migrationData.entrySet()) {
        String name = entry.getKey();
        QueueContainer container = entry.getValue();
        QueueConfig conf = config.findQueueConfig(name);
        container.setConfig(conf, nodeEngine, service);
        service.addContainer(name, container);
    }
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) QueueConfig(com.hazelcast.config.QueueConfig) Config(com.hazelcast.config.Config) QueueConfig(com.hazelcast.config.QueueConfig) QueueContainer(com.hazelcast.collection.impl.queue.QueueContainer) QueueService(com.hazelcast.collection.impl.queue.QueueService) MapUtil.createHashMap(com.hazelcast.internal.util.MapUtil.createHashMap) Map(java.util.Map)

Example 52 with NodeEngine

use of com.hazelcast.spi.impl.NodeEngine in project hazelcast by hazelcast.

the class QueueProxySupport method initialize.

@Override
public void initialize() {
    final NodeEngine nodeEngine = getNodeEngine();
    final List<ItemListenerConfig> itemListenerConfigs = config.getItemListenerConfigs();
    for (ItemListenerConfig itemListenerConfig : itemListenerConfigs) {
        ItemListener listener = itemListenerConfig.getImplementation();
        if (listener == null && itemListenerConfig.getClassName() != null) {
            try {
                listener = ClassLoaderUtil.newInstance(nodeEngine.getConfigClassLoader(), itemListenerConfig.getClassName());
            } catch (Exception e) {
                throw rethrow(e);
            }
        }
        if (listener != null) {
            if (listener instanceof HazelcastInstanceAware) {
                ((HazelcastInstanceAware) listener).setHazelcastInstance(nodeEngine.getHazelcastInstance());
            }
            addItemListener(listener, itemListenerConfig.isIncludeValue());
        }
    }
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) ItemListenerConfig(com.hazelcast.config.ItemListenerConfig) ItemListener(com.hazelcast.collection.ItemListener) HazelcastInstanceAware(com.hazelcast.core.HazelcastInstanceAware)

Example 53 with NodeEngine

use of com.hazelcast.spi.impl.NodeEngine in project hazelcast by hazelcast.

the class QueueProxySupport method invoke.

private InvocationFuture<Object> invoke(Operation operation) {
    final NodeEngine nodeEngine = getNodeEngine();
    OperationService operationService = nodeEngine.getOperationService();
    return operationService.invokeOnPartition(QueueService.SERVICE_NAME, operation, getPartitionId());
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) OperationService(com.hazelcast.spi.impl.operationservice.OperationService)

Example 54 with NodeEngine

use of com.hazelcast.spi.impl.NodeEngine in project hazelcast by hazelcast.

the class QueueProxySupport method invokeAndGetData.

private Object invokeAndGetData(QueueOperation operation) {
    final NodeEngine nodeEngine = getNodeEngine();
    try {
        OperationService operationService = nodeEngine.getOperationService();
        Future f = operationService.invokeOnPartition(QueueService.SERVICE_NAME, operation, partitionId);
        return f.get();
    } catch (Throwable throwable) {
        throw rethrow(throwable);
    }
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) InvocationFuture(com.hazelcast.spi.impl.operationservice.impl.InvocationFuture) Future(java.util.concurrent.Future) OperationService(com.hazelcast.spi.impl.operationservice.OperationService)

Example 55 with NodeEngine

use of com.hazelcast.spi.impl.NodeEngine in project hazelcast by hazelcast.

the class CheckAndEvictOperation method run.

@Override
public void run() throws Exception {
    final QueueContainer queueContainer = getContainer();
    if (queueContainer.isEvictable()) {
        NodeEngine nodeEngine = getNodeEngine();
        ProxyService proxyService = nodeEngine.getProxyService();
        UUID source = nodeEngine.getLocalMember().getUuid();
        proxyService.destroyDistributedObject(getServiceName(), name, source);
    }
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) ProxyService(com.hazelcast.spi.impl.proxyservice.ProxyService) QueueContainer(com.hazelcast.collection.impl.queue.QueueContainer) UUID(java.util.UUID)

Aggregations

NodeEngine (com.hazelcast.spi.impl.NodeEngine)165 Data (com.hazelcast.internal.serialization.Data)48 OperationService (com.hazelcast.spi.impl.operationservice.OperationService)30 Address (com.hazelcast.cluster.Address)22 Test (org.junit.Test)21 ILogger (com.hazelcast.logging.ILogger)20 HazelcastInstance (com.hazelcast.core.HazelcastInstance)18 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)18 QuickTest (com.hazelcast.test.annotation.QuickTest)18 Config (com.hazelcast.config.Config)17 Operation (com.hazelcast.spi.impl.operationservice.Operation)16 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)15 IPartitionService (com.hazelcast.internal.partition.IPartitionService)12 Nonnull (javax.annotation.Nonnull)12 ArrayList (java.util.ArrayList)11 Future (java.util.concurrent.Future)11 Member (com.hazelcast.cluster.Member)10 UUID (java.util.UUID)10 InitializingObject (com.hazelcast.spi.impl.InitializingObject)9 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)9