Fixed timezone issue while executing job with timezone

pull/1547/head
arpit728 7 years ago
parent ae76a65419
commit 9e22f3a236

@ -15,61 +15,18 @@
*/ */
package org.redisson; package org.redisson;
import java.io.DataInputStream; import io.netty.buffer.ByteBuf;
import java.io.IOException; import io.netty.buffer.ByteBufUtil;
import java.io.InputStream; import io.netty.util.concurrent.FutureListener;
import java.lang.ref.ReferenceQueue; import io.netty.util.internal.PlatformDependent;
import java.lang.reflect.Modifier; import org.redisson.api.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicReference;
import org.redisson.api.CronSchedule;
import org.redisson.api.ExecutorOptions;
import org.redisson.api.RAtomicLong;
import org.redisson.api.RExecutorBatchFuture;
import org.redisson.api.RExecutorFuture;
import org.redisson.api.RFuture;
import org.redisson.api.RRemoteService;
import org.redisson.api.RScheduledExecutorService;
import org.redisson.api.RScheduledFuture;
import org.redisson.api.RSemaphore;
import org.redisson.api.RTopic;
import org.redisson.api.RemoteInvocationOptions;
import org.redisson.api.listener.MessageListener; import org.redisson.api.listener.MessageListener;
import org.redisson.client.codec.Codec; import org.redisson.client.codec.Codec;
import org.redisson.client.codec.LongCodec; import org.redisson.client.codec.LongCodec;
import org.redisson.client.protocol.RedisCommands; import org.redisson.client.protocol.RedisCommands;
import org.redisson.command.CommandExecutor; import org.redisson.command.CommandExecutor;
import org.redisson.connection.ConnectionManager; import org.redisson.connection.ConnectionManager;
import org.redisson.executor.RedissonExecutorBatchFuture; import org.redisson.executor.*;
import org.redisson.executor.RedissonExecutorFuture;
import org.redisson.executor.RedissonExecutorFutureReference;
import org.redisson.executor.RedissonExecutorRemoteService;
import org.redisson.executor.RedissonScheduledFuture;
import org.redisson.executor.RemoteExecutorService;
import org.redisson.executor.RemoteExecutorServiceAsync;
import org.redisson.executor.RemotePromise;
import org.redisson.executor.ScheduledTasksService;
import org.redisson.executor.TasksBatchService;
import org.redisson.executor.TasksRunnerService;
import org.redisson.executor.TasksService;
import org.redisson.misc.Injector; import org.redisson.misc.Injector;
import org.redisson.misc.PromiseDelegator; import org.redisson.misc.PromiseDelegator;
import org.redisson.misc.RPromise; import org.redisson.misc.RPromise;
@ -80,10 +37,14 @@ import org.redisson.remote.ResponseEntry.Result;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import io.netty.buffer.ByteBuf; import java.io.DataInputStream;
import io.netty.buffer.ByteBufUtil; import java.io.IOException;
import io.netty.util.concurrent.FutureListener; import java.io.InputStream;
import io.netty.util.internal.PlatformDependent; import java.lang.ref.ReferenceQueue;
import java.lang.reflect.Modifier;
import java.util.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicReference;
/** /**
* *
@ -854,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().getCronExpression(), executorId, null); RemotePromise<Void> result = (RemotePromise<Void>) asyncScheduledServiceAtFixed.schedule(task.getClass().getName(), classBody, state, startTime, cronSchedule.getExpression(), 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) {

@ -32,24 +32,21 @@
package org.redisson.executor; package org.redisson.executor;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable; import java.io.Serializable;
import java.text.ParseException; import java.text.ParseException;
import java.util.Calendar; import java.util.*;
import java.util.Date;
import java.util.HashMap; import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.ANY;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
import java.util.SortedSet;
import java.util.StringTokenizer;
import java.util.TimeZone;
import java.util.TreeSet;
/** /**
* @author Sharada Jambula, James House * @author Sharada Jambula, James House
* @author Contributions from Mads Henderson * @author Contributions from Mads Henderson
* @author Refactoring from CronTrigger to CronExpression by Aaron Craven * @author Refactoring from CronTrigger to CronExpression by Aaron Craven
*/ */
@JsonAutoDetect(creatorVisibility = ANY, fieldVisibility = ANY)
public final class CronExpression implements Serializable, Cloneable { public final class CronExpression implements Serializable, Cloneable {
private static final long serialVersionUID = 12423409423L; private static final long serialVersionUID = 12423409423L;
@ -117,7 +114,7 @@ public final class CronExpression implements Serializable, Cloneable {
* @param cronExpression String representation of the cron expression the * @param cronExpression String representation of the cron expression the
* new object should represent * new object should represent
*/ */
public CronExpression(String cronExpression) { public CronExpression(@JsonProperty("cronExpression") String cronExpression) {
if (cronExpression == null) { if (cronExpression == null) {
throw new IllegalArgumentException("cronExpression cannot be null"); throw new IllegalArgumentException("cronExpression cannot be null");
} }

@ -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, String cronExpression, String executorId, String requestId); void schedule(String className, byte[] classBody, byte[] state, long startTime, CronExpression cronExpression, 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, String cronExpression, String executorId, String requestId); RFuture<Void> schedule(String className, byte[] classBody, byte[] state, long startTime, CronExpression cronExpression, String executorId, String requestId);
} }

@ -15,13 +15,12 @@
*/ */
package org.redisson.executor; package org.redisson.executor;
import java.io.IOException; import io.netty.buffer.ByteBuf;
import java.util.Arrays; import io.netty.buffer.ByteBufAllocator;
import java.util.Date; import io.netty.util.Timeout;
import java.util.concurrent.Callable; import io.netty.util.TimerTask;
import java.util.concurrent.ConcurrentMap; import io.netty.util.concurrent.Future;
import java.util.concurrent.TimeUnit; import io.netty.util.concurrent.FutureListener;
import org.redisson.Redisson; import org.redisson.Redisson;
import org.redisson.RedissonExecutorService; import org.redisson.RedissonExecutorService;
import org.redisson.RedissonShutdownException; import org.redisson.RedissonShutdownException;
@ -38,12 +37,12 @@ import org.redisson.misc.Injector;
import org.redisson.remote.RequestId; import org.redisson.remote.RequestId;
import org.redisson.remote.ResponseEntry; import org.redisson.remote.ResponseEntry;
import io.netty.buffer.ByteBuf; import java.io.IOException;
import io.netty.buffer.ByteBufAllocator; import java.util.Arrays;
import io.netty.util.Timeout; import java.util.Date;
import io.netty.util.TimerTask; import java.util.concurrent.Callable;
import io.netty.util.concurrent.Future; import java.util.concurrent.ConcurrentMap;
import io.netty.util.concurrent.FutureListener; import java.util.concurrent.TimeUnit;
/** /**
* Executor service runs Callable and Runnable tasks. * Executor service runs Callable and Runnable tasks.
@ -119,7 +118,7 @@ public class TasksRunnerService implements RemoteExecutorService {
} }
@Override @Override
public void schedule(String className, byte[] classBody, byte[] state, long startTime, String cronExpression, String executorId, String requestId) { public void schedule(String className, byte[] classBody, byte[] state, long startTime, CronExpression cronExpression, String executorId, String requestId) {
Date nextStartDate = new CronExpression(cronExpression).getNextValidTimeAfter(new Date()); Date nextStartDate = new CronExpression(cronExpression).getNextValidTimeAfter(new Date());
RFuture<Void> future = null; RFuture<Void> future = null;
if (nextStartDate != null) { if (nextStartDate != null) {

Loading…
Cancel
Save