rmatharu commented on code in PR #1604:
URL: https://github.com/apache/samza/pull/1604#discussion_r879942331
##########
samza-core/src/main/java/org/apache/samza/config/JobConfig.java:
##########
@@ -431,18 +433,30 @@ public boolean getStandbyTasksEnabled() {
}
/**
- * The metadata file is written in a {@code exec-env-container-id}.metadata
file in the log-dir of the container.
- * Here the {@code exec-env-container-id} refers to the ID assigned by the
cluster manager (e.g., YARN) to the container,
- * which uniquely identifies a container's lifecycle.
+ * Get the {@link File} in the "samza.log.dir" for writing container
metadata.
+ * If {@link EnvironmentVariables#ENV_CONTAINER_METADATA_FILENAME} is
specified, then use that as the file name.
+ * Otherwise, the file name is {@code exec-env-container-id}.metadata. Here
the {@code exec-env-container-id} refers
+ * to the ID assigned by the cluster manager (e.g., YARN) to the container,
which uniquely identifies a container's
+ * lifecycle.
*/
public static Optional<File> getMetadataFile(String execEnvContainerId) {
String dir = System.getProperty(CONTAINER_METADATA_DIRECTORY_SYS_PROPERTY);
- if (dir == null || execEnvContainerId == null) {
- return Optional.empty();
- } else {
- return Optional.of(
- new File(dir, String.format(CONTAINER_METADATA_FILENAME_FORMAT,
execEnvContainerId)));
+ if (dir != null) {
+ String fileName =
System.getenv(EnvironmentVariables.ENV_CONTAINER_METADATA_FILENAME);
+ if (StringUtils.isNotBlank(fileName)) {
+ if (fileName.contains(File.separator)) {
+ throw new IllegalStateException(String.format("%s should not include
directories, but it is %s",
+ EnvironmentVariables.ENV_CONTAINER_METADATA_FILENAME, fileName));
+ } else {
+ return Optional.of(new File(dir, fileName));
+ }
+ } else {
+ if (execEnvContainerId != null) {
Review Comment:
Would it be useful to add a
LOG.info("Choosing metadata filename: %s %s", dir, filename)
?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]