com.github.lontime.extredisson.container.NodeService Maven / Gradle / Ivy
The newest version!
package com.github.lontime.extredisson.container;
import java.time.Duration;
import com.github.lontime.base.commonj.components.DelayedProcessor;
import com.github.lontime.base.logging.GLogger;
import com.github.lontime.extredisson.RedissonInstance;
import com.github.lontime.extredisson.configuration.NodeOption;
import com.github.lontime.extredisson.configuration.OptionResolver;
/**
* NodeService.
* @author lontime
* @since 1.0
*/
public class NodeService extends DelayedProcessor {
private final NodeOption option;
public NodeService() {
this.option = OptionResolver.getInstance().getNodeOption();
}
@Override
public boolean doLoop() {
final long current = System.currentTimeMillis();
RedissonInstance.get().getScoredSortedSet(option.getNamespace())
.add(current, option.getId());
GLogger.node().debugv("Node ID {0} is living .......", option.getId());
return true;
}
@Override
protected Duration sleepTimeout() {
return option.getPeriod();
}
}