Java Code Examples for org.springframework.cloud.deployer.spi.task.LaunchState#running()
The following examples show how to use
org.springframework.cloud.deployer.spi.task.LaunchState#running() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KubernetesTaskLauncher.java From spring-cloud-deployer-kubernetes with Apache License 2.0 | 6 votes |
private TaskStatus buildPodStatus(String id) { Pod pod = getPodByName(id); if (pod == null) { return new TaskStatus(id, LaunchState.unknown, new HashMap<>()); } PodStatus podStatus = pod.getStatus(); if (podStatus == null) { return new TaskStatus(id, LaunchState.unknown, new HashMap<>()); } String phase = podStatus.getPhase(); switch (phase) { case "Pending": return new TaskStatus(id, LaunchState.launching, new HashMap<>()); case "Failed": return new TaskStatus(id, LaunchState.failed, new HashMap<>()); case "Succeeded": return new TaskStatus(id, LaunchState.complete, new HashMap<>()); default: return new TaskStatus(id, LaunchState.running, new HashMap<>()); } }
Example 2
Source File: AbstractCloudFoundryTaskLauncher.java From spring-cloud-deployer-cloudfoundry with Apache License 2.0 | 6 votes |
protected TaskStatus toTaskStatus(GetTaskResponse response) { switch (response.getState()) { case SUCCEEDED: return new TaskStatus(response.getId(), LaunchState.complete, null); case RUNNING: return new TaskStatus(response.getId(), LaunchState.running, null); case PENDING: return new TaskStatus(response.getId(), LaunchState.launching, null); case CANCELING: return new TaskStatus(response.getId(), LaunchState.cancelled, null); case FAILED: return new TaskStatus(response.getId(), LaunchState.failed, null); default: throw new IllegalStateException(String.format("Unsupported CF task state %s", response.getState())); } }
Example 3
Source File: LocalTaskLauncher.java From spring-cloud-deployer-local with Apache License 2.0 | 6 votes |
private void pruneTaskInstanceHistory(String taskDefinitionName, String taskLaunchId) { CopyOnWriteArrayList<String> oldTaskInstanceIds = taskInstanceHistory.get(taskDefinitionName); if (oldTaskInstanceIds == null) { oldTaskInstanceIds = new CopyOnWriteArrayList<>(); taskInstanceHistory.put(taskDefinitionName, oldTaskInstanceIds); } for (String oldTaskInstanceId : oldTaskInstanceIds) { TaskInstance oldTaskInstance = running.get(oldTaskInstanceId); if (oldTaskInstance != null && oldTaskInstance.getState() != LaunchState.running && oldTaskInstance.getState() != LaunchState.launching) { running.remove(oldTaskInstanceId); oldTaskInstanceIds.remove(oldTaskInstanceId); } else { oldTaskInstanceIds.remove(oldTaskInstanceId); } } oldTaskInstanceIds.add(taskLaunchId); }
Example 4
Source File: LocalTaskLauncher.java From spring-cloud-deployer-local with Apache License 2.0 | 6 votes |
public LaunchState getState() { if (cancelled) { return LaunchState.cancelled; } Integer exit = getProcessExitValue(process); // TODO: consider using exit code mapper concept from batch if (exit != null) { if (exit == 0) { return LaunchState.complete; } else { return LaunchState.failed; } } try { HttpURLConnection urlConnection = (HttpURLConnection) baseUrl.openConnection(); urlConnection.setConnectTimeout(100); urlConnection.connect(); urlConnection.disconnect(); return LaunchState.running; } catch (IOException e) { return LaunchState.launching; } }
Example 5
Source File: YarnTaskLauncher.java From spring-cloud-deployer-yarn with Apache License 2.0 | 5 votes |
@Override public TaskStatus status(String id) { logger.info("Status request for module {}", id); DeploymentKey key = new DeploymentKey(id); Collection<CloudAppInstanceInfo> instances = yarnCloudAppService.getInstances(CloudAppType.TASK); for (CloudAppInstanceInfo instance : instances) { if (instance.getApplicationId().equals(key.applicationId)) { if (instance.getState() == "RUNNING") { return new TaskStatus(id, LaunchState.running, null); } } } return new TaskStatus(id, LaunchState.unknown, null); }
Example 6
Source File: ChronosTaskLauncher.java From spring-cloud-deployer-mesos with Apache License 2.0 | 5 votes |
protected TaskStatus buildTaskStatus(ChronosTaskLauncherProperties properties, String id, Job job, String csv) { if (job == null) { return new TaskStatus(id, LaunchState.unknown, new HashMap<>()); } String last = null; String state= null; if (StringUtils.hasText(csv)) { List<String> csvLines = Arrays.asList(csv.split("\\r?\\n")); for (String line : csvLines) { if (line.startsWith("node")) { List<String> values = Arrays.asList(line.split("\\s*,\\s*")); if (values.size() >= 4) { if (id.equals(values.get(1))) { last = values.get(2); state = values.get(3); break; } } } } } if ("running".equals(state)) { return new TaskStatus(id, LaunchState.running, new HashMap<>()); } if ("queued".equals(state)) { return new TaskStatus(id, LaunchState.launching, new HashMap<>()); } if ("success".equals(last)) { return new TaskStatus(id, LaunchState.complete, new HashMap<>()); } else { // TODO: state == idle could indicate cancelled? return new TaskStatus(id, LaunchState.failed, new HashMap<>()); } }