Search in sources :

Example 1 with NodeParameter

use of com.alibaba.otter.shared.common.model.config.node.NodeParameter in project otter by alibaba.

the class NodeServiceImpl method doToModel.

/**
 * 用于DO对象转化为Model对象
 *
 * @param nodeDo
 * @return Node
 */
private Node doToModel(NodeDO nodeDo) {
    Node node = new Node();
    try {
        node.setId(nodeDo.getId());
        node.setIp(nodeDo.getIp());
        node.setName(nodeDo.getName());
        node.setPort(nodeDo.getPort());
        node.setDescription(nodeDo.getDescription());
        node.setStatus(nodeDo.getStatus());
        // 处理下zk集群
        NodeParameter parameter = nodeDo.getParameters();
        if (parameter.getZkCluster() != null) {
            AutoKeeperCluster zkCluster = autoKeeperClusterService.findAutoKeeperClusterById(parameter.getZkCluster().getId());
            parameter.setZkCluster(zkCluster);
        }
        node.setParameters(parameter);
        node.setGmtCreate(nodeDo.getGmtCreate());
        node.setGmtModified(nodeDo.getGmtModified());
    } catch (Exception e) {
        logger.error("ERROR ## change the node Do to Model has an exception");
        throw new ManagerException(e);
    }
    return node;
}
Also used : NodeParameter(com.alibaba.otter.shared.common.model.config.node.NodeParameter) Node(com.alibaba.otter.shared.common.model.config.node.Node) AutoKeeperCluster(com.alibaba.otter.shared.common.model.autokeeper.AutoKeeperCluster) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException)

Example 2 with NodeParameter

use of com.alibaba.otter.shared.common.model.config.node.NodeParameter in project otter by alibaba.

the class HttpPipeIntegration method test_attachment.

@Test
public void test_attachment() {
    final Node currentNode = new Node();
    currentNode.setId(1L);
    currentNode.setIp("127.0.0.1");
    currentNode.setParameters(new NodeParameter());
    final Pipeline pipeline = new Pipeline();
    pipeline.getParameters().setRetriever(RetrieverType.ARIA2C);
    // mock一下
    new NonStrictExpectations() {

        {
            configClientService.currentNode();
            returns(currentNode);
            configClientService.findPipeline(anyLong);
            returns(pipeline);
        }
    };
    Identity identity = new Identity();
    identity.setChannelId(100L);
    identity.setPipelineId(100L);
    identity.setProcessId(100L);
    FileBatch fileBatch = new FileBatch();
    fileBatch.setIdentity(identity);
    File localFile = new File(tmp, "httpPipeTest.jpg");
    FileData localFileData = new FileData();
    localFileData.setEventType(EventType.INSERT);
    localFileData.setPath(localFile.getPath());
    fileBatch.getFiles().add(localFileData);
    try {
        byte[] data = getBlock(10 * 1024);
        NioUtils.write(data, localFile);
        HttpPipeKey key = attachmentHttpPipe.put(fileBatch);
        File target = attachmentHttpPipe.get(key);
        byte[] getbytes = NioUtils.read(new File(target, localFile.getPath()));
        check(data, getbytes);
    } catch (IOException e) {
        want.fail();
    } finally {
        NioUtils.delete(localFile);
    }
}
Also used : HttpPipeKey(com.alibaba.otter.node.etl.common.pipe.impl.http.HttpPipeKey) FileBatch(com.alibaba.otter.shared.etl.model.FileBatch) NodeParameter(com.alibaba.otter.shared.common.model.config.node.NodeParameter) Node(com.alibaba.otter.shared.common.model.config.node.Node) IOException(java.io.IOException) Identity(com.alibaba.otter.shared.etl.model.Identity) File(java.io.File) FileData(com.alibaba.otter.shared.etl.model.FileData) Pipeline(com.alibaba.otter.shared.common.model.config.pipeline.Pipeline) Test(org.testng.annotations.Test) BaseOtterTest(com.alibaba.otter.node.etl.BaseOtterTest)

Example 3 with NodeParameter

use of com.alibaba.otter.shared.common.model.config.node.NodeParameter in project otter by alibaba.

the class HttpPipeIntegration method test_rowData.

