use of com.ctrip.xpipe.redis.console.exception.ServerException in project x-pipe by ctripcorp.
the class AbstractConsoleService method postConstruct.
@SuppressWarnings("unchecked")
@PostConstruct
private void postConstruct() {
try {
logger.info("[postConstruct]{}", getClass().getSimpleName());
Type superClass = getClass().getGenericSuperclass();
if (superClass instanceof Class<?>) {
// sanity check, should never happen
throw new IllegalArgumentException("Internal error: TypeReference constructed without actual type information");
}
Type type = ((ParameterizedType) superClass).getActualTypeArguments()[0];
Class clazz = Class.forName(parseTypeName(type.toString()));
dao = (T) ContainerLoader.getDefaultContainer().lookup(clazz);
} catch (ComponentLookupException e) {
throw new ServerException("Dao construct failed.", e);
} catch (ClassNotFoundException e) {
throw new ServerException("Dao construct failed due to class not found.", e);
}
}
use of com.ctrip.xpipe.redis.console.exception.ServerException in project x-pipe by ctripcorp.
the class ClusterDao method postConstruct.
@PostConstruct
private void postConstruct() {
try {
dcTblDao = ContainerLoader.getDefaultContainer().lookup(DcTblDao.class);
clusterTblDao = ContainerLoader.getDefaultContainer().lookup(ClusterTblDao.class);
dcClusterTblDao = ContainerLoader.getDefaultContainer().lookup(DcClusterTblDao.class);
shardTblDao = ContainerLoader.getDefaultContainer().lookup(ShardTblDao.class);
dcClusterShardTblDao = ContainerLoader.getDefaultContainer().lookup(DcClusterShardTblDao.class);
} catch (ComponentLookupException e) {
throw new ServerException("Cannot construct dao.", e);
}
}
use of com.ctrip.xpipe.redis.console.exception.ServerException in project x-pipe by ctripcorp.
the class DcClusterDao method postConstruct.
@PostConstruct
private void postConstruct() {
try {
dcClusterTblDao = ContainerLoader.getDefaultContainer().lookup(DcClusterTblDao.class);
dcClusterShardTblDao = ContainerLoader.getDefaultContainer().lookup(DcClusterShardTblDao.class);
} catch (ComponentLookupException e) {
throw new ServerException("Cannot construct dao.", e);
}
}
use of com.ctrip.xpipe.redis.console.exception.ServerException in project x-pipe by ctripcorp.
the class RedisDao method generateUniqueKeeperId.
private String generateUniqueKeeperId(final RedisTbl redis) {
final String runId = idGenerator.generateRunid();
// check for unique runId
DcClusterShardTbl targetDcClusterShard = queryHandler.handleQuery(new DalQuery<DcClusterShardTbl>() {
@Override
public DcClusterShardTbl doQuery() throws DalException {
return dcClusterShardTblDao.findByPK(redis.getDcClusterShardId(), DcClusterShardTblEntity.READSET_FULL);
}
});
if (null == targetDcClusterShard)
throw new BadRequestException("Cannot find related dc-cluster-shard");
List<RedisTbl> redisWithSameRunId = queryHandler.handleQuery(new DalQuery<List<RedisTbl>>() {
@Override
public List<RedisTbl> doQuery() throws DalException {
return redisTblDao.findByRunid(runId, RedisTblEntity.READSET_FULL);
}
});
if (null != redisWithSameRunId && redisWithSameRunId.size() > 0) {
for (final RedisTbl tmpRedis : redisWithSameRunId) {
DcClusterShardTbl tmpDcClusterShard = queryHandler.handleQuery(new DalQuery<DcClusterShardTbl>() {
@Override
public DcClusterShardTbl doQuery() throws DalException {
return dcClusterShardTblDao.findByPK(tmpRedis.getDcClusterShardId(), DcClusterShardTblEntity.READSET_FULL);
}
});
if (null != tmpDcClusterShard && targetDcClusterShard.getShardId() == tmpDcClusterShard.getShardId()) {
throw new ServerException("Cannot generate unque keeper id, please retry.");
}
}
}
return runId;
}
use of com.ctrip.xpipe.redis.console.exception.ServerException in project x-pipe by ctripcorp.
the class RedisDao method postConstruct.
@PostConstruct
private void postConstruct() {
try {
redisTblDao = ContainerLoader.getDefaultContainer().lookup(RedisTblDao.class);
dcClusterShardTblDao = ContainerLoader.getDefaultContainer().lookup(DcClusterShardTblDao.class);
} catch (ComponentLookupException e) {
throw new ServerException("Cannot construct dao.", e);
}
}
Aggregations