Skip to content

Compiled Plugin

Ioannis Papapanagiotou edited this page Nov 18, 2016 · 1 revision

TL;DR An example on how to create a plugin can be found in ndbench-sample-plugin

Package

The first step is to create a package with the corresponding name of the plugin suite. For example see ndbench-sample-plugins for a test plugin suite, ndbench-dyno-plugins for Dynomite plugins and ndbench-cass-plugins for Cassandra plugins and so forth.

NdBenchBaseClient

Developing a plugin requires extending NdBenchBaseClient and adding the annotation on NdBenchClientPlugin. Hence the class declaration can be as follows

@Singleton
@NdBenchClientPlugin("<PluginName>")
public class <ClassName> extends NdBenchBaseClient {
...
}

NdBenchBaseClient implements NdBenchClient, hence the following commands can be used in the plugin

  • Initialize: void init(DataGenerator dataGenerator) throws Exception;
  • Shutdown: void shutdown() throws Exception;
  • Perform a single read operation: String readSingle(final String key) throws Exception;
  • Perform a single write operation: String writeSingle(final String key) throws Exception;
  • Getting connection information: String getConnectionInfo() throws Exception;
  • Run workflow for functional test: String runWorkFlow() throws Exception;

Compile Plugins

Inside the package, a build.gradle is needed. An example on how to add one or more plugins is seen below

dependencies {
    compile project(':ndbench-api')

    // Add dependencies needed for plugin below
    
    //Datastax - Cassandra Java driver
    compile group: 'com.datastax.cassandra', name: 'cassandra-driver-core', version: '3.1.0'
}

The package finally needs to be added in settings.gradle and build.gradle inside ndbench-web.

Example of adding package to settings.gradle

include 'ndbench-sample-plugins', 'ndbench-dyno-plugins'

Example of adding package inside dependencies section of build.gradle in ndbench-web

compile project(':ndbench-dyno-plugins')
compile project(':ndbench-sample-plugins')

Verifying Plugin

In order to verify if plugin has been loaded, check the output for logs for the following

INFO NdBenchGuiceModule:84 - Installing NdBenchClientPlugin: com.netflix.ndbench.plugin.sample.InMemoryTestPlugin with Annotation: InMemoryTest