co.cask.tephra.util.ConfigurationFactory Maven / Gradle / Ivy
/*
* Copyright © 2015 Cask Data, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package co.cask.tephra.util;
import com.google.inject.Provider;
import org.apache.hadoop.conf.Configuration;
/**
* Provides {@code org.apache.hadoop.conf.Configuration} instances, constructed by the correct version used
* for the runtime.
*/
public class ConfigurationFactory implements Provider {
private static class ConfigurationProviderFactory extends HBaseVersionSpecificFactory {
@Override
protected String getHBase94Classname() {
return "co.cask.tephra.hbase94.HBase94ConfigurationProvider";
}
@Override
protected String getHBase96Classname() {
return "co.cask.tephra.hbase96.HBase96ConfigurationProvider";
}
@Override
protected String getHBase98Classname() {
return "co.cask.tephra.hbase98.HBase98ConfigurationProvider";
}
}
private final ConfigurationProvider provider = new ConfigurationProviderFactory().get();
/**
* Returns a new {@link org.apache.hadoop.conf.Configuration} instance from the HBase version-specific factory.
*/
@Override
public Configuration get() {
return provider.get();
}
/**
* Returns a new {@link org.apache.hadoop.conf.Configuration} instance from the HBase version-specific factory.
*
* @param baseConf additional configuration properties to merge on to the classpath configuration
* @return the merged configuration
*/
public Configuration get(Configuration baseConf) {
return provider.get(baseConf);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy