use of java.io.OutputStreamWriter in project druid by druid-io.
the class NamespacedExtractorModuleTest method testListNamespaces.
@Test
public void testListNamespaces() throws Exception {
final File tmpFile = temporaryFolder.newFile();
try (OutputStreamWriter out = new FileWriter(tmpFile)) {
out.write(mapper.writeValueAsString(ImmutableMap.<String, String>of("foo", "bar")));
}
final URIExtractionNamespace namespace = new URIExtractionNamespace(tmpFile.toURI(), null, null, new URIExtractionNamespace.ObjectMapperFlatDataParser(URIExtractionNamespaceTest.registerTypes(new DefaultObjectMapper())), new Period(0), null);
try (CacheScheduler.Entry entry = scheduler.scheduleAndWait(namespace, 1_000)) {
Assert.assertNotNull(entry);
entry.awaitTotalUpdates(1);
Assert.assertEquals(1, scheduler.getActiveEntries());
}
}
use of java.io.OutputStreamWriter in project druid by druid-io.
the class NamespacedExtractorModuleTest method testDeleteNamespaces.
//(timeout = 10_000)
@Test
public void testDeleteNamespaces() throws Exception {
final File tmpFile = temporaryFolder.newFile();
try (OutputStreamWriter out = new FileWriter(tmpFile)) {
out.write(mapper.writeValueAsString(ImmutableMap.<String, String>of("foo", "bar")));
}
final URIExtractionNamespace namespace = new URIExtractionNamespace(tmpFile.toURI(), null, null, new URIExtractionNamespace.ObjectMapperFlatDataParser(URIExtractionNamespaceTest.registerTypes(new DefaultObjectMapper())), new Period(0), null);
try (CacheScheduler.Entry entry = scheduler.scheduleAndWait(namespace, 1_000)) {
Assert.assertNotNull(entry);
}
}
use of java.io.OutputStreamWriter in project druid by druid-io.
the class FileSmoosher method close.
@Override
public void close() throws IOException {
//book keeping checks on created file.
if (!completedFiles.isEmpty() || !filesInProcess.isEmpty()) {
for (File file : completedFiles) {
if (!file.delete()) {
LOG.warn("Unable to delete file [%s]", file);
}
}
for (File file : filesInProcess) {
if (!file.delete()) {
LOG.warn("Unable to delete file [%s]", file);
}
}
throw new ISE("[%d] writers in progress and [%d] completed writers needs to be closed before closing smoosher.", filesInProcess.size(), completedFiles.size());
}
if (currOut != null) {
currOut.close();
}
File metaFile = metaFile(baseDir);
try (Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(metaFile), Charsets.UTF_8))) {
out.write(String.format("v1,%d,%d", maxChunkSize, outFiles.size()));
out.write("\n");
for (Map.Entry<String, Metadata> entry : internalFiles.entrySet()) {
final Metadata metadata = entry.getValue();
out.write(joiner.join(entry.getKey(), metadata.getFileNum(), metadata.getStartOffset(), metadata.getEndOffset()));
out.write("\n");
}
}
}
use of java.io.OutputStreamWriter in project che by eclipse.
the class CommitMessageWriter method writeTo.
/**
* @see MessageBodyWriter#writeTo(Object, Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType,
* javax.ws.rs.core.MultivaluedMap, java.io.OutputStream)
*/
@Override
public void writeTo(Revision revision, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException {
Writer writer = new OutputStreamWriter(entityStream);
writer.write('[');
writer.write(revision.getBranch());
writer.write(' ');
writer.write(revision.getId());
writer.write(']');
writer.write(' ');
writer.write(revision.getMessage());
writer.write('\n');
writer.flush();
}
use of java.io.OutputStreamWriter in project che by eclipse.
the class RemoteListWriter method writeTo.
/**
* @see MessageBodyWriter#writeTo(Object, Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType,
* javax.ws.rs.core.MultivaluedMap, java.io.OutputStream)
*/
@Override
public void writeTo(Iterable<Remote> remotes, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException {
Writer writer = new OutputStreamWriter(entityStream);
for (Remote remote : remotes) {
writer.write(remote.getName());
String url = remote.getUrl();
if (url != null) {
writer.write(' ');
writer.write(' ');
writer.write(url);
}
writer.write('\n');
}
writer.flush();
}
Aggregations