use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException in project otter by alibaba.
the class DataMediaServiceImpl method listByIds.
@Override
public List<DataMedia> listByIds(Long... identities) {
List<DataMedia> dataMedias = new ArrayList<DataMedia>();
try {
List<DataMediaDO> dataMediaDos = null;
if (identities.length < 1) {
dataMediaDos = dataMediaDao.listAll();
if (dataMediaDos.isEmpty()) {
logger.debug("DEBUG ## couldn't query any dataMedia, maybe hasn't create any dataMedia.");
return dataMedias;
}
} else {
dataMediaDos = dataMediaDao.listByMultiId(identities);
if (dataMediaDos.isEmpty()) {
String exceptionCause = "couldn't query any dataMedia by dataMediaIds:" + Arrays.toString(identities);
logger.error("ERROR ## " + exceptionCause);
throw new ManagerException(exceptionCause);
}
}
dataMedias = doToModel(dataMediaDos);
} catch (Exception e) {
logger.error("ERROR ## query dataMedias has an exception!");
throw new ManagerException(e);
}
return dataMedias;
}
use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException in project otter by alibaba.
the class DataMediaServiceImpl method create.
/**
* 添加
*/
@Override
public void create(DataMedia dataMedia) {
Assert.assertNotNull(dataMedia);
try {
DataMediaDO dataMediaDo = modelToDo(dataMedia);
dataMediaDo.setId(0L);
if (!dataMediaDao.checkUnique(dataMediaDo)) {
String exceptionCause = "exist the same name dataMedia in the database.";
logger.warn("WARN ## " + exceptionCause);
throw new RepeatConfigureException(exceptionCause);
}
dataMediaDao.insert(dataMediaDo);
} catch (RepeatConfigureException rce) {
throw rce;
} catch (Exception e) {
logger.error("ERROR ## create dataMedia has an exception!");
throw new ManagerException(e);
}
}
use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException in project otter by alibaba.
the class DataMediaServiceImpl method modelToDo.
/**
* 用于Model对象转化为DO对象
*
* @param dataMedia
* @return DataMediaDO
*/
private DataMediaDO modelToDo(DataMedia dataMedia) {
DataMediaDO dataMediaDo = new DataMediaDO();
try {
dataMediaDo.setId(dataMedia.getId());
dataMediaDo.setName(dataMedia.getName());
dataMediaDo.setNamespace(dataMedia.getNamespace());
dataMediaDo.setDataMediaSourceId(dataMedia.getSource().getId());
// if (dataMedia instanceof DbDataMedia) {
// dataMediaDo.setProperties(JsonUtils.marshalToString((DbDataMedia) dataMedia));
// }
dataMediaDo.setProperties(JsonUtils.marshalToString(dataMedia));
dataMediaDo.setGmtCreate(dataMedia.getGmtCreate());
dataMediaDo.setGmtModified(dataMedia.getGmtModified());
} catch (Exception e) {
logger.error("ERROR ## change the dataMedia Model to Do has an exception");
throw new ManagerException(e);
}
return dataMediaDo;
}
use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException in project otter by alibaba.
the class NodeServiceImpl method create.
/**
* 添加
*/
public void create(final Node node) {
Assert.assertNotNull(node);
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
protected void doInTransactionWithoutResult(TransactionStatus status) {
try {
NodeDO nodeDo = modelToDo(node);
nodeDo.setId(0L);
if (!nodeDao.checkUnique(nodeDo)) {
String exceptionCause = "exist the same repeat node in the database.";
logger.warn("WARN ## " + exceptionCause);
throw new RepeatConfigureException(exceptionCause);
}
nodeDao.insert(nodeDo);
} catch (RepeatConfigureException rce) {
throw rce;
} catch (Exception e) {
logger.error("ERROR ## create node has an exception!");
throw new ManagerException(e);
}
}
});
}
use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException in project otter by alibaba.
the class NodeServiceImpl method listByIds.
public List<Node> listByIds(Long... identities) {
List<Node> nodes = new ArrayList<Node>();
try {
List<NodeDO> nodeDos = null;
if (identities.length < 1) {
nodeDos = nodeDao.listAll();
if (nodeDos.isEmpty()) {
logger.debug("DEBUG ## couldn't query any node, maybe hasn't create any channel.");
return nodes;
}
} else {
nodeDos = nodeDao.listByMultiId(identities);
if (nodeDos.isEmpty()) {
String exceptionCause = "couldn't query any node by nodeIds:" + Arrays.toString(identities);
logger.error("ERROR ## " + exceptionCause);
throw new ManagerException(exceptionCause);
}
}
// 验证zk的node信息
List<Long> nodeIds = arbitrateManageService.nodeEvent().liveNodes();
for (NodeDO nodeDo : nodeDos) {
if (nodeIds.contains(nodeDo.getId())) {
nodeDo.setStatus(NodeStatus.START);
} else {
nodeDo.setStatus(NodeStatus.STOP);
}
}
nodes = doToModel(nodeDos);
} catch (Exception e) {
logger.error("ERROR ## query nodes has an exception!");
throw new ManagerException(e);
}
return nodes;
}
Aggregations