private LocalResource createLocalResource(Path resourcePath, LocalResourceType resourceType, LocalResourceVisibility resourceVisibility) {
    LocalResource localResource = Records.newRecord(LocalResource.class);
    URL resourceUrl = ConverterUtils.getYarnUrlFromPath(resourcePath);
    try {
      FileStatus resourceFileStatus = resourcePath.getFileSystem(yarnConfiguration).getFileStatus(resourcePath);

      if (null == resourceFileStatus) {
        throw new LocalizerResourceException("Check getFileStatus implementation. getFileStatus gets unexpected null for resourcePath " + resourcePath);
      }

      localResource.setResource(resourceUrl);
      log.info("setLocalizerResource for {}", resourceUrl);
      localResource.setSize(resourceFileStatus.getLen());
      localResource.setTimestamp(resourceFileStatus.getModificationTime());
      localResource.setType(resourceType);
      localResource.setVisibility(resourceVisibility);
      return localResource;
    } catch (IOException ioe) {
      log.error("IO Exception when accessing the resource file status from the filesystem: " + resourcePath, ioe);
      throw new LocalizerResourceException("IO Exception when accessing the resource file status from the filesystem: " + resourcePath);
    }

  }
A universal approach to generate local resource map which can be put in ContainerLaunchContext directly
samza-yarn3/src/main/java/org/apache/samza/job/yarn/LocalizerResourceMapper.java