@Override
    public void onBecomingLeader() {
      // Update table to denote that it is a leader.
      table.updateIsLeader(currentJMVersion.get(), processorId, true);

      // Schedule a task to renew the lease after a fixed time interval
      LOG.info("Starting scheduler to keep renewing lease held by the leader.");
      renewLease = new RenewLeaseScheduler((errorMsg) -> {
        LOG.error(errorMsg);
        table.updateIsLeader(currentJMVersion.get(), processorId, false);
        azureLeaderElector.resignLeadership();
        renewLease.shutdown();
        liveness.shutdown();
      }, azureLeaderElector.getLeaseBlobManager(), azureLeaderElector.getLeaseId());
      renewLease.scheduleTask();

      doOnProcessorChange(new ArrayList<>());

      // Start scheduler to check for change in list of live processors
      LOG.info("Starting scheduler to check for change in list of live processors in the system.");
      liveness = new LivenessCheckScheduler(errorHandler, table, leaderBlob, currentJMVersion, processorId);
      liveness.setStateChangeListener(createLivenessListener(liveness.getLiveProcessors()));
      liveness.scheduleTask();
    }
Keep renewing the lease and do the required tasks as a leader.
samza-azure/src/main/java/org/apache/samza/coordinator/AzureJobCoordinator.java