congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
org.eclipse.che.api.workspace.server
Code IndexAdd Tabnine to your IDE (free)

How to use org.eclipse.che.api.workspace.server

Best Java code snippets using org.eclipse.che.api.workspace.server (Showing top 20 results out of 315)

origin: org.eclipse.che.core/che-core-api-workspace

/**
 * Gets workspace status by its identifier.
 *
 * @param workspaceId workspace identifier
 */
public WorkspaceStatus getStatus(String workspaceId) {
 try (Unlocker ignored = lockService.readLock(workspaceId)) {
  final WorkspaceStatus status = statuses.get(workspaceId);
  return status != null ? status : STOPPED;
 }
}
origin: org.eclipse.che.core/che-core-api-workspace

/** Returns a set of supported recipe types */
public Set<String> getSupportedRecipes() {
 return runtimes.getSupportedRecipes();
}
origin: org.eclipse.che.core/che-core-api-workspace

/**
 * Returns true if workspace was started and its status is {@link WorkspaceStatus#RUNNING
 * running}, {@link WorkspaceStatus#STARTING starting} or {@link WorkspaceStatus#STOPPING
 * stopping} - otherwise returns false.
 *
 * @param workspaceId workspace identifier to perform check
 * @return true if workspace is running, otherwise false
 */
public boolean hasRuntime(String workspaceId) {
 return statuses.get(workspaceId) != null;
}
origin: org.eclipse.che.core/che-core-api-workspace

/**
 * Injects runtime information such as status and {@link
 * org.eclipse.che.api.core.model.workspace.Runtime} into the workspace object, if the workspace
 * doesn't have runtime sets the status to {@link WorkspaceStatus#STOPPED}.
 *
 * @param workspace the workspace to inject runtime into
 */
public void injectRuntime(WorkspaceImpl workspace) throws ServerException {
 try (Unlocker ignored = lockService.writeLock(workspace.getId())) {
  WorkspaceStatus workspaceStatus = statuses.get(workspace.getId());
  if (workspaceStatus == null) {
   workspace.setStatus(STOPPED);
   return;
  }
  InternalRuntime<?> internalRuntime;
  try {
   internalRuntime = getInternalRuntime(workspace.getId());
  } catch (ServerException | InfrastructureException e) {
   workspace.setStatus(STOPPED);
   return;
  }
  workspace.setRuntime(asRuntime(internalRuntime));
  workspace.setStatus(workspaceStatus);
 }
}
origin: org.eclipse.che.core/che-core-api-workspace

private WorkspaceImpl normalizeState(WorkspaceImpl workspace, boolean includeRuntimes)
  throws ServerException {
 if (includeRuntimes) {
  runtimes.injectRuntime(workspace);
 } else {
  workspace.setStatus(runtimes.getStatus(workspace.getId()));
 }
 return workspace;
}
origin: org.eclipse.che.core/che-core-api-workspace

/**
 * Blocks starting new workspaces and stops all that already running
 *
 * @throws InterruptedException
 */
@Override
public void terminate() throws InterruptedException {
 Preconditions.checkState(runtimes.refuseStart());
 WorkspaceStoppedEventsPropagator propagator = new WorkspaceStoppedEventsPropagator();
 eventService.subscribe(propagator);
 try {
  stopRunningAndStartingWorkspacesAsync();
  waitAllWorkspacesStopped();
  sharedPool.shutdown();
 } finally {
  eventService.unsubscribe(propagator);
 }
 try {
  workspaceRemover.shutdown();
 } catch (Exception ignored) {
 }
}
origin: org.eclipse.che.core/che-core-api-workspace

/**
 * Blocks starting new workspaces and waits until all workspaces that are currently in a
 * starting/stopping state to finish this process
 *
 * @throws InterruptedException
 * @throws UnsupportedOperationException
 */
@Override
public void suspend() throws InterruptedException, UnsupportedOperationException {
 try {
  runtimeInfrastructure.getIdentities();
 } catch (UnsupportedOperationException | InfrastructureException e) {
  throw new UnsupportedOperationException("Current infrastructure does not support suspend.");
 }
 Preconditions.checkState(runtimes.refuseStart());
 WorkspaceSuspendedEventsPropagator propagator = new WorkspaceSuspendedEventsPropagator();
 eventService.subscribe(propagator);
 try {
  waitAllWorkspacesRunningOrStopped();
  sharedPool.shutdown();
 } finally {
  eventService.unsubscribe(propagator);
 }
 try {
  workspaceRemover.shutdown();
 } catch (Exception ignored) {
 }
}
origin: org.eclipse.che.core/che-core-api-workspace

private WorkspaceDto asDtoWithLinksAndToken(Workspace workspace) throws ServerException {
 WorkspaceDto workspaceDto =
   asDto(workspace).withLinks(linksGenerator.genLinks(workspace, getServiceContext()));
 RuntimeDto runtimeDto = workspaceDto.getRuntime();
 if (runtimeDto != null) {
  try {
   runtimeDto.setMachineToken(machineTokenProvider.getToken(workspace.getId()));
  } catch (MachineAccessForbidden e) {
   // set runtime to null since user doesn't have the required permissions
   workspaceDto.setRuntime(null);
  } catch (MachineTokenException e) {
   throw new ServerException(e.getMessage(), e);
  }
 }
 return workspaceDto;
}
origin: org.eclipse.che.core/che-core-api-workspace

