use of com.ctrip.xpipe.concurrent.AbstractExceptionLogTask in project x-pipe by ctripcorp.
the class MultiMetaServer method invoke.
@Override
public Object invoke(Object proxy, final Method method, final Object[] rawArgs) throws Throwable {
for (final MetaServer metaServer : otherServers) {
final Object[] args = copy(rawArgs);
executors.execute(new AbstractExceptionLogTask() {
@Override
protected void doRun() throws Exception {
method.invoke(metaServer, args);
}
});
}
final Object[] args = copy(rawArgs);
return method.invoke(dstServer, args);
}
use of com.ctrip.xpipe.concurrent.AbstractExceptionLogTask in project x-pipe by ctripcorp.
the class MigrationPartialSuccessState method doAction.
@Override
public void doAction() {
for (final MigrationShard shard : getHolder().getMigrationShards()) {
ShardMigrationResult shardMigrationResult = shard.getShardMigrationResult();
if (!shardMigrationResult.stepSuccess(ShardMigrationStep.MIGRATE_NEW_PRIMARY_DC)) {
shardMigrationResult.stepRetry(ShardMigrationStep.MIGRATE_NEW_PRIMARY_DC);
String clusterName = getHolder().clusterName();
String shardName = shard.shardName();
logger.info("[doAction][execute]{}, {}", clusterName, shardName);
executors.execute(new AbstractExceptionLogTask() {
@Override
public void doRun() {
logger.info("[doMigrate][start]{},{}", clusterName, shardName);
shard.doMigrate();
logger.info("[doMigrate][done]{},{}", clusterName, shardName);
}
});
}
}
}
use of com.ctrip.xpipe.concurrent.AbstractExceptionLogTask in project x-pipe by ctripcorp.
the class KeeperServiceImpl method postConstruct.
@PostConstruct
public void postConstruct() {
logger.info("[postConstruct]{}", this);
refreshIntervalMilli = consoleConfig.getCacheRefreshInterval();
scheduled.scheduleWithFixedDelay(new AbstractExceptionLogTask() {
@Override
protected void doRun() throws Exception {
keepers = metaCache.allKeepers();
}
}, refreshIntervalMilli, refreshIntervalMilli, TimeUnit.SECONDS);
}
use of com.ctrip.xpipe.concurrent.AbstractExceptionLogTask in project x-pipe by ctripcorp.
the class ByteArrayOutputStreamPayloadTest method testNewHeap.
@Test
public void testNewHeap() throws Exception {
final MemoryPrinter memoryPrinter = new MemoryPrinter(scheduled);
memoryPrinter.printMemory();
final int length = 1 << 10;
int concurrentCount = 10;
final CountDownLatch latch = new CountDownLatch(concurrentCount);
final ByteBuf byteBuf = directByteBuf(length);
byteBuf.writeBytes(randomString(length).getBytes());
byte[] dst = new byte[length];
byteBuf.readBytes(dst);
memoryPrinter.printMemory();
for (int i = 0; i < concurrentCount; i++) {
Thread current = new Thread(new AbstractExceptionLogTask() {
@Override
protected void doRun() throws Exception {
try {
byteBuf.readerIndex(0);
ByteArrayOutputStream baous = new ByteArrayOutputStream();
byteBuf.readBytes(baous, length);
} finally {
latch.countDown();
}
}
});
current.start();
memoryPrinter.printMemory();
}
latch.await();
}
use of com.ctrip.xpipe.concurrent.AbstractExceptionLogTask in project x-pipe by ctripcorp.
the class AbstractNettyRequestResponseCommand method doSendRequest.
@Override
protected void doSendRequest(final NettyClient nettyClient, ByteBuf byteBuf) {
if (logRequest()) {
logger.info("[doSendRequest]{}, {}", nettyClient, ByteBufUtils.readToString(byteBuf.slice()));
}
if (hasResponse()) {
nettyClient.sendRequest(byteBuf, this);
} else {
nettyClient.sendRequest(byteBuf);
// TODO sendfuture, make sure send success
future().setSuccess(null);
return;
}
if (getCommandTimeoutMilli() > 0 && scheduled != null) {
logger.debug("[doSendRequest][schedule timeout]{}, {}", this, getCommandTimeoutMilli());
final ScheduledFuture<?> timeoutFuture = scheduled.schedule(new AbstractExceptionLogTask() {
@Override
public void doRun() {
logger.info("[run][timeout]{}", nettyClient);
future().setFailure(new CommandTimeoutException("timeout " + +getCommandTimeoutMilli()));
}
}, getCommandTimeoutMilli(), TimeUnit.MILLISECONDS);
future().addListener(new CommandFutureListener<V>() {
@Override
public void operationComplete(CommandFuture<V> commandFuture) {
boolean cancel = true;
try {
commandFuture.get();
} catch (InterruptedException e) {
} catch (ExecutionException e) {
if (e.getCause() instanceof CommandTimeoutException) {
cancel = false;
}
}
if (cancel) {
logger.debug("[operationComplete][cancel timeout future]");
timeoutFuture.cancel(false);
}
}
});
}
}
Aggregations