use of java.io.StringWriter in project hive by apache.
the class FileSinkOperator method logOutputFormatError.
private void logOutputFormatError(Configuration hconf, HiveException ex) {
StringWriter errorWriter = new StringWriter();
errorWriter.append("Failed to create output format; configuration: ");
try {
Configuration.dumpConfiguration(hconf, errorWriter);
} catch (IOException ex2) {
errorWriter.append("{ failed to dump configuration: " + ex2.getMessage() + " }");
}
Properties tdp = null;
if (this.conf.getTableInfo() != null && (tdp = this.conf.getTableInfo().getProperties()) != null) {
errorWriter.append(";\n table properties: { ");
for (Map.Entry<Object, Object> e : tdp.entrySet()) {
errorWriter.append(e.getKey() + ": " + e.getValue() + ", ");
}
errorWriter.append('}');
}
LOG.error(errorWriter.toString(), ex);
}
use of java.io.StringWriter in project hbase by apache.
the class TestExecutorService method checkStatusDump.
private void checkStatusDump(ExecutorStatus status) throws IOException {
StringWriter sw = new StringWriter();
status.dumpTo(sw, "");
String dump = sw.toString();
LOG.info("Got status dump:\n" + dump);
assertTrue(dump.contains("Waiting on java.util.concurrent.atomic.AtomicBoolean"));
}
use of java.io.StringWriter in project hbase by apache.
the class TestConfServlet method testWriteXml.
@Test
public void testWriteXml() throws Exception {
StringWriter sw = new StringWriter();
ConfServlet.writeResponse(getTestConf(), sw, "xml");
String xml = sw.toString();
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = docBuilderFactory.newDocumentBuilder();
Document doc = builder.parse(new InputSource(new StringReader(xml)));
NodeList nameNodes = doc.getElementsByTagName("name");
boolean foundSetting = false;
for (int i = 0; i < nameNodes.getLength(); i++) {
Node nameNode = nameNodes.item(i);
String key = nameNode.getTextContent();
System.err.println("xml key: " + key);
if (TEST_KEY.equals(key)) {
foundSetting = true;
Element propertyElem = (Element) nameNode.getParentNode();
String val = propertyElem.getElementsByTagName("value").item(0).getTextContent();
assertEquals(TEST_VAL, val);
}
}
assertTrue(foundSetting);
}
use of java.io.StringWriter in project hbase by apache.
the class TestMemoryBoundedLogMessageBuffer method testNonAsciiEncoding.
@Test
public void testNonAsciiEncoding() {
MemoryBoundedLogMessageBuffer buf = new MemoryBoundedLogMessageBuffer(TEN_KB);
buf.add(JP_TEXT);
StringWriter sw = new StringWriter();
buf.dumpTo(new PrintWriter(sw));
String dump = sw.toString();
assertTrue(dump.contains(JP_TEXT));
}
use of java.io.StringWriter in project hive by apache.
the class TestGenericMR method testIdentityReduce.
public void testIdentityReduce() throws Exception {
final String in = "a\tb\nc\td";
final StringWriter out = new StringWriter();
new GenericMR().reduce(new StringReader(in), out, identityReducer());
assertEquals(in + "\n", out.toString());
}
Aggregations