mirror of https://github.com/apache/druid.git
Detailed error message when unable to create temp dir (#5648)
This commit is contained in:
parent
8e441cd142
commit
a7ba2bf275
|
@ -23,6 +23,7 @@ import com.fasterxml.jackson.annotation.JsonCreator;
|
|||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.io.Files;
|
||||
import io.druid.java.util.common.ISE;
|
||||
import io.druid.segment.IndexSpec;
|
||||
import io.druid.segment.realtime.appenderator.AppenderatorConfig;
|
||||
import io.druid.segment.realtime.plumber.IntervalStartVersioningPolicy;
|
||||
|
@ -55,7 +56,15 @@ public class RealtimeTuningConfig implements TuningConfig, AppenderatorConfig
|
|||
|
||||
private static File createNewBasePersistDirectory()
|
||||
{
|
||||
return Files.createTempDir();
|
||||
try {
|
||||
return Files.createTempDir();
|
||||
}
|
||||
catch (IllegalStateException e) {
|
||||
String messageTemplate = "Failed to create temporary directory in [%s]! " +
|
||||
"Make sure the `java.io.tmpdir` property is set to an existing and writable directory " +
|
||||
"with enough free space.";
|
||||
throw new ISE(e, messageTemplate, System.getProperty("java.io.tmpdir"));
|
||||
}
|
||||
}
|
||||
|
||||
// Might make sense for this to be a builder
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.junit.Assert;
|
|||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.UUID;
|
||||
|
||||
public class RealtimeTuningConfigTest
|
||||
{
|
||||
|
@ -39,6 +40,24 @@ public class RealtimeTuningConfigTest
|
|||
Assert.assertNotEquals(tuningConfig1.getBasePersistDirectory(), tuningConfig2.getBasePersistDirectory());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testErrorMessageIsMeaningfulWhenUnableToCreateTemporaryDirectory()
|
||||
{
|
||||
String propertyName = "java.io.tmpdir";
|
||||
String originalValue = System.getProperty(propertyName);
|
||||
try {
|
||||
String nonExistedDirectory = "/tmp/" + UUID.randomUUID();
|
||||
System.setProperty(propertyName, nonExistedDirectory);
|
||||
RealtimeTuningConfig.makeDefaultTuningConfig(null);
|
||||
}
|
||||
catch (IllegalStateException e) {
|
||||
Assert.assertTrue(e.getMessage().startsWith("Failed to create temporary directory in"));
|
||||
}
|
||||
finally {
|
||||
System.setProperty(propertyName, originalValue);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSpecificBasePersistDirectory()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue