ecpool

Crates.ioecpool
lib.rsecpool
version1.0.2
sourcesrc
created_at2018-09-27 09:53:15.07048
updated_at2018-10-12 10:20:20.078308
descriptionThread pool for managing executions of erasure coding
homepagehttps://github.com/frugalos/ecpool
repositoryhttps://github.com/frugalos/ecpool
max_upload_size
id86801
size35,414
Toshihiro Shimizu (meso)

documentation

README

ecpool

Crates.io: ecpool Documentation Build Status License: MIT

This crate provides thread pool (ErasureCoderPool) for managing executions of erasure coding.

Documentation

ecpool also provides ErasureCode trait defines erasure coding interface and of which implemtations can be executed via ErasureCoderPool.

There are some built-in implementations of the trait:

  • LibErasureCoder:
  • ReplicaCoder:
    • This implementation simply replicates the input data.

    • It is provided for example and testing purposes only and not intended to use in production.

Build Prerequisites

It is required to install openstack/liberasurecode and its dependencies by executing the following commands before building this crate:

$ git clone https://github.com/frugalos/liberasurecode
$ cd liberasurecode && sudo ./install_deps.sh

Examples

Basic usage:

use ecpool::replica::ReplicaCoder;
use ecpool::{ErrorKind, ErasureCoderPool};
use std::num::NonZeroUsize;
use std::result::Result;
use trackable::error::{Failure, Failed};

// Creates a pool
let data_fragments = NonZeroUsize::new(4).ok_or_else(|| Failure::from(Failed))?;
let parity_fragments = NonZeroUsize::new(2).ok_or_else(|| Failure::from(Failed))?;
let coder = ErasureCoderPool::new(ReplicaCoder::new(data_fragments, parity_fragments));

// Encodes
let data = vec![0, 1, 2, 3];
let encoded = fibers_global::execute(coder.encode(data.clone()))?;

// Decodes
assert_eq!(
    Some(&data),
    fibers_global::execute(coder.decode(encoded[0..].to_vec()))
        .as_ref()
        .ok()
);
assert_eq!(
    Some(&data),
    fibers_global::execute(coder.decode(encoded[1..].to_vec()))
        .as_ref()
        .ok()
);
assert_eq!(
    Some(&data),
    fibers_global::execute(coder.decode(encoded[2..].to_vec()))
        .as_ref()
        .ok()
);
assert_eq!(
    Err(ErrorKind::InvalidInput),
    fibers_global::execute(coder.decode(encoded[3..].to_vec())).map_err(|e| *e.kind())
);
Commit count: 13

cargo fmt