use of com.ctrip.xpipe.concurrent.AbstractExceptionLogTask in project x-pipe by ctripcorp.
the class AbstractRedisMasterReplication method checkTimeout.
private void checkTimeout(final Channel channel) {
logger.info("[checkTimeout]{} ms, {}", replTimeoutMilli, ChannelUtil.getDesc(channel));
final ScheduledFuture<?> repliTimeoutCheckFuture = scheduled.scheduleAtFixedRate(new AbstractExceptionLogTask() {
@Override
protected void doRun() throws Exception {
long current = System.currentTimeMillis();
if ((current - repl_transfer_lastio) >= replTimeoutMilli) {
logger.info("[doRun][no action with master for a long time, close connection]{}, {}", channel, AbstractRedisMasterReplication.this);
channel.close();
}
}
}, replTimeoutMilli, replTimeoutMilli, TimeUnit.MILLISECONDS);
channel.closeFuture().addListener(new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture future) throws Exception {
logger.info("[cancelTimeout]{}ms, {}", replTimeoutMilli, channel);
repliTimeoutCheckFuture.cancel(true);
}
});
}
use of com.ctrip.xpipe.concurrent.AbstractExceptionLogTask in project x-pipe by ctripcorp.
the class DefaultRedisSlave method close.
public void close() throws IOException {
logger.info("[close]{}", this);
if (closeState.isClosed()) {
logger.info("[close][already closed]{}", this);
return;
}
closeState.setClosing();
psyncProcessed.addListener(new AbstractExceptionLogTask() {
@Override
protected void doRun() throws Exception {
doRealClose();
}
}, MoreExecutors.directExecutor());
if (closeState.isClosing()) {
scheduled.schedule(new AbstractExceptionLogTask() {
@Override
protected void doRun() throws Exception {
logger.info("[wait for psync processed timeout close slave]{}", DefaultRedisSlave.this);
doRealClose();
}
}, waitForPsyncProcessedTimeoutMilli, TimeUnit.MILLISECONDS);
}
}
use of com.ctrip.xpipe.concurrent.AbstractExceptionLogTask in project x-pipe by ctripcorp.
the class ScheduleCommandWrapper method doExecute.
@Override
protected void doExecute() throws Exception {
final ScheduledFuture<?> scheduleFuture = scheduled.schedule(new AbstractExceptionLogTask() {
@Override
protected void doRun() throws Exception {
try {
command.execute().addListener(new CommandFutureListener<V>() {
@Override
public void operationComplete(CommandFuture<V> commandFuture) throws Exception {
if (commandFuture.isSuccess()) {
future().setSuccess(commandFuture.get());
} else {
future().setFailure(ExceptionUtils.getRootCause(commandFuture.cause()));
}
}
});
} catch (Exception e) {
future().setFailure(ExceptionUtils.getRootCause(e));
}
}
}, time, timeUnit);
future().addListener(new CommandFutureListener<V>() {
@Override
public void operationComplete(CommandFuture<V> commandFuture) throws Exception {
if (commandFuture.isCancelled()) {
logger.info("[command canceled][cancel execution]{}", time);
command.future().cancel(true);
scheduleFuture.cancel(false);
}
}
});
}
use of com.ctrip.xpipe.concurrent.AbstractExceptionLogTask in project x-pipe by ctripcorp.
the class AlertManager method postConstruct.
@PostConstruct
public void postConstruct() {
scheduled.scheduleWithFixedDelay(new AbstractExceptionLogTask() {
@Override
protected void doRun() throws Exception {
alertClusterWhiteList = consoleConfig.getAlertWhileList();
}
}, 0, 30, TimeUnit.SECONDS);
scheduled.scheduleWithFixedDelay(new AbstractExceptionLogTask() {
@Override
protected void doRun() throws Exception {
logger.info("[clusterCreateTimeMapper][execute]");
List<ClusterTbl> clusterTbls = clusterService.findAllClustersWithOrgInfo();
for (ClusterTbl clusterTbl : clusterTbls) {
clusterCreateTime.put(clusterTbl.getClusterName(), clusterTbl.getCreateTime());
}
}
}, 1, 60, TimeUnit.MINUTES);
}
use of com.ctrip.xpipe.concurrent.AbstractExceptionLogTask in project x-pipe by ctripcorp.
the class AbstractIntervalCheck method postConstruct.
@PostConstruct
public void postConstruct() {
logger.info("[postConstruct]{}", this);
scheduled.scheduleAtFixedRate(new AbstractExceptionLogTask() {
@Override
protected void doRun() throws Exception {
checkStart();
}
}, 1, 1, TimeUnit.SECONDS);
}
Aggregations