-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduced two web-socket endpoints for workspace master to split JSO…
…N-RPC messages (#12673) * Introduced two web-socket endpoints for workspace master to split JSON-RPC messages Based on Dmytro's Kulieshov work #12252 Signed-off-by: Sergii Kabashniuk <[email protected]>
- Loading branch information
1 parent
3778f01
commit a5b06d4
Showing
35 changed files
with
1,027 additions
and
87 deletions.
There are no files selected for viewing
107 changes: 107 additions & 0 deletions
107
...ssembly-wsmaster-war/src/main/java/org/eclipse/che/api/deploy/MetricsOverrideBinding.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/* | ||
* Copyright (c) 2012-2018 Red Hat, Inc. | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
package org.eclipse.che.api.deploy; | ||
|
||
import com.google.inject.Binder; | ||
import com.google.inject.Module; | ||
import io.micrometer.core.instrument.Tags; | ||
import io.micrometer.prometheus.PrometheusMeterRegistry; | ||
import java.util.concurrent.ExecutorService; | ||
import javax.inject.Inject; | ||
import javax.inject.Named; | ||
import javax.inject.Singleton; | ||
import org.eclipse.che.api.deploy.jsonrpc.CheMajorWebSocketEndpointConfiguration; | ||
import org.eclipse.che.api.deploy.jsonrpc.CheMajorWebSocketEndpointExecutorServiceProvider; | ||
import org.eclipse.che.api.deploy.jsonrpc.CheMinorWebSocketEndpointConfiguration; | ||
import org.eclipse.che.api.deploy.jsonrpc.CheMinorWebSocketEndpointExecutorServiceProvider; | ||
import org.eclipse.che.core.metrics.ExecutorServiceMetrics; | ||
|
||
/** | ||
* {@link Module} that provides metered implementation for different classes. Metrics will be | ||
* published to {@link PrometheusMeterRegistry}. | ||
*/ | ||
public class MetricsOverrideBinding implements Module { | ||
@Override | ||
public void configure(Binder binder) { | ||
binder | ||
.bind(CheMajorWebSocketEndpointExecutorServiceProvider.class) | ||
.to(MeteredCheMajorWebSocketEndpointExecutorServiceProvider.class); | ||
|
||
binder | ||
.bind(CheMinorWebSocketEndpointExecutorServiceProvider.class) | ||
.to(MeteredCheMinorWebSocketEndpointExecutorServiceProvider.class); | ||
} | ||
|
||
@Singleton | ||
public static class MeteredCheMajorWebSocketEndpointExecutorServiceProvider | ||
extends CheMajorWebSocketEndpointExecutorServiceProvider { | ||
|
||
private final PrometheusMeterRegistry meterRegistry; | ||
|
||
private ExecutorService executorService; | ||
|
||
@Inject | ||
public MeteredCheMajorWebSocketEndpointExecutorServiceProvider( | ||
@Named(JSON_RPC_MAJOR_CORE_POOL_SIZE_PARAMETER_NAME) int corePoolSize, | ||
@Named(JSON_RPC_MAJOR_MAX_POOL_SIZE_PARAMETER_NAME) int maxPoolSize, | ||
@Named(JSON_RPC_MAJOR_QUEUE_CAPACITY_PARAMETER_NAME) int queueCapacity, | ||
PrometheusMeterRegistry meterRegistry) { | ||
super(corePoolSize, maxPoolSize, queueCapacity); | ||
this.meterRegistry = meterRegistry; | ||
} | ||
|
||
@Override | ||
public synchronized ExecutorService get() { | ||
if (executorService == null) { | ||
executorService = | ||
ExecutorServiceMetrics.monitor( | ||
meterRegistry, | ||
super.get(), | ||
CheMajorWebSocketEndpointConfiguration.EXECUTOR_NAME, | ||
Tags.empty()); | ||
} | ||
return executorService; | ||
} | ||
} | ||
|
||
@Singleton | ||
public static class MeteredCheMinorWebSocketEndpointExecutorServiceProvider | ||
extends CheMinorWebSocketEndpointExecutorServiceProvider { | ||
private final PrometheusMeterRegistry meterRegistry; | ||
|
||
private ExecutorService executorService; | ||
|
||
@Inject | ||
public MeteredCheMinorWebSocketEndpointExecutorServiceProvider( | ||
@Named(JSON_RPC_MINOR_CORE_POOL_SIZE_PARAMETER_NAME) int corePoolSize, | ||
@Named(JSON_RPC_MINOR_MAX_POOL_SIZE_PARAMETER_NAME) int maxPoolSize, | ||
@Named(JSON_RPC_MINOR_QUEUE_CAPACITY_PARAMETER_NAME) int queueCapacity, | ||
PrometheusMeterRegistry meterRegistry) { | ||
super(corePoolSize, maxPoolSize, queueCapacity); | ||
this.meterRegistry = meterRegistry; | ||
} | ||
|
||
@Override | ||
public synchronized ExecutorService get() { | ||
if (executorService == null) { | ||
|
||
executorService = | ||
ExecutorServiceMetrics.monitor( | ||
meterRegistry, | ||
super.get(), | ||
CheMinorWebSocketEndpointConfiguration.EXECUTOR_NAME, | ||
Tags.empty()); | ||
} | ||
return executorService; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
.../main/java/org/eclipse/che/api/deploy/jsonrpc/CheJsonRpcWebSocketConfigurationModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright (c) 2012-2018 Red Hat, Inc. | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
package org.eclipse.che.api.deploy.jsonrpc; | ||
|
||
import com.google.inject.Binder; | ||
import com.google.inject.Module; | ||
import com.google.inject.multibindings.Multibinder; | ||
import com.google.inject.name.Names; | ||
import java.util.concurrent.ExecutorService; | ||
import org.eclipse.che.api.core.jsonrpc.commons.RequestProcessorConfigurationProvider; | ||
|
||
/** Configures JSON RPC WebSocket Endpoints. */ | ||
public class CheJsonRpcWebSocketConfigurationModule implements Module { | ||
@Override | ||
public void configure(Binder binder) { | ||
binder | ||
.bind(ExecutorService.class) | ||
.annotatedWith(Names.named(CheMajorWebSocketEndpointConfiguration.EXECUTOR_NAME)) | ||
.toProvider(CheMajorWebSocketEndpointExecutorServiceProvider.class); | ||
|
||
binder | ||
.bind(ExecutorService.class) | ||
.annotatedWith(Names.named(CheMinorWebSocketEndpointConfiguration.EXECUTOR_NAME)) | ||
.toProvider(CheMinorWebSocketEndpointExecutorServiceProvider.class); | ||
|
||
Multibinder<RequestProcessorConfigurationProvider.Configuration> configurationMultibinder = | ||
Multibinder.newSetBinder(binder, RequestProcessorConfigurationProvider.Configuration.class); | ||
configurationMultibinder.addBinding().to(CheMajorWebSocketEndpointConfiguration.class); | ||
configurationMultibinder.addBinding().to(CheMinorWebSocketEndpointConfiguration.class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
.../main/java/org/eclipse/che/api/deploy/jsonrpc/CheMajorWebSocketEndpointConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright (c) 2012-2018 Red Hat, Inc. | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
package org.eclipse.che.api.deploy.jsonrpc; | ||
|
||
import java.util.concurrent.ExecutorService; | ||
import javax.inject.Inject; | ||
import javax.inject.Named; | ||
import org.eclipse.che.api.core.jsonrpc.commons.RequestProcessorConfigurationProvider; | ||
|
||
/** | ||
* {@link RequestProcessorConfigurationProvider.Configuration} implementation used to configure | ||
* {@link CheMajorWebSocketEndpoint} | ||
*/ | ||
public class CheMajorWebSocketEndpointConfiguration | ||
implements RequestProcessorConfigurationProvider.Configuration { | ||
|
||
private final ExecutorService executor; | ||
|
||
public static final String EXECUTOR_NAME = "che.core.jsonrpc.major_executor"; | ||
|
||
@Inject | ||
public CheMajorWebSocketEndpointConfiguration(@Named(EXECUTOR_NAME) ExecutorService executor) { | ||
this.executor = executor; | ||
} | ||
|
||
@Override | ||
public String getEndpointId() { | ||
return CheMajorWebSocketEndpoint.ENDPOINT_ID; | ||
} | ||
|
||
@Override | ||
public ExecutorService getExecutorService() { | ||
return executor; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
.../org/eclipse/che/api/deploy/jsonrpc/CheMajorWebSocketEndpointExecutorServiceProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright (c) 2012-2018 Red Hat, Inc. | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
package org.eclipse.che.api.deploy.jsonrpc; | ||
|
||
import java.util.concurrent.ExecutorService; | ||
import javax.inject.Inject; | ||
import javax.inject.Named; | ||
import javax.inject.Singleton; | ||
import org.eclipse.che.commons.lang.execution.ExecutorServiceProvider; | ||
|
||
/** {@link ExecutorService} provider used in {@link CheMajorWebSocketEndpoint}. */ | ||
@Singleton | ||
public class CheMajorWebSocketEndpointExecutorServiceProvider extends ExecutorServiceProvider { | ||
|
||
public static final String JSON_RPC_MAJOR_CORE_POOL_SIZE_PARAMETER_NAME = | ||
"che.core.jsonrpc.processor_core_pool_size"; | ||
public static final String JSON_RPC_MAJOR_MAX_POOL_SIZE_PARAMETER_NAME = | ||
"che.core.jsonrpc.processor_max_pool_size"; | ||
public static final String JSON_RPC_MAJOR_QUEUE_CAPACITY_PARAMETER_NAME = | ||
"che.core.jsonrpc.processor_queue_capacity"; | ||
|
||
@Inject | ||
public CheMajorWebSocketEndpointExecutorServiceProvider( | ||
@Named(JSON_RPC_MAJOR_CORE_POOL_SIZE_PARAMETER_NAME) int corePoolSize, | ||
@Named(JSON_RPC_MAJOR_MAX_POOL_SIZE_PARAMETER_NAME) int maxPoolSize, | ||
@Named(JSON_RPC_MAJOR_QUEUE_CAPACITY_PARAMETER_NAME) int queueCapacity) { | ||
super(corePoolSize, maxPoolSize, queueCapacity); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
.../main/java/org/eclipse/che/api/deploy/jsonrpc/CheMinorWebSocketEndpointConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright (c) 2012-2018 Red Hat, Inc. | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
package org.eclipse.che.api.deploy.jsonrpc; | ||
|
||
import java.util.concurrent.ExecutorService; | ||
import javax.inject.Inject; | ||
import javax.inject.Named; | ||
import org.eclipse.che.api.core.jsonrpc.commons.RequestProcessorConfigurationProvider; | ||
|
||
/** | ||
* {@link RequestProcessorConfigurationProvider.Configuration} implementation used to configure | ||
* {@link CheMinorWebSocketEndpoint} | ||
*/ | ||
public class CheMinorWebSocketEndpointConfiguration | ||
implements RequestProcessorConfigurationProvider.Configuration { | ||
|
||
private final ExecutorService executor; | ||
|
||
public static final String EXECUTOR_NAME = "che.core.jsonrpc.minor_executor"; | ||
|
||
@Inject | ||
public CheMinorWebSocketEndpointConfiguration(@Named(EXECUTOR_NAME) ExecutorService executor) { | ||
this.executor = executor; | ||
} | ||
|
||
@Override | ||
public String getEndpointId() { | ||
return CheMinorWebSocketEndpoint.ENDPOINT_ID; | ||
} | ||
|
||
@Override | ||
public ExecutorService getExecutorService() { | ||
return executor; | ||
} | ||
} |
Oops, something went wrong.