Fork me on GitHub

How to develop his own plugin

This feature is only possible with Hadoop Unit v3.x.

There are 2 classes which have to be implemented:

Moreover, as Service Provider Interface is used, the file META-INF/services/fr.jetoile.hadoopunit.component.Bootstrap has to be present with the reference to the class which implements the interface Bootstrap or BootstrapHadoop.

Interface Bootstrap

This interface define 6 methods:

elastic_class

Interface BootstrapHadoop

This interface extends the interface Bootstrap but declare the method getConfiguration() which return an instance of org.apache.hadoop.conf.Configuration.

bootstrap_class

Interface ComponentMetadata

This interface defines 2 methods:

componentMetadata_class

Add a plugin to Hadoop Unit Standalone

To add a plugin to Hadoop Unit in the standalone mode, add the following information into the file hadoop-unit-default.properties:

Note : the plugin’s jar has to be in your repository manager (or on maven central) as it will be searched and downloaded.

Sample of hadoop-unit-default.properties:

hdfs.artifactId=fr.jetoile.hadoop:hadoop-unit-hdfs:3.1
hdfs.mainClass=fr.jetoile.hadoopunit.component.HdfsBootstrap
hdfs.metadataClass=fr.jetoile.hadoopunit.component.HdfsMetadata

Add your plugin’s name into the file hadoop.properties.

Sample of hadoop.properties:

<pluginName>=true

Note that your plugin name has to be in lowercase and that his name declared into the ComponentMetadata’s class has to be in uppercase.

Add a plugin to Hadoop Unit’s maven plugin

To add a plugin to Hadoop Unit’s maven plugin, add your plugin into the configuration element as shown below:

<build>
    <plugins>
        <plugin>
            <artifactId>hadoop-unit-maven-plugin</artifactId>
            <groupId>fr.jetoile.hadoop</groupId>
            <version>${hadoop-unit.version}</version>
            <executions>
                <execution>
                    <id>start</id>
                    <goals>
                        <goal>embedded-start</goal>
                    </goals>
                    <phase>pre-integration-test</phase>
                </execution>
                <execution>
                    <id>embedded-stop</id>
                    <goals>
                        <goal>embedded-stop</goal>
                    </goals>
                    <phase>post-integration-test</phase>
                </execution>
            </executions>
            <configuration>
                <components>
                    <componentArtifact implementation="fr.jetoile.hadoopunit.ComponentArtifact">
                        <componentName>HDFS</componentName>
                        <artifactId>hadoop-unit-hdfs</artifactId>
                        <groupId>fr.jetoile.hadoop</groupId>
                        <version>${hadoop-unit.version}</version>
                        <mainClass>fr.jetoile.hadoopunit.component.HdfsBootstrap</mainClass>
                    </componentArtifact>
                </components>
            </configuration>
        </plugin>
    </plugins>
</build>

Note : the plugin’s jar has to be in your repository manager (or on maven central) as it will be searched and downloaded.

HDFS Sample

This diagram shows the hdfs’ plugin class diagram:

hdfs_class

This diagram shows a class diagram with multiple plugins:

multiple_class