Java Code Examples for org.apache.mesos.v1.Protos#AgentID

The following examples show how to use org.apache.mesos.v1.Protos#AgentID . 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 vote down vote up
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 vote down vote up
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: SchedulerCalls.java    From mesos-rxjava with Apache License 2.0 6 votes vote down vote up
/**
 * Utility method to more succinctly construct a {@link Call Call} of type {@link Type#ACKNOWLEDGE ACKNOWLEDGE}.
 * <p>
 *
 * @param frameworkId    The {@link Protos.FrameworkID} to be set on the {@link Call}
 * @param uuid           The {@link Protos.TaskStatus#getUuid() uuid} from the
 *                       {@link org.apache.mesos.v1.scheduler.Protos.Event.Update#getStatus() TaskStatus} received from Mesos.
 * @param agentId        The {@link Protos.TaskStatus#getAgentId() agentId} from the
 *                       {@link org.apache.mesos.v1.scheduler.Protos.Event.Update#getStatus() TaskStatus} received from Mesos.
 * @param taskId         The {@link Protos.TaskStatus#getTaskId() taskId} from the
 *                       {@link org.apache.mesos.v1.scheduler.Protos.Event.Update#getStatus() TaskStatus} received from Mesos.
 * @return  A {@link Call} with a configured {@link Acknowledge}.
 */
@NotNull
public static Call ackUpdate(
    @NotNull final Protos.FrameworkID frameworkId,
    @NotNull final ByteString uuid,
    @NotNull final Protos.AgentID agentId,
    @NotNull final Protos.TaskID taskId
) {
    return newBuilder()
        .setFrameworkId(frameworkId)
        .setType(Type.ACKNOWLEDGE)
        .setAcknowledge(
            Acknowledge.newBuilder()
                .setUuid(uuid)
                .setAgentId(agentId)
                .setTaskId(taskId)
                .build()
        )
        .build();
}
 
Example 4
Source File: SingularityMesosFrameworkMessageHandler.java    From Singularity with Apache License 2.0 6 votes vote down vote up
public void handleMessage(
  Protos.ExecutorID executorId,
  Protos.AgentID slaveId,
  byte[] data
) {
  SingularityTaskShellCommandUpdate shellUpdate = null;
  try {
    shellUpdate = commandUpdateTranscoder.fromBytes(data);

    SingularityCreateResult saved = taskManager.saveTaskShellCommandUpdate(shellUpdate);

    LOG.debug("Saved {} with result {}", shellUpdate, saved);
  } catch (SingularityTranscoderException ste) {
    LOG.warn("Framework message {} not a commandUpdate", new String(data, UTF_8));
  } catch (Exception e) {
    LOG.error("While processing framework message {}", shellUpdate, e);
  }
}
 
Example 5
Source File: SchedulerService.java    From Juice with GNU General Public License v3.0 5 votes vote down vote up
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 6
Source File: SchedulerService.java    From Juice with GNU General Public License v3.0 5 votes vote down vote up
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 7
Source File: HostOffers.java    From attic-aurora with Apache License 2.0 5 votes vote down vote up
synchronized Optional<HostOffer> get(Protos.AgentID slaveId) {
  HostOffer offer = offersBySlave.get(slaveId);
  if (offer == null || globallyBannedOffers.contains(offer.getOffer().getId())) {
    return Optional.empty();
  }

  return Optional.of(offer);
}
 
Example 8
Source File: HostOffers.java    From attic-aurora with Apache License 2.0 5 votes vote down vote up
synchronized Optional<HostOffer> getMatching(
    Protos.AgentID slaveId,
    ResourceRequest resourceRequest) {

  return get(slaveId)
      .filter(offer -> !isGloballyBanned(offer))
      .filter(offer -> !isVetoed(offer, resourceRequest, Optional.empty()));
}
 
Example 9
Source File: SingularityMesosSchedulerImpl.java    From Singularity with Apache License 2.0 4 votes vote down vote up
public void slaveLost(Protos.AgentID slaveId) {
  LOG.warn("Lost a slave {}", slaveId);
  slaveAndRackManager.slaveLost(slaveId);
}
 
Example 10
Source File: ProtosConversion.java    From attic-aurora with Apache License 2.0 4 votes vote down vote up
public static Protos.AgentID convert(org.apache.mesos.Protos.SlaveID s) {
  return convert(s, Protos.AgentID.newBuilder());
}
 
Example 11
Source File: ProtosConversion.java    From attic-aurora with Apache License 2.0 4 votes vote down vote up
public static org.apache.mesos.Protos.SlaveID convert(Protos.AgentID f) {
  return convert(f, org.apache.mesos.Protos.SlaveID.newBuilder());
}
 
Example 12
Source File: OfferManagerImpl.java    From attic-aurora with Apache License 2.0 4 votes vote down vote up
@Override
public Optional<HostOffer> get(Protos.AgentID slaveId) {
  return hostOffers.get(slaveId);
}
 
Example 13
Source File: OfferManagerImpl.java    From attic-aurora with Apache License 2.0 4 votes vote down vote up
@Override
public Optional<HostOffer> getMatching(Protos.AgentID slaveId, ResourceRequest resourceRequest) {
  return hostOffers.getMatching(slaveId, resourceRequest);
}
 
Example 14
Source File: FakeOfferManager.java    From attic-aurora with Apache License 2.0 4 votes vote down vote up
@Override
public Optional<HostOffer> get(Protos.AgentID agentId) {
  return Optional.empty();
}
 
Example 15
Source File: FakeOfferManager.java    From attic-aurora with Apache License 2.0 4 votes vote down vote up
@Override
public Optional<HostOffer> getMatching(Protos.AgentID slaveId, ResourceRequest resourceRequest) {
  return Optional.empty();
}