Search in sources :

Example 1 with DLOutputStream

use of org.apache.heron.dlog.DLOutputStream in project heron by twitter.

the class DLUploader method openOutputStream.

protected OutputStream openOutputStream(String pkgName) throws IOException {
    DistributedLogManager dlm = namespace.openLog(pkgName);
    AppendOnlyStreamWriter writer = dlm.getAppendOnlyStreamWriter();
    return new DLOutputStream(dlm, writer);
}
Also used : DistributedLogManager(org.apache.distributedlog.api.DistributedLogManager) AppendOnlyStreamWriter(org.apache.distributedlog.AppendOnlyStreamWriter) DLOutputStream(org.apache.heron.dlog.DLOutputStream)

Example 2 with DLOutputStream

use of org.apache.heron.dlog.DLOutputStream in project heron by twitter.

the class DlogStorage method storeCheckpoint.

@Override
public void storeCheckpoint(CheckpointInfo info, Checkpoint checkpoint) throws StatefulStorageException {
    String checkpointPath = getCheckpointPath(topologyName, info.getCheckpointId(), info.getComponent(), info.getInstanceId());
    OutputStream out = null;
    try {
        out = openOutputStream(checkpointPath);
        LOG.info(() -> String.format("writing a check point of %d bytes", checkpoint.getCheckpoint().getSerializedSize()));
        checkpoint.getCheckpoint().writeTo(out);
        out.flush();
    } catch (IOException e) {
        throw new StatefulStorageException("Failed to persist checkpoint @ " + checkpointPath, e);
    } finally {
        if (out != null) {
            final long num = ((DLOutputStream) out).getNumOfBytesWritten();
            LOG.info(() -> num + "bytes written");
        }
        SysUtils.closeIgnoringExceptions(out);
    }
}
Also used : StatefulStorageException(org.apache.heron.spi.statefulstorage.StatefulStorageException) OutputStream(java.io.OutputStream) DLOutputStream(org.apache.heron.dlog.DLOutputStream) IOException(java.io.IOException) DLOutputStream(org.apache.heron.dlog.DLOutputStream)

Example 3 with DLOutputStream

use of org.apache.heron.dlog.DLOutputStream in project heron by twitter.

the class DlogStorage method openOutputStream.

protected OutputStream openOutputStream(String path) throws IOException {
    DistributedLogManager dlm = namespace.openLog(path);
    AppendOnlyStreamWriter writer = dlm.getAppendOnlyStreamWriter();
    return new DLOutputStream(dlm, writer);
}
Also used : DistributedLogManager(org.apache.distributedlog.api.DistributedLogManager) AppendOnlyStreamWriter(org.apache.distributedlog.AppendOnlyStreamWriter) DLOutputStream(org.apache.heron.dlog.DLOutputStream)

Aggregations

DLOutputStream (org.apache.heron.dlog.DLOutputStream)3 AppendOnlyStreamWriter (org.apache.distributedlog.AppendOnlyStreamWriter)2 DistributedLogManager (org.apache.distributedlog.api.DistributedLogManager)2 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 StatefulStorageException (org.apache.heron.spi.statefulstorage.StatefulStorageException)1