Skip to content

Commit a8006ad

Browse files
Address PR comments
1 parent 6e29923 commit a8006ad

File tree

5 files changed

+10
-22
lines changed

5 files changed

+10
-22
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ Current
7575

7676
### Changed:
7777

78-
- [Added mandatory logging for LoadTask errors]
78+
- [Added mandatory logging for LoadTask errors](https://github.com/yahoo/fili/pull/553)
7979
* Finalized `run()` in `LoadTask` with mandatory logging of exceptions.
8080
* Created mandatory runInner to replace run in all `LoadTask` instances
8181

fili-core/src/main/java/com/yahoo/bard/webservice/application/LoadTask.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import com.yahoo.bard.webservice.druid.client.FailureCallback;
66
import com.yahoo.bard.webservice.druid.client.HttpErrorCallback;
7+
import com.yahoo.bard.webservice.web.ErrorMessageFormat;
78

89
import org.slf4j.Logger;
910
import org.slf4j.LoggerFactory;
@@ -20,7 +21,6 @@
2021
public abstract class LoadTask<V> implements Runnable {
2122

2223
private static final Logger LOG = LoggerFactory.getLogger(LoadTask.class);
23-
public static final String LOAD_TASK_ERROR_FORMAT = "Exception while running %s: %s";
2424

2525
protected final String loaderName;
2626
protected final long delay;
@@ -65,7 +65,7 @@ public final void run() {
6565
try {
6666
runInner();
6767
} catch (RuntimeException t) {
68-
LOG.error(String.format(LOAD_TASK_ERROR_FORMAT, getName(), t.getMessage()), t);
68+
LOG.error(ErrorMessageFormat.LOAD_TASK_FAILURE.logFormat(getName(), t.getMessage()), t);
6969
failed = true;
7070
throw t;
7171
}

fili-core/src/main/java/com/yahoo/bard/webservice/data/dimension/impl/LuceneSearchProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ public void clearDimension() {
458458
writer.deleteAll();
459459
writer.commit();
460460
} catch (IOException e) {
461-
LOG.error(ErrorMessageFormat.FAIL_TO_WIPTE_LUCENE_INDEX_DIR.format(luceneDirectory));
461+
LOG.error(ErrorMessageFormat.FAIL_TO_WIPE_LUCENE_INDEX_DIR.format(luceneDirectory));
462462
throw new RuntimeException(e);
463463
}
464464

fili-core/src/main/java/com/yahoo/bard/webservice/web/ErrorMessageFormat.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,9 @@ public enum ErrorMessageFormat implements MessageFormatter {
259259

260260
UNABLE_TO_CREATE_DIR("Unable to create directory %s."),
261261
UNABLE_TO_DELETE_DIR("Unable to delete directory %s."),
262-
FAIL_TO_WIPTE_LUCENE_INDEX_DIR("Failed to wipe Lucene index at directory: %s")
262+
FAIL_TO_WIPE_LUCENE_INDEX_DIR("Failed to wipe Lucene index at directory: %s"),
263+
264+
LOAD_TASK_FAILURE("Exception while running %s: %s")
263265
;
264266

265267
private final String messageFormat;

fili-core/src/test/groovy/com/yahoo/bard/webservice/application/LoadTaskSpec.groovy

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import com.yahoo.bard.webservice.druid.client.FailureCallback
1010
import com.yahoo.bard.webservice.druid.client.HttpErrorCallback
1111
import com.yahoo.bard.webservice.logging.TestLogAppender
1212

13-
import com.fasterxml.jackson.databind.ObjectMapper
14-
1513
import spock.lang.Ignore
1614
import spock.lang.Specification
1715
import spock.lang.Timeout
@@ -240,8 +238,7 @@ class LoadTaskSpec extends Specification {
240238

241239
class FailingTestLoadTask extends LoadTaskSpec.OneOffTestLoadTask {
242240

243-
244-
public static final String UNIQUE_VALUE_1 = "UNIQUE_VALUE_1"
241+
public static final String UNIQUE_VALUE_1 = "FailingTestLoadTask.UNIQUE_VALUE_1"
245242

246243
FailingTestLoadTask(long delay) {
247244
super(delay)
@@ -253,26 +250,15 @@ class LoadTaskSpec extends Specification {
253250
}
254251
}
255252

256-
257253
def "Test error gets logged on failed test"() {
258-
setup:
259254
setup: "Instantiate a task scheduler"
260-
ObjectMapper MAPPER = new ObjectMappersSuite().getMapper()
261-
262-
263255
TaskScheduler scheduler = new TaskScheduler(2)
264256
LoadTask<Boolean> loader = new FailingTestLoadTask(expectedDelay)
265-
loader.setFuture(
266-
scheduler.schedule(
267-
loader,
268-
1,
269-
TimeUnit.MILLISECONDS
270-
)
271-
)
257+
loader.setFuture(scheduler.schedule(loader,1, TimeUnit.MILLISECONDS))
272258
Thread.sleep(10)
273259

274260
expect:
275261
loader.failed
276-
logAppender.getMessages().find { it.contains(/UNIQUE_VALUE_1/) }
262+
logAppender.getMessages().find { it.contains(/FailingTestLoadTask.UNIQUE_VALUE_1/) }
277263
}
278264
}

0 commit comments

Comments
 (0)