-
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.
Merge branch 'master' into openshift_init_patch3
Signed-off-by: James Drummond <james@devcomb.com>
- Loading branch information
Showing
8,083 changed files
with
14,840 additions
and
10,242 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
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
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
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
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,50 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (c) 2012-2018 Red Hat, Inc. | ||
All rights reserved. This program and the accompanying materials | ||
are made available under the terms of the Eclipse Public License v1.0 | ||
which accompanies this distribution, and is available at | ||
http://www.eclipse.org/legal/epl-v10.html | ||
Contributors: | ||
Red Hat, Inc. - initial API and implementation | ||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<artifactId>exec-agent-parent</artifactId> | ||
<groupId>org.eclipse.che</groupId> | ||
<version>6.0.0-M5-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>che-exec-agent-client</artifactId> | ||
<packaging>jar</packaging> | ||
<name>Agent :: Exec :: Client</name> | ||
<dependencies> | ||
<dependency> | ||
<groupId>com.google.inject.extensions</groupId> | ||
<artifactId>guice-assistedinject</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>javax.inject</groupId> | ||
<artifactId>javax.inject</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.che</groupId> | ||
<artifactId>che-exec-agent-shared</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.che.core</groupId> | ||
<artifactId>che-core-api-core</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.che.core</groupId> | ||
<artifactId>che-core-api-dto</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.che.core</groupId> | ||
<artifactId>che-core-api-workspace</artifactId> | ||
</dependency> | ||
</dependencies> | ||
</project> |
120 changes: 120 additions & 0 deletions
120
...he-exec-agent-client/src/main/java/org/eclipse/che/agent/exec/client/ExecAgentClient.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,120 @@ | ||
/* | ||
* Copyright (c) 2012-2018 Red Hat, Inc. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
package org.eclipse.che.agent.exec.client; | ||
|
||
import static org.eclipse.che.dto.server.DtoFactory.newDto; | ||
|
||
import com.google.inject.assistedinject.Assisted; | ||
import java.io.IOException; | ||
import javax.inject.Inject; | ||
import org.eclipse.che.agent.exec.shared.dto.GetProcessResponseDto; | ||
import org.eclipse.che.agent.exec.shared.dto.ProcessKillResponseDto; | ||
import org.eclipse.che.agent.exec.shared.dto.ProcessStartRequestDto; | ||
import org.eclipse.che.agent.exec.shared.dto.ProcessStartResponseDto; | ||
import org.eclipse.che.api.core.ApiException; | ||
import org.eclipse.che.api.core.ServerException; | ||
import org.eclipse.che.api.core.rest.HttpJsonRequestFactory; | ||
import org.eclipse.che.api.workspace.server.token.MachineTokenException; | ||
import org.eclipse.che.api.workspace.server.token.MachineTokenProvider; | ||
|
||
/** | ||
* Helps to interact with exec agent via REST. | ||
* | ||
* @author Max Shaposhnik (mshaposh@redhat.com) | ||
*/ | ||
public class ExecAgentClient { | ||
|
||
private final HttpJsonRequestFactory requestFactory; | ||
private final MachineTokenProvider machineTokenProvider; | ||
private final String serverEndpoint; | ||
|
||
@Inject | ||
public ExecAgentClient( | ||
HttpJsonRequestFactory requestFactory, | ||
MachineTokenProvider machineTokenProvider, | ||
@Assisted String serverEndpoint) { | ||
this.requestFactory = requestFactory; | ||
this.machineTokenProvider = machineTokenProvider; | ||
this.serverEndpoint = serverEndpoint; | ||
} | ||
|
||
/** | ||
* Starts a process within a given command. | ||
* | ||
* @param workspaceId workspace to run command | ||
* @param command command to execute | ||
* @param name command name | ||
* @param type command type | ||
* @return start process response DTO | ||
* @throws ServerException when submit of the process is failed | ||
*/ | ||
public ProcessStartResponseDto startProcess( | ||
String workspaceId, String command, String name, String type) throws ServerException { | ||
ProcessStartRequestDto commandDto = | ||
newDto(ProcessStartRequestDto.class).withCommandLine(command).withName(name).withType(type); | ||
try { | ||
return requestFactory | ||
.fromUrl(serverEndpoint) | ||
.addQueryParam("token", machineTokenProvider.getToken(workspaceId)) | ||
.setAuthorizationHeader("none") // to prevent sending KC token | ||
.usePostMethod() | ||
.setBody(commandDto) | ||
.request() | ||
.asDto(ProcessStartResponseDto.class); | ||
} catch (IOException | ApiException | MachineTokenException e) { | ||
throw new ServerException(e); | ||
} | ||
} | ||
|
||
/** | ||
* Gets information about started process. | ||
* | ||
* @param workspaceId workspace to get process | ||
* @param pid pid of started process | ||
* @return process response DTO | ||
* @throws ServerException when get of the process is failed | ||
*/ | ||
public GetProcessResponseDto getProcess(String workspaceId, int pid) throws ServerException { | ||
try { | ||
return requestFactory | ||
.fromUrl(serverEndpoint + "/" + pid) | ||
.addQueryParam("token", machineTokenProvider.getToken(workspaceId)) | ||
.setAuthorizationHeader("none") // to prevent sending KC token | ||
.useGetMethod() | ||
.request() | ||
.asDto(GetProcessResponseDto.class); | ||
} catch (IOException | ApiException | MachineTokenException e) { | ||
throw new ServerException(e); | ||
} | ||
} | ||
|
||
/** | ||
* Kills started process. | ||
* | ||
* @param workspaceId workspace kill process | ||
* @param pid pid of started process | ||
* @return kill process response DTO | ||
* @throws ServerException when kill of the process is failed | ||
*/ | ||
public ProcessKillResponseDto killProcess(String workspaceId, int pid) throws ServerException { | ||
try { | ||
return requestFactory | ||
.fromUrl(serverEndpoint + "/" + pid) | ||
.useDeleteMethod() | ||
.addQueryParam("token", machineTokenProvider.getToken(workspaceId)) | ||
.setAuthorizationHeader("none") // to prevent sending KC token | ||
.request() | ||
.asDto(ProcessKillResponseDto.class); | ||
} catch (IOException | ApiException | MachineTokenException e) { | ||
throw new ServerException(e); | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...-agent-client/src/main/java/org/eclipse/che/agent/exec/client/ExecAgentClientFactory.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,21 @@ | ||
/* | ||
* Copyright (c) 2012-2018 Red Hat, Inc. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
package org.eclipse.che.agent.exec.client; | ||
|
||
/** | ||
* Creates instances of {@link ExecAgentClient} with given exec server endpoint. | ||
* | ||
* @author Max Shaposhnik (mshaposh@redhat.com) | ||
*/ | ||
public interface ExecAgentClientFactory { | ||
|
||
ExecAgentClient create(String serverEndpoint); | ||
} |
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,115 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (c) 2012-2018 Red Hat, Inc. | ||
All rights reserved. This program and the accompanying materials | ||
are made available under the terms of the Eclipse Public License v1.0 | ||
which accompanies this distribution, and is available at | ||
http://www.eclipse.org/legal/epl-v10.html | ||
Contributors: | ||
Red Hat, Inc. - initial API and implementation | ||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<artifactId>exec-agent-parent</artifactId> | ||
<groupId>org.eclipse.che</groupId> | ||
<version>6.0.0-M5-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>che-exec-agent-shared</artifactId> | ||
<packaging>jar</packaging> | ||
<name>Agent :: Exec :: Shared</name> | ||
<properties> | ||
<dto-generator-out-directory>${project.build.directory}/generated-sources/dto/</dto-generator-out-directory> | ||
</properties> | ||
<dependencies> | ||
<dependency> | ||
<groupId>com.google.code.gson</groupId> | ||
<artifactId>gson</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.che.core</groupId> | ||
<artifactId>che-core-api-dto</artifactId> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>build-helper-maven-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>add-resource</id> | ||
<phase>process-sources</phase> | ||
<goals> | ||
<goal>add-resource</goal> | ||
</goals> | ||
<configuration> | ||
<resources> | ||
<resource> | ||
<directory>${dto-generator-out-directory}/META-INF</directory> | ||
<targetPath>META-INF</targetPath> | ||
</resource> | ||
</resources> | ||
</configuration> | ||
</execution> | ||
<execution> | ||
<id>add-source</id> | ||
<phase>process-sources</phase> | ||
<goals> | ||
<goal>add-source</goal> | ||
</goals> | ||
<configuration> | ||
<sources> | ||
<source>${dto-generator-out-directory}</source> | ||
</sources> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>pre-compile</id> | ||
<phase>generate-sources</phase> | ||
<goals> | ||
<goal>compile</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.eclipse.che.core</groupId> | ||
<artifactId>che-core-api-dto-maven-plugin</artifactId> | ||
<version>${project.version}</version> | ||
<executions> | ||
<execution> | ||
<id>server</id> | ||
<phase>process-sources</phase> | ||
<goals> | ||
<goal>generate</goal> | ||
</goals> | ||
<configuration> | ||
<dtoPackages> | ||
<package>org.eclipse.che.agent.exec.shared.dto</package> | ||
</dtoPackages> | ||
<outputDirectory>${dto-generator-out-directory}</outputDirectory> | ||
<genClassName>org.eclipse.che.agent.exec.shared.dto.server.DtoServerImpls</genClassName> | ||
<impl>server</impl> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.eclipse.che</groupId> | ||
<artifactId>che-exec-agent-shared</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
</dependencies> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
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
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
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
Oops, something went wrong.