use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException in project otter by alibaba.
the class DataMediaPairServiceImpl method listByIds.
/*-----------------------------------查询方法,整合-----------------------------------------*/
public List<DataMediaPair> listByIds(Long... identities) {
List<DataMediaPair> dataMediaPairs = new ArrayList<DataMediaPair>();
try {
List<DataMediaPairDO> dataMediaPairDos = null;
if (identities.length < 1) {
dataMediaPairDos = dataMediaPairDao.listAll();
if (dataMediaPairDos.isEmpty()) {
logger.debug("DEBUG ## couldn't query any dataMediaPair, maybe hasn't create any dataMediaPair.");
return dataMediaPairs;
}
} else {
dataMediaPairDos = dataMediaPairDao.listByMultiId(identities);
if (dataMediaPairDos.isEmpty()) {
String exceptionCause = "couldn't query any dataMediaPair by dataMediaPairIds:" + Arrays.toString(identities);
logger.error("ERROR ## " + exceptionCause);
throw new ManagerException(exceptionCause);
}
}
dataMediaPairs = doToModel(dataMediaPairDos);
} catch (Exception e) {
logger.error("ERROR ## query dataMediaPairs has an exception!", e);
throw new ManagerException(e);
}
return dataMediaPairs;
}
use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException in project otter by alibaba.
the class DataMediaPairServiceImpl method modelToDo.
/**
* 用于Model对象转化为DO对象
*
* @param dataMediaPair
* @return DataMediaPairDO
*/
private DataMediaPairDO modelToDo(DataMediaPair dataMediaPair) {
DataMediaPairDO dataMediaPairDo = new DataMediaPairDO();
try {
dataMediaPairDo.setId(dataMediaPair.getId());
dataMediaPairDo.setPipelineId(dataMediaPair.getPipelineId());
dataMediaPairDo.setSourceDataMediaId(dataMediaPair.getSource().getId());
dataMediaPairDo.setTargetDataMediaId(dataMediaPair.getTarget().getId());
dataMediaPairDo.setFilter(JsonUtils.marshalToString(dataMediaPair.getFilterData()));
dataMediaPairDo.setResolver(JsonUtils.marshalToString(dataMediaPair.getResolverData()));
dataMediaPairDo.setPullWeight(dataMediaPair.getPullWeight());
dataMediaPairDo.setPushWeight(dataMediaPair.getPushWeight());
dataMediaPairDo.setColumnPairMode(dataMediaPair.getColumnPairMode());
dataMediaPairDo.setGmtCreate(dataMediaPair.getGmtCreate());
dataMediaPairDo.setGmtModified(dataMediaPair.getGmtModified());
} catch (Exception e) {
logger.error("ERROR ## change the dataMediaPair Model to Do has an exception", e);
throw new ManagerException(e);
}
return dataMediaPairDo;
}
use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException in project otter by alibaba.
the class DataMediaPairServiceImpl method listByCondition.
@Override
public List<DataMediaPair> listByCondition(Map condition) {
List<DataMediaPair> dataMediaPairs = new ArrayList<DataMediaPair>();
try {
List<DataMediaPairDO> dataMediaPairDos = dataMediaPairDao.listByCondition(condition);
if (dataMediaPairDos.isEmpty()) {
logger.debug("DEBUG ## couldn't query any DataMediaPairs by the condition:" + JsonUtils.marshalToString(condition));
return dataMediaPairs;
}
dataMediaPairs = doToModel(dataMediaPairDos);
} catch (Exception e) {
logger.error("ERROR ## query dataMediaPairs by condition has an exception!", e);
throw new ManagerException(e);
}
return dataMediaPairs;
}
use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException in project otter by alibaba.
the class LogRecordServiceImpl method modelToDo.
/*----------------------DO <-> MODEL 组装方法--------------------------*/
/**
* <pre>
* 用于Model对象转化为DO对象
* 优化:
* 无SQL交互,只是简单进行字段组装,暂时无须优化
* </pre>
*
* @param channel
* @return ChannelDO
*/
private LogRecordDO modelToDo(LogRecord entityObj) {
LogRecordDO logRecordDo = new LogRecordDO();
try {
if (entityObj.getPipeline() != null && entityObj.getPipeline().getId() > 0) {
Channel channel = channelService.findByPipelineId(entityObj.getPipeline().getId());
logRecordDo.setChannelId(channel.getId());
logRecordDo.setPipelineId(entityObj.getPipeline().getId());
} else {
logRecordDo.setChannelId(-1l);
logRecordDo.setPipelineId(-1l);
}
logRecordDo.setNid(entityObj.getNid());
logRecordDo.setTitle(entityObj.getTitle());
String message = entityObj.getMessage();
if (message != null && message.length() > 65535 / 3) {
message = message.substring(0, 65535 / 3);
}
logRecordDo.setMessage(message);
logRecordDo.setGmtCreate(entityObj.getGmtCreate());
logRecordDo.setGmtModified(entityObj.getGmtModified());
} catch (Exception e) {
logger.error("ERROR ## has an error where write log to db");
throw new ManagerException(e);
}
return logRecordDo;
}
use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException in project otter by alibaba.
the class LogRecordServiceImpl method doToModel.
/**
* <pre>
* 用于DO对象转化为Model对象
* </pre>
*
* @param channelDO
* @return Channel
*/
private LogRecord doToModel(LogRecordDO logRecordDo) {
LogRecord logRecord = new LogRecord();
try {
logRecord.setId(logRecordDo.getId());
if (logRecordDo.getPipelineId() > 0 && logRecordDo.getChannelId() > 0) {
try {
Channel channel = channelService.findByPipelineId(logRecordDo.getPipelineId());
logRecord.setChannel(channel);
for (Pipeline pipeline : channel.getPipelines()) {
if (pipeline.getId().equals(logRecordDo.getPipelineId())) {
logRecord.setPipeline(pipeline);
}
}
} catch (Exception e) {
// 可能历史的log记录对应的channel/pipeline已经被删除了,直接忽略吧
Channel channel = new Channel();
channel.setId(0l);
logRecord.setChannel(channel);
Pipeline pipeline = new Pipeline();
pipeline.setId(0l);
logRecord.setPipeline(pipeline);
}
} else {
Channel channel = new Channel();
channel.setId(-1l);
logRecord.setChannel(channel);
Pipeline pipeline = new Pipeline();
pipeline.setId(-1l);
logRecord.setPipeline(pipeline);
}
logRecord.setTitle(logRecordDo.getTitle());
logRecord.setNid(logRecordDo.getNid());
logRecord.setMessage(logRecordDo.getMessage());
logRecord.setGmtCreate(logRecordDo.getGmtCreate());
logRecord.setGmtModified(logRecordDo.getGmtModified());
} catch (Exception e) {
logger.error("ERROR ## ");
throw new ManagerException(e);
}
return logRecord;
}
Aggregations