|
@@ -22,6 +22,8 @@ import com.google.common.annotations.VisibleForTesting;
|
|
import com.google.common.base.Joiner;
|
|
import com.google.common.base.Joiner;
|
|
import com.google.common.base.Preconditions;
|
|
import com.google.common.base.Preconditions;
|
|
import com.google.common.base.Strings;
|
|
import com.google.common.base.Strings;
|
|
|
|
+
|
|
|
|
+import org.apache.commons.lang.math.RandomUtils;
|
|
import org.apache.commons.logging.Log;
|
|
import org.apache.commons.logging.Log;
|
|
import org.apache.commons.logging.LogFactory;
|
|
import org.apache.commons.logging.LogFactory;
|
|
import org.apache.hadoop.fs.CommonConfigurationKeys;
|
|
import org.apache.hadoop.fs.CommonConfigurationKeys;
|
|
@@ -59,7 +61,6 @@ import java.util.Random;
|
|
import java.util.Set;
|
|
import java.util.Set;
|
|
import java.util.regex.Pattern;
|
|
import java.util.regex.Pattern;
|
|
import java.net.InetSocketAddress;
|
|
import java.net.InetSocketAddress;
|
|
-
|
|
|
|
import static org.apache.hadoop.fs.CreateFlag.CREATE;
|
|
import static org.apache.hadoop.fs.CreateFlag.CREATE;
|
|
import static org.apache.hadoop.fs.CreateFlag.OVERWRITE;
|
|
import static org.apache.hadoop.fs.CreateFlag.OVERWRITE;
|
|
|
|
|
|
@@ -310,9 +311,9 @@ public class DockerContainerExecutor extends ContainerExecutor {
|
|
PrintStream ps = null;
|
|
PrintStream ps = null;
|
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
|
try {
|
|
try {
|
|
- pout = new PrintStream(out);
|
|
|
|
|
|
+ pout = new PrintStream(out, false, "UTF-8");
|
|
if (LOG.isDebugEnabled()) {
|
|
if (LOG.isDebugEnabled()) {
|
|
- ps = new PrintStream(baos);
|
|
|
|
|
|
+ ps = new PrintStream(baos, false, "UTF-8");
|
|
sb.write(ps);
|
|
sb.write(ps);
|
|
}
|
|
}
|
|
sb.write(pout);
|
|
sb.write(pout);
|
|
@@ -326,7 +327,7 @@ public class DockerContainerExecutor extends ContainerExecutor {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (LOG.isDebugEnabled()) {
|
|
if (LOG.isDebugEnabled()) {
|
|
- LOG.debug("Script: " + baos.toString());
|
|
|
|
|
|
+ LOG.debug("Script: " + baos.toString("UTF-8"));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -440,7 +441,7 @@ public class DockerContainerExecutor extends ContainerExecutor {
|
|
|
|
|
|
try {
|
|
try {
|
|
out = lfs.create(wrapperScriptPath, EnumSet.of(CREATE, OVERWRITE));
|
|
out = lfs.create(wrapperScriptPath, EnumSet.of(CREATE, OVERWRITE));
|
|
- pout = new PrintStream(out);
|
|
|
|
|
|
+ pout = new PrintStream(out, false, "UTF-8");
|
|
writeLocalWrapperScript(launchDst, pidFile, pout);
|
|
writeLocalWrapperScript(launchDst, pidFile, pout);
|
|
} finally {
|
|
} finally {
|
|
IOUtils.cleanup(LOG, pout, out);
|
|
IOUtils.cleanup(LOG, pout, out);
|
|
@@ -498,7 +499,7 @@ public class DockerContainerExecutor extends ContainerExecutor {
|
|
PrintStream pout = null;
|
|
PrintStream pout = null;
|
|
try {
|
|
try {
|
|
out = lfs.create(sessionScriptPath, EnumSet.of(CREATE, OVERWRITE));
|
|
out = lfs.create(sessionScriptPath, EnumSet.of(CREATE, OVERWRITE));
|
|
- pout = new PrintStream(out);
|
|
|
|
|
|
+ pout = new PrintStream(out, false, "UTF-8");
|
|
// We need to do a move as writing to a file is not atomic
|
|
// We need to do a move as writing to a file is not atomic
|
|
// Process reading a file being written to may get garbled data
|
|
// Process reading a file being written to may get garbled data
|
|
// hence write pid to tmp file first followed by a mv
|
|
// hence write pid to tmp file first followed by a mv
|
|
@@ -736,8 +737,7 @@ public class DockerContainerExecutor extends ContainerExecutor {
|
|
|
|
|
|
// make probability to pick a directory proportional to
|
|
// make probability to pick a directory proportional to
|
|
// the available space on the directory.
|
|
// the available space on the directory.
|
|
- Random r = new Random();
|
|
|
|
- long randomPosition = Math.abs(r.nextLong()) % totalAvailable;
|
|
|
|
|
|
+ long randomPosition = RandomUtils.nextLong() % totalAvailable;
|
|
int dir = 0;
|
|
int dir = 0;
|
|
// skip zero available space directory,
|
|
// skip zero available space directory,
|
|
// because totalAvailable is greater than 0 and randomPosition
|
|
// because totalAvailable is greater than 0 and randomPosition
|