Java Code Examples for org.apache.mesos.Protos#Request

The following examples show how to use org.apache.mesos.Protos#Request . 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: InternalSchedulerDriver.java    From jesos with Apache License 2.0 6 votes vote down vote up
@Override
public Status requestResources(final Collection<Protos.Request> requests)
{
    checkNotNull(requests, "requests is null");

    if (!context.isStateMachine(DRIVER_RUNNING)) {
        return context.getStateMachine();
    }

    final ResourceRequestMessage message = ResourceRequestMessage.newBuilder()
        .setFrameworkId(context.getFrameworkId())
        .addAllRequests(requests)
        .build();
    eventBus.post(new RemoteMessageEnvelope(context.getDriverUPID(), context.getMasterUPID(), message));

    return context.getStateMachine();
}
 
Example 2
Source File: ElasticsearchScheduler.java    From elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void registered(SchedulerDriver driver, Protos.FrameworkID frameworkId, Protos.MasterInfo masterInfo) {
    LOGGER.info("Framework registered as " + frameworkId.getValue());

    List<Protos.Resource> resources = Resources.buildFrameworkResources(configuration);

    Protos.Request request = Protos.Request.newBuilder()
            .addAllResources(resources)
            .build();

    List<Protos.Request> requests = Collections.singletonList(request);
    driver.requestResources(requests);

    frameworkState.markRegistered(frameworkId, driver);
}
 
Example 3
Source File: RequestMatcher.java    From elasticsearch with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public boolean matches(Object o) {
    Collection<Protos.Request> requests = (Collection<Protos.Request>) o;

    Protos.Resource cpuResource = Protos.Resource.newBuilder()
            .setName(Resources.RESOURCE_CPUS)
            .setType(Protos.Value.Type.SCALAR)
            .setScalar(Protos.Value.Scalar.newBuilder().setValue(cpus).build())
            .setRole(frameworkRole)
            .build();

    Protos.Resource memResource = Protos.Resource.newBuilder()
            .setName(Resources.RESOURCE_MEM)
            .setType(Protos.Value.Type.SCALAR)
            .setScalar(Protos.Value.Scalar.newBuilder().setValue(mem).build())
            .setRole(frameworkRole)
            .build();

    Protos.Resource diskResource = Protos.Resource.newBuilder()
            .setName(Resources.RESOURCE_DISK)
            .setType(Protos.Value.Type.SCALAR)
            .setScalar(Protos.Value.Scalar.newBuilder().setValue(disk).build())
            .setRole(frameworkRole)
            .build();

    Protos.Request request = Protos.Request.newBuilder()
            .addResources(cpuResource)
            .addResources(memResource)
            .addResources(diskResource)
            .build();

    return requests.contains(request);
}
 
Example 4
Source File: IgniteScheduler.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public synchronized void statusUpdate(SchedulerDriver schedulerDriver, Protos.TaskStatus taskStatus) {
    final String taskId = taskStatus.getTaskId().getValue();

    log.log(Level.INFO, "Received update event task: {0} is in state: {1}",
        new Object[]{taskId, taskStatus.getState()});

    if (taskStatus.getState().equals(Protos.TaskState.TASK_FAILED)
        || taskStatus.getState().equals(Protos.TaskState.TASK_ERROR)
        || taskStatus.getState().equals(Protos.TaskState.TASK_FINISHED)
        || taskStatus.getState().equals(Protos.TaskState.TASK_KILLED)
        || taskStatus.getState().equals(Protos.TaskState.TASK_LOST)) {
        IgniteTask failedTask = tasks.remove(taskId);

        if (failedTask != null) {
            List<Protos.Request> requests = new ArrayList<>();

            Protos.Request request = Protos.Request.newBuilder()
                .addResources(Protos.Resource.newBuilder()
                    .setType(Protos.Value.Type.SCALAR)
                    .setName(MEM)
                    .setScalar(Protos.Value.Scalar.newBuilder().setValue(failedTask.mem())))
                .addResources(Protos.Resource.newBuilder()
                    .setType(Protos.Value.Type.SCALAR)
                    .setName(CPU)
                    .setScalar(Protos.Value.Scalar.newBuilder().setValue(failedTask.cpuCores())))
                .build();

            requests.add(request);

            schedulerDriver.requestResources(requests);
        }
    }
}
 
Example 5
Source File: SimulatedLocalMesosSchedulerDriver.java    From titus-control-plane with Apache License 2.0 4 votes vote down vote up
@Override
public Status requestResources(Collection<Protos.Request> requests) {
    throw new IllegalStateException("method not implemented");
}
 
Example 6
Source File: SimulatedRemoteMesosSchedulerDriver.java    From titus-control-plane with Apache License 2.0 4 votes vote down vote up
@Override
public Protos.Status requestResources(Collection<Protos.Request> requests) {
    throw new IllegalStateException("method not supported");
}
 
Example 7
Source File: IgniteSchedulerSelfTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override public Protos.Status requestResources(Collection<Protos.Request> requests) {
    return null;
}
 
Example 8
Source File: MockSchedulerDriver.java    From cassandra-mesos-deprecated with Apache License 2.0 4 votes vote down vote up
@Override
public Protos.Status requestResources(final Collection<Protos.Request> requests) {
    throw new UnsupportedOperationException();
}
 
Example 9
Source File: FakeSchedulerDriver.java    From attic-aurora with Apache License 2.0 4 votes vote down vote up
@Override
public Protos.Status requestResources(
    Collection<Protos.Request> requests) {
  return null;
}