use of com.ctrip.xpipe.concurrent.AbstractExceptionLogTask in project x-pipe by ctripcorp.
the class HickwallMetricTest method testHickWall.
@Test
public void testHickWall() throws MetricProxyException, IOException {
int port = 11111;
logger.info("[testHickWall]{}", port);
scheduled.scheduleAtFixedRate(new AbstractExceptionLogTask() {
@Override
protected void doRun() throws Exception {
List<MetricData> data = new LinkedList<>();
HostPort hostPort = new HostPort("127.0.0.1", port);
MetricData metricData = new MetricData("delay", "cluster", "shard");
metricData.setValue(1000);
metricData.setHostPort(hostPort);
metricData.setTimestampMilli(System.currentTimeMillis());
data.add(metricData);
hickwallMetricProxy.writeBinMultiDataPoint(data);
}
}, 0, 2, TimeUnit.SECONDS);
waitForAnyKeyToExit();
}
use of com.ctrip.xpipe.concurrent.AbstractExceptionLogTask in project x-pipe by ctripcorp.
the class DefaultMigrationEventManager method defaultMigrationEventManager.
@PostConstruct
public void defaultMigrationEventManager() {
scheduled = Executors.newScheduledThreadPool(1, XpipeThreadFactory.create("EventManagerCleaner"));
scheduled.scheduleWithFixedDelay(new AbstractExceptionLogTask() {
@Override
protected void doRun() throws Exception {
List<Long> finished = new LinkedList<>();
currentWorkingEvents.forEach((id, migrationEvent) -> {
if (migrationEvent.isDone()) {
finished.add(id);
}
});
finished.forEach((id) -> removeEvent(id));
}
}, 60, 60, TimeUnit.SECONDS);
}
use of com.ctrip.xpipe.concurrent.AbstractExceptionLogTask in project x-pipe by ctripcorp.
the class DefaultRedisSlave method sendCommandForFullSync.
protected void sendCommandForFullSync() {
logger.info("[sendCommandForFullSync]{}, {}", this, rdbFileOffset + 1);
processPsyncSequentially(new AbstractExceptionLogTask() {
@Override
protected void doRun() throws Exception {
beginWriteCommands(rdbFileOffset + 1);
}
});
}
use of com.ctrip.xpipe.concurrent.AbstractExceptionLogTask in project x-pipe by ctripcorp.
the class RedisKeeperServerStateBackup method psync.
@Override
public boolean psync(final RedisClient redisClient, final String[] args) throws Exception {
logger.info("[psync][server state backup, ask slave to wait]{}, {}", redisClient, this);
if (redisKeeperServer.compareAndDo(this, new AbstractExceptionLogTask() {
@Override
protected void doRun() throws Exception {
redisClient.sendMessage(RedisProtocol.CRLF.getBytes());
PsyncKeeperServerStateObserver psyncKeeperServerStateObserver = new PsyncKeeperServerStateObserver(args, redisClient);
redisKeeperServer.addObserver(psyncKeeperServerStateObserver);
redisClient.addChannelCloseReleaseResources(new Releasable() {
@Override
public void release() throws Exception {
psyncKeeperServerStateObserver.release();
}
});
}
})) {
// state backup
return false;
}
logger.info("[psync][state change, use new state to psync]{}, {}", redisClient, redisKeeperServer);
return redisKeeperServer.getRedisKeeperServerState().psync(redisClient, args);
}
use of com.ctrip.xpipe.concurrent.AbstractExceptionLogTask in project x-pipe by ctripcorp.
the class BaseSampleMonitor method scanSamples.
@PostConstruct
public void scanSamples() {
daemonThread = XpipeThreadFactory.create("SampleMonitor-" + getClass().getSimpleName(), true).newThread(new Runnable() {
@Override
public void run() {
while (!Thread.currentThread().isInterrupted()) {
try {
doScan();
} catch (Exception e) {
log.error("Unexpected error when scan", e);
} finally {
try {
Thread.sleep(config.getRedisReplicationHealthCheckInterval());
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
break;
}
}
}
}
private void doScan() {
long start = System.currentTimeMillis();
int count = 0;
Iterator<Entry<Long, Sample<T>>> iter = samples.entrySet().iterator();
while (iter.hasNext()) {
count++;
Sample<T> sample = iter.next().getValue();
if (sample.isDone() || sample.isExpired()) {
try {
executors.execute(new AbstractExceptionLogTask() {
@Override
protected void doRun() throws Exception {
notifyCollectors(sample);
}
});
} catch (Exception e) {
log.error("Exception caught from notified collectors", e);
}
iter.remove();
}
}
long end = System.currentTimeMillis();
long cost = end - start;
if (cost > 10) {
log.info("[scan end][cost > 10 ms]count:{}, cost: {} ms", count, end - start);
}
}
});
daemonThread.start();
}
Aggregations