use of java.util.zip.GZIPOutputStream in project questdb by bluestreak01.
the class AppendObjectBlobs method processDir.
private static int processDir(JournalWriter writer, File dir) throws JournalException, IOException {
int count = 0;
File[] files = dir.listFiles();
if (files != null) {
for (File f : files) {
if (f.isDirectory()) {
count += processDir(writer, f);
continue;
}
JournalEntryWriter w = writer.entryWriter(System.currentTimeMillis());
w.putSym(0, f.getAbsolutePath());
try (InputStream in = new FileInputStream(f)) {
try (GZIPOutputStream out = new GZIPOutputStream(w.putBin(1))) {
pump(in, out);
}
}
w.append();
count++;
}
writer.commit();
}
return count;
}
use of java.util.zip.GZIPOutputStream in project nifi by apache.
the class TestPersistentProvenanceRepository method testWithWithEventFileMissingRecord.
/**
* Here the event file is simply corrupted by virtue of not having any event
* records while having correct headers
*/
@Test
public void testWithWithEventFileMissingRecord() throws Exception {
assumeFalse(isWindowsEnvironment());
File eventFile = this.prepCorruptedEventFileTests();
final Query query = new Query(UUID.randomUUID().toString());
query.addSearchTerm(SearchTerms.newSearchTerm(SearchableFields.ComponentID, "foo-*"));
query.setMaxResults(100);
DataOutputStream in = new DataOutputStream(new GZIPOutputStream(new FileOutputStream(eventFile)));
in.writeUTF("BlahBlah");
in.writeInt(4);
in.close();
assertTrue(eventFile.exists());
final QueryResult result = repo.queryEvents(query, createUser());
assertEquals(10, result.getMatchingEvents().size());
}
use of java.util.zip.GZIPOutputStream in project nifi by apache.
the class TestPersistentProvenanceRepository method testWithWithEventFileCorrupted.
/**
* Here the event file is simply corrupted by virtue of being empty (0
* bytes)
*/
@Test
public void testWithWithEventFileCorrupted() throws Exception {
assumeFalse(isWindowsEnvironment());
File eventFile = this.prepCorruptedEventFileTests();
final Query query = new Query(UUID.randomUUID().toString());
query.addSearchTerm(SearchTerms.newSearchTerm(SearchableFields.ComponentID, "foo-*"));
query.setMaxResults(100);
DataOutputStream in = new DataOutputStream(new GZIPOutputStream(new FileOutputStream(eventFile)));
in.close();
final QueryResult result = repo.queryEvents(query, createUser());
assertEquals(10, result.getMatchingEvents().size());
}
use of java.util.zip.GZIPOutputStream in project coprhd-controller by CoprHD.
the class WorkflowHelper method makeArchive.
/**
* @param out
* @param workflowPackage
* @throws IOException
* @throws JsonMappingException
* @throws JsonGenerationException
*/
private static void makeArchive(final ByteArrayOutputStream out, final CustomServicesWorkflowPackage workflowPackage) throws IOException {
try (final TarArchiveOutputStream tarOut = new TarArchiveOutputStream(new GZIPOutputStream(new BufferedOutputStream(out)))) {
tarOut.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU);
for (final Entry<URI, CustomServicesWorkflowRestRep> workflow : workflowPackage.workflows().entrySet()) {
final String name = WORKFLOWS_FOLDER + "/" + workflow.getKey().toString();
final byte[] content = MAPPER.writeValueAsBytes(workflow.getValue());
final Date modTime = workflow.getValue().getCreationTime().getTime();
addArchiveEntry(tarOut, name, modTime, content);
}
for (final Entry<URI, CustomServicesPrimitiveRestRep> operation : workflowPackage.operations().entrySet()) {
final String name = OPERATIONS_FOLDER + "/" + operation.getKey().toString();
final byte[] content = MAPPER.writeValueAsBytes(operation.getValue());
final Date modTime = operation.getValue().getCreationTime().getTime();
addArchiveEntry(tarOut, name, modTime, content);
}
for (final Entry<URI, ResourcePackage> resource : workflowPackage.resources().entrySet()) {
final String name = RESOURCES_FOLDER + "/" + resource.getKey().toString() + ".md";
final String resourceFile = RESOURCES_FOLDER + "/" + resource.getKey().toString();
final byte[] metadata = MAPPER.writeValueAsBytes(resource.getValue().metadata());
final Date modTime = resource.getValue().metadata().getCreationTime().getTime();
addArchiveEntry(tarOut, name, modTime, metadata);
addArchiveEntry(tarOut, resourceFile, modTime, resource.getValue().bytes());
}
tarOut.finish();
}
}
use of java.util.zip.GZIPOutputStream in project indy by Commonjava.
the class StorageFileIO method write.
@Override
public void write(MarshalledEntry<? extends String, ? extends byte[]> entry) {
String key = entry.getKey();
logKey("write()", key);
Path path = Paths.get(storageRoot, key);
File dir = path.getParent().toFile();
if (!dir.isDirectory() && !dir.mkdirs()) {
throw new RuntimeException("Cannot create storage directory: " + dir);
}
try (ObjectOutputStream out = new ObjectOutputStream(new GZIPOutputStream(new FileOutputStream(path.toFile())))) {
out.writeObject(new StorageFileEntry(entry));
} catch (IOException e) {
throw new RuntimeException("Cannot store: " + path, e);
}
}
Aggregations