Search in sources :

Example 6 with DalTransaction

use of com.ctrip.xpipe.redis.console.annotation.DalTransaction in project x-pipe by ctripcorp.

the class ShardDao method deleteShardsBatch.

@DalTransaction
public void deleteShardsBatch(final ShardTbl shard) throws DalException {
    if (null == shard)
        throw new DalException("Null cannot be deleted.");
    List<DcClusterShardTbl> relatedDcClusterShards = queryHandler.handleQuery(new DalQuery<List<DcClusterShardTbl>>() {

        @Override
        public List<DcClusterShardTbl> doQuery() throws DalException {
            return dcClusterShardTblDao.findAllByShardId(shard.getId(), DcClusterShardTblEntity.READSET_FULL);
        }
    });
    if (null != relatedDcClusterShards) {
        dcClusterShardDao.deleteDcClusterShardsBatch(relatedDcClusterShards);
    }
    ShardTbl proto = shard;
    proto.setShardName(generateDeletedName(shard.getShardName()));
    queryHandler.handleDelete(new DalQuery<Integer>() {

        @Override
        public Integer doQuery() throws DalException {
            return shardTblDao.deleteShard(proto, ShardTblEntity.UPDATESET_FULL);
        }
    }, true);
}
Also used : DalException(org.unidal.dal.jdbc.DalException) List(java.util.List) LinkedList(java.util.LinkedList) DalTransaction(com.ctrip.xpipe.redis.console.annotation.DalTransaction)

Aggregations

DalTransaction (com.ctrip.xpipe.redis.console.annotation.DalTransaction)6 DalException (org.unidal.dal.jdbc.DalException)5 LinkedList (java.util.LinkedList)3 List (java.util.List)2 XpipeRuntimeException (com.ctrip.xpipe.exception.XpipeRuntimeException)1 BadRequestException (com.ctrip.xpipe.redis.console.exception.BadRequestException)1 ServerException (com.ctrip.xpipe.redis.console.exception.ServerException)1 DcClusterShardTbl (com.ctrip.xpipe.redis.console.model.DcClusterShardTbl)1 RedisTbl (com.ctrip.xpipe.redis.console.model.RedisTbl)1 VisibleForTesting (com.ctrip.xpipe.utils.VisibleForTesting)1 Date (java.util.Date)1 TimeoutException (java.util.concurrent.TimeoutException)1