Commit b81872ca authored by lenboo's avatar lenboo
Browse files

merge from dev-1.3.0

parent 73cae7f0
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -522,7 +522,6 @@ public class DataSourceService extends BaseService{
            separator = ";";
        }

        Map<String, Object> parameterMap = new LinkedHashMap<String, Object>(6);
        parameterMap.put(TYPE, connectType);
        parameterMap.put(Constants.ADDRESS, address);
        parameterMap.put(Constants.DATABASE, database);
+14 −12
Original line number Diff line number Diff line
@@ -16,13 +16,11 @@
 */
package org.apache.dolphinscheduler.dao.upgrade;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.apache.dolphinscheduler.common.enums.DbType;
import org.apache.dolphinscheduler.common.utils.ConnectionUtils;
import org.apache.dolphinscheduler.common.utils.SchemaUtils;
import org.apache.dolphinscheduler.common.utils.ScriptRunner;
import org.apache.dolphinscheduler.common.utils.StringUtils;
import org.apache.dolphinscheduler.common.utils.*;
import org.apache.dolphinscheduler.dao.AbstractBaseDao;
import org.apache.dolphinscheduler.dao.datasource.ConnectionFactory;
import org.slf4j.Logger;
@@ -282,12 +280,16 @@ public abstract class UpgradeDao extends AbstractBaseDao {
            Map<Integer,String> processDefinitionJsonMap = processDefinitionDao.queryAllProcessDefinition(dataSource.getConnection());

            for (Map.Entry<Integer,String> entry : processDefinitionJsonMap.entrySet()){
                JSONObject jsonObject = JSONObject.parseObject(entry.getValue());
                JSONArray tasks = JSONArray.parseArray(jsonObject.getString("tasks"));
                ObjectNode jsonObject = JSONUtils.parseObject(entry.getValue());
                ArrayNode tasks = JSONUtils.parseArray(jsonObject.get("tasks").toString());

                for (int i = 0 ;i < tasks.size() ; i++){
                    JSONObject task = tasks.getJSONObject(i);
                    Integer workerGroupId = task.getInteger("workerGroupId");
                    ObjectNode task = (ObjectNode) tasks.path(i);
                    ObjectNode workerGroupNode = (ObjectNode) task.path("workerGroupId");
                    Integer workerGroupId = -1;
                    if(workerGroupNode != null && workerGroupNode.canConvertToInt()){
                        workerGroupId = workerGroupNode.asInt(-1);
                    }
                    if (workerGroupId == -1) {
                        task.put("workerGroup", "default");
                    }else {
@@ -295,11 +297,11 @@ public abstract class UpgradeDao extends AbstractBaseDao {
                    }
                }

                jsonObject.remove(jsonObject.getString("tasks"));
                jsonObject.remove("task");

                jsonObject.put("tasks",tasks);

                replaceProcessDefinitionMap.put(entry.getKey(),jsonObject.toJSONString());
                replaceProcessDefinitionMap.put(entry.getKey(),jsonObject.toString());
            }
            if (replaceProcessDefinitionMap.size() > 0){
                processDefinitionDao.updateProcessDefinitionJson(dataSource.getConnection(),replaceProcessDefinitionMap);
+4 −4
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ public class OracleDataSourceTest {
    @Test
    public void testGetOracleJdbcUrl() {
        OracleDataSource oracleDataSource = new OracleDataSource();
        oracleDataSource.setType(DbConnectType.ORACLE_SERVICE_NAME);
        oracleDataSource.setConnectType(DbConnectType.ORACLE_SERVICE_NAME);
        oracleDataSource.setAddress("jdbc:oracle:thin:@//127.0.0.1:1521");
        oracleDataSource.setDatabase("test");
        oracleDataSource.setPassword("123456");
@@ -43,7 +43,7 @@ public class OracleDataSourceTest {
        oracleDataSource2.setDatabase("orcl");
        oracleDataSource2.setPassword("123456");
        oracleDataSource2.setUser("test");
        oracleDataSource2.setType(DbConnectType.ORACLE_SID);
        oracleDataSource2.setConnectType(DbConnectType.ORACLE_SID);
        Assert.assertEquals("jdbc:oracle:thin:@127.0.0.1:1521:orcl", oracleDataSource2.getJdbcUrl());
        //set fake principal
        oracleDataSource2.setPrincipal("fake principal");
@@ -58,7 +58,7 @@ public class OracleDataSourceTest {
        OracleDataSource oracleDataSource = new OracleDataSource();
        oracleDataSource.setAddress("jdbc:oracle:thin:@//127.0.0.1:1521");
        oracleDataSource.setDatabase("test");
        oracleDataSource.setType(DbConnectType.ORACLE_SERVICE_NAME);
        oracleDataSource.setConnectType(DbConnectType.ORACLE_SERVICE_NAME);
        StringBuilder jdbcUrl = new StringBuilder(oracleDataSource.getAddress());
        oracleDataSource.appendDatabase(jdbcUrl);
        Assert.assertEquals("jdbc:oracle:thin:@//127.0.0.1:1521/test", jdbcUrl.toString());
@@ -66,7 +66,7 @@ public class OracleDataSourceTest {
        OracleDataSource oracleDataSource2 = new OracleDataSource();
        oracleDataSource2.setAddress("jdbc:oracle:thin:@127.0.0.1:1521");
        oracleDataSource2.setDatabase("orcl");
        oracleDataSource2.setType(DbConnectType.ORACLE_SID);
        oracleDataSource2.setConnectType(DbConnectType.ORACLE_SID);
        StringBuilder jdbcUrl2 = new StringBuilder(oracleDataSource2.getAddress());
        oracleDataSource2.appendDatabase(jdbcUrl2);
        Assert.assertEquals("jdbc:oracle:thin:@127.0.0.1:1521:orcl", jdbcUrl2.toString());
+2 −2
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@ package org.apache.dolphinscheduler.remote.command.log;

import org.apache.dolphinscheduler.remote.command.Command;
import org.apache.dolphinscheduler.remote.command.CommandType;
import org.apache.dolphinscheduler.remote.utils.FastJsonSerializer;
import org.apache.dolphinscheduler.remote.utils.JsonSerializer;

import java.io.Serializable;

@@ -56,7 +56,7 @@ public class RemoveTaskLogRequestCommand implements Serializable {
    public Command convert2Command(){
        Command command = new Command();
        command.setType(CommandType.REMOVE_TAK_LOG_REQUEST);
        byte[] body = FastJsonSerializer.serialize(this);
        byte[] body = JsonSerializer.serialize(this);
        command.setBody(body);
        return command;
    }
+3 −3
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@ package org.apache.dolphinscheduler.remote.command.log;

import org.apache.dolphinscheduler.remote.command.Command;
import org.apache.dolphinscheduler.remote.command.CommandType;
import org.apache.dolphinscheduler.remote.utils.FastJsonSerializer;
import org.apache.dolphinscheduler.remote.utils.JsonSerializer;

import java.io.Serializable;

@@ -28,7 +28,7 @@ import java.io.Serializable;
 */
public class RemoveTaskLogResponseCommand implements Serializable {

    /**
    /*TaskPriorityQueueConsumer.*
     *  log path
     */
    private Boolean status;
@@ -56,7 +56,7 @@ public class RemoveTaskLogResponseCommand implements Serializable {
    public Command convert2Command(long opaque){
        Command command = new Command(opaque);
        command.setType(CommandType.REMOVE_TAK_LOG_RESPONSE);
        byte[] body = FastJsonSerializer.serialize(this);
        byte[] body = JsonSerializer.serialize(this);
        command.setBody(body);
        return command;
    }
Loading