use of org.eclipse.che.api.workspace.server.hc.probe.HttpProbeConfig in project che-server by eclipse-che.
the class TerminalServerLivenessProbeConfigFactory method get.
@Override
public HttpProbeConfig get(String userId, String workspaceId, Server server) throws InternalInfrastructureException {
URI uri;
try {
uri = new URI(server.getUrl());
} catch (URISyntaxException e) {
throw new InternalInfrastructureException("Terminal agent server liveness probe url is invalid. Error: " + e.getMessage());
}
String protocol;
if ("wss".equals(uri.getScheme())) {
protocol = "https";
} else {
protocol = "http";
}
int port;
if (uri.getPort() == -1) {
if ("http".equals(protocol)) {
port = 80;
} else {
port = 443;
}
} else {
port = uri.getPort();
}
String path = uri.getPath().replaceFirst("/pty$", "/liveness");
return new HttpProbeConfig(port, uri.getHost(), protocol, path, null, successThreshold, 3, 120, 10, 10);
}
use of org.eclipse.che.api.workspace.server.hc.probe.HttpProbeConfig in project devspaces-images by redhat-developer.
the class TerminalServerLivenessProbeConfigFactory method get.
@Override
public HttpProbeConfig get(String userId, String workspaceId, Server server) throws InternalInfrastructureException {
URI uri;
try {
uri = new URI(server.getUrl());
} catch (URISyntaxException e) {
throw new InternalInfrastructureException("Terminal agent server liveness probe url is invalid. Error: " + e.getMessage());
}
String protocol;
if ("wss".equals(uri.getScheme())) {
protocol = "https";
} else {
protocol = "http";
}
int port;
if (uri.getPort() == -1) {
if ("http".equals(protocol)) {
port = 80;
} else {
port = 443;
}
} else {
port = uri.getPort();
}
String path = uri.getPath().replaceFirst("/pty$", "/liveness");
return new HttpProbeConfig(port, uri.getHost(), protocol, path, null, successThreshold, 3, 120, 10, 10);
}
use of org.eclipse.che.api.workspace.server.hc.probe.HttpProbeConfig in project devspaces-images by redhat-developer.
the class WsAgentServerLivenessProbeConfigFactory method get.
@Override
public HttpProbeConfig get(String userId, String workspaceId, Server server) throws InternalInfrastructureException {
try {
// add check path
URI uri = UriBuilder.fromUri(server.getUrl()).path("/liveness").build();
int port;
if (uri.getPort() == -1) {
if ("http".equals(uri.getScheme())) {
port = 80;
} else {
port = 443;
}
} else {
port = uri.getPort();
}
return new HttpProbeConfig(port, uri.getHost(), uri.getScheme(), uri.getPath(), singletonMap(HttpHeaders.AUTHORIZATION, "Bearer " + machineTokenProvider.getToken(userId, workspaceId)), successThreshold, 3, 120, 10, 10);
} catch (MachineTokenException e) {
throw new InternalInfrastructureException("Failed to retrieve workspace token for ws-agent server liveness probe. Error: " + e.getMessage());
} catch (UriBuilderException e) {
throw new InternalInfrastructureException("Wsagent server liveness probe url is invalid. Error: " + e.getMessage());
}
}
use of org.eclipse.che.api.workspace.server.hc.probe.HttpProbeConfig in project che-server by eclipse-che.
the class WsAgentServerLivenessProbeConfigFactory method get.
@Override
public HttpProbeConfig get(String userId, String workspaceId, Server server) throws InternalInfrastructureException {
try {
// add check path
URI uri = UriBuilder.fromUri(server.getUrl()).path("/liveness").build();
int port;
if (uri.getPort() == -1) {
if ("http".equals(uri.getScheme())) {
port = 80;
} else {
port = 443;
}
} else {
port = uri.getPort();
}
return new HttpProbeConfig(port, uri.getHost(), uri.getScheme(), uri.getPath(), singletonMap(HttpHeaders.AUTHORIZATION, "Bearer " + machineTokenProvider.getToken(userId, workspaceId)), successThreshold, 3, 120, 10, 10);
} catch (MachineTokenException e) {
throw new InternalInfrastructureException("Failed to retrieve workspace token for ws-agent server liveness probe. Error: " + e.getMessage());
} catch (UriBuilderException e) {
throw new InternalInfrastructureException("Wsagent server liveness probe url is invalid. Error: " + e.getMessage());
}
}
Aggregations