Skip to content

Add log dir creation in ProcessRuntime#3114

Merged
srkukarni merged 1 commit intoapache:masterfrom
aahmed-se:logdir1
Dec 4, 2018
Merged

Add log dir creation in ProcessRuntime#3114
srkukarni merged 1 commit intoapache:masterfrom
aahmed-se:logdir1

Conversation

@aahmed-se
Copy link
Contributor

We create the expected log folder in the ProcessRuntime before the function process logger attempts to create it. This is because if multiple instances are launched they can encounter a race condition in creation of the directory.

log.info("Creating function log directory {}", funcLogDir);
boolean success = createFolder(funcLogDir);

if (!success) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So what if the directory is already there? Shouldn't throw exception because directory is already there

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fine since new File(path).mkdirs() is idempotent

}

private boolean createFolder(final String path) {
final boolean success = new File(path).mkdirs();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should only attempt to create directories if they are not present

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fine since new File(path).mkdirs() is idempotent

@srkukarni srkukarni merged commit 45b6d73 into apache:master Dec 4, 2018
@aahmed-se aahmed-se deleted the logdir1 branch December 4, 2018 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants