public void writeContainerToHostMapping(String processorId, String hostName) {
    String existingHostMapping = Optional.ofNullable(readLocality().getProcessorLocality(processorId))
        .map(ProcessorLocality::host)
        .orElse(null);
    if (StringUtils.isNotBlank(existingHostMapping) && !existingHostMapping.equals(hostName)) {
      LOG.info("Container {} moved from {} to {}", processorId, existingHostMapping, hostName);
    } else {
      LOG.info("Container {} started at {}", processorId, hostName);
    }

    metadataStore.put(processorId, valueSerde.toBytes(hostName));
    metadataStore.flush();
  }
Method to write locality information to the {@link MetadataStore}. This method is used in {@link SamzaContainer}.

@param processorId a.k.a logical container ID
@param hostName  the hostname
samza-core/src/main/java/org/apache/samza/container/LocalityManager.java