Unverified Commit 1b1ca027 authored by gitfortian's avatar gitfortian Committed by GitHub

[Fix-2872][admin] Fix page shows message "Session dose not exists" when backend restart (#2876)

* fix multi user login with the same token value insert error * fix multi user login with the same token value insert error * 代码格式化 * use reentrant lock to instead synchronized * fix session dose not exists error * code format --------- Co-authored-by: tianxy105 <lucas123.COM>
parent 416684a2
......@@ -19,6 +19,7 @@
package org.dinky.context;
import org.dinky.data.constant.SseConstant;
import org.dinky.data.exception.BusException;
import org.dinky.data.vo.SseDataVo;
......@@ -51,7 +52,10 @@ public class SseSessionContextHolder {
if (exists(sessionId)) {
return sessionMap.get(sessionId).updateTopics(topics);
} else {
throw new BusException("Session does not exist");
HashSet<String> reconnectMessage = new HashSet<>(1);
reconnectMessage.add(SseConstant.SSE_SESSION_INVALID);
log.warn("session id is invalid");
return reconnectMessage;
}
}
......
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.dinky.data.constant;
public class SseConstant {
/**
* Sse label for front to reconnect session
*/
public static final String SSE_SESSION_INVALID = "SESSION_INVALID";
}
......@@ -43,10 +43,10 @@ const DagDataNode = (props: any) => {
ratio > 0.75
? '#cf1322'
: ratio > 0.5
? '#d46b08'
: ratio > 0.25
? '#d4b106'
: '#3f8600',
? '#d46b08'
: ratio > 0.25
? '#d4b106'
: '#3f8600',
fontSize: 10
}}
/>
......@@ -65,10 +65,10 @@ const DagDataNode = (props: any) => {
ratio > 0.75
? '#3f8600'
: ratio > 0.5
? '#d4b106'
: ratio > 0.25
? '#d46b08'
: '#cf1322',
? '#d4b106'
: ratio > 0.25
? '#d46b08'
: '#cf1322',
fontSize: 10
}}
/>
......
......@@ -92,54 +92,57 @@ export default class LineageDagExt extends LineageDag {
edges: result.edges
};
setTimeout(() => {
let tmpEdges = result.edges;
result.edges = [];
// this.canvas.wrapper.style.visibility = 'hidden';
this.canvas.draw(result, () => {
this.canvas.relayout(
{
edges: tmpEdges.map((item) => {
return {
source: item.sourceNode,
target: item.targetNode
};
})
},
true
);
// this.canvas.wrapper.style.visibility = 'visible';
this.canvas.addEdges(tmpEdges, true);
let minimap = _.get(this, 'props.config.minimap', {});
const minimapCfg = _.assign({}, minimap.config, {
events: ['system.node.click', 'system.canvas.click']
});
if (minimap && minimap.enable) {
this.canvas.setMinimap(true, minimapCfg);
}
setTimeout(
() => {
let tmpEdges = result.edges;
result.edges = [];
// this.canvas.wrapper.style.visibility = 'hidden';
this.canvas.draw(result, () => {
this.canvas.relayout(
{
edges: tmpEdges.map((item) => {
return {
source: item.sourceNode,
target: item.targetNode
};
})
},
true
);
// this.canvas.wrapper.style.visibility = 'visible';
this.canvas.addEdges(tmpEdges, true);
let minimap = _.get(this, 'props.config.minimap', {});
const minimapCfg = _.assign({}, minimap.config, {
events: ['system.node.click', 'system.canvas.click']
});
if (minimap && minimap.enable) {
this.canvas.setMinimap(true, minimapCfg);
}
if (_.get(this, 'props.config.gridMode')) {
this.canvas.setGridMode(true, _.assign({}, _.get(this, 'props.config.gridMode', {})));
}
if (_.get(this, 'props.config.gridMode')) {
this.canvas.setGridMode(true, _.assign({}, _.get(this, 'props.config.gridMode', {})));
}
if (result.nodes.length !== 0) {
this.canvas.focusCenterWithAnimate();
this._isFirstFocus = true;
}
if (result.nodes.length !== 0) {
this.canvas.focusCenterWithAnimate();
this._isFirstFocus = true;
}
this.forceUpdate();
this.props.onLoaded && this.props.onLoaded(this.canvas);
});
this.canvas.on('system.node.click', (data) => {
let node = data.node;
this.canvas.focus(node.id);
});
this.canvas.on('system.canvas.click', () => {
this.canvas.unfocus();
});
}, _.get(this.props, 'config.delayDraw', 0));
this.forceUpdate();
this.props.onLoaded && this.props.onLoaded(this.canvas);
});
this.canvas.on('system.node.click', (data) => {
let node = data.node;
this.canvas.focus(node.id);
});
this.canvas.on('system.canvas.click', () => {
this.canvas.unfocus();
});
},
_.get(this.props, 'config.delayDraw', 0)
);
}
}
......@@ -22,6 +22,7 @@ import { ErrorMessage } from '@/utils/messages';
import { useEffect, useRef, useState } from 'react';
import { v4 as uuidv4 } from 'uuid';
const session_invalid_label = 'SESSION_INVALID';
export type SseData = {
topic: string;
data: any;
......@@ -40,7 +41,13 @@ export default () => {
const topics: string[] = [];
subscriberRef.current.forEach((sub) => topics.push(...sub.topic));
const para = { sessionKey: uuidRef.current, topics: topics };
await postAll('api/sse/subscribeTopic', para).catch((e) => ErrorMessage(e));
await postAll('api/sse/subscribeTopic', para)
.then((res: any) => {
if (res.data.length === 1 && res.data[0] === session_invalid_label) {
reconnectSse();
}
})
.catch((e) => ErrorMessage(e));
};
const reconnectSse = () => {
const sseUrl = '/api/sse/connect?sessionKey=' + uuidRef.current;
......
......@@ -316,10 +316,10 @@ const MenuList: React.FC = () => {
{sysMenuValue?.id && editOpen
? l('menu.edit')
: !sysMenuValue?.id && addedOpen && !isRootMenu
? l('right.menu.addSub')
: !sysMenuValue?.id && addedOpen && isRootMenu
? l('right.menu.createRoot')
: ''}
? l('right.menu.addSub')
: !sysMenuValue?.id && addedOpen && isRootMenu
? l('right.menu.createRoot')
: ''}
</>
);
};
......
......@@ -87,11 +87,11 @@ const TokenModalForm: React.FC<TokenModalFormProps & connect> = (props) => {
value.expireType === 2
? parseDateStringToDate(value.expireEndTime)
: value.expireType === 3
? [
parseDateStringToDate(value.expireStartTime),
parseDateStringToDate(value.expireEndTime)
]
: undefined
? [
parseDateStringToDate(value.expireStartTime),
parseDateStringToDate(value.expireEndTime)
]
: undefined
});
}, [visible, value, form, selectUserId]);
......
......@@ -61,8 +61,8 @@ export const JobConfigInfo: React.FC<JobDetailInfoModelProps> = (props) => {
{row?.clusterId
? l('pages.datastudio.label.history.clusterInstance')
: row?.clusterConfigurationId
? l('pages.datastudio.label.history.clusterConfig')
: l('pages.datastudio.label.history.local')}
? l('pages.datastudio.label.history.clusterConfig')
: l('pages.datastudio.label.history.local')}
</ProDescriptions.Item>
<ProDescriptions.Item
......
......@@ -52,8 +52,8 @@ const JobRunningModal: React.FC<JobRunningModalProps> = (props) => {
? value?.jobState === 'RUNNING'
? 50
: value?.jobState === 'FINISHED'
? 100
: 0
? 100
: 0
: 0
}
status='active'
......
......@@ -202,14 +202,14 @@ export function getRightSelectKeyFromNodeClickJobType(jobType: string): string {
return isFlinkJob(jobType)
? RightMenuKey.JOB_CONFIG_KEY
: isSql(jobType)
? RightMenuKey.PREVIEW_CONFIG_KEY
: RightMenuKey.JOB_INFO_KEY;
? RightMenuKey.PREVIEW_CONFIG_KEY
: RightMenuKey.JOB_INFO_KEY;
}
export function getBottomSelectKeyFromNodeClickJobType(jobType: string): string {
return isFlinkJob(jobType) || isSql(jobType)
? LeftBottomKey.CONSOLE_KEY
: isUDF(jobType) || jobType.toLowerCase() === DIALECT.FLINKSQLENV
? LeftBottomKey.TOOLS_KEY
: LeftBottomKey.TOOLS_KEY;
? LeftBottomKey.TOOLS_KEY
: LeftBottomKey.TOOLS_KEY;
}
......@@ -204,8 +204,8 @@ const Project: React.FC = (props: connect) => {
options.parentId = projectState.isCreateTask
? projectState.value.id
: projectState.isEdit
? projectState.value.parentId
: options.parentId;
? projectState.value.parentId
: options.parentId;
} else {
options.url = API_CONSTANTS.SAVE_OR_UPDATE_CATALOGUE_URL;
}
......
......@@ -93,8 +93,8 @@ const DataStudio: React.FC<connect> = (props: any) => {
const newBottomHeight = !isProject
? 0
: bottomContainer.selectKey === ''
? 0
: bottomContainer.height;
? 0
: bottomContainer.height;
const centerContentHeight = getClientSize().contentHeight - newBottomHeight;
updateCenterContentHeight(centerContentHeight);
updateToolContentHeight(centerContentHeight - VIEW.leftMargin);
......@@ -118,8 +118,8 @@ const DataStudio: React.FC<connect> = (props: any) => {
const newBottomHeight = !isProject
? 0
: bottomContainer.selectKey === ''
? 0
: bottomContainer.height;
? 0
: bottomContainer.height;
const centerContentHeight = size.contentHeight - newBottomHeight;
updateCenterContentHeight(centerContentHeight);
updateToolContentHeight(centerContentHeight - VIEW.leftMargin);
......
......@@ -134,14 +134,14 @@ export const renderBranchesTagColor = (item: string) => {
return item.includes('dev')
? 'processing'
: item.includes('test')
? 'warning'
: item.includes('release')
? 'success'
: item.includes('master')
? 'success'
: item.includes('main')
? 'success'
: 'default';
? 'warning'
: item.includes('release')
? 'success'
: item.includes('master')
? 'success'
: item.includes('main')
? 'success'
: 'default';
};
/**
......
......@@ -296,8 +296,8 @@ const ResourceOverView: React.FC = () => {
editModal === 'createFolder'
? l('right.menu.createFolder')
: editModal === 'rename'
? l('right.menu.rename')
: ''
? l('right.menu.rename')
: ''
}
formValues={resourceState.value}
onOk={handleModalSubmit}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment