use of org.eclipse.che.api.core.model.workspace.Workspace in project che by eclipse.
the class AbstractPerspectiveAction method update.
/** {@inheritDoc} */
@Override
public final void update(@NotNull ActionEvent event) {
PerspectiveManager manager = event.getPerspectiveManager();
Presentation presentation = event.getPresentation();
boolean isWorkspaceRunning = false;
if (appContext != null) {
Workspace workspace = appContext.getWorkspace();
isWorkspaceRunning = workspace != null && WorkspaceStatus.RUNNING.equals(workspace.getStatus());
}
boolean inPerspective = perspectives == null || perspectives.isEmpty() ? true : perspectives.contains(manager.getPerspectiveId());
presentation.setEnabledAndVisible(inPerspective && isWorkspaceRunning);
if (inPerspective && isWorkspaceRunning) {
updateInPerspective(event);
}
}
use of org.eclipse.che.api.core.model.workspace.Workspace in project che by eclipse.
the class LocalWorkspaceFolderPathProvider method getPath.
@Override
public String getPath(@Assisted("workspace") String workspaceId) throws IOException {
if (!isWindows && hostProjectsFolder != null) {
return hostProjectsFolder;
}
try {
WorkspaceManager workspaceManager = this.workspaceManager.get();
Workspace workspace = workspaceManager.getWorkspace(workspaceId);
String wsName = workspace.getConfig().getName();
return doGetPathByName(wsName);
} catch (NotFoundException | ServerException e) {
throw new IOException(e.getLocalizedMessage());
}
}
use of org.eclipse.che.api.core.model.workspace.Workspace in project che by eclipse.
the class WorkspaceManagerTest method snapshottedAtAttributeIncludedToWorkspaceWhenStartingById.
@Test
public void snapshottedAtAttributeIncludedToWorkspaceWhenStartingById() throws Exception {
WorkspaceImpl workspace = createAndMockWorkspace();
mockSnapshots(workspace, 12345);
mockStart(workspace);
Workspace result = workspaceManager.startWorkspace(workspace.getId(), workspace.getConfig().getDefaultEnv(), false);
assertEquals(result.getAttributes().get(SNAPSHOTTED_AT_ATTRIBUTE_NAME), "12345");
}
use of org.eclipse.che.api.core.model.workspace.Workspace in project che by eclipse.
the class WorkspaceRuntimes method shutdown.
/**
* Terminates workspace runtimes service, so no more workspaces are allowed to start
* or to be stopped directly, all the running workspaces are going to be stopped,
* all the starting tasks will be eventually interrupted.
*
* @throws IllegalStateException
* if component shutdown is already called
*/
public void shutdown() throws InterruptedException {
if (!isShutdown.compareAndSet(false, true)) {
throw new IllegalStateException("Workspace runtimes service shutdown has been already called");
}
List<String> idsToStop;
try (@SuppressWarnings("unused") Unlocker u = locks.writeAllLock()) {
idsToStop = states.entrySet().stream().filter(e -> e.getValue().status != WorkspaceStatus.STOPPING).map(Map.Entry::getKey).collect(Collectors.toList());
states.clear();
}
if (!idsToStop.isEmpty()) {
LOG.info("Shutdown running environments, environments to stop: '{}'", idsToStop.size());
ExecutorService executor = Executors.newFixedThreadPool(2 * Runtime.getRuntime().availableProcessors(), new ThreadFactoryBuilder().setNameFormat("StopEnvironmentsPool-%d").setDaemon(false).build());
for (String id : idsToStop) {
executor.execute(() -> {
try {
envEngine.stop(id);
} catch (EnvironmentNotRunningException ignored) {
// might be already stopped
} catch (Exception x) {
LOG.error(x.getMessage(), x);
}
});
}
executor.shutdown();
try {
if (!executor.awaitTermination(30, TimeUnit.SECONDS)) {
executor.shutdownNow();
if (!executor.awaitTermination(60, TimeUnit.SECONDS)) {
LOG.error("Unable to stop runtimes termination pool");
}
}
} catch (InterruptedException e) {
executor.shutdownNow();
Thread.currentThread().interrupt();
}
}
}
use of org.eclipse.che.api.core.model.workspace.Workspace in project che by eclipse.
the class JpaTckModule method configure.
@Override
protected void configure() {
install(new JpaPersistModule("main"));
bind(DBInitializer.class).asEagerSingleton();
bind(SchemaInitializer.class).toInstance(new FlywaySchemaInitializer(H2TestHelper.inMemoryDefault(), "che-schema"));
bind(TckResourcesCleaner.class).to(H2JpaCleaner.class);
bind(new TypeLiteral<TckRepository<RecipeImpl>>() {
}).toInstance(new JpaTckRepository<>(RecipeImpl.class));
bind(new TypeLiteral<TckRepository<SnapshotImpl>>() {
}).toInstance(new JpaTckRepository<>(SnapshotImpl.class));
bind(new TypeLiteral<TckRepository<Workspace>>() {
}).toInstance(new TestWorkspacesTckRepository());
bind(new TypeLiteral<TckRepository<AccountImpl>>() {
}).toInstance(new JpaTckRepository<>(AccountImpl.class));
bind(RecipeDao.class).to(JpaRecipeDao.class);
bind(SnapshotDao.class).to(JpaSnapshotDao.class);
}
Aggregations