All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.lordofthejars.nosqlunit.hbase.EmbeddedHBaseConfigurationBuilder Maven / Gradle / Ivy

There is a newer version: 1.0.0
Show newest version
package com.lordofthejars.nosqlunit.hbase;

import org.apache.hadoop.conf.Configuration;

import com.lordofthejars.nosqlunit.core.FailureHandler;


public class EmbeddedHBaseConfigurationBuilder {

	private final HBaseConfiguration hBaseConfiguration;
	
	private EmbeddedHBaseConfigurationBuilder() {
		super();
		this.hBaseConfiguration = new HBaseConfiguration();
	}
	
	public static EmbeddedHBaseConfigurationBuilder newEmbeddedHBaseConfiguration() {
		return new EmbeddedHBaseConfigurationBuilder();
	}
	
	public EmbeddedHBaseConfigurationBuilder connectionIdentifier(String connectionIdentifier) {
		this.hBaseConfiguration.setConnectionIdentifier(connectionIdentifier);
		return this;
	}
	
	public HBaseConfiguration build() {
		Configuration defaultConfiguration = EmbeddedHBaseInstances.getInstance().getDefaultConfiguration();
		
		if(defaultConfiguration == null) {
			throw FailureHandler.createIllegalStateFailure("There is no EmbeddedHBase rule during test execution. Please create one using @Rule or @ClassRule before executing these tests.");
		}
		
		this.hBaseConfiguration.setConfiguration(defaultConfiguration);
		return this.hBaseConfiguration;
	}
	
	public HBaseConfiguration buildFromTargetPath(String targetPath) {
		Configuration configuration = EmbeddedHBaseInstances.getInstance().getConfigurationByTargetPath(targetPath);
		
		if(configuration == null) {
			throw FailureHandler.createIllegalStateFailure("There is no EmbeddedHBase rule with %s target defined during test execution. Please create one using @Rule or @ClassRule before executing these tests.", targetPath);
		}
		
		this.hBaseConfiguration.setConfiguration(configuration);
		return this.hBaseConfiguration;
	}
	
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy