use of com.alibaba.otter.shared.common.model.config.data.DataMediaPair in project otter by alibaba.
the class FreedomExtractorTest method getDataMediaPairForMysql.
private List<DataMediaPair> getDataMediaPairForMysql(long tableId, int count) {
List<DataMediaPair> pairs = new ArrayList<DataMediaPair>();
for (int i = 0; i < count; i++) {
DataMediaPair pair = new DataMediaPair();
pair.setId(Long.valueOf(i));
pair.setPullWeight(1L);
pair.setPushWeight(1L);
DbDataMedia mysqlMedia = getMysqlMedia();
mysqlMedia.setId(tableId + i);
pair.setSource(mysqlMedia);
DbDataMedia oracleMedia = getOracleMedia();
oracleMedia.setId(tableId + i + count);
pair.setTarget(oracleMedia);
pairs.add(pair);
}
return pairs;
}
use of com.alibaba.otter.shared.common.model.config.data.DataMediaPair in project otter by alibaba.
the class FreedomExtractorTest method getDataMediaPairForOracle.
private List<DataMediaPair> getDataMediaPairForOracle(long tableId, int count) {
List<DataMediaPair> pairs = new ArrayList<DataMediaPair>();
for (int i = 0; i < count; i++) {
DataMediaPair pair = new DataMediaPair();
pair.setId(Long.valueOf(i));
pair.setPullWeight(1L);
pair.setPushWeight(1L);
DbDataMedia oracleMedia = getOracleMedia();
oracleMedia.setId(tableId + i);
pair.setSource(oracleMedia);
DbDataMedia mysqlMedia = getMysqlMedia();
mysqlMedia.setId(tableId + i + count);
pair.setTarget(mysqlMedia);
pairs.add(pair);
}
return pairs;
}
use of com.alibaba.otter.shared.common.model.config.data.DataMediaPair in project otter by alibaba.
the class DbLoadActionTest method generatorDataMediaPairForOracle.
private List<DataMediaPair> generatorDataMediaPairForOracle(int count) {
List<DataMediaPair> pairs = new ArrayList<DataMediaPair>();
for (int i = 0; i < count; i++) {
DataMediaPair pair = new DataMediaPair();
int index = i + 1;
pair.setId(Long.valueOf(index));
pair.setPullWeight(count - Long.valueOf(index));
pair.setPushWeight(count - Long.valueOf(index));
DbDataMedia mysqlMedia = getMysqlMedia();
mysqlMedia.setId(2L);
pair.setSource(mysqlMedia);
DbDataMedia oracleMedia = getOracleMedia();
oracleMedia.setId(1L);
pair.setTarget(oracleMedia);
pairs.add(pair);
}
return pairs;
}
use of com.alibaba.otter.shared.common.model.config.data.DataMediaPair 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.data.DataMediaPair in project otter by alibaba.
the class BehaviorHistoryCurve method execute.
public void execute(@Param("d5221") String startTime, @Param("d5222") String endTime, @Param("dataMediaPairId") Long dataMediaPairId, HttpSession session, Context context) throws Exception {
Date end = null;
Date start = null;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
if (StringUtils.isEmpty(startTime) || StringUtils.isEmpty(endTime)) {
start = new Date(System.currentTimeMillis() / 60000 * 60000 - 24 * 60 * 60 * 1000);
end = new Date(System.currentTimeMillis() / 60000 * 60000);
} else {
// 当前24小时,时间取整分钟
sdf.setLenient(false);
if (null != startTime && null != endTime) {
start = sdf.parse(startTime);
end = sdf.parse(endTime);
}
}
DataMediaPair dataMediaPair = dataMediaPairService.findById(dataMediaPairId);
Channel channel = channelService.findByPipelineId(dataMediaPair.getPipelineId());
Map<Long, BehaviorHistoryInfo> behaviourHistoryInfos = new LinkedHashMap<Long, BehaviorHistoryInfo>();
TimelineBehaviorHistoryCondition condition = new TimelineBehaviorHistoryCondition();
if (null != start && null != end) {
condition.setStart(start);
condition.setEnd(end);
condition.setPairId(dataMediaPairId);
behaviourHistoryInfos = tableStatService.listTimelineBehaviorHistory(condition);
}
Long totalInsert = 0L;
Long totalUpdate = 0L;
Long totalDelete = 0L;
Long totalFileCount = 0L;
Long totalFileSize = 0L;
for (BehaviorHistoryInfo info : behaviourHistoryInfos.values()) {
totalInsert += info.getInsertNumber();
totalUpdate += info.getUpdateNumber();
totalDelete += info.getDeleteNumber();
totalFileCount += info.getFileNumber();
totalFileSize += info.getFileSize();
}
context.put("totalInsert", totalInsert);
context.put("totalUpdate", totalUpdate);
context.put("totalDelete", totalDelete);
context.put("totalFileCount", totalFileCount);
context.put("totalFileSize", totalFileSize);
context.put("behaviourHistoryInfos", behaviourHistoryInfos);
context.put("start", sdf.format(start));
context.put("end", sdf.format(end));
context.put("dataMediaPair", dataMediaPair);
context.put("channel", channel);
}
Aggregations