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 @@ ...@@ -19,6 +19,7 @@
package org.dinky.context; package org.dinky.context;
import org.dinky.data.constant.SseConstant;
import org.dinky.data.exception.BusException; import org.dinky.data.exception.BusException;
import org.dinky.data.vo.SseDataVo; import org.dinky.data.vo.SseDataVo;
...@@ -51,7 +52,10 @@ public class SseSessionContextHolder { ...@@ -51,7 +52,10 @@ public class SseSessionContextHolder {
if (exists(sessionId)) { if (exists(sessionId)) {
return sessionMap.get(sessionId).updateTopics(topics); return sessionMap.get(sessionId).updateTopics(topics);
} else { } 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) => { ...@@ -43,10 +43,10 @@ const DagDataNode = (props: any) => {
ratio > 0.75 ratio > 0.75
? '#cf1322' ? '#cf1322'
: ratio > 0.5 : ratio > 0.5
? '#d46b08' ? '#d46b08'
: ratio > 0.25 : ratio > 0.25
? '#d4b106' ? '#d4b106'
: '#3f8600', : '#3f8600',
fontSize: 10 fontSize: 10
}} }}
/> />
...@@ -65,10 +65,10 @@ const DagDataNode = (props: any) => { ...@@ -65,10 +65,10 @@ const DagDataNode = (props: any) => {
ratio > 0.75 ratio > 0.75
? '#3f8600' ? '#3f8600'
: ratio > 0.5 : ratio > 0.5
? '#d4b106' ? '#d4b106'
: ratio > 0.25 : ratio > 0.25
? '#d46b08' ? '#d46b08'
: '#cf1322', : '#cf1322',
fontSize: 10 fontSize: 10
}} }}
/> />
......
...@@ -92,54 +92,57 @@ export default class LineageDagExt extends LineageDag { ...@@ -92,54 +92,57 @@ export default class LineageDagExt extends LineageDag {
edges: result.edges edges: result.edges
}; };
setTimeout(() => { setTimeout(
let tmpEdges = result.edges; () => {
result.edges = []; let tmpEdges = result.edges;
// this.canvas.wrapper.style.visibility = 'hidden'; result.edges = [];
this.canvas.draw(result, () => { // this.canvas.wrapper.style.visibility = 'hidden';
this.canvas.relayout( this.canvas.draw(result, () => {
{ this.canvas.relayout(
edges: tmpEdges.map((item) => { {
return { edges: tmpEdges.map((item) => {
source: item.sourceNode, return {
target: item.targetNode source: item.sourceNode,
}; target: item.targetNode
}) };
}, })
true },
); true
// this.canvas.wrapper.style.visibility = 'visible'; );
this.canvas.addEdges(tmpEdges, true); // this.canvas.wrapper.style.visibility = 'visible';
this.canvas.addEdges(tmpEdges, true);
let minimap = _.get(this, 'props.config.minimap', {});
let minimap = _.get(this, 'props.config.minimap', {});
const minimapCfg = _.assign({}, minimap.config, {
events: ['system.node.click', 'system.canvas.click'] const minimapCfg = _.assign({}, minimap.config, {
}); events: ['system.node.click', 'system.canvas.click']
});
if (minimap && minimap.enable) {
this.canvas.setMinimap(true, minimapCfg); if (minimap && minimap.enable) {
} this.canvas.setMinimap(true, minimapCfg);
}
if (_.get(this, 'props.config.gridMode')) { if (_.get(this, 'props.config.gridMode')) {
this.canvas.setGridMode(true, _.assign({}, _.get(this, 'props.config.gridMode', {}))); this.canvas.setGridMode(true, _.assign({}, _.get(this, 'props.config.gridMode', {})));
} }
if (result.nodes.length !== 0) { if (result.nodes.length !== 0) {
this.canvas.focusCenterWithAnimate(); this.canvas.focusCenterWithAnimate();
this._isFirstFocus = true; this._isFirstFocus = true;
} }
this.forceUpdate(); this.forceUpdate();
this.props.onLoaded && this.props.onLoaded(this.canvas); this.props.onLoaded && this.props.onLoaded(this.canvas);
}); });
this.canvas.on('system.node.click', (data) => { this.canvas.on('system.node.click', (data) => {
let node = data.node; let node = data.node;
this.canvas.focus(node.id); this.canvas.focus(node.id);
}); });
this.canvas.on('system.canvas.click', () => { this.canvas.on('system.canvas.click', () => {
this.canvas.unfocus(); this.canvas.unfocus();
}); });
}, _.get(this.props, 'config.delayDraw', 0)); },
_.get(this.props, 'config.delayDraw', 0)
);
} }
} }
...@@ -22,6 +22,7 @@ import { ErrorMessage } from '@/utils/messages'; ...@@ -22,6 +22,7 @@ import { ErrorMessage } from '@/utils/messages';
import { useEffect, useRef, useState } from 'react'; import { useEffect, useRef, useState } from 'react';
import { v4 as uuidv4 } from 'uuid'; import { v4 as uuidv4 } from 'uuid';
const session_invalid_label = 'SESSION_INVALID';
export type SseData = { export type SseData = {
topic: string; topic: string;
data: any; data: any;
...@@ -40,7 +41,13 @@ export default () => { ...@@ -40,7 +41,13 @@ export default () => {
const topics: string[] = []; const topics: string[] = [];
subscriberRef.current.forEach((sub) => topics.push(...sub.topic)); subscriberRef.current.forEach((sub) => topics.push(...sub.topic));
const para = { sessionKey: uuidRef.current, topics: topics }; 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 reconnectSse = () => {
const sseUrl = '/api/sse/connect?sessionKey=' + uuidRef.current; const sseUrl = '/api/sse/connect?sessionKey=' + uuidRef.current;
......
...@@ -316,10 +316,10 @@ const MenuList: React.FC = () => { ...@@ -316,10 +316,10 @@ const MenuList: React.FC = () => {
{sysMenuValue?.id && editOpen {sysMenuValue?.id && editOpen
? l('menu.edit') ? l('menu.edit')
: !sysMenuValue?.id && addedOpen && !isRootMenu : !sysMenuValue?.id && addedOpen && !isRootMenu
? l('right.menu.addSub') ? l('right.menu.addSub')
: !sysMenuValue?.id && addedOpen && isRootMenu : !sysMenuValue?.id && addedOpen && isRootMenu
? l('right.menu.createRoot') ? l('right.menu.createRoot')
: ''} : ''}
</> </>
); );
}; };
......
...@@ -87,11 +87,11 @@ const TokenModalForm: React.FC<TokenModalFormProps & connect> = (props) => { ...@@ -87,11 +87,11 @@ const TokenModalForm: React.FC<TokenModalFormProps & connect> = (props) => {
value.expireType === 2 value.expireType === 2
? parseDateStringToDate(value.expireEndTime) ? parseDateStringToDate(value.expireEndTime)
: value.expireType === 3 : value.expireType === 3
? [ ? [
parseDateStringToDate(value.expireStartTime), parseDateStringToDate(value.expireStartTime),
parseDateStringToDate(value.expireEndTime) parseDateStringToDate(value.expireEndTime)
] ]
: undefined : undefined
}); });
}, [visible, value, form, selectUserId]); }, [visible, value, form, selectUserId]);
......
...@@ -61,8 +61,8 @@ export const JobConfigInfo: React.FC<JobDetailInfoModelProps> = (props) => { ...@@ -61,8 +61,8 @@ export const JobConfigInfo: React.FC<JobDetailInfoModelProps> = (props) => {
{row?.clusterId {row?.clusterId
? l('pages.datastudio.label.history.clusterInstance') ? l('pages.datastudio.label.history.clusterInstance')
: row?.clusterConfigurationId : row?.clusterConfigurationId
? l('pages.datastudio.label.history.clusterConfig') ? l('pages.datastudio.label.history.clusterConfig')
: l('pages.datastudio.label.history.local')} : l('pages.datastudio.label.history.local')}
</ProDescriptions.Item> </ProDescriptions.Item>
<ProDescriptions.Item <ProDescriptions.Item
......
...@@ -52,8 +52,8 @@ const JobRunningModal: React.FC<JobRunningModalProps> = (props) => { ...@@ -52,8 +52,8 @@ const JobRunningModal: React.FC<JobRunningModalProps> = (props) => {
? value?.jobState === 'RUNNING' ? value?.jobState === 'RUNNING'
? 50 ? 50
: value?.jobState === 'FINISHED' : value?.jobState === 'FINISHED'
? 100 ? 100
: 0 : 0
: 0 : 0
} }
status='active' status='active'
......
...@@ -202,14 +202,14 @@ export function getRightSelectKeyFromNodeClickJobType(jobType: string): string { ...@@ -202,14 +202,14 @@ export function getRightSelectKeyFromNodeClickJobType(jobType: string): string {
return isFlinkJob(jobType) return isFlinkJob(jobType)
? RightMenuKey.JOB_CONFIG_KEY ? RightMenuKey.JOB_CONFIG_KEY
: isSql(jobType) : isSql(jobType)
? RightMenuKey.PREVIEW_CONFIG_KEY ? RightMenuKey.PREVIEW_CONFIG_KEY
: RightMenuKey.JOB_INFO_KEY; : RightMenuKey.JOB_INFO_KEY;
} }
export function getBottomSelectKeyFromNodeClickJobType(jobType: string): string { export function getBottomSelectKeyFromNodeClickJobType(jobType: string): string {
return isFlinkJob(jobType) || isSql(jobType) return isFlinkJob(jobType) || isSql(jobType)
? LeftBottomKey.CONSOLE_KEY ? LeftBottomKey.CONSOLE_KEY
: isUDF(jobType) || jobType.toLowerCase() === DIALECT.FLINKSQLENV : 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) => { ...@@ -204,8 +204,8 @@ const Project: React.FC = (props: connect) => {
options.parentId = projectState.isCreateTask options.parentId = projectState.isCreateTask
? projectState.value.id ? projectState.value.id
: projectState.isEdit : projectState.isEdit
? projectState.value.parentId ? projectState.value.parentId
: options.parentId; : options.parentId;
} else { } else {
options.url = API_CONSTANTS.SAVE_OR_UPDATE_CATALOGUE_URL; options.url = API_CONSTANTS.SAVE_OR_UPDATE_CATALOGUE_URL;
} }
......
...@@ -93,8 +93,8 @@ const DataStudio: React.FC<connect> = (props: any) => { ...@@ -93,8 +93,8 @@ const DataStudio: React.FC<connect> = (props: any) => {
const newBottomHeight = !isProject const newBottomHeight = !isProject
? 0 ? 0
: bottomContainer.selectKey === '' : bottomContainer.selectKey === ''
? 0 ? 0
: bottomContainer.height; : bottomContainer.height;
const centerContentHeight = getClientSize().contentHeight - newBottomHeight; const centerContentHeight = getClientSize().contentHeight - newBottomHeight;
updateCenterContentHeight(centerContentHeight); updateCenterContentHeight(centerContentHeight);
updateToolContentHeight(centerContentHeight - VIEW.leftMargin); updateToolContentHeight(centerContentHeight - VIEW.leftMargin);
...@@ -118,8 +118,8 @@ const DataStudio: React.FC<connect> = (props: any) => { ...@@ -118,8 +118,8 @@ const DataStudio: React.FC<connect> = (props: any) => {
const newBottomHeight = !isProject const newBottomHeight = !isProject
? 0 ? 0
: bottomContainer.selectKey === '' : bottomContainer.selectKey === ''
? 0 ? 0
: bottomContainer.height; : bottomContainer.height;
const centerContentHeight = size.contentHeight - newBottomHeight; const centerContentHeight = size.contentHeight - newBottomHeight;
updateCenterContentHeight(centerContentHeight); updateCenterContentHeight(centerContentHeight);
updateToolContentHeight(centerContentHeight - VIEW.leftMargin); updateToolContentHeight(centerContentHeight - VIEW.leftMargin);
......
...@@ -134,14 +134,14 @@ export const renderBranchesTagColor = (item: string) => { ...@@ -134,14 +134,14 @@ export const renderBranchesTagColor = (item: string) => {
return item.includes('dev') return item.includes('dev')
? 'processing' ? 'processing'
: item.includes('test') : item.includes('test')
? 'warning' ? 'warning'
: item.includes('release') : item.includes('release')
? 'success' ? 'success'
: item.includes('master') : item.includes('master')
? 'success' ? 'success'
: item.includes('main') : item.includes('main')
? 'success' ? 'success'
: 'default'; : 'default';
}; };
/** /**
......
...@@ -296,8 +296,8 @@ const ResourceOverView: React.FC = () => { ...@@ -296,8 +296,8 @@ const ResourceOverView: React.FC = () => {
editModal === 'createFolder' editModal === 'createFolder'
? l('right.menu.createFolder') ? l('right.menu.createFolder')
: editModal === 'rename' : editModal === 'rename'
? l('right.menu.rename') ? l('right.menu.rename')
: '' : ''
} }
formValues={resourceState.value} formValues={resourceState.value}
onOk={handleModalSubmit} 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