Added timezone as a separate variable

pull/1547/head
arpit728 7 years ago
parent cdc58b10ff
commit b38f6d0bed

@ -815,7 +815,7 @@ public class RedissonExecutorService implements RScheduledExecutorService {
throw new IllegalArgumentException("Wrong cron expression! Unable to calculate start date"); throw new IllegalArgumentException("Wrong cron expression! Unable to calculate start date");
} }
long startTime = startDate.getTime(); long startTime = startDate.getTime();
RemotePromise<Void> result = (RemotePromise<Void>) asyncScheduledServiceAtFixed.schedule(task.getClass().getName(), classBody, state, startTime, cronSchedule.getExpression(), executorId, null); RemotePromise<Void> result = (RemotePromise<Void>) asyncScheduledServiceAtFixed.schedule(task.getClass().getName(), classBody, state, startTime, cronSchedule.getExpression().getCronExpression(),cronSchedule.getExpression().getTimeZone().getID(), executorId, null);
addListener(result); addListener(result);
RedissonScheduledFuture<Void> f = new RedissonScheduledFuture<Void>(result, startTime) { RedissonScheduledFuture<Void> f = new RedissonScheduledFuture<Void>(result, startTime) {
public long getDelay(TimeUnit unit) { public long getDelay(TimeUnit unit) {

@ -34,6 +34,6 @@ public interface RemoteExecutorService {
void scheduleWithFixedDelay(String className, byte[] classBody, byte[] state, long startTime, long delay, String executorId, String requestId); void scheduleWithFixedDelay(String className, byte[] classBody, byte[] state, long startTime, long delay, String executorId, String requestId);
void schedule(String className, byte[] classBody, byte[] state, long startTime, CronExpression cronExpression, String executorId, String requestId); void schedule(String className, byte[] classBody, byte[] state, long startTime, String cronExpression, String timezone, String executorId, String requestId);
} }

@ -38,6 +38,6 @@ public interface RemoteExecutorServiceAsync {
RFuture<Void> scheduleWithFixedDelay(String className, byte[] classBody, byte[] state, long startTime, long delay, String executorId, String requestId); RFuture<Void> scheduleWithFixedDelay(String className, byte[] classBody, byte[] state, long startTime, long delay, String executorId, String requestId);
RFuture<Void> schedule(String className, byte[] classBody, byte[] state, long startTime, CronExpression cronExpression, String executorId, String requestId); RFuture<Void> schedule(String className, byte[] classBody, byte[] state, long startTime, String cronExpression, String timezone, String executorId, String requestId);
} }

@ -40,6 +40,7 @@ import org.redisson.remote.ResponseEntry;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.TimeZone;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -118,12 +119,14 @@ public class TasksRunnerService implements RemoteExecutorService {
} }
@Override @Override
public void schedule(String className, byte[] classBody, byte[] state, long startTime, CronExpression cronExpression, String executorId, String requestId) { public void schedule(String className, byte[] classBody, byte[] state, long startTime, String cronExpression, String timezone, String executorId, String requestId) {
Date nextStartDate = cronExpression.getNextValidTimeAfter(new Date()); CronExpression expression = new CronExpression(cronExpression);
expression.setTimeZone(TimeZone.getTimeZone(timezone));
Date nextStartDate = expression.getNextValidTimeAfter(new Date());
RFuture<Void> future = null; RFuture<Void> future = null;
if (nextStartDate != null) { if (nextStartDate != null) {
RemoteExecutorServiceAsync service = asyncScheduledServiceAtFixed(executorId, requestId); RemoteExecutorServiceAsync service = asyncScheduledServiceAtFixed(executorId, requestId);
future = service.schedule(className, classBody, state, nextStartDate.getTime(), cronExpression, executorId, requestId); future = service.schedule(className, classBody, state, nextStartDate.getTime(), cronExpression, timezone, executorId, requestId);
} }
try { try {
executeRunnable(className, classBody, state, requestId); executeRunnable(className, classBody, state, requestId);

Loading…
Cancel
Save