[ https://issues.apache.org/jira/browse/CASSANDRA-12273?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15585145#comment-15585145 ]
Murukesh Mohanan edited comment on CASSANDRA-12273 at 10/18/16 10:46 AM: ------------------------------------------------------------------------- The attached patch uses {{Files.createDirectories}} to create any missing parent directories. {{Files.createDirectories}} will just return {{false}} if the parent directory path already exists and is a directory, or {{true}} if it could create the directory, so we can safely ignore the return value and look only at the exceptions it throws. If the path was a file, it will throw an exception. Unfortunately, it will *also* throw an exception if the path was a symbolic link, so I have added a check for that. Result when running {{tools/bin/cassandra-stress write n=1900 -graph file=bar/foo.html -port native=9142 > /dev/null; find bar -ls}}: h4. Before Case: {{bar/}} exists {code} 1701385 8 drwxr-xr-x 1 user group 3 Oct 18 19:39 bar 1701386 8 -rw-r--r-- 1 user group 3 Oct 18 19:39 bar/foo.html {code} Case: {{bar/}} doesn't exist {code} java.lang.RuntimeException: Couldn't write stats html. at org.apache.cassandra.stress.StressGraph.generateGraph(StressGraph.java:95) at org.apache.cassandra.stress.Stress.run(Stress.java:146) at org.apache.cassandra.stress.Stress.main(Stress.java:62) find: {{bar/}}: No such file or directory {code} Case: {{bar/}} is a file {code} java.lang.RuntimeException: Couldn't write stats html. at org.apache.cassandra.stress.StressGraph.generateGraph(StressGraph.java:95) at org.apache.cassandra.stress.Stress.run(Stress.java:146) at org.apache.cassandra.stress.Stress.main(Stress.java:62) 1701467 0 -rw-r--r-- 1 user group 0 Oct 18 19:41 bar {code} Case: {{bar/}} is a link to non-existing file {code} java.lang.RuntimeException: Couldn't write stats html. at org.apache.cassandra.stress.StressGraph.generateGraph(StressGraph.java:95) at org.apache.cassandra.stress.Stress.run(Stress.java:146) at org.apache.cassandra.stress.Stress.main(Stress.java:62) 1701472 8 lrwxr-xr-x 1 user group 8 Oct 18 19:41 bar -> /nothing {code} Case: {{bar/}} is a link to an existing directory {code} 1701477 8 lrwxr-xr-x 1 user group 3 Oct 18 19:41 bar -> foo 1701476 0 drwxr-xr-x 3 user group 102 Oct 18 19:41 bar 1701484 520 -rw-r--r-- 1 user group 265292 Oct 18 19:41 bar/foo.html {code} h4. After Case: {{bar/}} exists {code} 1701094 0 drwxr-xr-x 3 user group 102 Oct 18 19:30 bar 1701099 520 -rw-r--r-- 1 user group 265295 Oct 18 19:30 bar/foo.html {code} Case: {{bar/}} doesn't exist {code} 1701094 0 drwxr-xr-x 3 user group 102 Oct 18 19:30 bar 1701095 520 -rw-r--r-- 1 user group 265381 Oct 18 19:30 bar/foo.html {code} Case: {{bar/}} is a file {code} java.lang.RuntimeException: Parent directory of stats html is a file. at org.apache.cassandra.stress.StressGraph.generateGraph(StressGraph.java:104) at org.apache.cassandra.stress.Stress.run(Stress.java:146) at org.apache.cassandra.stress.Stress.main(Stress.java:62) 1701100 0 -rw-r--r-- 1 user group 0 Oct 18 19:30 bar {code} Case: {{bar/}} is a link to non-existing file {code} java.lang.RuntimeException: Couldn't write stats html. at org.apache.cassandra.stress.StressGraph.generateGraph(StressGraph.java:108) at org.apache.cassandra.stress.Stress.run(Stress.java:146) at org.apache.cassandra.stress.Stress.main(Stress.java:62) 1701107 8 lrwxr-xr-x 1 user group 8 Oct 18 19:30 bar -> /nothing {code} Case: {{bar/}} is a link to an existing directory {code} 1701112 8 lrwxr-xr-x 1 user group 3 Oct 18 19:30 bar -> foo 1701111 0 drwxr-xr-x 3 user group 102 Oct 18 19:31 bar 1701116 520 -rw-r--r-- 1 user group 265301 Oct 18 19:31 bar/foo.html {code} was (Author: muru): The attached patch uses {{Files.createDirectories}} to create any missing parent directories. {{Files.createDirectories}} will just return {{false}} if the parent directory path already exists and is a directory, or {{true}} if it could create the directory, so we can safely ignore the return value and look only at the exceptions it throws. If the path was a file, it will throw an exception. Unfortunately, it will *also* throw an exception if the path was a symbolic link, so I have added a check for that. Result when running {{tools/bin/cassandra-stress write n=1900 -graph file=bar/foo.html -port native=9142 > /dev/null; find bar -ls}}: h4. Before Case: {{bar/}} exists {code} 1701385 8 lrwxr-xr-x 1 user group 3 Oct 18 19:39 bar -> foo {code} Case: {{bar/}} doesn't exist {code} java.lang.RuntimeException: Couldn't write stats html. at org.apache.cassandra.stress.StressGraph.generateGraph(StressGraph.java:95) at org.apache.cassandra.stress.Stress.run(Stress.java:146) at org.apache.cassandra.stress.Stress.main(Stress.java:62) find: {{bar/}}: No such file or directory {code} Case: {{bar/}} is a file {code} java.lang.RuntimeException: Couldn't write stats html. at org.apache.cassandra.stress.StressGraph.generateGraph(StressGraph.java:95) at org.apache.cassandra.stress.Stress.run(Stress.java:146) at org.apache.cassandra.stress.Stress.main(Stress.java:62) 1701467 0 -rw-r--r-- 1 user group 0 Oct 18 19:41 bar {code} Case: {{bar/}} is a link to non-existing file {code} java.lang.RuntimeException: Couldn't write stats html. at org.apache.cassandra.stress.StressGraph.generateGraph(StressGraph.java:95) at org.apache.cassandra.stress.Stress.run(Stress.java:146) at org.apache.cassandra.stress.Stress.main(Stress.java:62) 1701472 8 lrwxr-xr-x 1 user group 8 Oct 18 19:41 bar -> /nothing {code} Case: {{bar/}} is a link to an existing directory {code} 1701477 8 lrwxr-xr-x 1 user group 3 Oct 18 19:41 bar -> foo 1701476 0 drwxr-xr-x 3 user group 102 Oct 18 19:41 bar 1701484 520 -rw-r--r-- 1 user group 265292 Oct 18 19:41 bar/foo.html {code} h4. After Case: {{bar/}} exists {code} 1701094 0 drwxr-xr-x 3 user group 102 Oct 18 19:30 bar 1701099 520 -rw-r--r-- 1 user group 265295 Oct 18 19:30 bar/foo.html {code} Case: {{bar/}} doesn't exist {code} 1701094 0 drwxr-xr-x 3 user group 102 Oct 18 19:30 bar 1701095 520 -rw-r--r-- 1 user group 265381 Oct 18 19:30 bar/foo.html {code} Case: {{bar/}} is a file {code} java.lang.RuntimeException: Parent directory of stats html is a file. at org.apache.cassandra.stress.StressGraph.generateGraph(StressGraph.java:104) at org.apache.cassandra.stress.Stress.run(Stress.java:146) at org.apache.cassandra.stress.Stress.main(Stress.java:62) 1701100 0 -rw-r--r-- 1 user group 0 Oct 18 19:30 bar {code} Case: {{bar/}} is a link to non-existing file {code} java.lang.RuntimeException: Couldn't write stats html. at org.apache.cassandra.stress.StressGraph.generateGraph(StressGraph.java:108) at org.apache.cassandra.stress.Stress.run(Stress.java:146) at org.apache.cassandra.stress.Stress.main(Stress.java:62) 1701107 8 lrwxr-xr-x 1 user group 8 Oct 18 19:30 bar -> /nothing {code} Case: {{bar/}} is a link to an existing directory {code} 1701112 8 lrwxr-xr-x 1 user group 3 Oct 18 19:30 bar -> foo 1701111 0 drwxr-xr-x 3 user group 102 Oct 18 19:31 bar 1701116 520 -rw-r--r-- 1 user group 265301 Oct 18 19:31 bar/foo.html {code} > Casandra stess graph: option to create directory for graph if it doesn't exist > ------------------------------------------------------------------------------ > > Key: CASSANDRA-12273 > URL: https://issues.apache.org/jira/browse/CASSANDRA-12273 > Project: Cassandra > Issue Type: Improvement > Components: Tools > Reporter: Christopher Batey > Assignee: Christopher Batey > Priority: Minor > Labels: lhf > Attachments: 12273.patch > > > I am running it in CI with ephemeral workspace / build dirs. It would be > nice if CS would create the directory so my build tool doesn't have to -- This message was sent by Atlassian JIRA (v6.3.4#6332)