private void stopRunningAndStartingWorkspacesAsync() {
 for (String workspaceId : runtimes.getActive()) {
  WorkspaceStatus status = runtimes.getStatus(workspaceId);
  if (status == WorkspaceStatus.RUNNING || status == WorkspaceStatus.STARTING) {
   try {
    manager.stopWorkspace(workspaceId, Collections.emptyMap());
   } catch (ServerException | ConflictException | NotFoundException x) {
    if (runtimes.hasRuntime(workspaceId)) {
     LOG.error(
       "Couldn't get the workspace '{}' while it's running, the occurred error: '{}'",
       workspaceId,
       x.getMessage());
    }
   }
  }
 }
}
origin: org.eclipse.che.core/che-core-api-workspace

@Override
protected InternalEnvironment doCreate(
  @Nullable InternalRecipe recipe,
  Map<String, InternalMachineConfig> machines,
  List<Warning> warnings)
  throws InternalInfrastructureException {
 if (recipe != null) {
  throw new InternalInfrastructureException(
    "No environment factory doesn't accept non-null workspace recipes");
 }
 return new NoEnvInternalEnvironment();
}
origin: org.eclipse.che.core/che-core-api-workspace

@PostConstruct
void init() {
 subscribeAbnormalRuntimeStopListener();
 recover();
}
origin: org.eclipse.che.core/che-core-api-workspace

private List<WorkspaceDto> withLinks(List<WorkspaceDto> workspaces) throws ServerException {
 for (WorkspaceDto workspace : workspaces) {
  workspace.setLinks(linksGenerator.genLinks(workspace, getServiceContext()));
 }
 return workspaces;
}
origin: org.eclipse.che.core/che-core-api-workspace

private void subscribeAbnormalRuntimeStopListener() {
 eventService.subscribe(new AbnormalRuntimeStoppingListener());
 eventService.subscribe(new AbnormalRuntimeStoppedListener());
}
origin: org.eclipse.che.core/che-core-api-workspace

private Workspace doUpdate(String id, Workspace update)
  throws BadRequestException, ConflictException, NotFoundException, ServerException {
 try {
  return workspaceManager.updateWorkspace(id, update);
 } catch (ValidationException x) {
  throw new BadRequestException(x.getMessage());
 }
}
origin: org.eclipse.che.core/che-core-api-workspace

/**
 * Returns true if there is at least one workspace active(it's status is different from {@link
 * WorkspaceStatus#STOPPED}), otherwise returns false.
 */
public boolean isAnyActive() {
 return !statuses.asMap().isEmpty();
}
origin: org.eclipse.che.core/che-core-api-workspace

 @Override
 public void run() {
  if (!runtimes.isAnyInProgress()) {
   timer.cancel();
   latch.countDown();
  }
 }
},
origin: org.eclipse.che.core/che-core-api-workspace

 @Override
 public void run() {
  if (!runtimes.isAnyActive()) {
   timer.cancel();
   latch.countDown();
  }
 }
},
origin: org.eclipse.che.core/che-core-api-workspace

private WorkspaceStoppedEventsPropagator() {
 this.totalRunning = runtimes.getActive().size();
 this.currentlyStopped = new AtomicInteger(0);
}
origin: org.eclipse.che.core/che-core-api-workspace

private void relativizeRecipeLinks(WorkspaceConfigDto config) {
 if (config != null) {
  Map<String, EnvironmentDto> environments = config.getEnvironments();
  if (environments != null && !environments.isEmpty()) {
   for (EnvironmentDto environment : environments.values()) {
    relativizeRecipeLinks(environment);
   }
  }
 }
}
origin: org.eclipse.che.core/che-core-api-workspace

/**
 * Gets the workspaces identifiers managed by this component. If an identifier is present in set
 * then that workspace wasn't stopped at the moment of method execution.
 *
 * @return workspaces identifiers for those workspaces that are active(not stopped), or an empty
 *     set if there is no a single active workspace
 */
public Set<String> getActive() {
 return ImmutableSet.copyOf(statuses.asMap().keySet());
}
org.eclipse.che.api.workspace.server

Most used classes

  • WorkspaceImpl
    Data object for Workspace.
  • InternalEnvironment
    Representation of Environment which holds internal representations of environment components to ease
  • InternalMachineConfig
    Machine Config to use inside infrastructure.It contains: * retrieved full information about installe
  • WorkspaceManager
    Facade for Workspace related operations.
  • BeforeWorkspaceRemovedEvent
    Published before WorkspaceImpl removed.
  • StackImpl,
  • InfrastructureException,
  • InternalEnvironmentFactory,
  • InternalRecipe,
  • WorkspaceRuntimes,
  • WsAgentMachineFinderUtil,
  • BeforeStackRemovedEvent,
  • StackPersistedEvent,
  • JpaStackDao,
  • EnvironmentImpl,
  • RecipeImpl,
  • ServerConfigImpl,
  • InternalInfrastructureException,
  • RuntimeContext
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now