use of com.ctrip.xpipe.concurrent.AbstractExceptionLogTask in project x-pipe by ctripcorp.
the class AbstractIntervalCheck method checkStart.
protected void checkStart() {
if (clusterServer != null && !clusterServer.amILeader()) {
logger.debug("[generatePlan][not leader quit]");
return;
}
long current = System.currentTimeMillis();
if (current - lastStartTime < getIntervalMilli()) {
logger.debug("[generatePlan][too quick {}, quit]", current - lastStartTime);
return;
}
lastStartTime = current;
executors.execute(new AbstractExceptionLogTask() {
@Override
protected void doRun() throws Exception {
doCheck();
}
});
}
use of com.ctrip.xpipe.concurrent.AbstractExceptionLogTask in project x-pipe by ctripcorp.
the class ControllableFileAbstractTest method testSizeAndFileLength.
@Test
public void testSizeAndFileLength() throws IOException {
RandomAccessFile randomAccessFile = new RandomAccessFile(file, "rw");
FileChannel channel = randomAccessFile.getChannel();
byte[] data = randomString(randomInt(0, 1000)).getBytes();
scheduled.scheduleAtFixedRate(new AbstractExceptionLogTask() {
@Override
protected void doRun() throws Exception {
channel.write(ByteBuffer.wrap(data));
}
}, 0, 1, TimeUnit.MILLISECONDS);
int testCount = 1 << 15;
long begin = System.currentTimeMillis();
Long size = 0L;
for (int i = 0; i < testCount; i++) {
// size = channel.size();
size = file.length();
}
long end = System.currentTimeMillis();
logger.info("each {} ns", (end - begin) * 1000000 / testCount);
logger.info("{}", size);
}
use of com.ctrip.xpipe.concurrent.AbstractExceptionLogTask in project x-pipe by ctripcorp.
the class DefaultRedisSessionManagerTest method testPubSub.
@Test
public void testPubSub() {
RedisSession redisSession = redisSessionManager.findOrCreateSession(host, port);
for (int i = 0; i < channels; i++) {
redisSession.subscribeIfAbsent(channelName(channel, i), new RedisSession.SubscribeCallback() {
@Override
public void message(String channel, String message) {
logger.info("[message]{}, {}", channel, message);
}
@Override
public void fail(Throwable e) {
logger.error("[fail]", e);
}
});
}
sleep(subscribeTimeoutSeconds * 2 * 1000);
scheduled.scheduleAtFixedRate(new AbstractExceptionLogTask() {
@Override
public void doRun() {
for (int i = 0; i < channels; i++) {
redisSession.publish(channelName(channel, i), randomString(10));
}
}
}, 0, 5, TimeUnit.SECONDS);
}
use of com.ctrip.xpipe.concurrent.AbstractExceptionLogTask in project x-pipe by ctripcorp.
the class MigrationCheckingState method doShardCheck.
private void doShardCheck(MigrationCluster migrationCluster) {
List<MigrationShard> migrationShards = migrationCluster.getMigrationShards();
for (final MigrationShard migrationShard : migrationShards) {
migrationShard.retry(ShardMigrationStep.CHECK);
executors.execute(new AbstractExceptionLogTask() {
@Override
public void doRun() {
migrationShard.doCheck();
}
});
}
}
use of com.ctrip.xpipe.concurrent.AbstractExceptionLogTask in project x-pipe by ctripcorp.
the class MigrationForcePublishState method doAction.
@Override
public void doAction() {
CountDownLatch latch = new CountDownLatch(getHolder().getMigrationShards().size());
for (MigrationShard migrationShard : getHolder().getMigrationShards()) {
executors.execute(new AbstractExceptionLogTask() {
@Override
public void doRun() {
try {
logger.info("[doOtherDcMigrate][start]{},{}", getHolder().clusterName(), migrationShard.getCurrentShard().getShardName());
migrationShard.doMigrateOtherDc();
logger.info("[doOtherDcMigrate][done]{},{}", getHolder().clusterName(), migrationShard.getCurrentShard().getShardName());
} finally {
latch.countDown();
}
}
});
}
try {
latch.await();
updateAndProcess(nextAfterSuccess());
} catch (InterruptedException e) {
logger.error("[MigrationForcePublishState][tryAction][Interrupted][will retry]", e);
updateAndProcess(nextAfterFail());
}
}
Aggregations