diff --git a/collector/src/main/resources/applicationContext-hbase.xml b/collector/src/main/resources/applicationContext-hbase.xml index e5ea388bf..0a89c9b26 100644 --- a/collector/src/main/resources/applicationContext-hbase.xml +++ b/collector/src/main/resources/applicationContext-hbase.xml @@ -14,7 +14,7 @@ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/hadoop http://www.springframework.org/schema/hadoop/spring-hadoop.xsd"> - + ${hbase.client.host} @@ -39,7 +39,6 @@ ${hbase.client.async.max.retries.in.queue} - diff --git a/commons-hbase/pom.xml b/commons-hbase/pom.xml index aa50aa609..04360b18c 100644 --- a/commons-hbase/pom.xml +++ b/commons-hbase/pom.xml @@ -160,85 +160,6 @@ spring-tx - - org.springframework.data - spring-data-hadoop-hbase - - - org.springframework - spring-tx - - - org.springframework - spring-context-support - - - org.springframework - spring-aop - - - org.springframework - spring-context - - - org.springframework - spring-jdbc - - - org.springframework.data - spring-data-hadoop-pig - - - org.springframework.data - spring-data-hadoop-batch - - - org.springframework.data - spring-data-hadoop-hive - - - org.apache.hadoop - hadoop-yarn-common - - - org.apache.hadoop - hadoop-common - - - org.apache.hadoop - hadoop-distcp - - - org.apache.hadoop - hadoop-hdfs - - - org.apache.hadoop - hadoop-mapreduce-client-core - - - org.apache.hadoop - hadoop-mapreduce-client-common - - - org.apache.hadoop - hadoop-mapreduce-client-shuffle - - - org.apache.hadoop - hadoop-mapreduce-client-jobclient - - - org.apache.hadoop - hadoop-streaming - - - jdk.tools - jdk.tools - - - - org.codehaus.jackson diff --git a/commons-hbase/src/main/java/com/navercorp/pinpoint/common/hbase/HbaseConfigurationFactoryBean.java b/commons-hbase/src/main/java/com/navercorp/pinpoint/common/hbase/HbaseConfigurationFactoryBean.java new file mode 100644 index 000000000..ff953b2cc --- /dev/null +++ b/commons-hbase/src/main/java/com/navercorp/pinpoint/common/hbase/HbaseConfigurationFactoryBean.java @@ -0,0 +1,89 @@ +/* + * Copyright 2011 the original author or authors. + * + * 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 com.navercorp.pinpoint.common.hbase; + +import java.util.Enumeration; +import java.util.Properties; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.hbase.HBaseConfiguration; +import org.springframework.beans.factory.FactoryBean; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.util.Assert; + +/** + * Factory for creating HBase specific configuration. By default cleans up any connection associated with the current configuration. + * + * @author Costin Leau + */ +public class HbaseConfigurationFactoryBean implements InitializingBean, FactoryBean { + + private Configuration configuration; + private Configuration hadoopConfig; + private Properties properties; + + /** + * Sets the Hadoop configuration to use. + * + * @param configuration The configuration to set. + */ + public void setConfiguration(Configuration configuration) { + this.hadoopConfig = configuration; + } + + /** + * Sets the configuration properties. + * + * @param properties The properties to set. + */ + public void setProperties(Properties properties) { + this.properties = properties; + } + + public void afterPropertiesSet() { + configuration = (hadoopConfig != null ? HBaseConfiguration.create(hadoopConfig) : HBaseConfiguration.create()); + addProperties(configuration, properties); + } + + /** + * Adds the specified properties to the given {@link Configuration} object. + * + * @param configuration configuration to manipulate. Should not be null. + * @param properties properties to add to the configuration. May be null. + */ + private void addProperties(Configuration configuration, Properties properties) { + Assert.notNull(configuration, "A non-null configuration is required"); + if (properties != null) { + Enumeration props = properties.propertyNames(); + while (props.hasMoreElements()) { + String key = props.nextElement().toString(); + configuration.set(key, properties.getProperty(key)); + } + } + } + + public Configuration getObject() { + return configuration; + } + + public Class getObjectType() { + return (configuration != null ? configuration.getClass() : Configuration.class); + } + + public boolean isSingleton() { + return true; + } +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index 8ccfcbd22..322e5e7e9 100644 --- a/pom.xml +++ b/pom.xml @@ -345,12 +345,6 @@ 0.1.0 - - org.springframework.data - spring-data-hadoop-hbase - 2.1.2.RELEASE - - org.slf4j slf4j-api diff --git a/web/src/main/resources/applicationContext-hbase.xml b/web/src/main/resources/applicationContext-hbase.xml index bc1d0337b..6a5522029 100644 --- a/web/src/main/resources/applicationContext-hbase.xml +++ b/web/src/main/resources/applicationContext-hbase.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> - + ${hbase.client.host} @@ -22,7 +22,6 @@ ${hbase.ipc.client.socket.timeout.write} -