|
|
@ -41,6 +41,7 @@ import java.util.concurrent.TimeoutException;
|
|
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
|
|
|
|
|
|
|
|
|
import org.redisson.api.CronSchedule;
|
|
|
|
import org.redisson.api.CronSchedule;
|
|
|
|
|
|
|
|
import org.redisson.api.ExecutorOptions;
|
|
|
|
import org.redisson.api.RAtomicLong;
|
|
|
|
import org.redisson.api.RAtomicLong;
|
|
|
|
import org.redisson.api.RExecutorBatchFuture;
|
|
|
|
import org.redisson.api.RExecutorBatchFuture;
|
|
|
|
import org.redisson.api.RExecutorFuture;
|
|
|
|
import org.redisson.api.RExecutorFuture;
|
|
|
@ -60,6 +61,7 @@ import org.redisson.connection.ConnectionManager;
|
|
|
|
import org.redisson.executor.RedissonExecutorBatchFuture;
|
|
|
|
import org.redisson.executor.RedissonExecutorBatchFuture;
|
|
|
|
import org.redisson.executor.RedissonExecutorFuture;
|
|
|
|
import org.redisson.executor.RedissonExecutorFuture;
|
|
|
|
import org.redisson.executor.RedissonExecutorFutureReference;
|
|
|
|
import org.redisson.executor.RedissonExecutorFutureReference;
|
|
|
|
|
|
|
|
import org.redisson.executor.RedissonExecutorRemoteService;
|
|
|
|
import org.redisson.executor.RedissonScheduledFuture;
|
|
|
|
import org.redisson.executor.RedissonScheduledFuture;
|
|
|
|
import org.redisson.executor.RemoteExecutorService;
|
|
|
|
import org.redisson.executor.RemoteExecutorService;
|
|
|
|
import org.redisson.executor.RemoteExecutorServiceAsync;
|
|
|
|
import org.redisson.executor.RemoteExecutorServiceAsync;
|
|
|
@ -92,6 +94,8 @@ public class RedissonExecutorService implements RScheduledExecutorService {
|
|
|
|
|
|
|
|
|
|
|
|
private static final Logger log = LoggerFactory.getLogger(RedissonExecutorService.class);
|
|
|
|
private static final Logger log = LoggerFactory.getLogger(RedissonExecutorService.class);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final RemoteInvocationOptions RESULT_OPTIONS = RemoteInvocationOptions.defaults().noAck().expectResultWithin(1, TimeUnit.HOURS);
|
|
|
|
|
|
|
|
|
|
|
|
public static final int SHUTDOWN_STATE = 1;
|
|
|
|
public static final int SHUTDOWN_STATE = 1;
|
|
|
|
public static final int TERMINATED_STATE = 2;
|
|
|
|
public static final int TERMINATED_STATE = 2;
|
|
|
|
|
|
|
|
|
|
|
@ -103,6 +107,7 @@ public class RedissonExecutorService implements RScheduledExecutorService {
|
|
|
|
private final String tasksName;
|
|
|
|
private final String tasksName;
|
|
|
|
private final String schedulerQueueName;
|
|
|
|
private final String schedulerQueueName;
|
|
|
|
private final String schedulerChannelName;
|
|
|
|
private final String schedulerChannelName;
|
|
|
|
|
|
|
|
private final String tasksRetryIntervalName;
|
|
|
|
|
|
|
|
|
|
|
|
private final String workersChannelName;
|
|
|
|
private final String workersChannelName;
|
|
|
|
private final String workersSemaphoreName;
|
|
|
|
private final String workersSemaphoreName;
|
|
|
@ -121,6 +126,7 @@ public class RedissonExecutorService implements RScheduledExecutorService {
|
|
|
|
private final RemoteExecutorServiceAsync asyncServiceWithoutResult;
|
|
|
|
private final RemoteExecutorServiceAsync asyncServiceWithoutResult;
|
|
|
|
|
|
|
|
|
|
|
|
private final ScheduledTasksService scheduledRemoteService;
|
|
|
|
private final ScheduledTasksService scheduledRemoteService;
|
|
|
|
|
|
|
|
private final TasksService executorRemoteService;
|
|
|
|
|
|
|
|
|
|
|
|
private final Map<Class<?>, byte[]> class2bytes = PlatformDependent.newConcurrentHashMap();
|
|
|
|
private final Map<Class<?>, byte[]> class2bytes = PlatformDependent.newConcurrentHashMap();
|
|
|
|
|
|
|
|
|
|
|
@ -134,7 +140,8 @@ public class RedissonExecutorService implements RScheduledExecutorService {
|
|
|
|
private final ReferenceQueue<RExecutorFuture<?>> referenceDueue = new ReferenceQueue<RExecutorFuture<?>>();
|
|
|
|
private final ReferenceQueue<RExecutorFuture<?>> referenceDueue = new ReferenceQueue<RExecutorFuture<?>>();
|
|
|
|
private final Collection<RedissonExecutorFutureReference> references = Collections.newSetFromMap(PlatformDependent.<RedissonExecutorFutureReference, Boolean>newConcurrentHashMap());
|
|
|
|
private final Collection<RedissonExecutorFutureReference> references = Collections.newSetFromMap(PlatformDependent.<RedissonExecutorFutureReference, Boolean>newConcurrentHashMap());
|
|
|
|
|
|
|
|
|
|
|
|
public RedissonExecutorService(Codec codec, CommandExecutor commandExecutor, Redisson redisson, String name, QueueTransferService queueTransferService, ConcurrentMap<String, ResponseEntry> responses) {
|
|
|
|
public RedissonExecutorService(Codec codec, CommandExecutor commandExecutor, Redisson redisson,
|
|
|
|
|
|
|
|
String name, QueueTransferService queueTransferService, ConcurrentMap<String, ResponseEntry> responses, ExecutorOptions options) {
|
|
|
|
super();
|
|
|
|
super();
|
|
|
|
this.codec = codec;
|
|
|
|
this.codec = codec;
|
|
|
|
this.commandExecutor = commandExecutor;
|
|
|
|
this.commandExecutor = commandExecutor;
|
|
|
@ -150,7 +157,7 @@ public class RedissonExecutorService implements RScheduledExecutorService {
|
|
|
|
this.executorId = connectionManager.getId().toString() + ":" + RemoteExecutorServiceAsync.class.getName() + ":" + name;
|
|
|
|
this.executorId = connectionManager.getId().toString() + ":" + RemoteExecutorServiceAsync.class.getName() + ":" + name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
remoteService = redisson.getRemoteService(name, codec);
|
|
|
|
remoteService = new RedissonExecutorRemoteService(codec, redisson, name, connectionManager.getCommandExecutor(), executorId, responses);
|
|
|
|
requestQueueName = ((RedissonRemoteService)remoteService).getRequestQueueName(RemoteExecutorService.class);
|
|
|
|
requestQueueName = ((RedissonRemoteService)remoteService).getRequestQueueName(RemoteExecutorService.class);
|
|
|
|
responseQueueName = ((RedissonRemoteService)remoteService).getResponseQueueName(executorId);
|
|
|
|
responseQueueName = ((RedissonRemoteService)remoteService).getResponseQueueName(executorId);
|
|
|
|
String objectName = requestQueueName;
|
|
|
|
String objectName = requestQueueName;
|
|
|
@ -159,7 +166,7 @@ public class RedissonExecutorService implements RScheduledExecutorService {
|
|
|
|
statusName = objectName + ":status";
|
|
|
|
statusName = objectName + ":status";
|
|
|
|
terminationTopic = redisson.getTopic(objectName + ":termination-topic", codec);
|
|
|
|
terminationTopic = redisson.getTopic(objectName + ":termination-topic", codec);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tasksRetryIntervalName = objectName + ":retry-interval";
|
|
|
|
schedulerChannelName = objectName + ":scheduler-channel";
|
|
|
|
schedulerChannelName = objectName + ":scheduler-channel";
|
|
|
|
schedulerQueueName = objectName + ":scheduler";
|
|
|
|
schedulerQueueName = objectName + ":scheduler";
|
|
|
|
|
|
|
|
|
|
|
@ -169,12 +176,16 @@ public class RedissonExecutorService implements RScheduledExecutorService {
|
|
|
|
|
|
|
|
|
|
|
|
workersTopic = redisson.getTopic(workersChannelName);
|
|
|
|
workersTopic = redisson.getTopic(workersChannelName);
|
|
|
|
|
|
|
|
|
|
|
|
TasksService executorRemoteService = new TasksService(codec, redisson, name, commandExecutor, executorId, responses);
|
|
|
|
executorRemoteService = new TasksService(codec, redisson, name, commandExecutor, executorId, responses);
|
|
|
|
executorRemoteService.setTerminationTopicName(terminationTopic.getChannelNames().get(0));
|
|
|
|
executorRemoteService.setTerminationTopicName(terminationTopic.getChannelNames().get(0));
|
|
|
|
executorRemoteService.setTasksCounterName(tasksCounterName);
|
|
|
|
executorRemoteService.setTasksCounterName(tasksCounterName);
|
|
|
|
executorRemoteService.setStatusName(statusName);
|
|
|
|
executorRemoteService.setStatusName(statusName);
|
|
|
|
executorRemoteService.setTasksName(tasksName);
|
|
|
|
executorRemoteService.setTasksName(tasksName);
|
|
|
|
asyncService = executorRemoteService.get(RemoteExecutorServiceAsync.class, RemoteInvocationOptions.defaults().noAck().expectResultWithin(1, TimeUnit.DAYS));
|
|
|
|
executorRemoteService.setSchedulerChannelName(schedulerChannelName);
|
|
|
|
|
|
|
|
executorRemoteService.setSchedulerQueueName(schedulerQueueName);
|
|
|
|
|
|
|
|
executorRemoteService.setTasksRetryIntervalName(tasksRetryIntervalName);
|
|
|
|
|
|
|
|
executorRemoteService.setTasksRetryInterval(options.getTaskRetryInterval());
|
|
|
|
|
|
|
|
asyncService = executorRemoteService.get(RemoteExecutorServiceAsync.class, RESULT_OPTIONS);
|
|
|
|
asyncServiceWithoutResult = executorRemoteService.get(RemoteExecutorServiceAsync.class, RemoteInvocationOptions.defaults().noAck().noResult());
|
|
|
|
asyncServiceWithoutResult = executorRemoteService.get(RemoteExecutorServiceAsync.class, RemoteInvocationOptions.defaults().noAck().noResult());
|
|
|
|
|
|
|
|
|
|
|
|
scheduledRemoteService = new ScheduledTasksService(codec, redisson, name, commandExecutor, executorId, responses);
|
|
|
|
scheduledRemoteService = new ScheduledTasksService(codec, redisson, name, commandExecutor, executorId, responses);
|
|
|
@ -184,7 +195,9 @@ public class RedissonExecutorService implements RScheduledExecutorService {
|
|
|
|
scheduledRemoteService.setSchedulerQueueName(schedulerQueueName);
|
|
|
|
scheduledRemoteService.setSchedulerQueueName(schedulerQueueName);
|
|
|
|
scheduledRemoteService.setSchedulerChannelName(schedulerChannelName);
|
|
|
|
scheduledRemoteService.setSchedulerChannelName(schedulerChannelName);
|
|
|
|
scheduledRemoteService.setTasksName(tasksName);
|
|
|
|
scheduledRemoteService.setTasksName(tasksName);
|
|
|
|
asyncScheduledService = scheduledRemoteService.get(RemoteExecutorServiceAsync.class, RemoteInvocationOptions.defaults().noAck().expectResultWithin(1, TimeUnit.DAYS));
|
|
|
|
scheduledRemoteService.setTasksRetryIntervalName(tasksRetryIntervalName);
|
|
|
|
|
|
|
|
scheduledRemoteService.setTasksRetryInterval(options.getTaskRetryInterval());
|
|
|
|
|
|
|
|
asyncScheduledService = scheduledRemoteService.get(RemoteExecutorServiceAsync.class, RESULT_OPTIONS);
|
|
|
|
asyncScheduledServiceAtFixed = scheduledRemoteService.get(RemoteExecutorServiceAsync.class, RemoteInvocationOptions.defaults().noAck().noResult());
|
|
|
|
asyncScheduledServiceAtFixed = scheduledRemoteService.get(RemoteExecutorServiceAsync.class, RemoteInvocationOptions.defaults().noAck().noResult());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -232,9 +245,32 @@ public class RedissonExecutorService implements RScheduledExecutorService {
|
|
|
|
protected RFuture<Long> pushTaskAsync() {
|
|
|
|
protected RFuture<Long> pushTaskAsync() {
|
|
|
|
return commandExecutor.evalWriteAsync(name, LongCodec.INSTANCE, RedisCommands.EVAL_LONG,
|
|
|
|
return commandExecutor.evalWriteAsync(name, LongCodec.INSTANCE, RedisCommands.EVAL_LONG,
|
|
|
|
"local expiredTaskIds = redis.call('zrangebyscore', KEYS[2], 0, ARGV[1], 'limit', 0, ARGV[2]); "
|
|
|
|
"local expiredTaskIds = redis.call('zrangebyscore', KEYS[2], 0, ARGV[1], 'limit', 0, ARGV[2]); "
|
|
|
|
|
|
|
|
+ "local retryInterval = redis.call('get', KEYS[4]);"
|
|
|
|
+ "if #expiredTaskIds > 0 then "
|
|
|
|
+ "if #expiredTaskIds > 0 then "
|
|
|
|
+ "redis.call('zrem', KEYS[2], unpack(expiredTaskIds));"
|
|
|
|
+ "redis.call('zrem', KEYS[2], unpack(expiredTaskIds));"
|
|
|
|
+ "redis.call('rpush', KEYS[1], unpack(expiredTaskIds));"
|
|
|
|
+ "if retryInterval ~= false then "
|
|
|
|
|
|
|
|
+ "local startTime = tonumber(ARGV[1]) + tonumber(retryInterval);"
|
|
|
|
|
|
|
|
+ "for i = 1, #expiredTaskIds, 1 do "
|
|
|
|
|
|
|
|
+ "local name = expiredTaskIds[i];"
|
|
|
|
|
|
|
|
+ "local scheduledName = expiredTaskIds[i];"
|
|
|
|
|
|
|
|
+ "if string.sub(scheduledName, 1, 2) ~= 'ff' then "
|
|
|
|
|
|
|
|
+ "scheduledName = 'ff' .. scheduledName; "
|
|
|
|
|
|
|
|
+ "else "
|
|
|
|
|
|
|
|
+ "name = string.sub(name, 3, string.len(name)); "
|
|
|
|
|
|
|
|
+ "end;"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ "redis.call('zadd', KEYS[2], startTime, scheduledName);"
|
|
|
|
|
|
|
|
+ "local v = redis.call('zrange', KEYS[2], 0, 0); "
|
|
|
|
|
|
|
|
// if new task added to queue head then publish its startTime
|
|
|
|
|
|
|
|
// to all scheduler workers
|
|
|
|
|
|
|
|
+ "if v[1] == expiredTaskIds[i] then "
|
|
|
|
|
|
|
|
+ "redis.call('publish', KEYS[3], startTime); "
|
|
|
|
|
|
|
|
+ "end;"
|
|
|
|
|
|
|
|
+ "redis.call('rpush', KEYS[1], name);"
|
|
|
|
|
|
|
|
+ "end; "
|
|
|
|
|
|
|
|
+ "else "
|
|
|
|
|
|
|
|
+ "redis.call('rpush', KEYS[1], unpack(expiredTaskIds));"
|
|
|
|
|
|
|
|
+ "end; "
|
|
|
|
+ "end; "
|
|
|
|
+ "end; "
|
|
|
|
// get startTime from scheduler queue head task
|
|
|
|
// get startTime from scheduler queue head task
|
|
|
|
+ "local v = redis.call('zrange', KEYS[2], 0, 0, 'WITHSCORES'); "
|
|
|
|
+ "local v = redis.call('zrange', KEYS[2], 0, 0, 'WITHSCORES'); "
|
|
|
@ -242,7 +278,7 @@ public class RedissonExecutorService implements RScheduledExecutorService {
|
|
|
|
+ "return v[2]; "
|
|
|
|
+ "return v[2]; "
|
|
|
|
+ "end "
|
|
|
|
+ "end "
|
|
|
|
+ "return nil;",
|
|
|
|
+ "return nil;",
|
|
|
|
Arrays.<Object>asList(requestQueueName, schedulerQueueName),
|
|
|
|
Arrays.<Object>asList(requestQueueName, schedulerQueueName, schedulerChannelName, tasksRetryIntervalName),
|
|
|
|
System.currentTimeMillis(), 100);
|
|
|
|
System.currentTimeMillis(), 100);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -256,6 +292,7 @@ public class RedissonExecutorService implements RScheduledExecutorService {
|
|
|
|
service.setTerminationTopicName(terminationTopic.getChannelNames().get(0));
|
|
|
|
service.setTerminationTopicName(terminationTopic.getChannelNames().get(0));
|
|
|
|
service.setSchedulerChannelName(schedulerChannelName);
|
|
|
|
service.setSchedulerChannelName(schedulerChannelName);
|
|
|
|
service.setSchedulerQueueName(schedulerQueueName);
|
|
|
|
service.setSchedulerQueueName(schedulerQueueName);
|
|
|
|
|
|
|
|
service.setTasksRetryIntervalName(tasksRetryIntervalName);
|
|
|
|
|
|
|
|
|
|
|
|
remoteService.register(RemoteExecutorService.class, service, workers, executor);
|
|
|
|
remoteService.register(RemoteExecutorService.class, service, workers, executor);
|
|
|
|
workersGroupListenerId = workersTopic.addListener(new MessageListener<String>() {
|
|
|
|
workersGroupListenerId = workersTopic.addListener(new MessageListener<String>() {
|
|
|
@ -267,6 +304,8 @@ public class RedissonExecutorService implements RScheduledExecutorService {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private long repeatInterval = 5000;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void execute(Runnable task) {
|
|
|
|
public void execute(Runnable task) {
|
|
|
|
check(task);
|
|
|
|
check(task);
|
|
|
@ -303,6 +342,9 @@ public class RedissonExecutorService implements RScheduledExecutorService {
|
|
|
|
executorRemoteService.setTasksCounterName(tasksCounterName);
|
|
|
|
executorRemoteService.setTasksCounterName(tasksCounterName);
|
|
|
|
executorRemoteService.setStatusName(statusName);
|
|
|
|
executorRemoteService.setStatusName(statusName);
|
|
|
|
executorRemoteService.setTasksName(tasksName);
|
|
|
|
executorRemoteService.setTasksName(tasksName);
|
|
|
|
|
|
|
|
executorRemoteService.setSchedulerChannelName(schedulerChannelName);
|
|
|
|
|
|
|
|
executorRemoteService.setSchedulerQueueName(schedulerQueueName);
|
|
|
|
|
|
|
|
executorRemoteService.setTasksRetryIntervalName(tasksRetryIntervalName);
|
|
|
|
return executorRemoteService;
|
|
|
|
return executorRemoteService;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -361,7 +403,7 @@ public class RedissonExecutorService implements RScheduledExecutorService {
|
|
|
|
+ "redis.call('set', KEYS[2], ARGV[1]);"
|
|
|
|
+ "redis.call('set', KEYS[2], ARGV[1]);"
|
|
|
|
+ "end;"
|
|
|
|
+ "end;"
|
|
|
|
+ "end;",
|
|
|
|
+ "end;",
|
|
|
|
Arrays.<Object>asList(tasksCounterName, statusName, terminationTopic.getChannelNames().get(0)),
|
|
|
|
Arrays.<Object>asList(tasksCounterName, statusName, terminationTopic.getChannelNames().get(0), tasksRetryIntervalName),
|
|
|
|
SHUTDOWN_STATE, TERMINATED_STATE);
|
|
|
|
SHUTDOWN_STATE, TERMINATED_STATE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -471,7 +513,7 @@ public class RedissonExecutorService implements RScheduledExecutorService {
|
|
|
|
|
|
|
|
|
|
|
|
List<RExecutorFuture<?>> result = new ArrayList<RExecutorFuture<?>>();
|
|
|
|
List<RExecutorFuture<?>> result = new ArrayList<RExecutorFuture<?>>();
|
|
|
|
TasksBatchService executorRemoteService = createBatchService();
|
|
|
|
TasksBatchService executorRemoteService = createBatchService();
|
|
|
|
RemoteExecutorServiceAsync asyncService = executorRemoteService.get(RemoteExecutorServiceAsync.class, RemoteInvocationOptions.defaults().noAck().expectResultWithin(1, TimeUnit.DAYS));
|
|
|
|
RemoteExecutorServiceAsync asyncService = executorRemoteService.get(RemoteExecutorServiceAsync.class, RESULT_OPTIONS);
|
|
|
|
for (Callable<?> task : tasks) {
|
|
|
|
for (Callable<?> task : tasks) {
|
|
|
|
check(task);
|
|
|
|
check(task);
|
|
|
|
byte[] classBody = getClassBody(task);
|
|
|
|
byte[] classBody = getClassBody(task);
|
|
|
@ -496,7 +538,7 @@ public class RedissonExecutorService implements RScheduledExecutorService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TasksBatchService executorRemoteService = createBatchService();
|
|
|
|
TasksBatchService executorRemoteService = createBatchService();
|
|
|
|
RemoteExecutorServiceAsync asyncService = executorRemoteService.get(RemoteExecutorServiceAsync.class, RemoteInvocationOptions.defaults().noAck().expectResultWithin(1, TimeUnit.DAYS));
|
|
|
|
RemoteExecutorServiceAsync asyncService = executorRemoteService.get(RemoteExecutorServiceAsync.class, RESULT_OPTIONS);
|
|
|
|
final List<RExecutorFuture<?>> result = new ArrayList<RExecutorFuture<?>>();
|
|
|
|
final List<RExecutorFuture<?>> result = new ArrayList<RExecutorFuture<?>>();
|
|
|
|
for (Callable<?> task : tasks) {
|
|
|
|
for (Callable<?> task : tasks) {
|
|
|
|
check(task);
|
|
|
|
check(task);
|
|
|
@ -599,7 +641,7 @@ public class RedissonExecutorService implements RScheduledExecutorService {
|
|
|
|
|
|
|
|
|
|
|
|
List<RExecutorFuture<?>> result = new ArrayList<RExecutorFuture<?>>();
|
|
|
|
List<RExecutorFuture<?>> result = new ArrayList<RExecutorFuture<?>>();
|
|
|
|
TasksBatchService executorRemoteService = createBatchService();
|
|
|
|
TasksBatchService executorRemoteService = createBatchService();
|
|
|
|
RemoteExecutorServiceAsync asyncService = executorRemoteService.get(RemoteExecutorServiceAsync.class, RemoteInvocationOptions.defaults().noAck().expectResultWithin(1, TimeUnit.DAYS));
|
|
|
|
RemoteExecutorServiceAsync asyncService = executorRemoteService.get(RemoteExecutorServiceAsync.class, RESULT_OPTIONS);
|
|
|
|
for (Runnable task : tasks) {
|
|
|
|
for (Runnable task : tasks) {
|
|
|
|
check(task);
|
|
|
|
check(task);
|
|
|
|
byte[] classBody = getClassBody(task);
|
|
|
|
byte[] classBody = getClassBody(task);
|
|
|
@ -624,7 +666,7 @@ public class RedissonExecutorService implements RScheduledExecutorService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TasksBatchService executorRemoteService = createBatchService();
|
|
|
|
TasksBatchService executorRemoteService = createBatchService();
|
|
|
|
RemoteExecutorServiceAsync asyncService = executorRemoteService.get(RemoteExecutorServiceAsync.class, RemoteInvocationOptions.defaults().noAck().expectResultWithin(1, TimeUnit.DAYS));
|
|
|
|
RemoteExecutorServiceAsync asyncService = executorRemoteService.get(RemoteExecutorServiceAsync.class, RESULT_OPTIONS);
|
|
|
|
final List<RExecutorFuture<?>> result = new ArrayList<RExecutorFuture<?>>();
|
|
|
|
final List<RExecutorFuture<?>> result = new ArrayList<RExecutorFuture<?>>();
|
|
|
|
for (Runnable task : tasks) {
|
|
|
|
for (Runnable task : tasks) {
|
|
|
|
check(task);
|
|
|
|
check(task);
|
|
|
@ -843,8 +885,13 @@ public class RedissonExecutorService implements RScheduledExecutorService {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean cancelTask(String taskId) {
|
|
|
|
public boolean cancelTask(String taskId) {
|
|
|
|
RFuture<Boolean> scheduledFuture = scheduledRemoteService.cancelExecutionAsync(new RequestId(taskId));
|
|
|
|
if (taskId.startsWith("01")) {
|
|
|
|
|
|
|
|
RFuture<Boolean> scheduledFuture = scheduledRemoteService.cancelExecutionAsync(new RequestId(taskId));
|
|
|
|
|
|
|
|
return commandExecutor.get(scheduledFuture);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
RFuture<Boolean> scheduledFuture = executorRemoteService.cancelExecutionAsync(new RequestId(taskId));
|
|
|
|
return commandExecutor.get(scheduledFuture);
|
|
|
|
return commandExecutor.get(scheduledFuture);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private <T> T doInvokeAny(Collection<? extends Callable<T>> tasks,
|
|
|
|
private <T> T doInvokeAny(Collection<? extends Callable<T>> tasks,
|
|
|
@ -908,8 +955,9 @@ public class RedissonExecutorService implements RScheduledExecutorService {
|
|
|
|
throw ee;
|
|
|
|
throw ee;
|
|
|
|
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
for (Future<T> f : futures)
|
|
|
|
for (Future<T> f : futures) {
|
|
|
|
f.cancel(true);
|
|
|
|
f.cancel(true);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|