Fix NPE when locations are empty (#4667)

* Fix NPE when locations are empty

* Addressing comments
This commit is contained in:
Niketh Sabbineni 2017-08-10 23:31:28 -07:00 committed by Gian Merlino
parent 5ff8c52f16
commit eb0deba54a
2 changed files with 6 additions and 1 deletions

View File

@ -31,7 +31,7 @@ The historical node uses several of the global configs in [Configuration](../con
|Property|Description|Default|
|--------|-----------|-------|
|`druid.segmentCache.locations`|Segments assigned to a Historical node are first stored on the local file system (in a disk cache) and then served by the Historical node. These locations define where that local cache resides. | none (no caching) |
|`druid.segmentCache.locations`|Segments assigned to a Historical node are first stored on the local file system (in a disk cache) and then served by the Historical node. These locations define where that local cache resides. This value cannot be NULL or EMPTY. Here is an example `druid.segmentCache.locations=[{"path": "/mnt/druidSegments", "maxSize": 10000}]`.| none |
|`druid.segmentCache.deleteOnRemove`|Delete segment files from cache once a node is no longer serving a segment.|true|
|`druid.segmentCache.dropSegmentDelayMillis`|How long a node delays before completely dropping segment.|30000 (30 seconds)|
|`druid.segmentCache.infoDir`|Historical nodes keep track of the segments they are serving so that when the process is restarted they can reload the same segments without waiting for the Coordinator to reassign. This path defines where this metadata is kept. Directory will be created if needed.|${first_location}/info_dir|

View File

@ -21,6 +21,7 @@ package io.druid.segment.loading;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.collect.Lists;
import io.druid.java.util.common.ISE;
import org.hibernate.validator.constraints.NotEmpty;
import java.io.File;
@ -85,6 +86,10 @@ public class SegmentLoaderConfig
public File getInfoDir()
{
if (infoDir == null) {
if (locations == null || locations.size() == 0) {
throw new ISE("You have no segment cache locations defined. Please configure druid.segmentCache.locations to use one or more locations.");
}
infoDir = new File(locations.get(0).getPath(), "info_dir");
}