use of com.alibaba.otter.shared.common.model.config.parameter.SystemParameter in project otter by alibaba.
the class AlarmRuleAction method doOnekeyAddMonitor.
/**
* 一键添加监控
*/
public void doOnekeyAddMonitor(@Param("pipelineId") Long pipelineId, Navigator nav) throws Exception {
List<AlarmRule> existRules = alarmRuleService.getAlarmRules(pipelineId);
if (!existRules.isEmpty()) {
nav.redirectToLocation("alarmRuleList.htm?pipelineId=" + pipelineId);
return;
}
SystemParameter systemParameter = systemParameterService.find();
AlarmRule alarmRule = new AlarmRule();
alarmRule.setPipelineId(pipelineId);
alarmRule.setDescription("one key added!");
alarmRule.setAutoRecovery(Boolean.FALSE);
alarmRule.setReceiverKey(systemParameter.getDefaultAlarmReceiveKey());
alarmRule.setStatus(AlarmRuleStatus.DISABLE);
alarmRule.setRecoveryThresold(3);
alarmRule.setIntervalTime(1800L);
try {
alarmRule.setMonitorName(MonitorName.EXCEPTION);
alarmRule.setMatchValue("ERROR,EXCEPTION");
alarmRule.setIntervalTime(1800L);
alarmRule.setAutoRecovery(false);
alarmRule.setRecoveryThresold(2);
alarmRuleService.create(alarmRule);
alarmRule.setMonitorName(MonitorName.POSITIONTIMEOUT);
alarmRule.setMatchValue("600");
alarmRule.setIntervalTime(1800L);
alarmRule.setAutoRecovery(true);
alarmRule.setRecoveryThresold(0);
alarmRuleService.create(alarmRule);
alarmRule.setMonitorName(MonitorName.DELAYTIME);
alarmRule.setMatchValue("600");
alarmRule.setIntervalTime(1800L);
alarmRule.setAutoRecovery(false);
alarmRule.setRecoveryThresold(2);
alarmRuleService.create(alarmRule);
alarmRule.setMonitorName(MonitorName.PROCESSTIMEOUT);
alarmRule.setMatchValue("60");
alarmRule.setIntervalTime(1800L);
alarmRule.setAutoRecovery(true);
alarmRule.setRecoveryThresold(2);
alarmRuleService.create(alarmRule);
// alarmRule.setMonitorName(MonitorName.PIPELINETIMEOUT);
// alarmRule.setMatchValue("43200");
// alarmRuleService.create(alarmRule);
} catch (Exception e) {
return;
}
nav.redirectToLocation("alarmRuleList.htm?pipelineId=" + pipelineId);
}
use of com.alibaba.otter.shared.common.model.config.parameter.SystemParameter in project otter by alibaba.
the class ChannelServiceImpl method doToModel.
/**
* <pre>
* 用于DO对象转化为Model对象
* 现阶段优化:
* 需要五次SQL交互:pipeline\node\dataMediaPair\dataMedia\dataMediaSource(五个层面)
* 目前优化方案为单层只执行一次SQL,避免重复循环造成IO及数据库查询开销
* 长期优化:
* 对SQL进行改造,尽量减小SQL调用次数
* </pre>
*
* @param channelDO
* @return Channel
*/
private Channel doToModel(ChannelDO channelDo) {
Channel channel = new Channel();
try {
channel.setId(channelDo.getId());
channel.setName(channelDo.getName());
channel.setDescription(channelDo.getDescription());
channel.setStatus(arbitrateManageService.channelEvent().status(channelDo.getId()));
channel.setParameters(channelDo.getParameters());
channel.setGmtCreate(channelDo.getGmtCreate());
channel.setGmtModified(channelDo.getGmtModified());
List<Pipeline> pipelines = pipelineService.listByChannelIds(channelDo.getId());
// 合并PipelineParameter和ChannelParameter
SystemParameter systemParameter = systemParameterService.find();
for (Pipeline pipeline : pipelines) {
PipelineParameter parameter = new PipelineParameter();
parameter.merge(systemParameter);
parameter.merge(channel.getParameters());
// 最后复制pipelineId参数
parameter.merge(pipeline.getParameters());
pipeline.setParameters(parameter);
// pipeline.getParameters().merge(channel.getParameters());
}
channel.setPipelines(pipelines);
} catch (Exception e) {
logger.error("ERROR ## change the channel DO to Model has an exception");
throw new ManagerException(e);
}
return channel;
}
use of com.alibaba.otter.shared.common.model.config.parameter.SystemParameter in project otter by alibaba.
the class ChannelServiceImpl method doToModel.
/**
* <pre>
* 用于DO对象数组转化为Model对象数组
* 现阶段优化:
* 需要五次SQL交互:pipeline\node\dataMediaPair\dataMedia\dataMediaSource(五个层面)
* 目前优化方案为单层只执行一次SQL,避免重复循环造成IO及数据库查询开销
* 长期优化:
* 对SQL进行改造,尽量减小SQL调用次数
* </pre>
*
* @param channelDO
* @return Channel
*/
private List<Channel> doToModel(List<ChannelDO> channelDos) {
List<Channel> channels = new ArrayList<Channel>();
try {
// 1.将ChannelID单独拿出来
List<Long> channelIds = new ArrayList<Long>();
for (ChannelDO channelDo : channelDos) {
channelIds.add(channelDo.getId());
}
Long[] idArray = new Long[channelIds.size()];
// 拿到所有的Pipeline进行ChannelID过滤,避免重复查询。
List<Pipeline> pipelines = pipelineService.listByChannelIds(channelIds.toArray(idArray));
SystemParameter systemParameter = systemParameterService.find();
for (ChannelDO channelDo : channelDos) {
Channel channel = new Channel();
channel.setId(channelDo.getId());
channel.setName(channelDo.getName());
channel.setDescription(channelDo.getDescription());
ChannelStatus channelStatus = arbitrateManageService.channelEvent().status(channelDo.getId());
channel.setStatus(null == channelStatus ? ChannelStatus.STOP : channelStatus);
channel.setParameters(channelDo.getParameters());
channel.setGmtCreate(channelDo.getGmtCreate());
channel.setGmtModified(channelDo.getGmtModified());
// 遍历,将该Channel节点下的Pipeline提取出来。
List<Pipeline> subPipelines = new ArrayList<Pipeline>();
for (Pipeline pipeline : pipelines) {
if (pipeline.getChannelId().equals(channelDo.getId())) {
// 合并PipelineParameter和ChannelParameter
PipelineParameter parameter = new PipelineParameter();
parameter.merge(systemParameter);
parameter.merge(channel.getParameters());
// 最后复制pipelineId参数
parameter.merge(pipeline.getParameters());
pipeline.setParameters(parameter);
subPipelines.add(pipeline);
}
}
channel.setPipelines(subPipelines);
channels.add(channel);
}
} catch (Exception e) {
logger.error("ERROR ## change the channels DO to Model has an exception");
throw new ManagerException(e);
}
return channels;
}
use of com.alibaba.otter.shared.common.model.config.parameter.SystemParameter in project otter by alibaba.
the class DbLoadActionTest method test_db_load_mysql.
@Test
public void test_db_load_mysql() {
ArbitrateConfigRegistry.regist(configClientService);
dbLoadAction = (DbLoadAction) TestedObject.getSpringBeanFactory().getBean("dbLoadAction");
final Channel channel = new Channel();
channel.setId(1L);
final Pipeline pipeline = new Pipeline();
pipeline.setId(100L);
List<DataMediaPair> pairs = generatorDataMediaPairForMysql(20);
pipeline.setPairs(pairs);
pipeline.getParameters().merge(new SystemParameter());
pipeline.getParameters().merge(new ChannelParameter());
// pipeline.getParameters().setChannelInfo("LJH_DEMO");
// final Pipeline oppositePipeline = new Pipeline();
// oppositePipeline.setId(101L);
channel.setPipelines(Arrays.asList(pipeline));
final Node currentNode = new Node();
currentNode.setId(1L);
new NonStrictExpectations() {
{
configClientService.findChannel(anyLong);
returns(channel);
configClientService.findPipeline(anyLong);
returns(pipeline);
configClientService.currentNode();
returns(currentNode);
}
};
Identity identity = new Identity();
identity.setChannelId(100L);
identity.setPipelineId(100L);
identity.setProcessId(100L);
RowBatch rowBatch = new RowBatch();
rowBatch.setIdentity(identity);
List<EventData> eventDatas = generatorEventDataForMysql(0, 20, EventType.INSERT);
for (EventData eventData : eventDatas) {
rowBatch.merge(eventData);
}
eventDatas = generatorEventDataForMysql(10, 10, EventType.INSERT);
for (EventData eventData : eventDatas) {
rowBatch.merge(eventData);
}
eventDatas = generatorEventDataForMysql(19, 1, EventType.DELETE);
for (EventData eventData : eventDatas) {
rowBatch.merge(eventData);
}
WeightController controller = new WeightController(1);
dbLoadAction.load(rowBatch, controller);
}
use of com.alibaba.otter.shared.common.model.config.parameter.SystemParameter in project otter by alibaba.
the class SystemParameterAction method doEdit.
/**
* 修改系统参数
*/
public void doEdit(@FormGroup("systemParameterDetailInfo") Group systemParameterDetailInfo, Navigator nav) throws Exception {
SystemParameter systemParameter = new SystemParameter();
systemParameterDetailInfo.setProperties(systemParameter);
String defaultAlarmReceiver = systemParameterDetailInfo.getField("defaultAlarmReceiver").getStringValue();
String[] defaultAlarmReceiverStrs = StringUtils.split(defaultAlarmReceiver, "=");
if (defaultAlarmReceiverStrs.length != 2) {
throw new ManagerException("defaultAlarmReceiver[" + defaultAlarmReceiver + "] is not valid!");
}
systemParameter.setDefaultAlarmReceiveKey(defaultAlarmReceiverStrs[0]);
systemParameter.setDefaultAlarmReceiver(defaultAlarmReceiverStrs[1]);
String alarmReceiver = systemParameterDetailInfo.getField("alarmReceiver").getStringValue();
List<String> alarmReceivers = new ArrayList<String>();
String[] alarmReceiver1 = StringUtils.split(alarmReceiver, "\n");
for (String alarmReceiverStr : alarmReceiver1) {
String[] alarmReceiver2 = StringUtils.split(alarmReceiverStr, ";");
for (String alarmReceiverStr2 : alarmReceiver2) {
alarmReceivers.add(alarmReceiverStr2);
}
}
Map<String, String> alarmReceiverMap = new LinkedHashMap<String, String>();
for (String alarmReceiverStr : alarmReceivers) {
String[] alarmReceiverStrs = StringUtils.split(alarmReceiverStr, "=");
if (alarmReceiverStrs.length != 2) {
throw new ManagerException("alarmReceiver[" + alarmReceiver + "] is not valid!");
}
alarmReceiverMap.put(alarmReceiverStrs[0], alarmReceiverStrs[1]);
}
systemParameter.setAlarmReceiver(alarmReceiverMap);
systemParameterService.createOrUpdate(systemParameter);
nav.redirectToLocation("systemParameter.htm?edit=true");
}
Aggregations