public static UUID writeDrainNotification(MetadataStore metadataStore) {
    Preconditions.checkArgument(metadataStore != null, "MetadataStore cannot be null.");
    final Config config = CoordinatorStreamUtil.readConfigFromCoordinatorStream(metadataStore);
    final ApplicationConfig applicationConfig = new ApplicationConfig(config);
    final String runId = applicationConfig.getRunId();
    if (Strings.isNullOrEmpty(runId)) {
      throw new SamzaException("Unable to retrieve runId from metadata store. DrainNotification will not be "
          + "written to the metadata store.");
    }
    LOG.info("Received runId {}", runId);
    LOG.info("Attempting to write DrainNotification to metadata-store for the deployment ID {}", runId);
    final UUID uuid = UUID.randomUUID();
    final DrainNotification message = DrainNotification.create(uuid, runId);
    return writeDrainNotification(metadataStore, message);
  }
Writes a {@link DrainNotification} to the underlying metastore. This method should be used by external controllers
to issue a DrainNotification to the JobCoordinator and Samza Containers.
@param metadataStore Metadata store to write drain notification to.

@return generated uuid for the DrainNotification
samza-core/src/main/java/org/apache/samza/drain/DrainUtils.java