de.kumpe.hadooptimizer.hadoop
Class HadoOptimizerBase<I>

java.lang.Object
  extended by de.kumpe.hadooptimizer.Optimizer<I>
      extended by de.kumpe.hadooptimizer.hadoop.HadoOptimizerBase<I>
Type Parameters:
I - the individuals' type
All Implemented Interfaces:
org.apache.hadoop.conf.Configurable
Direct Known Subclasses:
EaHadoOptimizer, EsHadoOptimizer

public abstract class HadoOptimizerBase<I>
extends Optimizer<I>
implements org.apache.hadoop.conf.Configurable

Base-class for all Hadoop-based Optimizer implementations. Subclasses need to override the doOptimize() method and setup and create the Hadoop-jobs to do the actual optimization.

When setting up Mappers or Reducers you can use readConfiguration(Mapper.Context) to read in the OptimizerConfiguration.

Author:
Christian Kumpe

Constructor Summary
HadoOptimizerBase(EaOptimizerConfigurationBase<I> configuration)
           
 
Method Summary
protected abstract  void doOptimize()
          Needs to be overridden to do the actual optimization.
 org.apache.hadoop.conf.Configuration getConf()
           
protected  EaOptimizerConfigurationBase<I> getConfiguration()
          Returns the optimizer's configuration.
 void optimize()
          Creates the output-directory, writes the EaOptimizerConfigurationBase into the file-system and starts the actual optimization in doOptimize().
static OptimizerConfiguration readConfiguration(org.apache.hadoop.mapreduce.Mapper.Context context)
          Reads the OptimizerConfiguration out of the hadoop's job configuration from the specified Mapper.Context.
 void setConf(org.apache.hadoop.conf.Configuration conf)
           
 
Methods inherited from class de.kumpe.hadooptimizer.Optimizer
getRandomGenerator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HadoOptimizerBase

public HadoOptimizerBase(EaOptimizerConfigurationBase<I> configuration)
Method Detail

readConfiguration

public static OptimizerConfiguration readConfiguration(org.apache.hadoop.mapreduce.Mapper.Context context)
                                                throws IOException
Reads the OptimizerConfiguration out of the hadoop's job configuration from the specified Mapper.Context.

If the InputSplit of the specified Mapper.Context is implementing HasSeed then a new Well44497b.Well44497b(long) -instance with the retrieved seed is injected into the configuration. Otherwise taskAttemptID is used to create a seed.

Parameters:
context - the mapper's context
Returns:
the read configuration
Throws:
IOException

getConfiguration

protected EaOptimizerConfigurationBase<I> getConfiguration()
Description copied from class: Optimizer
Returns the optimizer's configuration. This configuration should not be modified once the optimizer has been created.

This method can be overridden to cast the OptimizerConfiguration to the appropriate subtype for the concrete optimizer implementation.

Overrides:
getConfiguration in class Optimizer<I>
Returns:
the optimizer's configuration

getConf

public org.apache.hadoop.conf.Configuration getConf()
Specified by:
getConf in interface org.apache.hadoop.conf.Configurable

setConf

public void setConf(org.apache.hadoop.conf.Configuration conf)
Specified by:
setConf in interface org.apache.hadoop.conf.Configurable

optimize

public final void optimize()
Creates the output-directory, writes the EaOptimizerConfigurationBase into the file-system and starts the actual optimization in doOptimize().

Specified by:
optimize in class Optimizer<I>
See Also:
Optimizer.optimize()

doOptimize

protected abstract void doOptimize()
                            throws Exception
Needs to be overridden to do the actual optimization.

Throws:
Exception


Copyright © 2011 Christian Kumpe. All Rights Reserved.