private static ActorRef startResourceManager(Configuration config, ActorRef jobManager) {
   return FlinkResourceManager.startResourceManagerActors(
       config,
       actorSystem,
       new StandaloneLeaderRetrievalService(jobManager.path().toString()),
       StandaloneResourceManager.class);
 }
  @Override
  protected void handleMessage(Object message) {

    // check for Mesos-specific actor messages first

    // --- messages about Mesos connection
    if (message instanceof Registered) {
      registered((Registered) message);
    } else if (message instanceof ReRegistered) {
      reregistered((ReRegistered) message);
    } else if (message instanceof Disconnected) {
      disconnected((Disconnected) message);
    } else if (message instanceof Error) {
      error(((Error) message).message());

      // --- messages about offers
    } else if (message instanceof ResourceOffers || message instanceof OfferRescinded) {
      launchCoordinator.tell(message, self());
    } else if (message instanceof AcceptOffers) {
      acceptOffers((AcceptOffers) message);

      // --- messages about tasks
    } else if (message instanceof StatusUpdate) {
      taskStatusUpdated((StatusUpdate) message);
    } else if (message instanceof ReconciliationCoordinator.Reconcile) {
      // a reconciliation request from a task
      reconciliationCoordinator.tell(message, self());
    } else if (message instanceof TaskMonitor.TaskTerminated) {
      // a termination message from a task
      TaskMonitor.TaskTerminated msg = (TaskMonitor.TaskTerminated) message;
      taskTerminated(msg.taskID(), msg.status());

    } else {
      // message handled by the generic resource master code
      super.handleMessage(message);
    }
  }
 @Override
 public void postStop() {
   LOG.info("Stopping Mesos resource master");
   super.postStop();
 }