use of com.alibaba.otter.shared.common.model.config.channel.ChannelParameter in project otter by alibaba.
the class ChannelAction method doEdit.
/**
* 修改Channel
*
* @param channelInfo
* @param channelParameterInfo
* @throws Exception
*/
public void doEdit(@FormGroup("channelInfo") Group channelInfo, @Param("pageIndex") int pageIndex, @Param("searchKey") String searchKey, @FormGroup("channelParameterInfo") Group channelParameterInfo, @FormField(name = "formChannelError", group = "channelInfo") CustomErrors err, Navigator nav) throws Exception {
Channel channel = new Channel();
ChannelParameter parameter = new ChannelParameter();
channelInfo.setProperties(channel);
channelParameterInfo.setProperties(parameter);
channel.setStatus(channelService.findById(channel.getId()).getStatus());
parameter.setChannelId(channel.getId());
channel.setParameters(parameter);
try {
channelService.modify(channel);
} catch (RepeatConfigureException rce) {
err.setMessage("invalidChannelName");
return;
}
nav.redirectToLocation("channelList.htm?pageIndex=" + pageIndex + "&searchKey=" + urlEncode(searchKey));
}
use of com.alibaba.otter.shared.common.model.config.channel.ChannelParameter 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.channel.ChannelParameter in project otter by alibaba.
the class ChannelAction method doAdd.
/**
* 添加Channel
*
* @param channelInfo
* @param channelParameterInfo
* @throws Exception
*/
public void doAdd(@FormGroup("channelInfo") Group channelInfo, @FormGroup("channelParameterInfo") Group channelParameterInfo, @FormField(name = "formChannelError", group = "channelInfo") CustomErrors err, Navigator nav) throws Exception {
Channel channel = new Channel();
ChannelParameter parameter = new ChannelParameter();
channelInfo.setProperties(channel);
channelParameterInfo.setProperties(parameter);
// 新建Channel默认关闭该状态
channel.setStatus(ChannelStatus.STOP);
channel.setParameters(parameter);
try {
channelService.create(channel);
} catch (RepeatConfigureException rce) {
err.setMessage("invalidChannelName");
return;
}
nav.redirectTo(WebConstant.CHANNEL_LIST_LINK);
}
use of com.alibaba.otter.shared.common.model.config.channel.ChannelParameter in project otter by alibaba.
the class DbLoadActionTest method test_db_load_oracle.
@Test
public void test_db_load_oracle() {
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 = generatorDataMediaPairForOracle(20);
pipeline.setPairs(pairs);
pipeline.getParameters().merge(new SystemParameter());
pipeline.getParameters().merge(new ChannelParameter());
// 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 = generatorEventDataForOracle(0, 20, EventType.INSERT);
for (EventData eventData : eventDatas) {
rowBatch.merge(eventData);
}
eventDatas = generatorEventDataForOracle(10, 10, EventType.INSERT);
for (EventData eventData : eventDatas) {
rowBatch.merge(eventData);
}
eventDatas = generatorEventDataForOracle(19, 1, EventType.DELETE);
for (EventData eventData : eventDatas) {
rowBatch.merge(eventData);
}
WeightController controller = new WeightController(1);
dbLoadAction.load(rowBatch, controller);
}
Aggregations