use of java.io.Writer in project hadoop by apache.
the class TestMRIntermediateDataEncryption method createInput.
private void createInput(FileSystem fs, int numMappers, int numLines) throws Exception {
fs.delete(INPUT_DIR, true);
for (int i = 0; i < numMappers; i++) {
OutputStream os = fs.create(new Path(INPUT_DIR, "input_" + i + ".txt"));
Writer writer = new OutputStreamWriter(os);
for (int j = 0; j < numLines; j++) {
// Create sorted key, value pairs.
int k = j + 1;
String formattedNumber = String.format("%09d", k);
writer.write(formattedNumber + " " + formattedNumber + "\n");
}
writer.close();
}
}
use of java.io.Writer in project hadoop by apache.
the class TestLogsCLI method createContainerLogInLocalDir.
private static void createContainerLogInLocalDir(Path appLogsDir, ContainerId containerId, FileSystem fs, List<String> logTypes) throws Exception {
Path containerLogsDir = new Path(appLogsDir, containerId.toString());
if (fs.exists(containerLogsDir)) {
fs.delete(containerLogsDir, true);
}
assertTrue(fs.mkdirs(containerLogsDir));
for (String logType : logTypes) {
Writer writer = new FileWriter(new File(containerLogsDir.toString(), logType));
writer.write(logMessage(containerId, logType));
writer.close();
}
}
use of java.io.Writer in project hadoop by apache.
the class TestMapReduceLazyOutput method createInput.
public void createInput(FileSystem fs, int numMappers) throws Exception {
for (int i = 0; i < numMappers; i++) {
OutputStream os = fs.create(new Path(INPUTPATH, "text" + i + ".txt"));
Writer wr = new OutputStreamWriter(os);
for (String inp : INPUTLIST) {
wr.write(inp + "\n");
}
wr.close();
}
}
use of java.io.Writer in project hadoop by apache.
the class TestStreamingBadRecords method createInput.
private void createInput() throws Exception {
OutputStream os = getFileSystem().create(new Path(getInputDir(), "text.txt"));
Writer wr = new OutputStreamWriter(os);
//increasing the record size so that we have stream flushing
String prefix = new String(new byte[20 * 1024]);
for (int i = 1; i <= INPUTSIZE; i++) {
String str = "" + i;
int zerosToPrepend = 3 - str.length();
for (int j = 0; j < zerosToPrepend; j++) {
str = "0" + str;
}
wr.write(prefix + "hey" + str + "\n");
}
wr.close();
}
use of java.io.Writer in project hbase by apache.
the class ConfServlet method doGet.
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
if (!HttpServer.isInstrumentationAccessAllowed(getServletContext(), request, response)) {
return;
}
String format = request.getParameter(FORMAT_PARAM);
if (null == format) {
format = FORMAT_XML;
}
if (FORMAT_XML.equals(format)) {
response.setContentType("text/xml; charset=utf-8");
} else if (FORMAT_JSON.equals(format)) {
response.setContentType("application/json; charset=utf-8");
}
Writer out = response.getWriter();
try {
writeResponse(getConfFromContext(), out, format);
} catch (BadFormatException bfe) {
response.sendError(HttpServletResponse.SC_BAD_REQUEST, bfe.getMessage());
}
out.close();
}
Aggregations