use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.
the class PostJoinOperation method beforeRun.
@Override
public void beforeRun() throws Exception {
if (operations != null && operations.length > 0) {
final NodeEngine nodeEngine = getNodeEngine();
final int len = operations.length;
for (int i = 0; i < len; i++) {
final Operation op = operations[i];
op.setNodeEngine(nodeEngine);
op.setOperationResponseHandler(new OperationResponseHandler() {
@Override
public void sendResponse(Operation op, Object obj) {
if (obj instanceof Throwable) {
Throwable t = (Throwable) obj;
ILogger logger = nodeEngine.getLogger(op.getClass());
logger.warning("Error while running post-join operation: " + t.getClass().getSimpleName() + ": " + t.getMessage());
if (logger.isFineEnabled()) {
logger.fine("Error while running post-join operation: ", t);
}
}
}
});
OperationAccessor.setCallerAddress(op, getCallerAddress());
OperationAccessor.setConnection(op, getConnection());
operations[i] = op;
}
}
}
use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.
the class PostJoinOperation method writeInternal.
@Override
protected void writeInternal(final ObjectDataOutput out) throws IOException {
final int len = operations != null ? operations.length : 0;
out.writeInt(len);
if (len > 0) {
for (Operation op : operations) {
out.writeObject(op);
}
}
}
use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.
the class PartitionServiceProxy method isClusterSafe.
@Override
public boolean isClusterSafe() {
Collection<Member> members = nodeEngine.getClusterService().getMembers();
if (members == null || members.isEmpty()) {
return true;
}
final Collection<Future<Boolean>> futures = new ArrayList<Future<Boolean>>(members.size());
for (Member member : members) {
final Address target = member.getAddress();
final Operation operation = new SafeStateCheckOperation();
final Future<Boolean> future = nodeEngine.getOperationService().invokeOnTarget(InternalPartitionService.SERVICE_NAME, operation, target);
futures.add(future);
}
// todo this max wait is appropriate?
final int maxWaitTime = getMaxWaitTime();
Collection<Boolean> results = FutureUtil.returnWithDeadline(futures, maxWaitTime, TimeUnit.SECONDS, exceptionHandler);
if (results.size() != futures.size()) {
return false;
}
for (Boolean result : results) {
if (!result) {
return false;
}
}
return true;
}
use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.
the class ReplicaSyncResponse method nodeNotOwnsBackup.
/** Fail all replication operations with the exception that this node is no longer the replica with the sent index */
private void nodeNotOwnsBackup(InternalPartitionImpl partition) {
int partitionId = getPartitionId();
int replicaIndex = getReplicaIndex();
Address thisAddress = getNodeEngine().getThisAddress();
int currentReplicaIndex = partition.getReplicaIndex(thisAddress);
ILogger logger = getLogger();
if (logger.isFinestEnabled()) {
logger.finest("This node is not backup replica of partitionId=" + partitionId + ", replicaIndex=" + replicaIndex + " anymore. current replicaIndex=" + currentReplicaIndex);
}
if (tasks != null) {
Throwable throwable = new WrongTargetException(thisAddress, partition.getReplicaAddress(replicaIndex), partitionId, replicaIndex, getClass().getName());
for (Operation op : tasks) {
prepareOperation(op);
onOperationFailure(op, throwable);
}
}
}
use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.
the class ReplicaSyncResponse method readInternal.
@Override
protected void readInternal(ObjectDataInput in) throws IOException {
replicaVersions = in.readLongArray();
int size = in.readInt();
if (size > 0) {
tasks = new ArrayList<Operation>(size);
for (int i = 0; i < size; i++) {
Operation op = in.readObject();
tasks.add(op);
}
}
}
Aggregations