Search in sources :

Example 16 with ServerException

use of com.ctrip.xpipe.redis.console.exception.ServerException in project x-pipe by ctripcorp.

the class DalTransactionAspect method invokeDalTransactionMethod.

@Around("dalTransaction()")
public Object invokeDalTransactionMethod(ProceedingJoinPoint joinPoint) {
    String datasource = config.getDatasource();
    if (null == datasource) {
        throw new ServerException("Cannot fetch datasource.");
    }
    logger.info("[invokeDalTransactionMethod] TransactionManager: {}", transactionManager.getClass());
    transactionManager.startTransaction(datasource);
    Object result;
    try {
        result = joinPoint.proceed();
        transactionManager.commitTransaction();
        return result;
    } catch (Throwable e) {
        transactionManager.rollbackTransaction();
        throw new ServerException(e.getMessage(), e);
    }
}
Also used : ServerException(com.ctrip.xpipe.redis.console.exception.ServerException) Around(org.aspectj.lang.annotation.Around)

Example 17 with ServerException

use of com.ctrip.xpipe.redis.console.exception.ServerException in project x-pipe by ctripcorp.

the class DalTransactionAspect method postConstruct.

@PostConstruct
private void postConstruct() {
    try {
        transactionManager = ContainerLoader.getDefaultContainer().lookup(TransactionManager.class, ROLE_HINT);
        logger.info("[postConstruct]Load TransactionManager: {}", transactionManager.getClass());
    } catch (ComponentLookupException e) {
        throw new ServerException("Cannot find transaction manager.", e);
    }
}
Also used : ServerException(com.ctrip.xpipe.redis.console.exception.ServerException) TransactionManager(org.unidal.dal.jdbc.transaction.TransactionManager) ComponentLookupException(org.codehaus.plexus.component.repository.exception.ComponentLookupException) PostConstruct(javax.annotation.PostConstruct)

Example 18 with ServerException

use of com.ctrip.xpipe.redis.console.exception.ServerException in project x-pipe by ctripcorp.

the class ShardDao method postConstruct.

@PostConstruct
private void postConstruct() {
    try {
        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);
    }
}
Also used : ServerException(com.ctrip.xpipe.redis.console.exception.ServerException) ComponentLookupException(org.codehaus.plexus.component.repository.exception.ComponentLookupException) PostConstruct(javax.annotation.PostConstruct)

Aggregations

ServerException (com.ctrip.xpipe.redis.console.exception.ServerException)18 PostConstruct (javax.annotation.PostConstruct)7 ComponentLookupException (org.codehaus.plexus.component.repository.exception.ComponentLookupException)7 DalException (org.unidal.dal.jdbc.DalException)7 DataNotFoundException (com.ctrip.xpipe.redis.console.exception.DataNotFoundException)4 BadRequestException (com.ctrip.xpipe.redis.console.exception.BadRequestException)3 List (java.util.List)3 LinkedList (java.util.LinkedList)2 XpipeRuntimeException (com.ctrip.xpipe.exception.XpipeRuntimeException)1 DalTransaction (com.ctrip.xpipe.redis.console.annotation.DalTransaction)1 ClusterEvent (com.ctrip.xpipe.redis.console.notifier.cluster.ClusterEvent)1 ShardEvent (com.ctrip.xpipe.redis.console.notifier.shard.ShardEvent)1 DcMetaQueryVO (com.ctrip.xpipe.redis.console.service.vo.DcMetaQueryVO)1 ClusterMeta (com.ctrip.xpipe.redis.core.entity.ClusterMeta)1 DcMeta (com.ctrip.xpipe.redis.core.entity.DcMeta)1 ShardMeta (com.ctrip.xpipe.redis.core.entity.ShardMeta)1 ParameterizedType (java.lang.reflect.ParameterizedType)1 Type (java.lang.reflect.Type)1 HashMap (java.util.HashMap)1 TimeoutException (java.util.concurrent.TimeoutException)1