Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it possible to have distributed ProjectRegistry #9848

Merged
merged 50 commits into from
May 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
279a8f4
Adding pipeline
gazarenkov Feb 25, 2018
75110a8
Merge remote-tracking branch 'upstream/master'
Apr 4, 2018
303f689
del jenkinsfile
Apr 5, 2018
f9e5815
Merge remote-tracking branch 'upstream/master'
Apr 10, 2018
6fa7a55
Make exec agent not to use setsid for other than Linux envs
Apr 10, 2018
714aa1c
revert pom.xml
Apr 11, 2018
d778a01
goformat
Apr 11, 2018
95ee1cc
get projects folder from workkspace configuration
Apr 11, 2018
763848a
Merge remote-tracking branch 'upstream/master'
Apr 12, 2018
241390d
Merge remote-tracking branch 'upstream/master'
Apr 13, 2018
d625790
Merge with upstream
Apr 13, 2018
99abb5e
clean code
Apr 13, 2018
90b9167
clean code
Apr 13, 2018
127a79e
Fix calculation Projects Root so it wont cause NPE if there are no 'p…
gazarenkov Apr 16, 2018
2b5c11c
Revert "Fix calculation Projects Root so it wont cause NPE if there a…
gazarenkov Apr 16, 2018
f69fd75
Merge remote-tracking branch 'upstream/master'
gazarenkov Apr 16, 2018
1a407c0
Fix calculation Projects Root so it wont cause NPE if there are no 'p…
gazarenkov Apr 16, 2018
4fff97c
Merge remote-tracking branch 'upstream/master'
gazarenkov Apr 26, 2018
47faa53
replace provided attribute values with stored (src, out) in PlainJava…
gazarenkov Apr 26, 2018
e676928
Merge remote-tracking branch 'upstream/master'
gazarenkov Apr 29, 2018
82e4c17
fix PlainJavaProjectType for getting rid and deprecate using Settable…
gazarenkov Apr 29, 2018
3232ecc
remove comented code
May 3, 2018
65238e2
hide brouse source folder button, set source folder field as disabled
May 3, 2018
e6414e9
hide the browse source button, set source folder field to read only m…
May 4, 2018
d368a0d
adapt test for current changes on UI, set save button to enable state
May 4, 2018
7e56901
apply formatting
May 4, 2018
63eaf6e
fs cache PT
gazarenkov May 5, 2018
1eb3cb7
merge upstream
gazarenkov May 5, 2018
cd193c0
Merge branch 'master' of https://github.com/gazarenkov/che
gazarenkov May 5, 2018
32f0767
fix order of steps in the test
May 7, 2018
9139278
resolve conflicts, merge with master
May 7, 2018
98cba0d
Refactor RegisteredProject to make it possible to cache it (as DTO) t…
gazarenkov May 7, 2018
bef1d44
Merge branch 'master'
gazarenkov May 7, 2018
ad8f12d
resolve conflicts, merge with master
May 7, 2018
fa3b90a
Merge branch 'master' of https://github.com/gazarenkov/che
gazarenkov May 7, 2018
a59353d
Merge branch 'master'
gazarenkov May 7, 2018
6568ca3
merge upstream
gazarenkov May 7, 2018
ca96a2b
cache Projects and PTs to files
gazarenkov May 8, 2018
d8a2b0f
Make it possible to have several impls for ProjectRegistry preparing …
gazarenkov May 17, 2018
dd358ff
merge upstream
gazarenkov May 17, 2018
91606e4
merge upstream
gazarenkov May 18, 2018
be9433e
merge upstream
gazarenkov May 22, 2018
3118652
merge upstream
gazarenkov May 28, 2018
7a70bad
merge upstream
gazarenkov May 28, 2018
6205d8f
merge upstream
gazarenkov May 28, 2018
56a9348
Update MavenServerService.java
gazarenkov May 29, 2018
3a680bc
clean code
gazarenkov May 29, 2018
56377b8
small fix
gazarenkov May 30, 2018
7a67aa9
small fix
gazarenkov May 30, 2018
6266a5d
small fix
gazarenkov May 30, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.eclipse.che.api.project.server.impl.ProjectServiceApi;
import org.eclipse.che.api.project.server.impl.ProjectServiceApiFactory;
import org.eclipse.che.api.project.server.impl.ProjectServiceVcsStatusInjector;
import org.eclipse.che.api.project.server.impl.RootDirPathProvider;
import org.eclipse.che.api.project.server.impl.WorkspaceProjectSynchronizer;
import org.eclipse.che.api.search.server.SearchApiModule;
import org.eclipse.che.api.watcher.server.FileWatcherApiModule;
Expand Down Expand Up @@ -135,13 +136,15 @@ protected void configure() {
ProjectManager projectManager = injector.getInstance(ProjectManager.class);
FsManager fsManager = injector.getInstance(FsManager.class);
PathTransformer pathTransformer = injector.getInstance(PathTransformer.class);
RootDirPathProvider pathProvider = injector.getInstance(RootDirPathProvider.class);

projectManager.setType("/test", "java", false);

ResourcesPlugin resourcesPlugin =
new ResourcesPlugin(
indexDir.getAbsolutePath(),
root.getAbsolutePath(),
pathProvider,
// root.getAbsolutePath(),
() -> projectManager,
() -> pathTransformer,
() -> fsManager);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-project</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-project-shared</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-workspace</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.eclipse.che.api.project.server.impl.RegisteredProject;
import org.eclipse.che.api.project.shared.RegisteredProject;
import org.eclipse.core.resources.IBuildConfiguration;
import org.eclipse.core.resources.ICommand;
import org.eclipse.core.resources.IContainer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import org.eclipse.che.api.project.server.ProjectManager;
import org.eclipse.che.api.project.server.impl.RegisteredProject;
import org.eclipse.che.api.project.shared.RegisteredProject;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.eclipse.che.api.fs.server.FsManager;
import org.eclipse.che.api.fs.server.PathTransformer;
import org.eclipse.che.api.project.server.ProjectManager;
import org.eclipse.che.api.project.server.impl.RootDirPathProvider;
import org.eclipse.che.core.internal.resources.Workspace;
import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.internal.utils.Messages;
Expand Down Expand Up @@ -189,12 +190,12 @@ public class ResourcesPlugin {
@Inject
public ResourcesPlugin(
@Named("che.jdt.workspace.index.dir") String indexPath,
@Named("che.user.workspaces.storage") String workspacePath,
RootDirPathProvider pathProvider,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if keep in constructor
@Named("che.workspaces.storage") String workspacePath
and will use provider for this property

    bind(String.class)
        .annotatedWith(Names.named("che.workspaces.root.dir"))
        .toProvider(RootDirPathProvider.class);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why to make this logic more complex?

what needed is to inject configuration object (called RootDirPathProvider)?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you do not mind, I'll put in my five cents. Though technically there is almost no difference between two cases, I find it more comfortable to remember, to navigate and to use (in IDE) RootDirPathProvider class instead of a variable named "che.workspaces.root.dir" or "che.workspace.storage", it's much easier to access provider class (or property) documentation and so on. Probably it is caused by the way object oriented programmer thinks - in objects and classes, not properties and values.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ок

Provider<ProjectManager> projectManagerProvider,
Provider<PathTransformer> pathTransformerProvider,
Provider<FsManager> fsManagerProvider) {
ResourcesPlugin.indexPath = indexPath;
ResourcesPlugin.workspacePath = workspacePath;
ResourcesPlugin.workspacePath = pathProvider.get();
pluginId = "cheWsPlugin";
EFS.setWsPath(workspacePath);
workspace =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-dto</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-model</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-project</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
import javax.annotation.PreDestroy;
import org.eclipse.che.api.core.NotFoundException;
import org.eclipse.che.api.core.jsonrpc.commons.RequestTransmitter;
import org.eclipse.che.api.core.model.workspace.config.ProjectConfig;
import org.eclipse.che.api.core.notification.EventService;
import org.eclipse.che.api.core.notification.EventSubscriber;
import org.eclipse.che.api.editor.server.impl.EditorWorkingCopy;
import org.eclipse.che.api.editor.server.impl.EditorWorkingCopyManager;
import org.eclipse.che.api.editor.server.impl.EditorWorkingCopyUpdatedEvent;
import org.eclipse.che.api.project.server.ProjectManager;
import org.eclipse.che.api.project.server.impl.RegisteredProject;
import org.eclipse.che.api.project.shared.dto.EditorChangesDto;
import org.eclipse.che.api.project.shared.dto.ServerError;
import org.eclipse.che.api.project.shared.dto.event.FileTrackingOperationDto;
Expand Down Expand Up @@ -213,7 +213,7 @@ private void onFileOperation(String endpointId, FileTrackingOperationDto operati
case START:
{
String filePath = operation.getPath();
RegisteredProject project =
ProjectConfig project =
projectManager
.getClosest(filePath)
.orElseThrow(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@

import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.google.inject.name.Named;
import java.io.File;
import org.eclipse.che.api.core.NotFoundException;
import org.eclipse.che.api.core.model.workspace.config.ProjectConfig;
import org.eclipse.che.api.core.notification.EventService;
import org.eclipse.che.api.core.notification.EventSubscriber;
import org.eclipse.che.api.fs.server.PathTransformer;
import org.eclipse.che.api.project.server.ProjectManager;
import org.eclipse.che.api.project.server.impl.RootDirPathProvider;
import org.eclipse.che.api.project.server.notification.ProjectCreatedEvent;
import org.eclipse.che.api.project.server.notification.ProjectItemModifiedEvent;
import org.eclipse.che.api.project.server.type.ProjectTypeRegistry;
Expand All @@ -46,19 +45,16 @@ public class ProjectListeners {
private final File workspace;
private final ProjectManager projectRegistry;
private final ProjectTypeRegistry projectTypeRegistry;
private final PathTransformer pathTransformer;

@Inject
public ProjectListeners(
@Named("che.user.workspaces.storage") String workspacePath,
RootDirPathProvider pathProvider,
EventService eventService,
ProjectManager projectRegistry,
ProjectTypeRegistry projectTypeRegistry,
PathTransformer pathTransformer) {
ProjectTypeRegistry projectTypeRegistry) {
this.projectRegistry = projectRegistry;
this.projectTypeRegistry = projectTypeRegistry;
workspace = new File(workspacePath);
this.pathTransformer = pathTransformer;
workspace = new File(pathProvider.get());
eventService.subscribe(new ProjectCreated());
eventService.subscribe(
new EventSubscriber<ProjectItemModifiedEvent>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import java.util.Arrays;
import java.util.List;
import org.eclipse.che.api.core.ServerException;
import org.eclipse.che.api.core.model.workspace.config.ProjectConfig;
import org.eclipse.che.api.project.server.ProjectManager;
import org.eclipse.che.api.project.server.impl.RegisteredProject;
import org.eclipse.che.ide.ext.java.shared.Constants;
import org.eclipse.che.plugin.java.server.projecttype.AbstractJavaInitHandler;
import org.eclipse.jdt.core.IClasspathEntry;
Expand Down Expand Up @@ -70,7 +70,7 @@ protected void initializeClasspath(IJavaProject javaProject) throws ServerExcept
}

String wsPath = absolutize(javaProject.getPath().toOSString());
RegisteredProject project =
ProjectConfig project =
projectRegistryProvider
.get()
.get(wsPath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
import org.eclipse.che.api.core.ForbiddenException;
import org.eclipse.che.api.core.NotFoundException;
import org.eclipse.che.api.core.ServerException;
import org.eclipse.che.api.core.model.workspace.config.ProjectConfig;
import org.eclipse.che.api.fs.server.PathTransformer;
import org.eclipse.che.api.project.server.ProjectManager;
import org.eclipse.che.api.project.server.impl.NewProjectConfigImpl;
import org.eclipse.che.api.project.server.impl.RegisteredProject;
import org.eclipse.che.api.project.shared.NewProjectConfig;
import org.eclipse.che.ide.ext.java.shared.dto.classpath.ClasspathEntryDto;
import org.eclipse.core.runtime.IPath;
Expand Down Expand Up @@ -94,7 +94,7 @@ private void updateProjectConfig(String projectWsPath)
throws IOException, ForbiddenException, ConflictException, NotFoundException, ServerException,
BadRequestException {
String wsPath = absolutize(projectWsPath);
RegisteredProject project =
ProjectConfig project =
projectManager
.get(wsPath)
.orElseThrow(() -> new NotFoundException("Can't find project: " + projectWsPath));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import java.util.Map;
import java.util.Optional;
import org.eclipse.che.api.project.server.ProjectManager;
import org.eclipse.che.api.project.server.impl.RegisteredProject;
import org.eclipse.che.api.project.shared.RegisteredProject;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.InjectMocks;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
import org.eclipse.che.api.core.ForbiddenException;
import org.eclipse.che.api.core.NotFoundException;
import org.eclipse.che.api.core.ServerException;
import org.eclipse.che.api.core.model.workspace.config.ProjectConfig;
import org.eclipse.che.api.core.notification.EventService;
import org.eclipse.che.api.core.notification.EventSubscriber;
import org.eclipse.che.api.project.server.ProjectManager;
import org.eclipse.che.api.project.server.impl.RegisteredProject;
import org.eclipse.che.api.project.server.notification.ProjectDeletedEvent;
import org.eclipse.che.ide.ext.java.shared.Constants;
import org.eclipse.che.jdt.core.launching.JREContainerInitializer;
Expand Down Expand Up @@ -240,7 +240,7 @@ private void addSourcesFromBuildHelperPlugin(MavenProject project) {
"org.codehaus.mojo", "build-helper-maven-plugin", "add-test-source");

IPath projectPath = project.getProject().getFullPath();
RegisteredProject registeredProject =
ProjectConfig registeredProject =
projectManagerProvider
.get()
.get(projectPath.toOSString())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@

import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.google.inject.name.Named;
import java.io.File;
import java.util.Collections;
import java.util.List;
import org.eclipse.che.api.project.server.impl.RootDirPathProvider;
import org.eclipse.che.maven.data.MavenArtifact;
import org.eclipse.che.maven.data.MavenArtifactKey;
import org.eclipse.che.maven.data.MavenRemoteRepository;
Expand Down Expand Up @@ -64,13 +64,13 @@ public class ClasspathManager {

@Inject
public ClasspathManager(
@Named("che.user.workspaces.storage") String workspacePath,
RootDirPathProvider pathProvider,
MavenWrapperManager wrapperManager,
MavenProjectManager projectManager,
MavenTerminal terminal,
MavenProgressNotifier notifier) {

this.workspacePath = workspacePath;
this.workspacePath = pathProvider.get();
this.wrapperManager = wrapperManager;
this.projectManager = projectManager;
this.terminal = terminal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.google.inject.name.Named;
import java.io.File;
import java.util.HashSet;
import java.util.List;
Expand All @@ -24,6 +23,7 @@
import org.eclipse.che.api.core.notification.EventSubscriber;
import org.eclipse.che.api.editor.server.impl.EditorWorkingCopy;
import org.eclipse.che.api.editor.server.impl.EditorWorkingCopyManager;
import org.eclipse.che.api.project.server.impl.RootDirPathProvider;
import org.eclipse.che.api.project.server.notification.ProjectItemModifiedEvent;
import org.eclipse.che.api.project.shared.dto.event.PomModifiedEventDto;
import org.eclipse.che.commons.schedule.executor.ThreadPullLauncher;
Expand Down Expand Up @@ -52,11 +52,11 @@ public PomChangeListener(
EclipseWorkspaceProvider eclipseWorkspaceProvider,
EditorWorkingCopyManager editorWorkingCopyManager,
ThreadPullLauncher launcher,
@Named("che.user.workspaces.storage") String workspacePath) {
RootDirPathProvider pathProvider) {
this.mavenWorkspace = mavenWorkspace;
this.eclipseWorkspaceProvider = eclipseWorkspaceProvider;
this.editorWorkingCopyManager = editorWorkingCopyManager;
this.workspacePath = workspacePath;
this.workspacePath = pathProvider.get();

launcher.scheduleWithFixedDelay(this::updateProms, 20, 3, TimeUnit.SECONDS);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
import java.nio.file.PathMatcher;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.eclipse.che.api.core.model.workspace.config.ProjectConfig;
import org.eclipse.che.api.fs.server.PathTransformer;
import org.eclipse.che.api.project.server.ProjectManager;
import org.eclipse.che.api.project.server.impl.RegisteredProject;
import org.eclipse.che.plugin.maven.shared.MavenAttributes;

@Singleton
Expand All @@ -34,7 +34,7 @@ public MavenTargetExcludeMatcher(ProjectManager projectManager, PathTransformer
@Override
public boolean matches(Path fsPath) {
String wsPath = pathTransformer.transform(fsPath);
RegisteredProject project = projectManager.getClosestOrNull(wsPath);
ProjectConfig project = projectManager.getClosestOrNull(wsPath);
if (project == null) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import org.eclipse.che.api.core.ServerException;
import org.eclipse.che.api.fs.server.FsManager;
import org.eclipse.che.api.project.server.ProjectManager;
import org.eclipse.che.api.project.server.impl.RegisteredProject;
import org.eclipse.che.maven.server.MavenTerminal;
import org.eclipse.che.plugin.maven.server.MavenServerWrapper;
import org.eclipse.che.plugin.maven.server.MavenWrapperManager;
Expand Down Expand Up @@ -104,11 +103,6 @@ public String getEffectivePom(@QueryParam("projectpath") String projectPath)
throws ServerException, NotFoundException, ForbiddenException {
String projectWsPath = absolutize(projectPath);

RegisteredProject project =
projectManager
.get(projectWsPath)
.orElseThrow(() -> new NotFoundException("Can't find project: " + projectWsPath));

MavenServerWrapper mavenServer =
wrapperManager.getMavenServer(MavenWrapperManager.ServerType.DOWNLOAD);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-git-shared</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-model</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-project</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
import org.eclipse.che.api.core.ForbiddenException;
import org.eclipse.che.api.core.NotFoundException;
import org.eclipse.che.api.core.ServerException;
import org.eclipse.che.api.core.model.workspace.config.ProjectConfig;
import org.eclipse.che.api.core.notification.EventService;
import org.eclipse.che.api.core.notification.EventSubscriber;
import org.eclipse.che.api.git.shared.event.GitRepositoryDeletedEvent;
import org.eclipse.che.api.project.server.ProjectManager;
import org.eclipse.che.api.project.server.impl.NewProjectConfigImpl;
import org.eclipse.che.api.project.server.impl.RegisteredProject;
import org.slf4j.Logger;

/** @author Vitalii Parfonov */
Expand Down Expand Up @@ -65,7 +65,7 @@ private void onGitRepositoryDeletedEventReceived(String projectPath) {
try {
ProjectManager projectManager = projectManagerProvider.get();
projectManager.removeType(projectPath, CONTRIBUTION_PROJECT_TYPE_ID);
RegisteredProject project = projectManager.get(projectPath).get();
ProjectConfig project = projectManager.get(projectPath).get();
Map<String, List<String>> attributes = project.getAttributes();
attributes.remove(CONTRIBUTE_LOCAL_BRANCH_NAME);
attributes.remove(CONTRIBUTE_TO_BRANCH_VARIABLE_NAME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
*/
package org.eclipse.che.plugin.java.testing;

import com.google.inject.name.Named;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.eclipse.che.api.project.server.impl.RootDirPathProvider;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaProject;
Expand All @@ -34,8 +34,8 @@ public class ProjectClasspathProvider {
private final String workspacePath;

@Inject
public ProjectClasspathProvider(@Named("che.user.workspaces.storage") String workspacePath) {
this.workspacePath = workspacePath;
public ProjectClasspathProvider(RootDirPathProvider pathProvider) {
this.workspacePath = pathProvider.get();
}

/**
Expand Down
Loading