/** * 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(); }
/** * 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()); }
/** Returns workspace ids which has {@link WorkspaceStatus#RUNNING} runtimes. */ public Set<String> getRunning() { return statuses .asMap() .entrySet() .stream() .filter(e -> RUNNING == e.getValue()) .map(Entry::getKey) .collect(toSet()); }
/** * Returns true if there is at least one local workspace starting or stopping (it's status is * {@link WorkspaceStatus#STARTING} or {@link WorkspaceStatus#STOPPING}), otherwise returns false. */ public boolean isAnyInProgress() { return statuses .asMap() .entrySet() .stream() .filter(e -> STARTING == e.getValue() || STOPPING == e.getValue()) .map(Entry::getKey) .anyMatch(this::containsThisRuntimesId); }
/** * Gets the list of workspace id's which are currently starting or stopping on given node. (it's * status is {@link WorkspaceStatus#STARTING} or {@link WorkspaceStatus#STOPPING}) */ public Set<String> getInProgress() { return statuses .asMap() .entrySet() .stream() .filter(e -> STARTING == e.getValue() || STOPPING == e.getValue()) .map(Entry::getKey) .filter(this::containsThisRuntimesId) .collect(toSet()); }