use of org.eclipse.che.commons.annotation.Traced in project che-server by eclipse-che.
the class OpenShiftInternalRuntime method createServices.
@Traced
// package-private so that interception is possible
@SuppressWarnings("WeakerAccess")
List<Service> createServices(OpenShiftEnvironment env, String workspaceId) throws InfrastructureException {
TracingTags.WORKSPACE_ID.set(workspaceId);
Collection<Service> servicesToCreate = env.getServices().values();
List<Service> createdServices = new ArrayList<>(servicesToCreate.size());
for (Service service : servicesToCreate) {
createdServices.add(project.services().create(service));
}
return createdServices;
}
use of org.eclipse.che.commons.annotation.Traced in project che-server by eclipse-che.
the class TracingInterceptor method getSpanName.
private String getSpanName(MethodInvocation invocation) {
Class<?> objectType = invocation.getThis().getClass();
Method method = invocation.getMethod();
// we assume that there won't be more than 4 traced methods on a type. If there are, we're
// adding a little bit of runtime overhead of enlarging the hashmap's capacity, but in the usual
// case we're saving 12 entries in the map (16 is the default capacity).
String ret = spanNames.computeIfAbsent(objectType, __ -> new WeakHashMap<>(4)).get(method);
if (ret != null) {
return ret;
}
Traced annotation = method.getAnnotation(Traced.class);
if (annotation == null) {
throw new IllegalStateException("Misconfigured Guice interception. Tracing interceptor called on method " + method + " that is not annotated with @Traced.");
}
String name = annotation.name();
if (name.isEmpty()) {
name = cleanName(objectType) + "#" + method.getName();
}
spanNames.get(objectType).put(method, name);
return name;
}
use of org.eclipse.che.commons.annotation.Traced in project che-server by eclipse-che.
the class PluginBrokerManager method getTooling.
/**
* Deploys Che plugin brokers in a workspace, receives result of theirs execution and returns
* resolved workspace tooling or error of plugins brokering execution.
*
* <p>This API is in <b>Beta</b> and is subject to changes or removal.
*/
@Beta
@Traced
public List<ChePlugin> getTooling(RuntimeIdentity identity, StartSynchronizer startSynchronizer, Collection<PluginFQN> pluginFQNs, boolean isEphemeral, boolean mergePlugins, Map<String, String> startOptions) throws InfrastructureException {
String workspaceId = identity.getWorkspaceId();
KubernetesNamespace kubernetesNamespace = factory.getOrCreate(identity);
BrokersResult brokersResult = new BrokersResult();
E brokerEnvironment = brokerEnvironmentFactory.createForMetadataBroker(pluginFQNs, identity, mergePlugins);
if (isEphemeral) {
EphemeralWorkspaceUtility.makeEphemeral(brokerEnvironment.getAttributes());
}
environmentProvisioner.provision(brokerEnvironment, identity);
ListenBrokerEvents listenBrokerEvents = getListenEventPhase(workspaceId, brokersResult);
PrepareStorage prepareStorage = getPrepareStoragePhase(identity, startSynchronizer, brokerEnvironment, startOptions);
WaitBrokerResult waitBrokerResult = getWaitBrokerPhase(workspaceId, brokersResult);
DeployBroker deployBroker = getDeployBrokerPhase(identity, kubernetesNamespace, brokerEnvironment, brokersResult, startOptions);
LOG.debug("Entering plugin brokers deployment chain workspace '{}'", workspaceId);
listenBrokerEvents.then(prepareStorage).then(deployBroker).then(waitBrokerResult);
return listenBrokerEvents.execute();
}
use of org.eclipse.che.commons.annotation.Traced in project che-server by eclipse-che.
the class WorkspaceRuntimes method stopAsync.
/**
* Stops running workspace runtime asynchronously.
*
* <p>Stops environment in an implementation specific way. During the stop of the workspace its
* runtime is accessible with {@link WorkspaceStatus#STOPPING stopping} status. Workspace may be
* stopped only if its status is {@link WorkspaceStatus#RUNNING} or {@link
* WorkspaceStatus#STARTING}.
*
* @param workspace workspace which runtime should be stopped
* @throws NotFoundException when workspace with specified identifier does not have runtime
* @throws ConflictException when running workspace status is different from {@link
* WorkspaceStatus#RUNNING} or {@link WorkspaceStatus#STARTING}
* @see WorkspaceStatus#STOPPING
*/
@Traced
public CompletableFuture<Void> stopAsync(WorkspaceImpl workspace, Map<String, String> options) throws NotFoundException, ConflictException {
TracingTags.WORKSPACE_ID.set(workspace.getId());
TracingTags.STOPPED_BY.set(getStoppedBy(workspace));
String workspaceId = workspace.getId();
WorkspaceStatus status = statuses.get(workspaceId);
if (status == null) {
throw new NotFoundException("Workspace with id '" + workspaceId + "' is not running.");
}
if (status != RUNNING && status != STARTING) {
throw new ConflictException(format("Could not stop workspace '%s' because its state is '%s'", workspaceId, status));
}
if (!statuses.replace(workspaceId, status, STOPPING)) {
WorkspaceStatus newStatus = statuses.get(workspaceId);
throw new ConflictException(format("Could not stop workspace '%s' because its state is '%s'", workspaceId, newStatus == null ? STOPPED : newStatus));
}
setRuntimesId(workspaceId);
String stoppedBy = firstNonNull(sessionUserNameOr(workspace.getAttributes().get(WORKSPACE_STOPPED_BY)), "undefined");
LOG.info("Workspace '{}/{}' with id '{}' is stopping by user '{}'", workspace.getNamespace(), workspace.getName(), workspace.getId(), stoppedBy);
publishWorkspaceStatusEvent(workspaceId, STOPPING, status, options.get(WORKSPACE_STOP_REASON), true);
return CompletableFuture.runAsync(ThreadLocalPropagateContext.wrap(new StopRuntimeTask(workspace, options, stoppedBy)), sharedPool.getExecutor());
}
use of org.eclipse.che.commons.annotation.Traced in project che-server by eclipse-che.
the class WorkspaceManager method createWorkspace.
/**
* Creates a workspace out of a devfile.
*
* <p>The devfile should have been validated using the {@link
* DevfileIntegrityValidator#validateDevfile(Devfile)}. This method does rest of the validation
* and actually creates the workspace.
*
* @param devfile the devfile describing the workspace
* @param namespace workspace name is unique in this namespace
* @param attributes workspace instance attributes
* @param contentProvider the content provider to use for resolving content references in the
* devfile
* @return new workspace instance
* @throws NullPointerException when either {@code config} or {@code namespace} is null
* @throws NotFoundException when account with given id was not found
* @throws ConflictException when any conflict occurs (e.g Workspace with such name already exists
* for {@code owner})
* @throws ServerException when any other error occurs
* @throws ValidationException when incoming configuration or attributes are not valid
*/
@Traced
public WorkspaceImpl createWorkspace(Devfile devfile, String namespace, Map<String, String> attributes, FileContentProvider contentProvider) throws ServerException, NotFoundException, ConflictException, ValidationException {
requireNonNull(devfile, "Required non-null devfile");
requireNonNull(namespace, "Required non-null namespace");
validator.validateAttributes(attributes);
devfile = generateNameIfNeeded(devfile);
try {
devfileIntegrityValidator.validateContentReferences(devfile, contentProvider);
} catch (DevfileFormatException e) {
throw new ValidationException(e.getMessage(), e);
}
WorkspaceImpl workspace = doCreateWorkspace(devfile, accountManager.getByName(namespace), attributes, false);
TracingTags.WORKSPACE_ID.set(workspace.getId());
return workspace;
}
Aggregations