@Test
public void test_rowData() {
    final Node currentNode = new Node();
    currentNode.setId(1L);
    currentNode.setIp("127.0.0.1");
    currentNode.setParameters(new NodeParameter());
    final Pipeline pipeline = new Pipeline();
    pipeline.getParameters().setRetriever(RetrieverType.ARIA2C);
    // mock一下
    new NonStrictExpectations() {

        {
            configClientService.currentNode();
            returns(currentNode);
            configClientService.findPipeline(anyLong);
            returns(pipeline);
        }
    };
    Identity identity = new Identity();
    identity.setChannelId(100L);
    identity.setPipelineId(100L);
    identity.setProcessId(100L);
    FileBatch fileBatch = new FileBatch();
    fileBatch.setIdentity(identity);
    File localFile = new File(tmp, "httpPipeTest.jpg");
    FileData localFileData = new FileData();
    localFileData.setPath(localFile.getPath());
    localFileData.setEventType(EventType.INSERT);
    localFileData.setLastModifiedTime(new Date().getTime());
    localFileData.setSize(100L);
    localFileData.setTableId(1L);
    fileBatch.getFiles().add(localFileData);
    RowBatch rowBatch = new RowBatch();
    rowBatch.setIdentity(identity);
    EventData eventData = new EventData();
    eventData.setTableId(1L);
    eventData.setSchemaName("otter");
    eventData.setTableName("test");
    eventData.setEventType(EventType.INSERT);
    eventData.setExecuteTime(100L);
    EventColumn primaryKey = new EventColumn();
    primaryKey.setColumnName("id");
    primaryKey.setColumnType(1);
    primaryKey.setColumnValue("1");
    primaryKey.setKey(true);
    primaryKey.setNull(false);
    eventData.getKeys().add(primaryKey);
    EventColumn column = new EventColumn();
    column.setColumnName("name");
    column.setColumnType(1);
    column.setColumnValue("test");
    column.setKey(false);
    column.setNull(false);
    eventData.getColumns().add(column);
    rowBatch.merge(eventData);
    DbBatch dbBatch = new DbBatch();
    dbBatch.setRowBatch(rowBatch);
    dbBatch.setFileBatch(fileBatch);
    HttpPipeKey key = rowDataHttpPipe.put(dbBatch);
    DbBatch target = rowDataHttpPipe.get(key);
    want.bool(target.getRowBatch().getIdentity().equals(identity));
    want.object(target).notNull();
}
Also used : FileBatch(com.alibaba.otter.shared.etl.model.FileBatch) EventColumn(com.alibaba.otter.shared.etl.model.EventColumn) Node(com.alibaba.otter.shared.common.model.config.node.Node) Date(java.util.Date) EventData(com.alibaba.otter.shared.etl.model.EventData) DbBatch(com.alibaba.otter.shared.etl.model.DbBatch) Pipeline(com.alibaba.otter.shared.common.model.config.pipeline.Pipeline) HttpPipeKey(com.alibaba.otter.node.etl.common.pipe.impl.http.HttpPipeKey) RowBatch(com.alibaba.otter.shared.etl.model.RowBatch) NodeParameter(com.alibaba.otter.shared.common.model.config.node.NodeParameter) Identity(com.alibaba.otter.shared.etl.model.Identity) File(java.io.File) FileData(com.alibaba.otter.shared.etl.model.FileData) Test(org.testng.annotations.Test) BaseOtterTest(com.alibaba.otter.node.etl.BaseOtterTest)

Example 4 with NodeParameter

use of com.alibaba.otter.shared.common.model.config.node.NodeParameter in project otter by alibaba.

the class NodeAction method doEdit.

/**
 * 修改Node
 */
