use of com.ctrip.xpipe.concurrent.AbstractExceptionLogTask in project x-pipe by ctripcorp.
the class MigrationPartialSuccessRollBackState method doAction.
@Override
public void doAction() {
CountDownLatch latch = new CountDownLatch(getHolder().getMigrationShards().size());
StringBuilder errorMessage = new StringBuilder();
for (MigrationShard migrationShard : getHolder().getMigrationShards()) {
executors.execute(new AbstractExceptionLogTask() {
@Override
protected void doRun() throws Exception {
try {
migrationShard.doRollBack();
} catch (Exception e) {
logger.error("[run]" + migrationShard, e);
errorMessage.append(LogUtils.error(String.format("%s", migrationShard, e.toString())));
} finally {
latch.countDown();
}
}
});
}
try {
latch.await(migrationWaitTimeMilli, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
logger.error("[MigrationRollBackStat][await][shard][doRollBack][fail]", e);
errorMessage.append(LogUtils.error(String.format("[wait time exceed]%s ms", migrationWaitTimeMilli)));
}
String error = errorMessage.toString();
if (StringUtil.isEmpty(error)) {
updateAndProcess(nextAfterSuccess());
} else {
updateAndStop(nextAfterFail());
}
}
use of com.ctrip.xpipe.concurrent.AbstractExceptionLogTask in project x-pipe by ctripcorp.
the class MuchRedisData method sendDataToMaster.
private void sendDataToMaster() {
final CountDownLatch latch = new CountDownLatch(concurrentCount);
logger.info("[sendDataToMaster][begin]{}, {}", messageCount, messageSize);
for (int i = 0; i < concurrentCount; i++) {
executors.execute(new AbstractExceptionLogTask() {
@Override
protected void doRun() throws Exception {
try {
sendMessage(getRedisMaster(), messageCount / concurrentCount, randomString(messageSize));
} finally {
latch.countDown();
}
}
});
}
try {
latch.await();
logger.info("[sendDataToMaster][ end ]{}, {}", messageCount, messageSize);
} catch (InterruptedException e) {
logger.error("[sendDataToMaster]", e);
}
}
use of com.ctrip.xpipe.concurrent.AbstractExceptionLogTask in project x-pipe by ctripcorp.
the class OneDcKeepers method testKeeperChangeState.
@Test
public void testKeeperChangeState() throws Exception {
int round = 1000;
scheduled.scheduleAtFixedRate(new AbstractExceptionLogTask() {
@Override
protected void doRun() throws Exception {
sendMessageToMaster(getRedisMaster(), 100);
}
}, 0, 500, TimeUnit.SECONDS.MILLISECONDS);
RedisMeta redisMaster = getRedisMaster();
KeeperMeta currentActive = activeKeeper;
KeeperMeta currentBackup = backupKeeper;
for (int i = 0; i < round; i++) {
logger.info(remarkableMessage("round: {}"), i);
setKeeperState(currentBackup, KeeperState.ACTIVE, redisMaster.getIp(), redisMaster.getPort());
setKeeperState(currentActive, KeeperState.BACKUP, currentBackup.getIp(), currentBackup.getPort());
sleep(1000);
KeeperMeta tmp = currentActive;
currentActive = currentBackup;
currentBackup = tmp;
}
waitForAnyKey();
}
use of com.ctrip.xpipe.concurrent.AbstractExceptionLogTask in project x-pipe by ctripcorp.
the class RedisTest method testIncr.
@Test
public void testIncr() throws IOException {
Jedis jedis = createJedis("localhost", 6379);
scheduled.scheduleAtFixedRate(new AbstractExceptionLogTask() {
@Override
protected void doRun() throws Exception {
jedis.incr("incr");
}
}, 0, 100, TimeUnit.MILLISECONDS);
waitForAnyKeyToExit();
}
use of com.ctrip.xpipe.concurrent.AbstractExceptionLogTask in project x-pipe by ctripcorp.
the class DefaultMetaCache method postConstruct.
@PostConstruct
public void postConstruct() {
logger.info("[postConstruct]{}", this);
refreshIntervalMilli = consoleConfig.getCacheRefreshInterval();
scheduled.scheduleWithFixedDelay(new AbstractExceptionLogTask() {
@Override
protected void doRun() throws Exception {
loadCache();
}
}, 1000, refreshIntervalMilli, TimeUnit.MILLISECONDS);
}
Aggregations