Class AddRedundancy

java.lang.Object
net.messagevortex.router.operation.AbstractOperation
net.messagevortex.router.operation.AddRedundancy
All Implemented Interfaces:
Serializable, Operation

public class AddRedundancy extends AbstractOperation implements Serializable

This is the core of the redundancy add operation.

It builds redundant data blocksfrom the existing data blocks.

See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Wrapper for the java random number generator (not normative).
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final long
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Checks if all prerequisiting fields do exist or can be provided by a subsequent operation.
    static byte[]
    execute(byte[] in, int redundancy, int dataStripes, int gf)
    Execute the add redundancy operation on the provided data.
    int[]
    execute(int[] id)
    Executes the operation and sets at least the provided set of id.
    int[]
    Gets all ids which are required to execute this operation.
    int[]
    Gets all ids which are written by this operation.
    static byte[]
    pad(int blocksize, int numberOfOutBlocks, byte[] data, Prng prng, int c1, int c2)
    padds a given payload block.
     
    static byte[]
    unpad(int blocksize, int numberOfOutBlocks, byte[] in, Prng prng)
    Removes padding from a byte array.

    Methods inherited from class net.messagevortex.router.operation.AbstractOperation

    getIdentity, getUsagePeriod, isInUsagePeriod, setInternalPayload, setUsagePeriod

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • canRun

      public boolean canRun()
      Description copied from interface: Operation

      Checks if all prerequisiting fields do exist or can be provided by a subsequent operation.

      Specified by:
      canRun in interface Operation
      Specified by:
      canRun in class AbstractOperation
      Returns:
      true if all prerequisits can potentially be satisfied
    • getOutputId

      public int[] getOutputId()
      Description copied from interface: Operation

      Gets all ids which are written by this operation.

      Specified by:
      getOutputId in interface Operation
      Returns:
      array representing all ids which will be potentially set by this operation
    • getInputId

      public int[] getInputId()
      Description copied from interface: Operation

      Gets all ids which are required to execute this operation.

      Specified by:
      getInputId in interface Operation
      Returns:
      array representing all ids which will be potentially set by this operation
    • execute

      public int[] execute(int[] id)
      Description copied from interface: Operation

      Executes the operation and sets at least the provided set of id.

      This operation might trigger to execute prerequisiting operations.

      Specified by:
      execute in interface Operation
      Specified by:
      execute in class AbstractOperation
      Parameters:
      id - the namespace id to be set minimally
      Returns:
      array representing all ids which have been set
    • execute

      public static byte[] execute(byte[] in, int redundancy, int dataStripes, int gf)

      Execute the add redundancy operation on the provided data.

      Parameters:
      in - data to add redundancy
      redundancy - the number of redundancy blocks
      dataStripes - the number of data stripes
      gf - the size of the GF
      Returns:
      the data with added redundancy
    • pad

      public static byte[] pad(int blocksize, int numberOfOutBlocks, byte[] data, Prng prng, int c1, int c2)

      padds a given payload block.

      Parameters:
      blocksize - the size of the blocks of the used encryption in the addRedundancy operation
      numberOfOutBlocks - the number of resulting blocks in the addRedundancy operation
      data - the data to be padded (payload block
      prng - the Prng to be used for padding
      c1 - the padding parameter c1 as specified in the padding spec
      c2 - the padding parameter c2 as specified in the padding spec
      Returns:
      the padded data array
    • unpad

      public static byte[] unpad(int blocksize, int numberOfOutBlocks, byte[] in, Prng prng) throws IOException

      Removes padding from a byte array.

      Parameters:
      blocksize - encryption block size
      numberOfOutBlocks - number of out streams in the RS function
      in - the padded array
      prng - the random number generator for the padding data
      Returns:
      the unpadded data stream
      Throws:
      IOException - if unpadding fails for any reason
    • toString

      public String toString()
      Overrides:
      toString in class Object