Skip to content

Commit 97a2054

Browse files
author
Greg Denton
authored
Make job log directory location be configurable in opencue.properties (#223)
* make job log directory location be configurable in opencue.properties * adding tests for getting job logs
1 parent cef1484 commit 97a2054

File tree

3 files changed

+83
-5
lines changed

3 files changed

+83
-5
lines changed

cuebot/src/main/java/com/imageworks/spcue/util/JobLogUtil.java

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,17 @@
2020
package com.imageworks.spcue.util;
2121

2222
import java.io.File;
23+
24+
import org.springframework.beans.factory.annotation.Value;
25+
import org.springframework.stereotype.Component;
26+
2327
import com.imageworks.spcue.JobDetail;
2428

29+
@Component
2530
public class JobLogUtil {
2631

32+
public static String jobLogRootDir;
33+
2734
public static boolean createJobLogDirectory(String path) {
2835
File f = new File(path);
2936
f.mkdir();
@@ -32,24 +39,41 @@ public static boolean createJobLogDirectory(String path) {
3239
}
3340

3441
public static boolean shotLogDirectoryExists(String show, String shot) {
35-
return new File(String.format("/shots/%s/%s/logs", show, shot)).exists();
42+
return new File(getJobLogDir(show, shot)).exists();
3643
}
3744

3845
public static boolean jobLogDirectoryExists(JobDetail job) {
3946
return new File(job.logDir).exists();
4047
}
4148

49+
public static String getJobLogDir(String show, String shot) {
50+
StringBuilder sb = new StringBuilder(512);
51+
sb.append(jobLogRootDir);
52+
sb.append("/");
53+
sb.append(show);
54+
sb.append("/");
55+
sb.append(shot);
56+
sb.append("/logs");
57+
return sb.toString();
58+
}
59+
4260
public static String getJobLogPath(JobDetail job) {
4361
StringBuilder sb = new StringBuilder(512);
44-
sb.append("/shots/");
45-
sb.append(job.showName);
62+
sb.append(getJobLogDir(job.showName, job.shot));
4663
sb.append("/");
47-
sb.append(job.shot);
48-
sb.append("/logs/");
4964
sb.append(job.name);
5065
sb.append("--");
5166
sb.append(job.id);
5267
return sb.toString();
5368
}
69+
70+
public static String getJobLogRootDir() {
71+
return jobLogRootDir;
72+
}
73+
74+
@Value("${log.frameLogDirRoot}")
75+
public void setJobLogRootDir(String logRootDir) {
76+
jobLogRootDir = logRootDir;
77+
}
5478
}
5579

cuebot/src/main/resources/opencue.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,6 @@ grpc.rqd_server_port=${CUEBOT_GRPC_RQD_SERVER_PORT:8444}
2828
# Whether or not to enable publishing to a messaging topic.
2929
# Set to a boolean value. See com/imageworks/spcue/services/JmsMover.java.
3030
messaging.enabled=false
31+
32+
# Root directory for which logs will be stored. See com/imageworks/spcue/util/JobLogUtil.java.
33+
log.frameLogDirRoot=/shots
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Copyright (c) 2018 Sony Pictures Imageworks Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
18+
19+
package com.imageworks.spcue.test.util;
20+
21+
import junit.framework.TestCase;
22+
import org.junit.Before;
23+
24+
import com.imageworks.spcue.JobDetail;
25+
import com.imageworks.spcue.util.JobLogUtil;
26+
27+
public class JobLogUtilTests extends TestCase {
28+
29+
@Before
30+
public void setUp() {
31+
JobLogUtil.jobLogRootDir = "/shots";
32+
}
33+
34+
public void testGetJobLogRootDir() {
35+
assertEquals(JobLogUtil.getJobLogRootDir(), "/shots");
36+
}
37+
38+
public void testGetJobLogDir() {
39+
assertEquals(JobLogUtil.getJobLogDir("show", "shot"), "/shots/show/shot/logs");
40+
}
41+
42+
public void testGetJobLogPath() {
43+
JobDetail jobDetail = new JobDetail();
44+
jobDetail.id = "id";
45+
jobDetail.name = "name";
46+
jobDetail.showName = "show";
47+
jobDetail.shot = "shot";
48+
assertEquals(JobLogUtil.getJobLogPath(jobDetail), "/shots/show/shot/logs/name--id");
49+
}
50+
}
51+

0 commit comments

Comments
 (0)