CHE-1787: Remove workspace id from websocket connection path to master (#2907)
parent
d74b24fb07
commit
bfcc846f22
|
|
@ -23,7 +23,7 @@
|
|||
</context-param>
|
||||
<context-param>
|
||||
<param-name>org.eclipse.che.websocket.endpoint</param-name>
|
||||
<param-value>/ws/{ws-id}</param-value>
|
||||
<param-value>/ws</param-value>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>org.eclipse.che.eventbus.endpoint</param-name>
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ class IdeSvc {
|
|||
|
||||
this.updateRecentWorkspace(workspace.id);
|
||||
|
||||
let bus = this.cheAPI.getWebsocket().getBus(workspace.id);
|
||||
let bus = this.cheAPI.getWebsocket().getBus();
|
||||
|
||||
let startWorkspaceDefer = this.$q.defer();
|
||||
this.startWorkspace(bus, workspace).then(() => {
|
||||
|
|
@ -279,7 +279,7 @@ class IdeSvc {
|
|||
websocketStream.close();
|
||||
}
|
||||
|
||||
let workspaceBus = this.cheAPI.getWebsocket().getBus(workspaceId);
|
||||
let workspaceBus = this.cheAPI.getWebsocket().getBus();
|
||||
|
||||
if (workspaceBus != null) {
|
||||
this.listeningChannels.forEach((channel) => {
|
||||
|
|
|
|||
|
|
@ -221,7 +221,7 @@ export class CreateProjectController {
|
|||
//check current workspace
|
||||
if (findWorkspace) {
|
||||
// init WS bus
|
||||
this.messageBus = this.cheAPI.getWebsocket().getBus(findWorkspace.id);
|
||||
this.messageBus = this.cheAPI.getWebsocket().getBus();
|
||||
} else {
|
||||
this.resetCreateProgress();
|
||||
}
|
||||
|
|
@ -914,7 +914,7 @@ export class CreateProjectController {
|
|||
});
|
||||
} else {
|
||||
this.subscribeStatusChannel(workspace);
|
||||
let bus = this.cheAPI.getWebsocket().getBus(workspace.id);
|
||||
let bus = this.cheAPI.getWebsocket().getBus();
|
||||
this.startWorkspace(bus, workspace);
|
||||
}
|
||||
}
|
||||
|
|
@ -945,7 +945,7 @@ export class CreateProjectController {
|
|||
let promiseWorkspace = this.cheAPI.getWorkspace().fetchWorkspaceDetails(workspace.id);
|
||||
promiseWorkspace.then(() => {
|
||||
let websocketUrl = this.cheAPI.getWorkspace().getWebsocketUrl(workspace.id),
|
||||
bus = this.cheAPI.getWebsocket().getBus(workspace.id);
|
||||
bus = this.cheAPI.getWebsocket().getBus();
|
||||
// try to connect
|
||||
this.websocketReconnect = 10;
|
||||
this.connectToExtensionServer(websocketUrl, workspace.id, this.importProjectData.project.name, this.importProjectData, bus);
|
||||
|
|
@ -974,7 +974,7 @@ export class CreateProjectController {
|
|||
|
||||
// init message bus if not there
|
||||
if (this.workspaces.length === 0) {
|
||||
this.messageBus = this.cheAPI.getWebsocket().getBus(workspace.id);
|
||||
this.messageBus = this.cheAPI.getWebsocket().getBus();
|
||||
}
|
||||
|
||||
this.cheAPI.getWorkspace().fetchWorkspaceDetails(workspace.id).then(() => {
|
||||
|
|
@ -982,7 +982,7 @@ export class CreateProjectController {
|
|||
});
|
||||
|
||||
this.$timeout(() => {
|
||||
let bus = this.cheAPI.getWebsocket().getBus(workspace.id);
|
||||
let bus = this.cheAPI.getWebsocket().getBus();
|
||||
this.startWorkspace(bus, workspace);
|
||||
}, 1000);
|
||||
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ export class ExportWorkspaceDialogController {
|
|||
|
||||
// compute WS url
|
||||
let remoteURL = authData.url;
|
||||
let remoteWsURL = remoteURL.replace('http', 'ws') + '/api/ws/';
|
||||
let remoteWsURL = remoteURL.replace('http', 'ws') + '/api/ws';
|
||||
|
||||
let startWorkspacePromise = remoteWorkspaceAPI.startWorkspace(remoteWsURL, remoteWorkspace.id, remoteWorkspace.config.defaultEnv);
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ export class CheWebsocket {
|
|||
|
||||
if (inDevMode) {
|
||||
// it handle then http and https
|
||||
wsUrl = proxySettings.replace('http', 'ws') + '/api/ws/';
|
||||
wsUrl = proxySettings.replace('http', 'ws') + '/api/ws';
|
||||
} else {
|
||||
|
||||
var wsProtocol;
|
||||
|
|
@ -42,10 +42,11 @@ export class CheWebsocket {
|
|||
wsProtocol = 'wss';
|
||||
}
|
||||
|
||||
wsUrl = wsProtocol + '://' + $location.host() + ':' + $location.port() + '/api/ws/';
|
||||
wsUrl = wsProtocol + '://' + $location.host() + ':' + $location.port() + '/api/ws';
|
||||
}
|
||||
this.wsBaseUrl = wsUrl;
|
||||
this.sockets = new Map();
|
||||
this.bus = null;
|
||||
this.remoteBus = null;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -54,34 +55,25 @@ export class CheWebsocket {
|
|||
}
|
||||
|
||||
|
||||
getBus(workspaceId) {
|
||||
var currentBus = this.sockets.get(workspaceId);
|
||||
if (!currentBus) {
|
||||
getBus() {
|
||||
if (!this.bus) {
|
||||
// needs to initialize
|
||||
var url = this.wsBaseUrl + workspaceId;
|
||||
var dataStream = this.$websocket(url);
|
||||
var bus = new MessageBus(dataStream, this.$interval);
|
||||
this.sockets.set(workspaceId, bus);
|
||||
currentBus = bus;
|
||||
this.bus = new MessageBus(this.$websocket(this.wsBaseUrl), this.$interval);
|
||||
}
|
||||
return currentBus;
|
||||
return this.bus;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets a bus for a remote worksace, by providing the remote URL to this websocket
|
||||
* @param websocketURL the remote host base WS url
|
||||
* @param workspaceId the workspaceID used as suffix for the URL
|
||||
*/
|
||||
getRemoteBus(websocketURL, workspaceId) {
|
||||
var currentBus = this.sockets.get(workspaceId);
|
||||
if (!currentBus) {
|
||||
var dataStream = this.$websocket(websocketURL + workspaceId);
|
||||
var bus = new MessageBus(dataStream, this.$interval);
|
||||
this.sockets.set(workspaceId, bus);
|
||||
currentBus = bus;
|
||||
getRemoteBus(websocketURL) {
|
||||
if (!this.remoteBus) {
|
||||
// needs to initialize
|
||||
this.remoteBus = new MessageBus(this.$websocket(websocketURL), this.$interval);
|
||||
}
|
||||
return currentBus;
|
||||
return this.remoteBus;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,8 +47,8 @@ export class CheWorkspace {
|
|||
// listeners if workspaces are changed/updated
|
||||
this.listeners = [];
|
||||
|
||||
// list of websocket bus per workspace
|
||||
this.websocketBusByWorkspaceId = new Map();
|
||||
// list of subscribed to websocket workspace Ids
|
||||
this.subscribedWorkspacesIds = [];
|
||||
this.statusDefers = {};
|
||||
|
||||
// remote call
|
||||
|
|
@ -474,9 +474,9 @@ export class CheWorkspace {
|
|||
* @param workspaceId
|
||||
*/
|
||||
startUpdateWorkspaceStatus(workspaceId) {
|
||||
if (!this.websocketBusByWorkspaceId.has(workspaceId)) {
|
||||
let bus = this.cheWebsocket.getBus(workspaceId);
|
||||
this.websocketBusByWorkspaceId.set(workspaceId, bus);
|
||||
if (!this.subscribedWorkspacesIds.includes(workspaceId)) {
|
||||
let bus = this.cheWebsocket.getBus();
|
||||
this.subscribedWorkspacesIds.push(workspaceId);
|
||||
|
||||
bus.subscribe('workspace:' + workspaceId, (message) => {
|
||||
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ export class CheRemoteWorkspace {
|
|||
let deferred = this.$q.defer();
|
||||
let deferredPromise = deferred.promise;
|
||||
|
||||
let bus = this.cheWebsocket.getRemoteBus(remoteWsURL, workspaceId);
|
||||
let bus = this.cheWebsocket.getRemoteBus(remoteWsURL);
|
||||
// subscribe to workspace events
|
||||
bus.subscribe('workspace:' + workspaceId, (message) => {
|
||||
if (message.eventType === 'RUNNING' && message.workspaceId === workspaceId) {
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ public abstract class WorkspaceComponent implements Component, WsAgentStateHandl
|
|||
if (messageBus != null) {
|
||||
messageBus.cancelReconnection();
|
||||
}
|
||||
messageBus = messageBusProvider.createMessageBus(workspace.getId());
|
||||
messageBus = messageBusProvider.createMessageBus();
|
||||
|
||||
messageBus.addOnOpenHandler(new ConnectionOpenedHandler() {
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@ import static com.google.gwt.user.client.Window.Location.getProtocol;
|
|||
*/
|
||||
public class MessageBusImpl extends AbstractMessageBus {
|
||||
|
||||
public MessageBusImpl(String workspaceId) {
|
||||
super((getProtocol().equals("https:") ? "wss://" : "ws://") + getHost() + getRestContext() + "/ws/" + workspaceId);
|
||||
public MessageBusImpl() {
|
||||
super((getProtocol().equals("https:") ? "wss://" : "ws://") + getHost() + getRestContext() + "/ws");
|
||||
}
|
||||
|
||||
private static native String getRestContext() /*-{
|
||||
|
|
|
|||
|
|
@ -37,12 +37,10 @@ public class MessageBusProvider {
|
|||
* Creates new instance of {@link MessageBusImpl} and connects to web socket via special url. The method returns new
|
||||
* instance each time it is called. Message bus is created only one time when we start workspace.
|
||||
*
|
||||
* @param workspaceId
|
||||
* workspace id which need for path to connect to web socket
|
||||
* @return instance of {@link MessageBusImpl}
|
||||
*/
|
||||
public MessageBus createMessageBus(String workspaceId) {
|
||||
this.messageBus = new MessageBusImpl(workspaceId);
|
||||
public MessageBus createMessageBus() {
|
||||
this.messageBus = new MessageBusImpl();
|
||||
|
||||
return messageBus;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue