parent
c169193bc6
commit
10f8839f29
@ -0,0 +1,56 @@
|
||||
/**
|
||||
* Copyright 2018 Nikita Koksharov
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.redisson.api;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Configuration for ExecutorService.
|
||||
*
|
||||
* @author Nikita Koksharov
|
||||
*
|
||||
*/
|
||||
public class ExecutorOptions {
|
||||
|
||||
private long taskRetryInterval = 60000;
|
||||
|
||||
private ExecutorOptions() {
|
||||
}
|
||||
|
||||
public static ExecutorOptions defaults() {
|
||||
return new ExecutorOptions();
|
||||
}
|
||||
|
||||
public long getTaskRetryInterval() {
|
||||
return taskRetryInterval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines task retry interval at the end of which task is executed again.
|
||||
* ExecutorService worker re-schedule task execution retry every 5 seconds.
|
||||
* <p>
|
||||
* Default is <code>1 minute</code>
|
||||
*
|
||||
* @param timeout value
|
||||
* @param unit value
|
||||
* @return self instance
|
||||
*/
|
||||
public ExecutorOptions taskRetryInterval(long timeout, TimeUnit unit) {
|
||||
this.taskRetryInterval = unit.toMillis(timeout);
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
/**
|
||||
* Copyright 2018 Nikita Koksharov
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.redisson.executor;
|
||||
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
import org.redisson.RedissonRemoteService;
|
||||
import org.redisson.api.RFuture;
|
||||
import org.redisson.api.RMap;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.redisson.client.codec.Codec;
|
||||
import org.redisson.command.CommandExecutor;
|
||||
import org.redisson.remote.RemoteServiceRequest;
|
||||
import org.redisson.remote.ResponseEntry;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Nikita Koksharov
|
||||
*
|
||||
*/
|
||||
public class RedissonExecutorRemoteService extends RedissonRemoteService {
|
||||
|
||||
public RedissonExecutorRemoteService(Codec codec, RedissonClient redisson, String name,
|
||||
CommandExecutor commandExecutor, String executorId, ConcurrentMap<String, ResponseEntry> responses) {
|
||||
super(codec, redisson, name, commandExecutor, executorId, responses);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RFuture<RemoteServiceRequest> getTask(String requestId, RMap<String, RemoteServiceRequest> tasks) {
|
||||
return tasks.getAsync(requestId);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package org.redisson.executor;
|
||||
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.redisson.api.annotation.RInject;
|
||||
|
||||
public class FailoverTask implements Runnable {
|
||||
|
||||
@RInject
|
||||
private RedissonClient redisson;
|
||||
private String objectName;
|
||||
|
||||
public FailoverTask() {
|
||||
}
|
||||
|
||||
public FailoverTask(String objectName) {
|
||||
super();
|
||||
this.objectName = objectName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (long i = 0; i < 20_000_000_000L; i++) {
|
||||
}
|
||||
redisson.getBucket(objectName).set(true);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue