private void publishMetadata(String metadataValue, int branchId, Path metadataOutputPath)
      throws IOException {
    try {
      if (metadataOutputPath == null) {
        LOG.info("Metadata output path not set for branch " + String.valueOf(branchId) + ", not publishing.");
        return;
      }

      if (metadataValue == null) {
        LOG.info("No metadata collected for branch " + String.valueOf(branchId) + ", not publishing.");
        return;
      }

      FileSystem fs = this.metaDataWriterFileSystemByBranches.get(branchId);

        if (!fs.exists(metadataOutputPath.getParent())) {
          WriterUtils.mkdirsWithRecursivePermissionWithRetry(fs, metadataOutputPath, this.permissions.get(branchId), retrierConfig);
        }

      //Delete the file if metadata already exists
      if (fs.exists(metadataOutputPath)) {
        HadoopUtils.deletePath(fs, metadataOutputPath, false);
      }
      LOG.info("Writing metadata for branch " + String.valueOf(branchId) + " to " + metadataOutputPath.toString());
      try (FSDataOutputStream outputStream = fs.create(metadataOutputPath)) {
        outputStream.write(metadataValue.getBytes(StandardCharsets.UTF_8));
      }
    } catch (IOException e) {
      LOG.error("Metadata file is not generated: " + e, e);
    }
  }
private void publishMetadata ( String metadataValue , int branchId , Path metadataOutputPath ) throws IOException { try { if ( metadataOutputPath == null ) { LOG . info ( "Metadata output path not set for branch " + String . valueOf ( branchId ) + ", not publishing." ) ; return ; } if ( metadataValue == null ) { LOG . info ( "No metadata collected for branch " + String . valueOf ( branchId ) + ", not publishing." ) ; return ; } FileSystem fs = this . metaDataWriterFileSystemByBranches . get ( branchId ) ; if ( ! fs . exists ( metadataOutputPath . getParent ( ) ) ) { WriterUtils . mkdirsWithRecursivePermissionWithRetry ( fs , metadataOutputPath , this . permissions . get ( branchId ) , retrierConfig ) ; } if ( fs . exists ( metadataOutputPath ) ) { HadoopUtils . deletePath ( fs , metadataOutputPath , false ) ; } LOG . info ( "Writing metadata for branch " + String . valueOf ( branchId ) + " to " + metadataOutputPath . toString ( ) ) ; try ( FSDataOutputStream outputStream = fs . create ( metadataOutputPath ) ) { outputStream . write ( metadataValue . getBytes ( StandardCharsets . UTF_8 ) ) ; } } catch ( IOException e ) { LOG . error ( "Metadata file is not generated: " + e , e ) ; } }
Publish metadata to a set of paths