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

The following examples show how to use org.apache.mesos.v1.Protos#FrameworkID . 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: 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 2
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#SUBSCRIBE SUBSCRIBE}.
 * <p>
 *
 * @param frameworkId               The frameworkId to set on the {@link Protos.FrameworkInfo FrameworkInfo} and
 *                                  {@link Call Call} messages.
 * @param user                      The user to set on the {@link Protos.FrameworkInfo FrameworkInfo} message.
 * @param frameworkName             The name to set on the {@link Protos.FrameworkInfo FrameworkInfo} message.
 * @param failoverTimeoutSeconds    The failoverTimeoutSeconds to set on the
 *                                  {@link Protos.FrameworkInfo FrameworkInfo} message.
 * @return An {@link Call Call} of type {@link Type#SUBSCRIBE SUBSCRIBE} with the configured
 * {@link Subscribe Subscribe} sub-message.
 */
@NotNull
public static Call subscribe(
    @NotNull final Protos.FrameworkID frameworkId,
    @NotNull final String user,
    @NotNull final String frameworkName,
    final long failoverTimeoutSeconds
) {
    final Protos.FrameworkInfo frameworkInfo = Protos.FrameworkInfo.newBuilder()
        .setId(frameworkId)
        .setUser(user)
        .setName(frameworkName)
        .setFailoverTimeout(failoverTimeoutSeconds)
        .build();
    return subscribe(frameworkId, frameworkInfo);
}
 
Example 3
Source File: SchedulerCalls.java    From mesos-rxjava with Apache License 2.0 5 votes vote down vote up
/**
 * Utility method to more succinctly construct a {@link Call Call} of type {@link Type#DECLINE DECLINE}.
 * <p>
 *
 * @param frameworkId    The {@link Protos.FrameworkID FrameworkID} to be set on the {@link Call}
 * @param offerIds       A list of {@link Protos.OfferID OfferID} from the
 *                       {@link Protos.Offer}s received from Mesos.
 * @return  A {@link Call} with a configured {@link Decline}.
 */
@NotNull
public static Call decline(@NotNull final Protos.FrameworkID frameworkId, @NotNull final List<Protos.OfferID> offerIds) {
    return newBuilder()
        .setFrameworkId(frameworkId)
        .setType(Type.DECLINE)
        .setDecline(
            Decline.newBuilder()
                .addAllOfferIds(offerIds)
        )
        .build();
}
 
Example 4
Source File: SchedulerCalls.java    From mesos-rxjava with Apache License 2.0 5 votes vote down vote up
/**
 * Utility method to more succinctly construct a {@link Call Call} of type {@link Type#SUBSCRIBE SUBSCRIBE}.
 * <p>
 *
 * @param frameworkId   The frameworkId to set on the {@link Call Call} messages.
 * @param frameworkInfo The frameworkInfo to set on the {@link Subscribe Subscribe} sub-message.
 * @return An {@link Call Call} of type {@link Type#SUBSCRIBE SUBSCRIBE} with the configured
 * {@link Subscribe Subscribe} sub-message.
 */
@NotNull
public static Call subscribe(
    @NotNull final Protos.FrameworkID frameworkId,
    @NotNull final Protos.FrameworkInfo frameworkInfo
) {
    return newBuilder()
        .setFrameworkId(frameworkId)
        .setType(Type.SUBSCRIBE)
        .setSubscribe(
            Subscribe.newBuilder()
                .setFrameworkInfo(frameworkInfo)
        )
        .build();
}
 
Example 5
Source File: SendErrors.java    From Juice with GNU General Public License v3.0 4 votes vote down vote up
public SendErrors(Protos.FrameworkID frameworkId,  org.apache.mesos.v1.scheduler.Protos.Call call) {
    this.frameworkId = frameworkId;
    this.call = call;
}
 
Example 6
Source File: ProtosConversion.java    From attic-aurora with Apache License 2.0 4 votes vote down vote up
public static Protos.FrameworkID convert(org.apache.mesos.Protos.FrameworkID id) {
  return convert(id, Protos.FrameworkID.newBuilder());
}
 
Example 7
Source File: ProtosConversion.java    From attic-aurora with Apache License 2.0 4 votes vote down vote up
public static org.apache.mesos.Protos.FrameworkID convert(Protos.FrameworkID id) {
  return convert(id, org.apache.mesos.Protos.FrameworkID.newBuilder());
}
 
Example 8
Source File: VersionedMesosSchedulerImpl.java    From attic-aurora with Apache License 2.0 4 votes vote down vote up
@Override
public void connected(Mesos mesos) {
  LOG.info("Connected to Mesos master.");
  isConnected.set(true);

  Optional<String> frameworkId = storage.read(
      storeProvider -> storeProvider.getSchedulerStore().fetchFrameworkId());

  Protos.FrameworkInfo.Builder frameworkBuilder = infoFactory.getFrameworkInfo().toBuilder();

  Call.Builder call = Call.newBuilder().setType(Call.Type.SUBSCRIBE);

  if (frameworkId.isPresent()) {
    LOG.info("Found persisted framework ID: " + frameworkId);
    Protos.FrameworkID id = Protos.FrameworkID.newBuilder().setValue(frameworkId.get()).build();
    frameworkBuilder.setId(id);
    call.setFrameworkId(id);
  } else {
    frameworkBuilder.clearId();
    call.clearFrameworkId();
    LOG.warn("Did not find a persisted framework ID, connecting as a new framework.");
  }

  call.setSubscribe(Call.Subscribe.newBuilder().setFrameworkInfo(frameworkBuilder));

  executor.execute(() -> {
    LOG.info("Starting to subscribe to Mesos with backoff.");
    try {
      backoffHelper.doUntilSuccess(() -> {
        if (!isConnected.get())  {
          LOG.info("Disconnected while attempting to subscribe. Stopping attempt.");
          return true;
        }
        if (!isSubscribed.get()) {
          LOG.info("Sending subscribe call.");
          mesos.send(call.build());
          subcriptionCalls.incrementAndGet();
          return false;
        }
        LOG.info("Subscribed to Mesos");
        return true;
      });
    } catch (InterruptedException e) {
      throw new RuntimeException(e);
    }
  });
}
 
Example 9
Source File: SchedulerCalls.java    From mesos-rxjava with Apache License 2.0 3 votes vote down vote up
/**
 * Utility method to more succinctly construct a {@link Call Call} of type {@link Type#SUBSCRIBE SUBSCRIBE}.
 * <p>
 *
 * @param frameworkId               The frameworkId to set on the {@link Protos.FrameworkInfo FrameworkInfo} and
 *                                  {@link Call Call} messages.
 * @param user                      The user to set on the {@link Protos.FrameworkInfo FrameworkInfo} message.
 * @param frameworkName             The name to set on the {@link Protos.FrameworkInfo FrameworkInfo} message.
 * @param failoverTimeoutSeconds    The failoverTimeoutSeconds to set on the
 *                                  {@link Protos.FrameworkInfo FrameworkInfo} message.
 * @return An {@link Call Call} of type {@link Type#SUBSCRIBE SUBSCRIBE} with the configured
 * {@link Subscribe Subscribe} sub-message.
 */
@NotNull
public static Call subscribe(
    @NotNull final String frameworkId,
    @NotNull final String user,
    @NotNull final String frameworkName,
    final long failoverTimeoutSeconds
) {
    final Protos.FrameworkID frameworkID = Protos.FrameworkID.newBuilder().setValue(frameworkId).build();
    return subscribe(frameworkID, user, frameworkName, failoverTimeoutSeconds);
}