use of com.hazelcast.spi.NodeEngine in project hazelcast by hazelcast.
the class TransactionalSetProxy method add.
@Override
public boolean add(E e) {
checkTransactionActive();
checkObjectNotNull(e);
final NodeEngine nodeEngine = getNodeEngine();
final Data value = nodeEngine.toData(e);
if (!getCollection().add(new CollectionItem(-1, value))) {
return false;
}
CollectionReserveAddOperation operation = new CollectionReserveAddOperation(name, tx.getTxnId(), value);
try {
Future<Long> f = nodeEngine.getOperationService().invokeOnPartition(getServiceName(), operation, partitionId);
Long itemId = f.get();
if (itemId != null) {
if (!itemIdSet.add(itemId)) {
throw new TransactionException("Duplicate itemId: " + itemId);
}
CollectionTxnAddOperation op = new CollectionTxnAddOperation(name, itemId, value);
putToRecord(op);
return true;
}
} catch (Throwable t) {
throw ExceptionUtil.rethrow(t);
}
return false;
}
use of com.hazelcast.spi.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 ExceptionUtil.rethrow(throwable);
}
}
use of com.hazelcast.spi.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 ExceptionUtil.rethrow(e);
}
}
if (listener != null) {
if (listener instanceof HazelcastInstanceAware) {
((HazelcastInstanceAware) listener).setHazelcastInstance(nodeEngine.getHazelcastInstance());
}
addItemListener(listener, itemListenerConfig.isIncludeValue());
}
}
}
use of com.hazelcast.spi.NodeEngine in project hazelcast by hazelcast.
the class QueueProxySupport method invoke.
private InternalCompletableFuture invoke(Operation operation) {
final NodeEngine nodeEngine = getNodeEngine();
OperationService operationService = nodeEngine.getOperationService();
return operationService.invokeOnPartition(QueueService.SERVICE_NAME, operation, getPartitionId());
}
use of com.hazelcast.spi.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);
}
}
Aggregations