Browse Source

Merge pull request #8309 in DEC/decision-webui-dcm from release/11.0 to final/11.0

* commit 'f63af026e1a15d632a96644aaa0ef8b32eabe217':
  REPORT-108103 Starrocks数据连接解析不包含catalog的数据连接出错
  REPORT-99289 删除代码中的debugger
  REPORT-99289 数据连接适配加一个catalog配置项
  REPORT-105428 fix: 移除SSH主机校验
final/11.0
superman 1 year ago
parent
commit
006ef00752
  1. 37
      src/modules/app.provider.ts
  2. 8
      src/modules/app.service.ts
  3. 2
      src/modules/constants/constant.ts
  4. 8
      src/modules/pages/connection/connection_jdbc/connection_jdbc.ts
  5. 34
      src/modules/pages/maintain/forms/components/form.jdbc.ts

37
src/modules/app.provider.ts

@ -6,25 +6,50 @@ BI.provider('dec.connection.provider.datebase', function () {
function starRocksResolve(url: string) { function starRocksResolve(url: string) {
// 处理starRocks数据连接常规模式 // 处理starRocks数据连接常规模式
const result = url.match(/^jdbc:mysql:\/\/([0-9a-zA-Z_\\.-]+):([0-9a-zA-Z_\\.-]+)\/([0-9a-zA-Z_\\.-]+)\.([^]+)(.*)/i); let result = url.match(/^jdbc:mysql:\/\/([0-9a-zA-Z_\\.-]+):([0-9a-zA-Z_\\.-]+)\/([0-9a-zA-Z_\\.-]+)\.([^]+)(.*)/i);
if (result) { if (result) {
return { return {
host: result[1], host: result[1],
port: result[2] === 'port' ? '' : result[2], port: result[2] === 'port' ? '' : result[2],
databaseName: result[4] || '', catalog: result[3],
databaseName: result[4],
urlInfo: result[0], urlInfo: result[0],
}; };
} else {
// 兼容老数据库里面没有catalog的情况
result = url.match(/^jdbc:mysql:\/\/([0-9a-zA-Z_\\.-]+):([0-9a-zA-Z_\\.-]+)\/([^]+)(.*)/i);
if (result) {
return {
host: result[1],
port: result[2] === 'port' ? '' : result[2],
catalog: '',
databaseName: result[3],
urlInfo: result[0],
};
}
} }
// 处理starRocks数据连接负载均衡模式 // 处理starRocks数据连接负载均衡模式
const loadBalance = url.match(/^jdbc:mysql:loadbalance:\/\/[^/]+\/([^/]+)\.([^/]+)/i); let loadBalance = url.match(/^jdbc:mysql:loadbalance:\/\/[^/]+\/([^/]+)\.([^/]+)/i);
if (loadBalance){ if (loadBalance) {
const database: string = loadBalance[2];
return { return {
host: '', host: '',
port: '', port: '',
databaseName: database, catalog: loadBalance[1],
databaseName: loadBalance[2],
urlInfo: loadBalance[0], urlInfo: loadBalance[0],
} }
} else {
// 兼容老数据库里面没有catalog的情况
loadBalance = url.match(/^jdbc:mysql:loadbalance:\/\/[^/]+\/([^/]+)([^/]+)/i);
if (loadBalance) {
return {
host: '',
port: '',
catalog: '',
databaseName: loadBalance[1],
urlInfo: loadBalance[0],
}
}
} }
return { return {
host: '', host: '',

8
src/modules/app.service.ts

@ -61,7 +61,7 @@ export function resolveUrlInfo(url: string, database?: string) {
} }
// 拼接url // 拼接url
export function splitUrl(host: string, port: string, database: string, baseUrl: string) { export function splitUrl(host: string, port: string, catalog: string, database: string, baseUrl: string) {
if (baseUrl.startsWith('jdbc:sqlserver')) { if (baseUrl.startsWith('jdbc:sqlserver')) {
return baseUrl.replace('hostname', host).replace(':port', port ? `:${port}` : '') return baseUrl.replace('hostname', host).replace(':port', port ? `:${port}` : '')
.replace('=database', `=${database}`); .replace('=database', `=${database}`);
@ -75,6 +75,12 @@ export function splitUrl(host: string, port: string, database: string, baseUrl:
.replace(':INFORMIXSERVER={server}', ''); .replace(':INFORMIXSERVER={server}', '');
} }
if (catalog) {
return baseUrl.replace('hostname', host).replace(':port', port ? `:${port}` : '')
.replace('default_catalog', catalog)
.replace('database', database)
}
return baseUrl.replace('hostname', host).replace(':port', port ? `:${port}` : '') return baseUrl.replace('hostname', host).replace(':port', port ? `:${port}` : '')
.replace('/database', `/${database}`) .replace('/database', `/${database}`)
.replace(':database', `:${database}`) .replace(':database', `:${database}`)

2
src/modules/constants/constant.ts

@ -722,7 +722,7 @@ export const DATA_BASE_TYPES = [
databaseType: 'starrocks', databaseType: 'starrocks',
driver: 'com.mysql.jdbc.Driver', driver: 'com.mysql.jdbc.Driver',
drivers: ['com.mysql.jdbc.Driver'], drivers: ['com.mysql.jdbc.Driver'],
url: 'jdbc:mysql://hostname:port/database', url: 'jdbc:mysql://hostname:port/default_catalog.database',
commonly: false, commonly: false,
internal: true, internal: true,
type: 'jdbc', type: 'jdbc',

8
src/modules/pages/connection/connection_jdbc/connection_jdbc.ts

@ -57,7 +57,7 @@ export class ConnectionJdbc extends BI.Widget {
hdfs, hdfs,
} = connectionData; } = connectionData;
const databaseType = getJdbcDatabaseType(database, driver); const databaseType = getJdbcDatabaseType(database, driver);
const { host, port, databaseName, version } = resolveUrlInfo(url, database); const { host, port, catalog, databaseName, version } = resolveUrlInfo(url, database);
this.version = !BI.isUndefined(databaseType.versions) ? (version ?? databaseType.versions[0]) : version; this.version = !BI.isUndefined(databaseType.versions) ? (version ?? databaseType.versions[0]) : version;
const { hgap, vgap } = CONNECTION_LAYOUT; const { hgap, vgap } = CONNECTION_LAYOUT;
@ -78,6 +78,12 @@ export class ConnectionJdbc extends BI.Widget {
name: BI.i18nText('Dec-Dcm_Connection_Form_Driver'), name: BI.i18nText('Dec-Dcm_Connection_Form_Driver'),
value: BI.isKey(driverSource) ? `${driver} (${driverSource})` : driver, value: BI.isKey(driverSource) ? `${driver} (${driverSource})` : driver,
}, },
{
type: FormItem.xtype,
name: 'catalog',
invisible: database !== 'starrocks',
value: catalog,
},
{ {
type: FormItem.xtype, type: FormItem.xtype,
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Name'), name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Name'),

34
src/modules/pages/maintain/forms/components/form.jdbc.ts

@ -51,6 +51,7 @@ export class FormJdbc extends BI.Widget {
connectionName: null, connectionName: null,
version: null, version: null,
driver: null, driver: null,
catalog: null,
database: null, database: null,
host: null, host: null,
port: null, port: null,
@ -160,7 +161,7 @@ export class FormJdbc extends BI.Widget {
} = connectionPoolAttr as ConnectionPoolJDBC; } = connectionPoolAttr as ConnectionPoolJDBC;
const databaseType = getJdbcDatabaseType(database, driver); const databaseType = getJdbcDatabaseType(database, driver);
this.databaseType = databaseType; this.databaseType = databaseType;
const { host, port, databaseName, version } = resolveUrlInfo(url, database); const { host, port, catalog, databaseName, version } = resolveUrlInfo(url, database);
this.version = !BI.isUndefined(databaseType.versions) ? (version ?? databaseType.versions[0]) : version; this.version = !BI.isUndefined(databaseType.versions) ? (version ?? databaseType.versions[0]) : version;
const { hgap, vgap } = CONNECTION_LAYOUT; const { hgap, vgap } = CONNECTION_LAYOUT;
@ -262,6 +263,33 @@ export class FormJdbc extends BI.Widget {
}, },
], ],
}, },
// catalog
{
type: FormItem.xtype,
name: 'catalog',
invisible: database !== 'starrocks',
forms: [
{
type: BI.TextEditor.xtype,
$value: 'database-catalog',
width: EDITOR_WIDTH,
allowBlank: true,
watermark: 'catalog',
value: catalog,
ref: (_ref: any) => {
this.form.catalog = _ref;
},
listeners: [
{
eventName: BI.Editor.EVENT_CHANGE,
action: () => {
this.onHostPortChange(databaseType);
},
},
],
},
],
},
// 数据库名称 // 数据库名称
{ {
type: FormItem.xtype, type: FormItem.xtype,
@ -843,6 +871,7 @@ export class FormJdbc extends BI.Widget {
action: () => { action: () => {
const urlInfo = resolveUrlInfo(this.form.url.getValue(), database); const urlInfo = resolveUrlInfo(this.form.url.getValue(), database);
this.form.host.setValue(urlInfo.host); this.form.host.setValue(urlInfo.host);
this.form.catalog.setValue(urlInfo.catalog);
this.form.database.setValue(urlInfo.databaseName); this.form.database.setValue(urlInfo.databaseName);
this.form.port.setValue(urlInfo.port); this.form.port.setValue(urlInfo.port);
}, },
@ -1578,8 +1607,9 @@ export class FormJdbc extends BI.Widget {
const selectUrl = BI.get(urls, driver.driver) || url; const selectUrl = BI.get(urls, driver.driver) || url;
const host = this.form.host.getValue(); const host = this.form.host.getValue();
const port = this.form.port.getValue(); const port = this.form.port.getValue();
const catalog = this.form.catalog.getValue();
const database = this.form.database.getValue(); const database = this.form.database.getValue();
this.form.url.setValue(splitUrl(host, port, database, selectUrl)); this.form.url.setValue(splitUrl(host, port, catalog, database, selectUrl));
} }
private onSshTypeChange(sshType) { private onSshTypeChange(sshType) {

Loading…
Cancel
Save