public void doEdit(@FormGroup("nodeInfo") Group nodeInfo, @FormGroup("nodeParameterInfo") Group nodeParameterInfo, @Param("pageIndex") int pageIndex, @Param("searchKey") String searchKey, @FormField(name = "formNodeError", group = "nodeInfo") CustomErrors err, Navigator nav) throws Exception {
    Node node = new Node();
    NodeParameter parameter = new NodeParameter();
    nodeInfo.setProperties(node);
    nodeParameterInfo.setProperties(parameter);
    if (parameter.getDownloadPort() == null || parameter.getDownloadPort() == 0) {
        parameter.setDownloadPort(node.getPort().intValue() + 1);
    }
    if (parameter.getMbeanPort() == null || parameter.getMbeanPort() == 0) {
        parameter.setMbeanPort(node.getPort().intValue() + 2);
    }
    Long autoKeeperclusterId = nodeParameterInfo.getField("autoKeeperclusterId").getLongValue();
    if (autoKeeperclusterId != null && autoKeeperclusterId > 0) {
        AutoKeeperCluster autoKeeperCluster = autoKeeperClusterService.findAutoKeeperClusterById(autoKeeperclusterId);
        parameter.setZkCluster(autoKeeperCluster);
    }
    node.setParameters(parameter);
    try {
        nodeService.modify(node);
    } catch (RepeatConfigureException rce) {
        err.setMessage("invalidNode");
        return;
    }
    nav.redirectToLocation("nodeList.htm?pageIndex=" + pageIndex + "&searchKey=" + urlEncode(searchKey));
}
Also used : RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException) NodeParameter(com.alibaba.otter.shared.common.model.config.node.NodeParameter) Node(com.alibaba.otter.shared.common.model.config.node.Node) AutoKeeperCluster(com.alibaba.otter.shared.common.model.autokeeper.AutoKeeperCluster)

Example 5 with NodeParameter

use of com.alibaba.otter.shared.common.model.config.node.NodeParameter in project otter by alibaba.

the class NodeAction method doAdd.

public void doAdd(@FormGroup("nodeInfo") Group nodeInfo, @FormGroup("nodeParameterInfo") Group nodeParameterInfo, @FormField(name = "formNodeError", group = "nodeInfo") CustomErrors err, Navigator nav) throws Exception {
    Node node = new Node();
    NodeParameter parameter = new NodeParameter();
    nodeInfo.setProperties(node);
    nodeParameterInfo.setProperties(parameter);
    if (parameter.getDownloadPort() == null || parameter.getDownloadPort() == 0) {
        parameter.setDownloadPort(node.getPort().intValue() + 1);
    }
    if (parameter.getMbeanPort() == null || parameter.getMbeanPort() == 0) {
        parameter.setMbeanPort(node.getPort().intValue() + 2);
    }
    Long autoKeeperclusterId = nodeParameterInfo.getField("autoKeeperclusterId").getLongValue();
    if (autoKeeperclusterId != null && autoKeeperclusterId > 0) {
        AutoKeeperCluster autoKeeperCluster = autoKeeperClusterService.findAutoKeeperClusterById(autoKeeperclusterId);
        parameter.setZkCluster(autoKeeperCluster);
    }
    node.setParameters(parameter);
    try {
        nodeService.create(node);
    } catch (RepeatConfigureException rce) {
        err.setMessage("invalidNode");
        return;
    }
    nav.redirectTo(WebConstant.NODE_LIST_LINK);
}
Also used : RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException) NodeParameter(com.alibaba.otter.shared.common.model.config.node.NodeParameter) Node(com.alibaba.otter.shared.common.model.config.node.Node) AutoKeeperCluster(com.alibaba.otter.shared.common.model.autokeeper.AutoKeeperCluster)

Aggregations

Node (com.alibaba.otter.shared.common.model.config.node.Node)5 NodeParameter (com.alibaba.otter.shared.common.model.config.node.NodeParameter)5 RepeatConfigureException (com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException)3 AutoKeeperCluster (com.alibaba.otter.shared.common.model.autokeeper.AutoKeeperCluster)3 BaseOtterTest (com.alibaba.otter.node.etl.BaseOtterTest)2 HttpPipeKey (com.alibaba.otter.node.etl.common.pipe.impl.http.HttpPipeKey)2 Pipeline (com.alibaba.otter.shared.common.model.config.pipeline.Pipeline)2 FileBatch (com.alibaba.otter.shared.etl.model.FileBatch)2 FileData (com.alibaba.otter.shared.etl.model.FileData)2 Identity (com.alibaba.otter.shared.etl.model.Identity)2 File (java.io.File)2 Test (org.testng.annotations.Test)2 ManagerException (com.alibaba.otter.manager.biz.common.exceptions.ManagerException)1 DbBatch (com.alibaba.otter.shared.etl.model.DbBatch)1 EventColumn (com.alibaba.otter.shared.etl.model.EventColumn)1 EventData (com.alibaba.otter.shared.etl.model.EventData)1 RowBatch (com.alibaba.otter.shared.etl.model.RowBatch)1 IOException (java.io.IOException)1 Date (java.util.Date)1