use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.
the class ReplicaSyncRequest method createReplicationOperations.
private List<Operation> createReplicationOperations() {
NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine();
Collection<ServiceInfo> services = nodeEngine.getServiceInfos(MigrationAwareService.class);
PartitionReplicationEvent event = new PartitionReplicationEvent(getPartitionId(), getReplicaIndex());
List<Operation> tasks = new LinkedList<Operation>();
for (ServiceInfo serviceInfo : services) {
MigrationAwareService service = (MigrationAwareService) serviceInfo.getService();
Operation op = service.prepareReplicationOperation(event);
if (op != null) {
op.setServiceName(serviceInfo.getName());
tasks.add(op);
}
}
return tasks;
}
use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.
the class ReplicaSyncResponse method executeTasks.
private void executeTasks() {
int partitionId = getPartitionId();
int replicaIndex = getReplicaIndex();
if (tasks != null && !tasks.isEmpty()) {
logApplyReplicaSync(partitionId, replicaIndex);
for (Operation op : tasks) {
prepareOperation(op);
try {
op.beforeRun();
op.run();
op.afterRun();
} catch (Throwable e) {
onOperationFailure(op, e);
logException(op, e);
}
}
} else {
logEmptyTaskList(partitionId, replicaIndex);
}
}
use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.
the class MigrationOperation method writeInternal.
@Override
protected void writeInternal(ObjectDataOutput out) throws IOException {
super.writeInternal(out);
out.writeLongArray(replicaVersions);
int size = tasks != null ? tasks.size() : 0;
out.writeInt(size);
if (size > 0) {
for (Operation task : tasks) {
out.writeObject(task);
}
}
}
use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.
the class MigrationOperation method doRun.
private void doRun() throws Exception {
if (migrationInfo.startProcessing()) {
try {
executeBeforeMigrations();
for (Operation op : tasks) {
runMigrationOperation(op);
}
success = true;
} catch (Throwable e) {
success = false;
failureReason = e;
getLogger().severe("Error while executing replication operations " + migrationInfo, e);
} finally {
afterMigrate();
}
} else {
success = false;
logMigrationCancelled();
}
}
use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.
the class AbstractInternalCacheProxy method removeAsyncInternal.
<T> InternalCompletableFuture<T> removeAsyncInternal(K key, V oldValue, boolean hasOldValue, boolean isGet, boolean withCompletionEvent) {
ensureOpen();
if (hasOldValue) {
validateNotNull(key, oldValue);
CacheProxyUtil.validateConfiguredTypes(cacheConfig, key, oldValue);
} else {
validateNotNull(key);
CacheProxyUtil.validateConfiguredTypes(cacheConfig, key);
}
Data keyData = serializationService.toData(key);
Data valueData = serializationService.toData(oldValue);
Operation operation;
if (isGet) {
operation = operationProvider.createGetAndRemoveOperation(keyData, IGNORE_COMPLETION);
} else {
operation = operationProvider.createRemoveOperation(keyData, valueData, IGNORE_COMPLETION);
}
return invoke(operation, keyData, withCompletionEvent);
}
Aggregations