Java Code Examples for org.apache.mesos.v1.Protos#TaskInfo
The following examples show how to use
org.apache.mesos.v1.Protos#TaskInfo .
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: SchedulerService.java From Juice with GNU General Public License v3.0 | 6 votes |
private static void addTask(@NotNull Map<Long, String> killMap, @NotNull Protos.AgentID agentId, @NotNull Task task, @NotNull List<Protos.TaskInfo> tasks, boolean isRetryTask, Address address) { boolean isToKilled = false; try { isToKilled = killMap.containsKey(task.getTaskId()); //update db set taskAgentRel AuxiliaryService.updateTask(killMap, task.getTaskId(), agentId.getValue(), isToKilled, address); if(!isToKilled){ tasks.add(task.getTask(agentId)); log.info("resourceAllocation --> add task : " + task.getTaskId()); } } catch (Exception e) { if(!isToKilled) { taskReserve(task, isRetryTask); } } }
Example 2
Source File: Task.java From Juice with GNU General Public License v3.0 | 6 votes |
public @NotNull Protos.TaskInfo getTask( final @NotNull Protos.AgentID agentID ) { Protos.TaskInfo.Builder taskInfoBuilder = Protos.TaskInfo.newBuilder(); taskInfoBuilder.setName(taskName); taskInfoBuilder.setTaskId(Protos.TaskID.newBuilder().setValue(generateTaskNameId(taskName, taskId, retry))); taskInfoBuilder.setAgentId(agentID); taskInfoBuilder.addAllResources(resources.protos()); if(null != command && StringUtils.isNotBlank(command.getValue())) { // run shell return taskInfoBuilder.setCommand(command.protos(true)).build(); } else { // run docker return taskInfoBuilder.setContainer(container.protos()).setCommand(command.protos(false)).build(); } }
Example 3
Source File: TaskAssignerImpl.java From attic-aurora with Apache License 2.0 | 6 votes |
private Protos.TaskInfo assign( MutableStoreProvider storeProvider, Protos.Offer offer, String taskId, boolean revocable) { String host = offer.getHostname(); IAssignedTask assigned = stateManager.assignTask( storeProvider, taskId, host, offer.getAgentId(), task -> mapAndAssignResources(offer, task)); LOG.info( "Offer on agent {} (id {}) is being assigned task for {}.", host, offer.getAgentId().getValue(), taskId); return taskFactory.createFrom(assigned, offer, revocable); }
Example 4
Source File: TaskAssignerImpl.java From attic-aurora with Apache License 2.0 | 6 votes |
private void launchUsingOffer( MutableStoreProvider stores, ResourceRequest resourceRequest, IAssignedTask task, HostOffer offer) throws LaunchException { String taskId = task.getTaskId(); Protos.TaskInfo taskInfo = assign(stores, offer.getOffer(), taskId, resourceRequest.isRevocable()); resourceRequest.getJobState().updateAttributeAggregate(offer.getAttributes()); try { offerManager.launchTask(offer.getOffer().getId(), taskInfo); } catch (LaunchException e) { LOG.warn("Failed to launch task.", e); launchFailures.incrementAndGet(); // The attempt to schedule the task failed, so we need to backpedal on the assignment. // It is in the LOST state and a new task will move to PENDING to replace it. // Should the state change fail due to storage issues, that's okay. The task will // time out in the ASSIGNED state and be moved to LOST. stateManager.changeState(stores, taskId, Optional.of(ASSIGNED), LOST, LAUNCH_FAILED_MSG); throw e; } }
Example 5
Source File: OfferManagerImpl.java From attic-aurora with Apache License 2.0 | 6 votes |
@Timed("offer_manager_launch_task") @Override public void launchTask(Protos.OfferID offerId, Protos.TaskInfo task) throws LaunchException { // Guard against an offer being removed after we grabbed it from the iterator. // If that happens, the offer will not exist in hostOffers, and we can immediately // send it back to LOST for quick reschedule. // Removing while iterating counts on the use of a weakly-consistent iterator being used, // which is a feature of ConcurrentSkipListSet. if (hostOffers.remove(offerId)) { try { Protos.Offer.Operation launch = Protos.Offer.Operation.newBuilder() .setType(Protos.Offer.Operation.Type.LAUNCH) .setLaunch(Protos.Offer.Operation.Launch.newBuilder().addTaskInfos(task)) .build(); driver.acceptOffers(offerId, ImmutableList.of(launch), getOfferFilter()); } catch (IllegalStateException e) { // TODO(William Farner): Catch only the checked exception produced by Driver // once it changes from throwing IllegalStateException when the driver is not yet // registered. throw new LaunchException("Failed to launch task.", e); } } else { offerRaces.incrementAndGet(); throw new LaunchException("Offer no longer exists in offer queue, likely data race."); } }
Example 6
Source File: SchedulerService.java From Juice with GNU General Public License v3.0 | 5 votes |
private static boolean allocatingUntilExhausted(Map<Long, String> killMap, Protos.AgentID agentId, Map<String, Set<String>> facts, ResourcesUtils hardware, List<Protos.TaskInfo> tasks, Address address) { long cacheTries = CACHE_TRIES; // when either cpu or memory reach the picket line, will stop allocation task while (hardware.isAvailable()) { if (cacheTries > 0) { cacheTries = taskOrResourceExhausted(killMap, agentId, facts, hardware, tasks, true, address) ? 0 : cacheTries - 1; } else { if (taskOrResourceExhausted(killMap, agentId, facts, hardware, tasks, false, address)) { return true; } } } return false; }
Example 7
Source File: SchedulerService.java From Juice with GNU General Public License v3.0 | 5 votes |
private static boolean taskOrResourceExhausted(@NotNull Map<Long, String> killMap, Protos.AgentID agentId, Map<String, Set<String>> facts, ResourcesUtils hardware, List<Protos.TaskInfo> tasks, boolean isRetryTask, Address address) { // is task in cache exhausted ? String tskStr = isRetryTask ? cacheUtils.popFromQueue(TASK_RETRY_QUEUE) : cacheUtils.popFromQueue(TASK_QUEUE); if (StringUtils.isBlank(tskStr)) { return true; } // is resource exhausted ? com.hujiang.juice.common.model.Task task = gson.fromJson(tskStr, Task.class); // current offer not match task, try next if (!availableConstraints(task.getConstraints(), facts)) { task.getExpire().incrementOfferLack(); taskReserve(task, isRetryTask); } else { if (hardware.allocating(task.getResources())) { // accept task addTask(killMap, agentId, task, tasks, isRetryTask, address); } else { // resources is exhausted task.getExpire().incrementResourceLack(); taskReserve(task, isRetryTask); return true; } } return false; }
Example 8
Source File: FakeOfferManager.java From attic-aurora with Apache License 2.0 | 4 votes |
@Override public void launchTask(Protos.OfferID offerId, Protos.TaskInfo taskInfo) throws LaunchException { // no-op }
Example 9
Source File: OfferManager.java From attic-aurora with Apache License 2.0 | 2 votes |
/** * Launches the task matched against the offer. * * @param offerId Matched offer ID. * @param task Matched task info. * @throws LaunchException If there was an error launching the task. */ void launchTask(OfferID offerId, Protos.TaskInfo task) throws LaunchException;