Search in sources :

Example 6 with DbDataMedia

use of com.alibaba.otter.shared.common.model.config.data.db.DbDataMedia 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;
}
Also used : DataMediaPair(com.alibaba.otter.shared.common.model.config.data.DataMediaPair) ArrayList(java.util.ArrayList) DbDataMedia(com.alibaba.otter.shared.common.model.config.data.db.DbDataMedia)

Example 7 with DbDataMedia

use of com.alibaba.otter.shared.common.model.config.data.db.DbDataMedia 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;
}
Also used : DataMediaPair(com.alibaba.otter.shared.common.model.config.data.DataMediaPair) ArrayList(java.util.ArrayList) DbDataMedia(com.alibaba.otter.shared.common.model.config.data.db.DbDataMedia)

Example 8 with DbDataMedia

use of com.alibaba.otter.shared.common.model.config.data.db.DbDataMedia in project otter by alibaba.

the class BaseDbTest method getMysqlMedia.

public DbDataMedia getMysqlMedia() {
    DbMediaSource dbMediaSource = new DbMediaSource();
    dbMediaSource.setId(10L);
    dbMediaSource.setDriver("com.mysql.jdbc.Driver");
    dbMediaSource.setUsername("xxxxx");
    dbMediaSource.setPassword("xxxxx");
    dbMediaSource.setUrl("jdbc:mysql://127.0.0.1:3306/srf");
    dbMediaSource.setEncode("UTF-8");
    dbMediaSource.setType(DataMediaType.MYSQL);
    DbDataMedia dataMedia = new DbDataMedia();
    dataMedia.setSource(dbMediaSource);
    dataMedia.setId(1L);
    dataMedia.setName("columns");
    dataMedia.setNamespace("srf");
    return dataMedia;
}
Also used : DbMediaSource(com.alibaba.otter.shared.common.model.config.data.db.DbMediaSource) DbDataMedia(com.alibaba.otter.shared.common.model.config.data.db.DbDataMedia)

Example 9 with DbDataMedia

use of com.alibaba.otter.shared.common.model.config.data.db.DbDataMedia in project otter by alibaba.

the class BaseDbTest method getOracleMedia.

public DbDataMedia getOracleMedia() {
    DbMediaSource dbMediaSource = new DbMediaSource();
    dbMediaSource.setId(11L);
    dbMediaSource.setDriver("oracle.jdbc.OracleDriver");
    dbMediaSource.setUsername("xxxxx");
    dbMediaSource.setPassword("xxxxx");
    dbMediaSource.setUrl("jdbc:oracle:thin:@127.0.0.1:1521:crmgsb");
    dbMediaSource.setEncode("UTF-8");
    dbMediaSource.setType(DataMediaType.ORACLE);
    DbDataMedia dataMedia = new DbDataMedia();
    dataMedia.setSource(dbMediaSource);
    dataMedia.setId(2L);
    dataMedia.setName("columns");
    dataMedia.setNamespace("srf");
    return dataMedia;
}
Also used : DbMediaSource(com.alibaba.otter.shared.common.model.config.data.db.DbMediaSource) DbDataMedia(com.alibaba.otter.shared.common.model.config.data.db.DbDataMedia)

Example 10 with DbDataMedia

use of com.alibaba.otter.shared.common.model.config.data.db.DbDataMedia in project otter by alibaba.

the class DbDialectTableTest method testOracleTable.

@Test
public void testOracleTable() {
    DbDataMedia oracleMedia = getOracleMedia();
    DbDialect dbDialect = dbDialectFactory.getDbDialect(1L, oracleMedia.getSource());
    Table table = dbDialect.findTable(oracleMedia.getNamespace(), oracleMedia.getName());
    want.object(table).notNull();
    System.out.println("tableName = " + table.getName());
    Column[] columns = table.getColumns();
    for (Column column : columns) {
        System.out.println("columnName = " + column.getName() + ",columnType = " + column.getTypeCode() + ",isPrimary = " + column.isPrimaryKey() + ",nullable = " + column.isRequired());
    }
}
Also used : Table(org.apache.ddlutils.model.Table) Column(org.apache.ddlutils.model.Column) DbDialect(com.alibaba.otter.node.etl.common.db.dialect.DbDialect) DbDataMedia(com.alibaba.otter.shared.common.model.config.data.db.DbDataMedia) Test(org.testng.annotations.Test) BaseDbTest(com.alibaba.otter.node.etl.BaseDbTest)

Aggregations

DbDataMedia (com.alibaba.otter.shared.common.model.config.data.db.DbDataMedia)17 DataMediaPair (com.alibaba.otter.shared.common.model.config.data.DataMediaPair)10 ArrayList (java.util.ArrayList)10 BaseDbTest (com.alibaba.otter.node.etl.BaseDbTest)8 Test (org.testng.annotations.Test)8 DbDialect (com.alibaba.otter.node.etl.common.db.dialect.DbDialect)5 DbMediaSource (com.alibaba.otter.shared.common.model.config.data.db.DbMediaSource)3 Pipeline (com.alibaba.otter.shared.common.model.config.pipeline.Pipeline)3 BatchObject (com.alibaba.otter.shared.etl.model.BatchObject)3 Identity (com.alibaba.otter.shared.etl.model.Identity)3 PreparedStatement (java.sql.PreparedStatement)3 JdbcTemplate (org.springframework.jdbc.core.JdbcTemplate)3 TransactionStatus (org.springframework.transaction.TransactionStatus)3 TransactionCallback (org.springframework.transaction.support.TransactionCallback)3 TransactionTemplate (org.springframework.transaction.support.TransactionTemplate)3 SqlTemplate (com.alibaba.otter.node.etl.common.db.dialect.SqlTemplate)2 PipelineParameter (com.alibaba.otter.shared.common.model.config.pipeline.PipelineParameter)2 EventData (com.alibaba.otter.shared.etl.model.EventData)2 RowBatch (com.alibaba.otter.shared.etl.model.RowBatch)2 Column (org.apache.ddlutils.model.Column)2