diff --git a/.gitignore b/.gitignore index 23eb059e..08b1dd93 100755 --- a/.gitignore +++ b/.gitignore @@ -10,5 +10,6 @@ target *.log *.log.gz rebel.xml -metastore_db +**/metastore_db +**/embedded_kafka **/dependency-reduced-pom.xml diff --git a/hadoop-unit-cassandra/pom.xml b/hadoop-unit-cassandra/pom.xml index cda05975..61565cc3 100644 --- a/hadoop-unit-cassandra/pom.xml +++ b/hadoop-unit-cassandra/pom.xml @@ -6,7 +6,7 @@ hadoop-unit fr.jetoile.hadoop - 1.6-SNAPSHOT + 2.0-SNAPSHOT 4.0.0 @@ -23,21 +23,6 @@ info.archinnov achilles-embedded - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/hadoop-unit-cassandra/src/main/java/fr/jetoile/hadoopunit/component/CassandraBootstrap.java b/hadoop-unit-cassandra/src/main/java/fr/jetoile/hadoopunit/component/CassandraBootstrap.java index b425c376..bf8032ab 100644 --- a/hadoop-unit-cassandra/src/main/java/fr/jetoile/hadoopunit/component/CassandraBootstrap.java +++ b/hadoop-unit-cassandra/src/main/java/fr/jetoile/hadoopunit/component/CassandraBootstrap.java @@ -16,13 +16,16 @@ import com.datastax.driver.core.Session; import fr.jetoile.hadoopunit.Component; +import fr.jetoile.hadoopunit.HadoopBootstrap; import fr.jetoile.hadoopunit.HadoopUnitConfig; import fr.jetoile.hadoopunit.exception.BootstrapException; +import fr.jetoile.hadoopunit.exception.NotFoundServiceException; import info.archinnov.achilles.embedded.CassandraEmbeddedServerBuilder; import org.apache.commons.configuration.Configuration; import org.apache.commons.configuration.ConfigurationException; import org.apache.commons.configuration.PropertiesConfiguration; import org.apache.commons.io.FileUtils; +import org.apache.commons.lang.StringUtils; import org.apache.thrift.transport.TTransportException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -30,14 +33,12 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; - -//import org.cassandraunit.dataset.CQLDataSet; -//import org.cassandraunit.utils.EmbeddedCassandraServerHelper; +import java.util.Map; public class CassandraBootstrap implements Bootstrap { final public static String NAME = Component.CASSANDRA.name(); - final private Logger LOGGER = LoggerFactory.getLogger(CassandraBootstrap.class); + static final private Logger LOGGER = LoggerFactory.getLogger(CassandraBootstrap.class); private State state = State.STOPPED; @@ -80,6 +81,16 @@ private void loadConfig() throws BootstrapException { ip = configuration.getString(HadoopUnitConfig.CASSANDRA_IP_KEY); } + @Override + public void loadConfig(Map configs) { + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.CASSANDRA_PORT_KEY))) { + port = Integer.parseInt(configs.get(HadoopUnitConfig.CASSANDRA_PORT_KEY)); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.CASSANDRA_IP_KEY))) { + ip = configs.get(HadoopUnitConfig.CASSANDRA_IP_KEY); + } + } + private void build() throws InterruptedException, IOException, TTransportException { Files.createDirectory(Paths.get(configuration.getString(HadoopUnitConfig.CASSANDRA_TEMP_DIR_KEY))); Files.createDirectory(Paths.get(configuration.getString(HadoopUnitConfig.CASSANDRA_TEMP_DIR_KEY) + "/data")); diff --git a/hadoop-unit-standalone/hadoop-unit-standalone-elasticsearch/src/main/conf/hadoop-unit-default.properties b/hadoop-unit-cassandra/src/main/resources/hadoop-unit-default.properties similarity index 100% rename from hadoop-unit-standalone/hadoop-unit-standalone-elasticsearch/src/main/conf/hadoop-unit-default.properties rename to hadoop-unit-cassandra/src/main/resources/hadoop-unit-default.properties diff --git a/hadoop-unit-standalone/hadoop-unit-standalone-elasticsearch/src/main/conf/logback.xml b/hadoop-unit-cassandra/src/main/resources/logback.xml similarity index 100% rename from hadoop-unit-standalone/hadoop-unit-standalone-elasticsearch/src/main/conf/logback.xml rename to hadoop-unit-cassandra/src/main/resources/logback.xml diff --git a/hadoop-unit-client/hadoop-unit-client-hdfs/pom.xml b/hadoop-unit-client/hadoop-unit-client-hdfs/pom.xml index cc46a978..e1e24a2a 100755 --- a/hadoop-unit-client/hadoop-unit-client-hdfs/pom.xml +++ b/hadoop-unit-client/hadoop-unit-client-hdfs/pom.xml @@ -4,7 +4,7 @@ hadoop-unit-client fr.jetoile.hadoop - 1.6-SNAPSHOT + 2.0-SNAPSHOT 4.0.0 @@ -12,49 +12,32 @@ hadoop-unit-client-hdfs - fr.jetoile.hadoop hadoop-unit-commons - org.apache.hadoop hadoop-client + + + slf4j-log4j12 + org.slf4j + + - - - - - org.apache.hadoop hadoop-common - - - - - - commons-configuration commons-configuration - - - - - - - - - - org.slf4j slf4j-api @@ -64,13 +47,6 @@ ch.qos.logback logback-classic - - - - - - - diff --git a/hadoop-unit-client/hadoop-unit-client-hive/pom.xml b/hadoop-unit-client/hadoop-unit-client-hive/pom.xml index b48f6b79..bf4e42a5 100755 --- a/hadoop-unit-client/hadoop-unit-client-hive/pom.xml +++ b/hadoop-unit-client/hadoop-unit-client-hive/pom.xml @@ -4,7 +4,7 @@ hadoop-unit-client fr.jetoile.hadoop - 1.6-SNAPSHOT + 2.0-SNAPSHOT 4.0.0 @@ -18,17 +18,6 @@ hadoop-unit-commons - - - - - - - - - - - commons-configuration commons-configuration diff --git a/hadoop-unit-client/hadoop-unit-client-kafka/pom.xml b/hadoop-unit-client/hadoop-unit-client-kafka/pom.xml index 1c747456..83a00104 100644 --- a/hadoop-unit-client/hadoop-unit-client-kafka/pom.xml +++ b/hadoop-unit-client/hadoop-unit-client-kafka/pom.xml @@ -5,7 +5,7 @@ hadoop-unit-client fr.jetoile.hadoop - 1.6-SNAPSHOT + 2.0-SNAPSHOT 4.0.0 diff --git a/hadoop-unit-client/hadoop-unit-client-solrcloud/pom.xml b/hadoop-unit-client/hadoop-unit-client-solrcloud/pom.xml index 3bf55e3d..650e9ad7 100644 --- a/hadoop-unit-client/hadoop-unit-client-solrcloud/pom.xml +++ b/hadoop-unit-client/hadoop-unit-client-solrcloud/pom.xml @@ -5,7 +5,7 @@ hadoop-unit-client fr.jetoile.hadoop - 1.6-SNAPSHOT + 2.0-SNAPSHOT 4.0.0 diff --git a/hadoop-unit-client/hadoop-unit-client-spark/pom.xml b/hadoop-unit-client/hadoop-unit-client-spark/pom.xml index 559aec30..6a4ea6d6 100644 --- a/hadoop-unit-client/hadoop-unit-client-spark/pom.xml +++ b/hadoop-unit-client/hadoop-unit-client-spark/pom.xml @@ -5,7 +5,7 @@ hadoop-unit-client fr.jetoile.hadoop - 1.6-SNAPSHOT + 2.0-SNAPSHOT 4.0.0 @@ -14,7 +14,6 @@ - org.apache.spark spark-core_2.10 diff --git a/hadoop-unit-client/pom.xml b/hadoop-unit-client/pom.xml index 99ac4350..15c6ff0a 100755 --- a/hadoop-unit-client/pom.xml +++ b/hadoop-unit-client/pom.xml @@ -4,7 +4,7 @@ hadoop-unit fr.jetoile.hadoop - 1.6-SNAPSHOT + 2.0-SNAPSHOT 4.0.0 diff --git a/hadoop-unit-commons/pom.xml b/hadoop-unit-commons/pom.xml index 72b0bf00..22de43dd 100644 --- a/hadoop-unit-commons/pom.xml +++ b/hadoop-unit-commons/pom.xml @@ -5,7 +5,7 @@ hadoop-unit fr.jetoile.hadoop - 1.6-SNAPSHOT + 2.0-SNAPSHOT 4.0.0 @@ -19,26 +19,11 @@ commons-configuration - - commons-collections - commons-collections - - - - commons-io - commons-io - - org.apache.hadoop hadoop-common - - com.google.guava - guava - - org.apache.httpcomponents httpclient @@ -70,11 +55,6 @@ provided - - org.eclipse.jetty - jetty-util - - javax.servlet javax.servlet-api diff --git a/hadoop-unit-commons/src/main/java/com/github/sakserv/minicluster/util/WindowsLibsUtils.java b/hadoop-unit-commons/src/main/java/com/github/sakserv/minicluster/util/WindowsLibsUtils.java index 2625807b..523c0d2c 100644 --- a/hadoop-unit-commons/src/main/java/com/github/sakserv/minicluster/util/WindowsLibsUtils.java +++ b/hadoop-unit-commons/src/main/java/com/github/sakserv/minicluster/util/WindowsLibsUtils.java @@ -12,43 +12,6 @@ public class WindowsLibsUtils { private static final Logger LOG = LoggerFactory.getLogger(WindowsLibsUtils.class); public static void setHadoopHome() { - - // Set hadoop.home.dir to point to the windows lib dir - if (System.getProperty("os.name").startsWith("Windows")) { - - String windowsLibDir = getHadoopHome(); - - LOG.info("WINDOWS: Setting hadoop.home.dir: {}", windowsLibDir); - System.setProperty("hadoop.home.dir", windowsLibDir); - System.load(new File(windowsLibDir + Path.SEPARATOR + "bin" + Path.SEPARATOR + "hadoop.dll").getAbsolutePath()); - System.load(new File(windowsLibDir + Path.SEPARATOR + "bin" + Path.SEPARATOR + "hdfs.dll").getAbsolutePath()); - - } - } - - public static String getHadoopHome() { - - LOG.info("HADOOP_HOME: " + System.getenv("HADOOP_HOME")); - - if(System.getenv("HADOOP_HOME") != null) { - return System.getenv("HADOOP_HOME"); - } else { - if (System.getProperty("HADOOP_HOME") != null) { - return System.getProperty("HADOOP_HOME"); - } else { - File windowsLibDir = new File("." + Path.SEPARATOR + "windows_libs" + - Path.SEPARATOR + System.getProperty("hdp.release.version")); - - if (!windowsLibDir.exists()) { - windowsLibDir = new File(".." + Path.SEPARATOR + windowsLibDir); - if (!windowsLibDir.exists()) { - LOG.error("WINDOWS: ERROR: Could not find windows native libs"); - } - } - return windowsLibDir.getAbsolutePath(); - } - } - } } diff --git a/hadoop-unit-commons/src/main/java/fr/jetoile/hadoopunit/Component.java b/hadoop-unit-commons/src/main/java/fr/jetoile/hadoopunit/Component.java index e1874fc6..b601811b 100644 --- a/hadoop-unit-commons/src/main/java/fr/jetoile/hadoopunit/Component.java +++ b/hadoop-unit-commons/src/main/java/fr/jetoile/hadoopunit/Component.java @@ -18,29 +18,40 @@ * Warning : this list should be sorted */ public enum Component { - ZOOKEEPER("zookeeper"), - HDFS("hdfs"), - HIVEMETA("hivemeta"), - HIVESERVER2("hiveserver2"), - KAFKA("kafka"), - HBASE("hbase"), - OOZIE("oozie"), - SOLRCLOUD("solrcloud"), - SOLR("solr"), - CASSANDRA("cassandra"), - MONGODB("mongodb"), - ELASTICSEARCH("elastic"), - NEO4J("neo4j"); + HDFS("hdfs", "fr.jetoile.hadoopunit.component.HdfsBootstrap", "hdfs.artifact"), + ZOOKEEPER("zookeeper", "fr.jetoile.hadoopunit.component.ZookeeperBootstrap", "zookeeper.artifact"), + HIVEMETA("hivemeta", "fr.jetoile.hadoopunit.component.HiveMetastoreBootstrap", "hivemeta.artifact"), + HIVESERVER2("hiveserver2", "fr.jetoile.hadoopunit.component.HiveServer2Bootstrap", "hiveserver2.artifact"), + KAFKA("kafka", "fr.jetoile.hadoopunit.component.KafkaBootstrap", "kafka.artifact"), + HBASE("hbase", "fr.jetoile.hadoopunit.component.HBaseBootstrap", "hbase.artifact"), + OOZIE("oozie", "fr.jetoile.hadoopunit.component.OozieBootstrap", "oozie.artifact"), + SOLRCLOUD("solrcloud", "fr.jetoile.hadoopunit.component.SolrCloudBootstrap", "solrcloud.artifact"), + SOLR("solr", "fr.jetoile.hadoopunit.component.SolrBootstrap", "solr.artifact"), + CASSANDRA("cassandra", "fr.jetoile.hadoopunit.component.CassandraBootstrap", "cassandra.artifact"), + MONGODB("mongodb", "fr.jetoile.hadoopunit.component.MongoDbBootstrap", "mongodb.artifact"), + ELASTICSEARCH("elasticsearch", "fr.jetoile.hadoopunit.component.ElasticSearchBootstrap", "elasticsearch.artifact"), + NEO4J("neo4j", "fr.jetoile.hadoopunit.component.Neo4jBootstrap", "neo4j.artifact"); private String key; + private String mainClass; + private String artifactKey; - Component(String key) { + Component(String key, String mainClass, String artifactKey) { this.key = key; + this.mainClass = mainClass; + this.artifactKey = artifactKey; } public String getKey() { return key; } + public String getMainClass() { + return mainClass; + } + + public String getArtifactKey() { + return artifactKey; + } } diff --git a/hadoop-unit-commons/src/main/java/fr/jetoile/hadoopunit/HadoopBootstrap.java b/hadoop-unit-commons/src/main/java/fr/jetoile/hadoopunit/HadoopBootstrap.java index f25ded58..a1ff24a9 100644 --- a/hadoop-unit-commons/src/main/java/fr/jetoile/hadoopunit/HadoopBootstrap.java +++ b/hadoop-unit-commons/src/main/java/fr/jetoile/hadoopunit/HadoopBootstrap.java @@ -13,7 +13,6 @@ */ package fr.jetoile.hadoopunit; -import com.google.common.collect.Lists; import fr.jetoile.hadoopunit.component.Bootstrap; import fr.jetoile.hadoopunit.exception.NotFoundServiceException; import org.apache.commons.configuration.Configuration; @@ -24,13 +23,13 @@ import java.nio.charset.Charset; import java.util.*; +import static java.util.stream.Collectors.toList; + public enum HadoopBootstrap { INSTANCE; final private static Logger LOGGER = LoggerFactory.getLogger(HadoopBootstrap.class); - - private Configuration configuration; List componentsToStart = new ArrayList<>(); List manualComponentsToStart = new ArrayList<>(); List componentsToStop = new ArrayList<>(); @@ -56,7 +55,7 @@ public enum HadoopBootstrap { } }); - componentsToStop = Lists.newArrayList(this.componentsToStart); + componentsToStop = this.componentsToStart.stream().collect(toList()); Collections.reverse(componentsToStop); Runtime.getRuntime().addShutdownHook(new Thread() { @@ -89,7 +88,7 @@ public void stopAll() { if (manualComponentsToStop.isEmpty()) { internalStop(componentsToStop); } else { - manualComponentsToStop = Lists.newArrayList(this.manualComponentsToStart); + manualComponentsToStop = this.manualComponentsToStart.stream().collect(toList()); Collections.reverse(manualComponentsToStop); internalStop(manualComponentsToStop); } @@ -104,7 +103,7 @@ private void internalStart(List componentsToStart) { componentsToStart.stream().forEach(c -> { startService(c); }); - HadoopUtils.printBanner(System.out); + HadoopUtils.INSTANCE.printBanner(System.out); componentsToStart.stream().forEach(c -> System.out.println("\t\t - " + c.getName() + " " + c.getProperties())); System.out.println(); } diff --git a/hadoop-unit-commons/src/main/java/fr/jetoile/hadoopunit/HadoopUnitConfig.java b/hadoop-unit-commons/src/main/java/fr/jetoile/hadoopunit/HadoopUnitConfig.java index 2205a841..9d25a98a 100644 --- a/hadoop-unit-commons/src/main/java/fr/jetoile/hadoopunit/HadoopUnitConfig.java +++ b/hadoop-unit-commons/src/main/java/fr/jetoile/hadoopunit/HadoopUnitConfig.java @@ -134,4 +134,15 @@ public class HadoopUnitConfig { public static final String OOZIE_SHARE_LIB_CREATE_KEY = "oozie.share.lib.create"; public static final String OOZIE_LOCAL_SHARE_LIB_CACHE_DIR_KEY = "oozie.local.share.lib.cache.dir"; public static final String OOZIE_PURGE_LOCAL_SHARE_LIB_CACHE_KEY = "oozie.purge.local.share.lib.cache"; + public static final String OOZIE_PORT = "oozie.port"; + public static final String OOZIE_HOST = "oozie.host"; + public static final String OOZIE_SHARELIB_PATH_KEY = "oozie.sharelib.path"; + public static final String OOZIE_SHARELIB_NAME_KEY = "oozie.sharelib.name"; + public static final String SHARE_LIB_LOCAL_TEMP_PREFIX = "oozie_share_lib_tmp"; + public static final String SHARE_LIB_PREFIX = "lib_"; + + // SOLR + public static final String SOLR_DIR_KEY = "solr.dir"; + public static final String SOLR_COLLECTION_NAME = "solr.collection.name"; + public static final String SOLR_PORT = "solr.cloud.port"; } diff --git a/hadoop-unit-commons/src/main/java/fr/jetoile/hadoopunit/HadoopUtils.java b/hadoop-unit-commons/src/main/java/fr/jetoile/hadoopunit/HadoopUtils.java index c36b878e..3fd7af2c 100644 --- a/hadoop-unit-commons/src/main/java/fr/jetoile/hadoopunit/HadoopUtils.java +++ b/hadoop-unit-commons/src/main/java/fr/jetoile/hadoopunit/HadoopUtils.java @@ -23,14 +23,13 @@ import java.io.*; -public class HadoopUtils { +public enum HadoopUtils { + INSTANCE; + private final Logger LOG = LoggerFactory.getLogger(HadoopUtils.class); + private Configuration configuration; - private static final Logger LOG = LoggerFactory.getLogger(HadoopUtils.class); - private static Configuration configuration; - - public static void setHadoopHome() { - + private HadoopUtils() { // Set hadoop.home.dir to point to the windows lib dir if (System.getProperty("os.name").startsWith("Windows")) { @@ -60,12 +59,20 @@ public static void setHadoopHome() { LOG.info("WINDOWS: Setting hadoop.home.dir: {}", windowsLibDir); System.setProperty("hadoop.home.dir", windowsLibDir); - System.load(new File(windowsLibDir + Path.SEPARATOR + "bin" + Path.SEPARATOR + "hadoop.dll").getAbsolutePath()); - System.load(new File(windowsLibDir + Path.SEPARATOR + "bin" + Path.SEPARATOR + "hdfs.dll").getAbsolutePath()); + try { + System.load(new File(windowsLibDir + Path.SEPARATOR + "bin" + Path.SEPARATOR + "hadoop.dll").getAbsolutePath()); + System.load(new File(windowsLibDir + Path.SEPARATOR + "bin" + Path.SEPARATOR + "hdfs.dll").getAbsolutePath()); + } catch (UnsatisfiedLinkError e) { + //ignore it + } } } - public static void printBanner(PrintStream out) { + public void setHadoopHome() { + + } + + public void printBanner(PrintStream out) { try { InputStream banner = HadoopUtils.class.getResourceAsStream("/banner.txt"); diff --git a/hadoop-unit-commons/src/main/java/fr/jetoile/hadoopunit/component/Bootstrap.java b/hadoop-unit-commons/src/main/java/fr/jetoile/hadoopunit/component/Bootstrap.java index c46e1abb..e63826db 100644 --- a/hadoop-unit-commons/src/main/java/fr/jetoile/hadoopunit/component/Bootstrap.java +++ b/hadoop-unit-commons/src/main/java/fr/jetoile/hadoopunit/component/Bootstrap.java @@ -17,6 +17,8 @@ import org.apache.hadoop.conf.Configuration; +import java.util.Map; + public interface Bootstrap { Bootstrap start(); @@ -28,5 +30,10 @@ public interface Bootstrap { String getProperties(); + /** + * Allow to override configurations when using maven plugin + * @param configs + */ + void loadConfig(Map configs); } diff --git a/hadoop-unit-elasticsearch/pom.xml b/hadoop-unit-elasticsearch/pom.xml index 25da123b..2833626a 100644 --- a/hadoop-unit-elasticsearch/pom.xml +++ b/hadoop-unit-elasticsearch/pom.xml @@ -6,7 +6,7 @@ hadoop-unit fr.jetoile.hadoop - 1.6-SNAPSHOT + 2.0-SNAPSHOT 4.0.0 diff --git a/hadoop-unit-elasticsearch/src/main/java/fr/jetoile/hadoopunit/component/ElasticSearchBootstrap.java b/hadoop-unit-elasticsearch/src/main/java/fr/jetoile/hadoopunit/component/ElasticSearchBootstrap.java index 80fd9d81..94d82976 100644 --- a/hadoop-unit-elasticsearch/src/main/java/fr/jetoile/hadoopunit/component/ElasticSearchBootstrap.java +++ b/hadoop-unit-elasticsearch/src/main/java/fr/jetoile/hadoopunit/component/ElasticSearchBootstrap.java @@ -15,25 +15,30 @@ package fr.jetoile.hadoopunit.component; import fr.jetoile.hadoopunit.Component; +import fr.jetoile.hadoopunit.HadoopBootstrap; import fr.jetoile.hadoopunit.HadoopUnitConfig; import fr.jetoile.hadoopunit.exception.BootstrapException; +import fr.jetoile.hadoopunit.exception.NotFoundServiceException; import org.apache.commons.configuration.Configuration; import org.apache.commons.configuration.ConfigurationException; import org.apache.commons.configuration.PropertiesConfiguration; import org.apache.commons.io.FileUtils; +import org.apache.commons.lang.StringUtils; import org.elasticsearch.client.Client; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.node.Node; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.Console; import java.io.IOException; import java.nio.file.Paths; +import java.util.Map; public class ElasticSearchBootstrap implements Bootstrap { final public static String NAME = Component.ELASTICSEARCH.name(); - final private Logger LOGGER = LoggerFactory.getLogger(ElasticSearchBootstrap.class); + static final private Logger LOGGER = LoggerFactory.getLogger(ElasticSearchBootstrap.class); private State state = State.STOPPED; @@ -88,6 +93,28 @@ private void loadConfig() throws BootstrapException { clusterName = configuration.getString(HadoopUnitConfig.ELASTICSEARCH_CLUSTER_NAME); } + @Override + public void loadConfig(Map configs) { + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.ELASTICSEARCH_HTTP_PORT_KEY))) { + httpPort = Integer.parseInt(configs.get(HadoopUnitConfig.ELASTICSEARCH_HTTP_PORT_KEY)); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.ELASTICSEARCH_TCP_PORT_KEY))) { + tcpPort = Integer.parseInt(configs.get(HadoopUnitConfig.ELASTICSEARCH_TCP_PORT_KEY)); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.ELASTICSEARCH_IP_KEY))) { + ip = configs.get(HadoopUnitConfig.ELASTICSEARCH_IP_KEY); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.ELASTICSEARCH_TEMP_DIR_KEY))) { + tmpDir = configs.get(HadoopUnitConfig.ELASTICSEARCH_TEMP_DIR_KEY); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.ELASTICSEARCH_INDEX_NAME))) { + indexName = configs.get(HadoopUnitConfig.ELASTICSEARCH_INDEX_NAME); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.ELASTICSEARCH_CLUSTER_NAME))) { + clusterName = configs.get(HadoopUnitConfig.ELASTICSEARCH_CLUSTER_NAME); + } + } + private void build() { client = createEmbeddedNode().client(); } diff --git a/hadoop-unit-standalone/hadoop-unit-standalone-elasticsearch/src/test/resources/hadoop-unit-default.properties b/hadoop-unit-elasticsearch/src/main/resources/hadoop-unit-default.properties similarity index 100% rename from hadoop-unit-standalone/hadoop-unit-standalone-elasticsearch/src/test/resources/hadoop-unit-default.properties rename to hadoop-unit-elasticsearch/src/main/resources/hadoop-unit-default.properties diff --git a/hadoop-unit-hbase/pom.xml b/hadoop-unit-hbase/pom.xml index ca6bdb20..b18f0c26 100644 --- a/hadoop-unit-hbase/pom.xml +++ b/hadoop-unit-hbase/pom.xml @@ -5,7 +5,7 @@ hadoop-unit fr.jetoile.hadoop - 1.6-SNAPSHOT + 2.0-SNAPSHOT 4.0.0 @@ -36,4 +36,5 @@ + \ No newline at end of file diff --git a/hadoop-unit-hbase/src/main/java/fr/jetoile/hadoopunit/component/HBaseBootstrap.java b/hadoop-unit-hbase/src/main/java/fr/jetoile/hadoopunit/component/HBaseBootstrap.java index 20babe2b..58affb3f 100644 --- a/hadoop-unit-hbase/src/main/java/fr/jetoile/hadoopunit/component/HBaseBootstrap.java +++ b/hadoop-unit-hbase/src/main/java/fr/jetoile/hadoopunit/component/HBaseBootstrap.java @@ -16,19 +16,24 @@ import com.github.sakserv.minicluster.impl.HbaseLocalCluster; import com.github.sakserv.minicluster.util.FileUtils; import fr.jetoile.hadoopunit.Component; +import fr.jetoile.hadoopunit.HadoopBootstrap; import fr.jetoile.hadoopunit.HadoopUnitConfig; import fr.jetoile.hadoopunit.HadoopUtils; import fr.jetoile.hadoopunit.exception.BootstrapException; +import fr.jetoile.hadoopunit.exception.NotFoundServiceException; import org.apache.commons.configuration.Configuration; import org.apache.commons.configuration.ConfigurationException; import org.apache.commons.configuration.PropertiesConfiguration; +import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Map; + public class HBaseBootstrap implements Bootstrap { final public static String NAME = Component.HBASE.name(); - final private Logger LOGGER = LoggerFactory.getLogger(HBaseBootstrap.class); + static final private Logger LOGGER = LoggerFactory.getLogger(HBaseBootstrap.class); private HbaseLocalCluster hbaseLocalCluster; @@ -90,7 +95,7 @@ private void build() { } private void loadConfig() throws BootstrapException { - HadoopUtils.setHadoopHome(); + HadoopUtils.INSTANCE.setHadoopHome(); try { configuration = new PropertiesConfiguration(HadoopUnitConfig.DEFAULT_PROPS_FILE); } catch (ConfigurationException e) { @@ -105,6 +110,34 @@ private void loadConfig() throws BootstrapException { zookeeperPort = configuration.getInt(HadoopUnitConfig.ZOOKEEPER_PORT_KEY); zookeeperZnodeParent = configuration.getString(HadoopUnitConfig.HBASE_ZNODE_PARENT_KEY); enableWalReplication = configuration.getBoolean(HadoopUnitConfig.HBASE_WAL_REPLICATION_ENABLED_KEY); + } + + @Override + public void loadConfig(Map configs) { + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.HBASE_MASTER_PORT_KEY))) { + port = Integer.parseInt(configs.get(HadoopUnitConfig.HBASE_MASTER_PORT_KEY)); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.HBASE_MASTER_INFO_PORT_KEY))) { + infoPort = Integer.parseInt(configs.get(HadoopUnitConfig.HBASE_MASTER_INFO_PORT_KEY)); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.HBASE_NUM_REGION_SERVERS_KEY))) { + nbRegionServer = Integer.parseInt(configs.get(HadoopUnitConfig.HBASE_NUM_REGION_SERVERS_KEY)); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.HBASE_ROOT_DIR_KEY))) { + rootDirectory = configs.get(HadoopUnitConfig.HBASE_ROOT_DIR_KEY); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.ZOOKEEPER_HOST_KEY)) && StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.ZOOKEEPER_PORT_KEY))) { + zookeeperConnectionString = configs.get(HadoopUnitConfig.ZOOKEEPER_HOST_KEY) + ":" + configs.get(HadoopUnitConfig.ZOOKEEPER_PORT_KEY); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.ZOOKEEPER_PORT_KEY))) { + zookeeperPort = Integer.parseInt(configs.get(HadoopUnitConfig.ZOOKEEPER_PORT_KEY)); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.HBASE_ZNODE_PARENT_KEY))) { + zookeeperZnodeParent = configs.get(HadoopUnitConfig.HBASE_ZNODE_PARENT_KEY); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.HBASE_WAL_REPLICATION_ENABLED_KEY))) { + enableWalReplication = Boolean.parseBoolean(configs.get(HadoopUnitConfig.HBASE_WAL_REPLICATION_ENABLED_KEY)); + } } @@ -155,5 +188,4 @@ public org.apache.hadoop.conf.Configuration getConfiguration() { return hbaseLocalCluster.getHbaseConfiguration(); } - } diff --git a/hadoop-unit-hbase/src/main/resources/hadoop-unit-default.properties b/hadoop-unit-hbase/src/main/resources/hadoop-unit-default.properties new file mode 100644 index 00000000..4c8e7332 --- /dev/null +++ b/hadoop-unit-hbase/src/main/resources/hadoop-unit-default.properties @@ -0,0 +1,129 @@ +#HADOOP_HOME=/opt/hadoop + +# Zookeeper +zookeeper.temp.dir=/tmp/embedded_zk +zookeeper.host=127.0.0.1 +zookeeper.port=22010 + +# Hive +hive.scratch.dir=/tmp/hive_scratch_dir +hive.warehouse.dir=/tmp/warehouse_dir + +# Hive Metastore +hive.metastore.hostname=localhost +hive.metastore.port=20102 +hive.metastore.derby.db.dir=metastore_db + +# Hive Server2 +hive.server2.hostname=localhost +hive.server2.port=20103 + +# Hive Test +hive.test.database.name=default +hive.test.table.name=test_table + + +# HDFS +hdfs.namenode.port=20112 +hdfs.namenode.http.port=50070 +hdfs.temp.dir=/tmp/embedded_hdfs +hdfs.num.datanodes=1 +hdfs.enable.permissions=false +hdfs.format=true +hdfs.enable.running.user.as.proxy.user=true + +# HDFS Test +hdfs.test.file=/tmp/testing +hdfs.test.string=TESTING + + +# HBase +hbase.master.port=25111 +hbase.master.info.port=-1 +hbase.num.region.servers=1 +hbase.root.dir=/tmp/embedded_hbase +hbase.znode.parent=/hbase-unsecure +hbase.wal.replication.enabled=false + +# HBase Test +hbase.test.table.name=hbase_test_table +hbase.test.col.family.name=cf1 +hbase.test.col.qualifier.name=cq1 +hbase.test.num.rows.to.put=50 + +# Kafka +kafka.hostname=127.0.0.1 +kafka.port=20111 + +# Kafka Test +kafka.test.topic=testtopic +kafka.test.message.count=10 +kafka.test.broker.id=1 +kafka.test.temp.dir=embedded_kafka + +#SolR + SolRCloud +solr.dir=solr + +#SolR +solr.collection.internal.name=collection1_shard1_replica1 + +#SolRCloud +solr.collection.name=collection1 +solr.cloud.port=8983 + + + + + +# YARN +yarn.num.node.managers=1 +yarn.num.local.dirs=1 +yarn.num.log.dirs=1 +yarn.resource.manager.address=localhost:37001 +yarn.resource.manager.hostname=localhost +yarn.resource.manager.scheduler.address=localhost:37002 +yarn.resource.manager.resource.tracker.address=localhost:37003 +yarn.resource.manager.webapp.address=localhost:37004 +yarn.use.in.jvm.container.executor=false + +# MR +mr.job.history.address=localhost:37005 + +# Oozie +oozie.tmp.dir=/tmp/oozie_tmp +oozie.test.dir=/tmp/embedded_oozie +oozie.home.dir=/tmp/oozie_home +oozie.username=blah +oozie.groupname=testgroup +oozie.hdfs.share.lib.dir=/tmp/share_lib +oozie.share.lib.create=true +oozie.local.share.lib.cache.dir=/tmp/share_lib_cache +oozie.purge.local.share.lib.cache=false +oozie.sharelib.path=/home/khanh/github +oozie.sharelib.name=oozie-4.2.0.2.3.2.0-2950-distro.tar.gz +oozie.port=20113 +oozie.host=localhost + +# MongoDB +mongo.ip=127.0.0.1 +mongo.port=13333 +mongo.database.name=test_database +mongo.collection.name=test_collection + +# Cassandra +cassandra.ip=127.0.0.1 +cassandra.port=13433 +cassandra.temp.dir=/tmp/embedded_cassandra + +# ElasticSearch +elasticsearch.ip=127.0.0.1 +elasticsearch.http.port=14433 +elasticsearch.tcp.port=14533 +elasticsearch.temp.dir=/tmp/elasticsearch +elasticsearch.index.name=test_index +elasticsearch.cluster.name=elasticsearch + +# Neo4j +neo4j.ip=127.0.0.1 +neo4j.port=13533 +neo4j.temp.dir=/tmp/embedded_neo4j \ No newline at end of file diff --git a/hadoop-unit-standalone/hadoop-unit-standalone-solr/src/main/conf/logback.xml b/hadoop-unit-hbase/src/main/resources/logback.xml similarity index 100% rename from hadoop-unit-standalone/hadoop-unit-standalone-solr/src/main/conf/logback.xml rename to hadoop-unit-hbase/src/main/resources/logback.xml diff --git a/hadoop-unit-hdfs/pom.xml b/hadoop-unit-hdfs/pom.xml index bfa53965..bd7f9d9a 100644 --- a/hadoop-unit-hdfs/pom.xml +++ b/hadoop-unit-hdfs/pom.xml @@ -5,7 +5,7 @@ hadoop-unit fr.jetoile.hadoop - 1.6-SNAPSHOT + 2.0-SNAPSHOT 4.0.0 @@ -24,11 +24,6 @@ hadoop-mini-clusters-hdfs - - - javax.servlet - javax.servlet-api - \ No newline at end of file diff --git a/hadoop-unit-hdfs/src/main/java/fr/jetoile/hadoopunit/component/HdfsBootstrap.java b/hadoop-unit-hdfs/src/main/java/fr/jetoile/hadoopunit/component/HdfsBootstrap.java index 43911575..83fa7d45 100644 --- a/hadoop-unit-hdfs/src/main/java/fr/jetoile/hadoopunit/component/HdfsBootstrap.java +++ b/hadoop-unit-hdfs/src/main/java/fr/jetoile/hadoopunit/component/HdfsBootstrap.java @@ -15,21 +15,26 @@ import com.github.sakserv.minicluster.impl.HdfsLocalCluster; import fr.jetoile.hadoopunit.Component; +import fr.jetoile.hadoopunit.HadoopBootstrap; import fr.jetoile.hadoopunit.HadoopUnitConfig; import fr.jetoile.hadoopunit.HadoopUtils; import fr.jetoile.hadoopunit.exception.BootstrapException; +import fr.jetoile.hadoopunit.exception.NotFoundServiceException; import org.apache.commons.configuration.Configuration; import org.apache.commons.configuration.ConfigurationException; import org.apache.commons.configuration.PropertiesConfiguration; +import org.apache.commons.lang.StringUtils; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.hdfs.HdfsConfiguration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Map; + public class HdfsBootstrap implements Bootstrap { final public static String NAME = Component.HDFS.name(); - final private Logger LOGGER = LoggerFactory.getLogger(HdfsBootstrap.class); + static final private Logger LOGGER = LoggerFactory.getLogger(HdfsBootstrap.class); private HdfsLocalCluster hdfsLocalCluster; @@ -86,7 +91,7 @@ private void build() { } private void loadConfig() throws BootstrapException { - HadoopUtils.setHadoopHome(); + HadoopUtils.INSTANCE.setHadoopHome(); try { configuration = new PropertiesConfiguration(HadoopUnitConfig.DEFAULT_PROPS_FILE); } catch (ConfigurationException e) { @@ -102,6 +107,32 @@ private void loadConfig() throws BootstrapException { enableRunningUserAsProxy = configuration.getBoolean(HadoopUnitConfig.HDFS_ENABLE_RUNNING_USER_AS_PROXY_USER); } + @Override + public void loadConfig(Map configs) { + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.HDFS_NAMENODE_PORT_KEY))) { + port = Integer.parseInt(configs.get(HadoopUnitConfig.HDFS_NAMENODE_PORT_KEY)); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.HDFS_NAMENODE_HTTP_PORT_KEY))) { + httpPort = Integer.parseInt(configs.get(HadoopUnitConfig.HDFS_NAMENODE_HTTP_PORT_KEY)); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.HDFS_TEMP_DIR_KEY))) { + tempDirectory = configs.get(HadoopUnitConfig.HDFS_TEMP_DIR_KEY); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.HDFS_NUM_DATANODES_KEY))) { + numDatanodes = Integer.parseInt(configs.get(HadoopUnitConfig.HDFS_NUM_DATANODES_KEY)); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.HDFS_ENABLE_PERMISSIONS_KEY))) { + enablePermission = Boolean.parseBoolean(configs.get(HadoopUnitConfig.HDFS_ENABLE_PERMISSIONS_KEY)); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.HDFS_FORMAT_KEY))) { + format = Boolean.parseBoolean(configs.get(HadoopUnitConfig.HDFS_FORMAT_KEY)); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.HDFS_ENABLE_RUNNING_USER_AS_PROXY_USER))) { + enableRunningUserAsProxy = Boolean.parseBoolean(configs.get(HadoopUnitConfig.HDFS_ENABLE_RUNNING_USER_AS_PROXY_USER)); + } + } + + @Override public Bootstrap start() { if (state == State.STOPPED) { @@ -148,5 +179,4 @@ public FileSystem getHdfsFileSystemHandle() throws Exception { return hdfsLocalCluster.getHdfsFileSystemHandle(); } - } diff --git a/hadoop-unit-hdfs/src/main/resources/hadoop-unit-default.properties b/hadoop-unit-hdfs/src/main/resources/hadoop-unit-default.properties new file mode 100644 index 00000000..ad8559d8 --- /dev/null +++ b/hadoop-unit-hdfs/src/main/resources/hadoop-unit-default.properties @@ -0,0 +1,106 @@ +#HADOOP_HOME=/opt/hadoop + +# Zookeeper +zookeeper.temp.dir=/tmp/embedded_zk +zookeeper.host=127.0.0.1 +zookeeper.port=22010 + +# Hive +hive.scratch.dir=/tmp/hive_scratch_dir +hive.warehouse.dir=/tmp/warehouse_dir + +# Hive Metastore +hive.metastore.hostname=localhost +hive.metastore.port=20102 +hive.metastore.derby.db.dir=metastore_db + +# Hive Server2 +hive.server2.hostname=localhost +hive.server2.port=20103 + +# Hive Test +hive.test.database.name=default +hive.test.table.name=test_table + + +# HDFS +hdfs.namenode.port=20112 +hdfs.namenode.http.port=50070 +hdfs.temp.dir=/tmp/embedded_hdfs +hdfs.num.datanodes=1 +hdfs.enable.permissions=false +hdfs.format=true +hdfs.enable.running.user.as.proxy.user=true + +# HDFS Test +hdfs.test.file=/tmp/testing +hdfs.test.string=TESTING + + +# HBase +hbase.master.port=25111 +hbase.master.info.port=-1 +hbase.num.region.servers=1 +hbase.root.dir=/tmp/embedded_hbase +hbase.znode.parent=/hbase-unsecure +hbase.wal.replication.enabled=false + +# HBase Test +hbase.test.table.name=hbase_test_table +hbase.test.col.family.name=cf1 +hbase.test.col.qualifier.name=cq1 +hbase.test.num.rows.to.put=50 + +# Kafka +kafka.hostname=127.0.0.1 +kafka.port=20111 + +# Kafka Test +kafka.test.topic=testtopic +kafka.test.message.count=10 +kafka.test.broker.id=1 +kafka.test.temp.dir=embedded_kafka + +#SolR + SolRCloud +solr.dir=solr + +#SolR +solr.collection.internal.name=collection1_shard1_replica1 + +#SolRCloud +solr.collection.name=collection1 +solr.cloud.port=8983 + + +# YARN +yarn.num.node.managers=1 +yarn.num.local.dirs=1 +yarn.num.log.dirs=1 +yarn.resource.manager.address=localhost:37001 +yarn.resource.manager.hostname=localhost +yarn.resource.manager.scheduler.address=localhost:37002 +yarn.resource.manager.resource.tracker.address=localhost:37003 +yarn.resource.manager.webapp.address=localhost:37004 +yarn.use.in.jvm.container.executor=false + +# MR +mr.job.history.address=localhost:37005 + +# Oozie +oozie.test.dir=/tmp/embedded_oozie +oozie.home.dir=/tmp/oozie_home +oozie.username=blah +oozie.groupname=testgroup +oozie.hdfs.share.lib.dir=/tmp/share_lib +oozie.share.lib.create=true +oozie.local.share.lib.cache.dir=/tmp/share_lib_cache +oozie.purge.local.share.lib.cache=false +oozie.sharelib.path=/home/khanh/github +oozie.sharelib.name=oozie-4.2.0.2.3.2.0-2950-distro.tar.gz +oozie.port=20113 +oozie.host=localhost + +# Neo4j +neo4j.ip=127.0.0.1 +neo4j.port=13533 +neo4j.temp.dir=/tmp/embedded_neo4j \ No newline at end of file diff --git a/hadoop-unit-hive/pom.xml b/hadoop-unit-hive/pom.xml index b10de6cc..21c72925 100644 --- a/hadoop-unit-hive/pom.xml +++ b/hadoop-unit-hive/pom.xml @@ -5,7 +5,7 @@ hadoop-unit fr.jetoile.hadoop - 1.6-SNAPSHOT + 2.0-SNAPSHOT 4.0.0 @@ -32,11 +32,6 @@ hadoop-mini-clusters-hiveserver2 - - org.eclipse.jetty - jetty-util - - \ No newline at end of file diff --git a/hadoop-unit-hive/src/main/java/fr/jetoile/hadoopunit/component/HiveMetastoreBootstrap.java b/hadoop-unit-hive/src/main/java/fr/jetoile/hadoopunit/component/HiveMetastoreBootstrap.java index f23e15a7..007a355d 100644 --- a/hadoop-unit-hive/src/main/java/fr/jetoile/hadoopunit/component/HiveMetastoreBootstrap.java +++ b/hadoop-unit-hive/src/main/java/fr/jetoile/hadoopunit/component/HiveMetastoreBootstrap.java @@ -17,20 +17,25 @@ import com.github.sakserv.minicluster.util.FileUtils; import com.github.sakserv.minicluster.util.WindowsLibsUtils; import fr.jetoile.hadoopunit.Component; +import fr.jetoile.hadoopunit.HadoopBootstrap; import fr.jetoile.hadoopunit.HadoopUnitConfig; import fr.jetoile.hadoopunit.HadoopUtils; import fr.jetoile.hadoopunit.exception.BootstrapException; +import fr.jetoile.hadoopunit.exception.NotFoundServiceException; import org.apache.commons.configuration.Configuration; import org.apache.commons.configuration.ConfigurationException; import org.apache.commons.configuration.PropertiesConfiguration; +import org.apache.commons.lang.StringUtils; import org.apache.hadoop.hive.conf.HiveConf; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Map; + public class HiveMetastoreBootstrap implements Bootstrap { final public static String NAME = Component.HIVEMETA.name(); - final private Logger LOGGER = LoggerFactory.getLogger(HiveMetastoreBootstrap.class); + final static private Logger LOGGER = LoggerFactory.getLogger(HiveMetastoreBootstrap.class); private HiveLocalMetaStore hiveLocalMetaStore; @@ -66,7 +71,7 @@ public String getProperties() { } private void loadConfig() throws BootstrapException { - HadoopUtils.setHadoopHome(); + HadoopUtils.INSTANCE.setHadoopHome(); try { configuration = new PropertiesConfiguration(HadoopUnitConfig.DEFAULT_PROPS_FILE); } catch (ConfigurationException e) { @@ -77,9 +82,26 @@ private void loadConfig() throws BootstrapException { derbyDirectory = configuration.getString(HadoopUnitConfig.HIVE_METASTORE_DERBY_DB_DIR_KEY); scratchDirectory = configuration.getString(HadoopUnitConfig.HIVE_SCRATCH_DIR_KEY); warehouseDirectory = configuration.getString(HadoopUnitConfig.HIVE_WAREHOUSE_DIR_KEY); - } + @Override + public void loadConfig(Map configs) { + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.HIVE_METASTORE_HOSTNAME_KEY))) { + host = configs.get(HadoopUnitConfig.HIVE_METASTORE_HOSTNAME_KEY); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.HIVE_METASTORE_PORT_KEY))) { + port = Integer.parseInt(configs.get(HadoopUnitConfig.HIVE_METASTORE_PORT_KEY)); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.HIVE_METASTORE_DERBY_DB_DIR_KEY))) { + derbyDirectory = configs.get(HadoopUnitConfig.HIVE_METASTORE_DERBY_DB_DIR_KEY); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.HIVE_SCRATCH_DIR_KEY))) { + scratchDirectory = configs.get(HadoopUnitConfig.HIVE_SCRATCH_DIR_KEY); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.HIVE_WAREHOUSE_DIR_KEY))) { + warehouseDirectory = configs.get(HadoopUnitConfig.HIVE_WAREHOUSE_DIR_KEY); + } + } private void cleanup() { FileUtils.deleteFolder(derbyDirectory); @@ -156,5 +178,4 @@ public org.apache.hadoop.conf.Configuration getConfiguration() { return hiveLocalMetaStore.getHiveConf(); } - } diff --git a/hadoop-unit-hive/src/main/java/fr/jetoile/hadoopunit/component/HiveServer2Bootstrap.java b/hadoop-unit-hive/src/main/java/fr/jetoile/hadoopunit/component/HiveServer2Bootstrap.java index db7e44f6..b2d85b5e 100644 --- a/hadoop-unit-hive/src/main/java/fr/jetoile/hadoopunit/component/HiveServer2Bootstrap.java +++ b/hadoop-unit-hive/src/main/java/fr/jetoile/hadoopunit/component/HiveServer2Bootstrap.java @@ -17,20 +17,25 @@ import com.github.sakserv.minicluster.util.FileUtils; import com.github.sakserv.minicluster.util.WindowsLibsUtils; import fr.jetoile.hadoopunit.Component; +import fr.jetoile.hadoopunit.HadoopBootstrap; import fr.jetoile.hadoopunit.HadoopUnitConfig; import fr.jetoile.hadoopunit.HadoopUtils; import fr.jetoile.hadoopunit.exception.BootstrapException; +import fr.jetoile.hadoopunit.exception.NotFoundServiceException; import org.apache.commons.configuration.Configuration; import org.apache.commons.configuration.ConfigurationException; import org.apache.commons.configuration.PropertiesConfiguration; +import org.apache.commons.lang.StringUtils; import org.apache.hadoop.hive.conf.HiveConf; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Map; + public class HiveServer2Bootstrap implements Bootstrap { final public static String NAME = Component.HIVESERVER2.name(); - final private Logger LOGGER = LoggerFactory.getLogger(HiveServer2Bootstrap.class); + static final private Logger LOGGER = LoggerFactory.getLogger(HiveServer2Bootstrap.class); private HiveLocalServer2 hiveLocalServer2; @@ -70,7 +75,7 @@ public String getProperties() { } private void loadConfig() throws BootstrapException { - HadoopUtils.setHadoopHome(); + HadoopUtils.INSTANCE.setHadoopHome(); try { configuration = new PropertiesConfiguration(HadoopUnitConfig.DEFAULT_PROPS_FILE); } catch (ConfigurationException e) { @@ -84,7 +89,34 @@ private void loadConfig() throws BootstrapException { scratchDirectory = configuration.getString(HadoopUnitConfig.HIVE_SCRATCH_DIR_KEY); warehouseDirectory = configuration.getString(HadoopUnitConfig.HIVE_WAREHOUSE_DIR_KEY); zookeeperConnectionString = configuration.getString(HadoopUnitConfig.ZOOKEEPER_HOST_KEY) + ":" + configuration.getInt(HadoopUnitConfig.ZOOKEEPER_PORT_KEY); + } + @Override + public void loadConfig(Map configs) { + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.HIVE_SERVER2_HOSTNAME_KEY))) { + host = configs.get(HadoopUnitConfig.HIVE_SERVER2_HOSTNAME_KEY); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.HIVE_SERVER2_PORT_KEY))) { + port = Integer.parseInt(configs.get(HadoopUnitConfig.HIVE_SERVER2_PORT_KEY)); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.HIVE_METASTORE_HOSTNAME_KEY))) { + hostMetastore = configs.get(HadoopUnitConfig.HIVE_METASTORE_HOSTNAME_KEY); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.HIVE_METASTORE_PORT_KEY))) { + portMetastore = Integer.parseInt(configs.get(HadoopUnitConfig.HIVE_METASTORE_PORT_KEY)); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.HIVE_METASTORE_DERBY_DB_DIR_KEY))) { + derbyDirectory = configs.get(HadoopUnitConfig.HIVE_METASTORE_DERBY_DB_DIR_KEY); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.HIVE_SCRATCH_DIR_KEY))) { + scratchDirectory = configs.get(HadoopUnitConfig.HIVE_SCRATCH_DIR_KEY); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.HIVE_WAREHOUSE_DIR_KEY))) { + warehouseDirectory = configs.get(HadoopUnitConfig.HIVE_WAREHOUSE_DIR_KEY); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.ZOOKEEPER_HOST_KEY)) && StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.ZOOKEEPER_PORT_KEY))) { + zookeeperConnectionString = configs.get(HadoopUnitConfig.ZOOKEEPER_HOST_KEY) + ":" + configs.get(HadoopUnitConfig.ZOOKEEPER_PORT_KEY); + } } @@ -167,5 +199,4 @@ public org.apache.hadoop.conf.Configuration getConfiguration() { return hiveLocalServer2.getHiveConf(); } - } diff --git a/hadoop-unit-hive/src/main/resources/hadoop-unit-default.properties b/hadoop-unit-hive/src/main/resources/hadoop-unit-default.properties new file mode 100644 index 00000000..ad8559d8 --- /dev/null +++ b/hadoop-unit-hive/src/main/resources/hadoop-unit-default.properties @@ -0,0 +1,106 @@ +#HADOOP_HOME=/opt/hadoop + +# Zookeeper +zookeeper.temp.dir=/tmp/embedded_zk +zookeeper.host=127.0.0.1 +zookeeper.port=22010 + +# Hive +hive.scratch.dir=/tmp/hive_scratch_dir +hive.warehouse.dir=/tmp/warehouse_dir + +# Hive Metastore +hive.metastore.hostname=localhost +hive.metastore.port=20102 +hive.metastore.derby.db.dir=metastore_db + +# Hive Server2 +hive.server2.hostname=localhost +hive.server2.port=20103 + +# Hive Test +hive.test.database.name=default +hive.test.table.name=test_table + + +# HDFS +hdfs.namenode.port=20112 +hdfs.namenode.http.port=50070 +hdfs.temp.dir=/tmp/embedded_hdfs +hdfs.num.datanodes=1 +hdfs.enable.permissions=false +hdfs.format=true +hdfs.enable.running.user.as.proxy.user=true + +# HDFS Test +hdfs.test.file=/tmp/testing +hdfs.test.string=TESTING + + +# HBase +hbase.master.port=25111 +hbase.master.info.port=-1 +hbase.num.region.servers=1 +hbase.root.dir=/tmp/embedded_hbase +hbase.znode.parent=/hbase-unsecure +hbase.wal.replication.enabled=false + +# HBase Test +hbase.test.table.name=hbase_test_table +hbase.test.col.family.name=cf1 +hbase.test.col.qualifier.name=cq1 +hbase.test.num.rows.to.put=50 + +# Kafka +kafka.hostname=127.0.0.1 +kafka.port=20111 + +# Kafka Test +kafka.test.topic=testtopic +kafka.test.message.count=10 +kafka.test.broker.id=1 +kafka.test.temp.dir=embedded_kafka + +#SolR + SolRCloud +solr.dir=solr + +#SolR +solr.collection.internal.name=collection1_shard1_replica1 + +#SolRCloud +solr.collection.name=collection1 +solr.cloud.port=8983 + + +# YARN +yarn.num.node.managers=1 +yarn.num.local.dirs=1 +yarn.num.log.dirs=1 +yarn.resource.manager.address=localhost:37001 +yarn.resource.manager.hostname=localhost +yarn.resource.manager.scheduler.address=localhost:37002 +yarn.resource.manager.resource.tracker.address=localhost:37003 +yarn.resource.manager.webapp.address=localhost:37004 +yarn.use.in.jvm.container.executor=false + +# MR +mr.job.history.address=localhost:37005 + +# Oozie +oozie.test.dir=/tmp/embedded_oozie +oozie.home.dir=/tmp/oozie_home +oozie.username=blah +oozie.groupname=testgroup +oozie.hdfs.share.lib.dir=/tmp/share_lib +oozie.share.lib.create=true +oozie.local.share.lib.cache.dir=/tmp/share_lib_cache +oozie.purge.local.share.lib.cache=false +oozie.sharelib.path=/home/khanh/github +oozie.sharelib.name=oozie-4.2.0.2.3.2.0-2950-distro.tar.gz +oozie.port=20113 +oozie.host=localhost + +# Neo4j +neo4j.ip=127.0.0.1 +neo4j.port=13533 +neo4j.temp.dir=/tmp/embedded_neo4j \ No newline at end of file diff --git a/hadoop-unit-kafka/pom.xml b/hadoop-unit-kafka/pom.xml index e783075f..3868be6f 100644 --- a/hadoop-unit-kafka/pom.xml +++ b/hadoop-unit-kafka/pom.xml @@ -19,7 +19,7 @@ hadoop-unit fr.jetoile.hadoop - 1.6-SNAPSHOT + 2.0-SNAPSHOT 4.0.0 @@ -51,6 +51,8 @@ fr.jetoile.hadoop hadoop-unit-client-kafka + test + \ No newline at end of file diff --git a/hadoop-unit-kafka/src/main/java/fr/jetoile/hadoopunit/component/KafkaBootstrap.java b/hadoop-unit-kafka/src/main/java/fr/jetoile/hadoopunit/component/KafkaBootstrap.java index 1c7672bd..446d8f09 100644 --- a/hadoop-unit-kafka/src/main/java/fr/jetoile/hadoopunit/component/KafkaBootstrap.java +++ b/hadoop-unit-kafka/src/main/java/fr/jetoile/hadoopunit/component/KafkaBootstrap.java @@ -15,21 +15,25 @@ import com.github.sakserv.minicluster.impl.KafkaLocalBroker; import fr.jetoile.hadoopunit.Component; +import fr.jetoile.hadoopunit.HadoopBootstrap; import fr.jetoile.hadoopunit.HadoopUnitConfig; import fr.jetoile.hadoopunit.HadoopUtils; import fr.jetoile.hadoopunit.exception.BootstrapException; +import fr.jetoile.hadoopunit.exception.NotFoundServiceException; import org.apache.commons.configuration.Configuration; import org.apache.commons.configuration.ConfigurationException; import org.apache.commons.configuration.PropertiesConfiguration; +import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Map; import java.util.Properties; public class KafkaBootstrap implements Bootstrap { final public static String NAME = Component.KAFKA.name(); - final private Logger LOGGER = LoggerFactory.getLogger(KafkaBootstrap.class); + static final private Logger LOGGER = LoggerFactory.getLogger(KafkaBootstrap.class); private KafkaLocalBroker kafkaLocalCluster; @@ -83,7 +87,7 @@ private void build() { } private void loadConfig() throws BootstrapException { - HadoopUtils.setHadoopHome(); + HadoopUtils.INSTANCE.setHadoopHome(); try { configuration = new PropertiesConfiguration(HadoopUnitConfig.DEFAULT_PROPS_FILE); } catch (ConfigurationException e) { @@ -94,7 +98,25 @@ private void loadConfig() throws BootstrapException { brokerId = configuration.getInt(HadoopUnitConfig.KAFKA_TEST_BROKER_ID_KEY); tmpDirectory = configuration.getString(HadoopUnitConfig.KAFKA_TEST_TEMP_DIR_KEY); zookeeperConnectionString = configuration.getString(HadoopUnitConfig.ZOOKEEPER_HOST_KEY) + ":" + configuration.getInt(HadoopUnitConfig.ZOOKEEPER_PORT_KEY); + } + @Override + public void loadConfig(Map configs) { + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.KAFKA_HOSTNAME_KEY))) { + host = configs.get(HadoopUnitConfig.KAFKA_HOSTNAME_KEY); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.KAFKA_PORT_KEY))) { + port = Integer.parseInt(configs.get(HadoopUnitConfig.KAFKA_PORT_KEY)); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.KAFKA_TEST_BROKER_ID_KEY))) { + brokerId = Integer.parseInt(configs.get(HadoopUnitConfig.KAFKA_TEST_BROKER_ID_KEY)); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.KAFKA_TEST_TEMP_DIR_KEY))) { + tmpDirectory = configs.get(HadoopUnitConfig.KAFKA_TEST_TEMP_DIR_KEY); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.ZOOKEEPER_HOST_KEY)) && StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.ZOOKEEPER_PORT_KEY))) { + zookeeperConnectionString = configs.get(HadoopUnitConfig.ZOOKEEPER_HOST_KEY) + ":" + configs.get(HadoopUnitConfig.ZOOKEEPER_PORT_KEY); + } } @Override @@ -138,5 +160,4 @@ public Bootstrap stop() { public org.apache.hadoop.conf.Configuration getConfiguration() { throw new UnsupportedOperationException("the method getConfiguration can not be called on KafkaBootstrap"); } - } diff --git a/hadoop-unit-kafka/src/main/resources/hadoop-unit-default.properties b/hadoop-unit-kafka/src/main/resources/hadoop-unit-default.properties new file mode 100644 index 00000000..ad8559d8 --- /dev/null +++ b/hadoop-unit-kafka/src/main/resources/hadoop-unit-default.properties @@ -0,0 +1,106 @@ +#HADOOP_HOME=/opt/hadoop + +# Zookeeper +zookeeper.temp.dir=/tmp/embedded_zk +zookeeper.host=127.0.0.1 +zookeeper.port=22010 + +# Hive +hive.scratch.dir=/tmp/hive_scratch_dir +hive.warehouse.dir=/tmp/warehouse_dir + +# Hive Metastore +hive.metastore.hostname=localhost +hive.metastore.port=20102 +hive.metastore.derby.db.dir=metastore_db + +# Hive Server2 +hive.server2.hostname=localhost +hive.server2.port=20103 + +# Hive Test +hive.test.database.name=default +hive.test.table.name=test_table + + +# HDFS +hdfs.namenode.port=20112 +hdfs.namenode.http.port=50070 +hdfs.temp.dir=/tmp/embedded_hdfs +hdfs.num.datanodes=1 +hdfs.enable.permissions=false +hdfs.format=true +hdfs.enable.running.user.as.proxy.user=true + +# HDFS Test +hdfs.test.file=/tmp/testing +hdfs.test.string=TESTING + + +# HBase +hbase.master.port=25111 +hbase.master.info.port=-1 +hbase.num.region.servers=1 +hbase.root.dir=/tmp/embedded_hbase +hbase.znode.parent=/hbase-unsecure +hbase.wal.replication.enabled=false + +# HBase Test +hbase.test.table.name=hbase_test_table +hbase.test.col.family.name=cf1 +hbase.test.col.qualifier.name=cq1 +hbase.test.num.rows.to.put=50 + +# Kafka +kafka.hostname=127.0.0.1 +kafka.port=20111 + +# Kafka Test +kafka.test.topic=testtopic +kafka.test.message.count=10 +kafka.test.broker.id=1 +kafka.test.temp.dir=embedded_kafka + +#SolR + SolRCloud +solr.dir=solr + +#SolR +solr.collection.internal.name=collection1_shard1_replica1 + +#SolRCloud +solr.collection.name=collection1 +solr.cloud.port=8983 + + +# YARN +yarn.num.node.managers=1 +yarn.num.local.dirs=1 +yarn.num.log.dirs=1 +yarn.resource.manager.address=localhost:37001 +yarn.resource.manager.hostname=localhost +yarn.resource.manager.scheduler.address=localhost:37002 +yarn.resource.manager.resource.tracker.address=localhost:37003 +yarn.resource.manager.webapp.address=localhost:37004 +yarn.use.in.jvm.container.executor=false + +# MR +mr.job.history.address=localhost:37005 + +# Oozie +oozie.test.dir=/tmp/embedded_oozie +oozie.home.dir=/tmp/oozie_home +oozie.username=blah +oozie.groupname=testgroup +oozie.hdfs.share.lib.dir=/tmp/share_lib +oozie.share.lib.create=true +oozie.local.share.lib.cache.dir=/tmp/share_lib_cache +oozie.purge.local.share.lib.cache=false +oozie.sharelib.path=/home/khanh/github +oozie.sharelib.name=oozie-4.2.0.2.3.2.0-2950-distro.tar.gz +oozie.port=20113 +oozie.host=localhost + +# Neo4j +neo4j.ip=127.0.0.1 +neo4j.port=13533 +neo4j.temp.dir=/tmp/embedded_neo4j \ No newline at end of file diff --git a/hadoop-unit-maven-plugin/pom.xml b/hadoop-unit-maven-plugin/pom.xml index 7cb6d3d3..a8e3a4de 100644 --- a/hadoop-unit-maven-plugin/pom.xml +++ b/hadoop-unit-maven-plugin/pom.xml @@ -5,7 +5,7 @@ hadoop-unit fr.jetoile.hadoop - 1.6-SNAPSHOT + 2.0-SNAPSHOT 4.0.0 @@ -13,73 +13,84 @@ maven-plugin hadoop-unit-maven-plugin + + 3.3.9 + + 1.1.0 + + + + + commons-configuration + commons-configuration + fr.jetoile.hadoop hadoop-unit-commons - fr.jetoile.hadoop - hadoop-unit-hbase + org.apache.maven + maven-plugin-api + 3.2.1 + - fr.jetoile.hadoop - hadoop-unit-hdfs + org.apache.maven.plugin-tools + maven-plugin-annotations + 3.4 + provided - fr.jetoile.hadoop - hadoop-unit-hive + org.twdata.maven + mojo-executor + 2.2.0 - fr.jetoile.hadoop - hadoop-unit-kafka + org.eclipse.aether + aether-api + ${aetherVersion} - - fr.jetoile.hadoop - hadoop-unit-oozie + org.eclipse.aether + aether-spi + ${aetherVersion} - - fr.jetoile.hadoop - hadoop-unit-solr + org.eclipse.aether + aether-util + ${aetherVersion} - - fr.jetoile.hadoop - hadoop-unit-solrcloud + org.eclipse.aether + aether-impl + ${aetherVersion} - - fr.jetoile.hadoop - hadoop-unit-zookeeper + org.eclipse.aether + aether-connector-basic + ${aetherVersion} - - org.apache.maven - maven-plugin-api - 3.2.1 + org.eclipse.aether + aether-transport-file + ${aetherVersion} - - - org.apache.maven.plugin-tools - maven-plugin-annotations - 3.4 - provided + org.eclipse.aether + aether-transport-http + ${aetherVersion} - - org.twdata.maven - mojo-executor - 2.2.0 + org.apache.maven + maven-aether-provider + ${mavenVersion} - @@ -101,7 +112,6 @@ true - diff --git a/hadoop-unit-maven-plugin/src/main/java/fr/jetoile/hadoopunit/ComponentArtifact.java b/hadoop-unit-maven-plugin/src/main/java/fr/jetoile/hadoopunit/ComponentArtifact.java new file mode 100644 index 00000000..8fb3091a --- /dev/null +++ b/hadoop-unit-maven-plugin/src/main/java/fr/jetoile/hadoopunit/ComponentArtifact.java @@ -0,0 +1,34 @@ +package fr.jetoile.hadoopunit; + +import java.util.Map; + +public class ComponentArtifact { + + private String artifact; + private String componentName; + private Map properties; + + public String getArtifact() { + return artifact; + } + + public void setArtifact(String artifact) { + this.artifact = artifact; + } + + public String getComponentName() { + return componentName; + } + + public void setComponentName(String componentName) { + this.componentName = componentName; + } + + public Map getProperties() { + return properties; + } + + public void setProperties(Map properties) { + this.properties = properties; + } +} diff --git a/hadoop-unit-maven-plugin/src/main/java/fr/jetoile/hadoopunit/HadoopBootstrapStarter.java b/hadoop-unit-maven-plugin/src/main/java/fr/jetoile/hadoopunit/HadoopBootstrapStarter.java index ce8296ff..85d22bf6 100644 --- a/hadoop-unit-maven-plugin/src/main/java/fr/jetoile/hadoopunit/HadoopBootstrapStarter.java +++ b/hadoop-unit-maven-plugin/src/main/java/fr/jetoile/hadoopunit/HadoopBootstrapStarter.java @@ -14,45 +14,269 @@ package fr.jetoile.hadoopunit; -import fr.jetoile.hadoopunit.HadoopBootstrap; +import org.apache.commons.lang3.StringUtils; +import org.apache.log4j.WriterAppender; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.repository.internal.MavenRepositorySystemUtils; +import org.eclipse.aether.DefaultRepositorySystemSession; +import org.eclipse.aether.RepositorySystem; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.artifact.DefaultArtifact; +import org.eclipse.aether.collection.CollectRequest; +import org.eclipse.aether.connector.basic.BasicRepositoryConnectorFactory; +import org.eclipse.aether.graph.Dependency; +import org.eclipse.aether.graph.DependencyFilter; +import org.eclipse.aether.impl.DefaultServiceLocator; +import org.eclipse.aether.repository.LocalRepository; +import org.eclipse.aether.repository.RemoteRepository; +import org.eclipse.aether.resolution.ArtifactRequest; +import org.eclipse.aether.resolution.ArtifactResult; +import org.eclipse.aether.resolution.DependencyRequest; +import org.eclipse.aether.resolution.DependencyResolutionException; +import org.eclipse.aether.spi.connector.RepositoryConnectorFactory; +import org.eclipse.aether.spi.connector.transport.TransporterFactory; +import org.eclipse.aether.transport.file.FileTransporterFactory; +import org.eclipse.aether.transport.http.HttpTransporterFactory; +import org.eclipse.aether.util.artifact.JavaScopes; +import org.eclipse.aether.util.filter.DependencyFilterUtils; -import java.util.List; -import java.util.stream.Collectors; +import java.io.File; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.*; + +import static com.sun.tools.doclint.Entity.prop; @Mojo(name = "embedded-start", defaultPhase = LifecyclePhase.PRE_INTEGRATION_TEST, threadSafe = false) public class HadoopBootstrapStarter extends AbstractMojo { - @Parameter(property = "values", required = true) - protected List values; + /** + * The {@code :[:[:]]:} of the artifact to resolve. + */ + @Parameter(property = "components", required = true) + protected List components; + + @Parameter(property = "localRepo", required = true) + protected String localRepo; + + @Parameter(property = "centralRepo", required = true) + protected String centralRepo; + + private List componentProperties = new ArrayList<>(); + + public static RepositorySystem newRepositorySystem() { + DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator(); + locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class); + locator.addService(TransporterFactory.class, FileTransporterFactory.class); + locator.addService(TransporterFactory.class, HttpTransporterFactory.class); + + locator.setErrorHandler(new DefaultServiceLocator.ErrorHandler() { + @Override + public void serviceCreationFailed(Class type, Class impl, Throwable exception) { + exception.printStackTrace(); + } + }); + + return locator.getService(RepositorySystem.class); + } + + public DefaultRepositorySystemSession newRepositorySystemSession(RepositorySystem system) { + DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession(); + + LocalRepository localRepo1 = new LocalRepository(localRepo); + session.setLocalRepositoryManager(system.newLocalRepositoryManager(session, localRepo1)); + +// session.setTransferListener(new ConsoleTransferListener()); +// session.setRepositoryListener(new ConsoleRepositoryListener()); + + return session; + } + + public List newRepositories(RepositorySystem system, RepositorySystemSession session) { + return new ArrayList<>(Arrays.asList(newCentralRepository())); + } + + private RemoteRepository newCentralRepository() { + return new RemoteRepository.Builder("central", "default", centralRepo).build(); + } @Override public void execute() throws MojoExecutionException, MojoFailureException { - HadoopBootstrap bootstrap = HadoopBootstrap.INSTANCE; + getLog().info("is going to start hadoop unit"); + + RepositorySystem system = newRepositorySystem(); + DefaultRepositorySystemSession session = newRepositorySystemSession(system); + DependencyFilter classpathFilter = DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE); + components.stream().forEach( + c -> { + Artifact artifact = new DefaultArtifact(c.getArtifact()); - bootstrap.componentsToStart = bootstrap.componentsToStart.stream().filter(c -> - values.contains(c.getName().toUpperCase()) - ).collect(Collectors.toList()); + ArtifactRequest request = new ArtifactRequest(); + CollectRequest collectRequest = new CollectRequest(); + collectRequest.setRoot(new Dependency(artifact, JavaScopes.COMPILE)); + collectRequest.setRepositories(newRepositories(system, session)); - bootstrap.componentsToStop = bootstrap.componentsToStop.stream().filter(c -> - values.contains(c.getName().toUpperCase()) - ).collect(Collectors.toList()); + getLog().info("Resolving artifact " + artifact + " from " + centralRepo); - getLog().info("is going to start hadoop unit"); + DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, classpathFilter); + + List artifactResults = null; + try { + artifactResults = system.resolveDependencies(session, dependencyRequest).getArtifactResults(); + } catch (DependencyResolutionException e) { + e.printStackTrace(); + } + + List artifacts = new ArrayList<>(); + artifactResults.stream().forEach(a -> + artifacts.add(a.getArtifact().getFile()) + ); + + ComponentProperties componentProperty = loadAndRun(c, artifacts); + componentProperties.add(componentProperty); + } + ); + getLog().info("hadoop unit started"); + + printBanner(); + + Runtime.getRuntime().addShutdownHook(new Thread() { + public void run() { + getLog().info("All services are going to be stopped"); + stopAll(componentProperties); + } + }); + } + + private void stopAll(List componentProperties) { + List componentsToStop = new ArrayList<>(componentProperties); + Collections.reverse(componentsToStop); + + componentsToStop.stream().forEach(c -> { + try { + Method main = null; + main = c.getMainClass().getMethod("stop"); + main.invoke(c.getInstance()); + } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { + getLog().error("unable to reflect main", e); + } + }); + } + + private void printBanner() { + HadoopUtils.INSTANCE.printBanner(System.out); + componentProperties.stream().forEach(c -> { + Object name = null; + Object prop = null; + + if (c != null) { + try { + Method main = c.getMainClass().getMethod("getName"); + name = main.invoke(c.getInstance()); + + main = c.getMainClass().getMethod("getProperties"); + prop = main.invoke(c.getInstance()); + } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { + getLog().error("unable to reflect main", e); + } + + System.out.println("\t\t - " + name + " " + prop); + } + }); + System.out.println(); + } + + private ComponentProperties loadAndRun(ComponentArtifact c, List artifacts) { + + Component component = Component.valueOf(c.getComponentName()); + String componentKey = component.getKey(); + String className = component.getMainClass(); + + List urls = new ArrayList(); + + Map properties = c.getProperties(); + + if ("hiveserver2".equalsIgnoreCase(componentKey)) { + urls.add(WriterAppender.class.getProtectionDomain().getCodeSource().getLocation()); + } + + if ("solrcloud".equalsIgnoreCase(componentKey)) { + + String solrDir = properties.get("solr.dir"); + if (StringUtils.isEmpty(solrDir)) { + getLog().warn("unable to find solr.dir property"); + } + } + + artifacts.forEach(f -> { + try { + urls.add(f.toURL()); + } catch (MalformedURLException e) { + getLog().error("unable to find correct url for " + f, e); + } + }); + + ClassLoader classloader = new URLClassLoader( + urls.toArray(new URL[0]), + ClassLoader.getSystemClassLoader().getParent()); + + // relative to that classloader, find the main class + Class mainClass = null; try { - HadoopBootstrap.INSTANCE.startAll(); - } catch (Exception e) { - getLog().error("unable to start embedded hadoop unit", e); + mainClass = classloader.loadClass(className); + } catch (ClassNotFoundException e) { + getLog().error("unable to load class", e); } - getLog().info("hadoop unit started"); + Method main; + try { + Thread.currentThread().setContextClassLoader(classloader); + + Object o = mainClass.getConstructor().newInstance(); + + if (properties != null) { + main = mainClass.getMethod("loadConfig", Map.class); + main.invoke(o, properties); + } + + main = mainClass.getMethod("start"); + main.invoke(o); + return new ComponentProperties(o, mainClass); + } catch (NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException e) { + getLog().error("unable to reflect main", e); + } + return null; + } + + private static class ComponentProperties { + private Object instance; + private Class mainClass; + + public ComponentProperties(Object instance, Class mainClass) { + this.instance = instance; + this.mainClass = mainClass; + } + + public Object getInstance() { + return instance; + } + + public Class getMainClass() { + return mainClass; + } } } + + diff --git a/hadoop-unit-mongodb/pom.xml b/hadoop-unit-mongodb/pom.xml index 8b2623a6..f12aeb75 100644 --- a/hadoop-unit-mongodb/pom.xml +++ b/hadoop-unit-mongodb/pom.xml @@ -6,7 +6,7 @@ hadoop-unit fr.jetoile.hadoop - 1.6-SNAPSHOT + 2.0-SNAPSHOT 4.0.0 @@ -36,5 +36,4 @@ - \ No newline at end of file diff --git a/hadoop-unit-mongodb/src/main/java/fr/jetoile/hadoopunit/component/MongoDbBootstrap.java b/hadoop-unit-mongodb/src/main/java/fr/jetoile/hadoopunit/component/MongoDbBootstrap.java index ae5d9b95..4bbf0a55 100644 --- a/hadoop-unit-mongodb/src/main/java/fr/jetoile/hadoopunit/component/MongoDbBootstrap.java +++ b/hadoop-unit-mongodb/src/main/java/fr/jetoile/hadoopunit/component/MongoDbBootstrap.java @@ -16,18 +16,24 @@ import com.github.sakserv.minicluster.impl.MongodbLocalServer; import fr.jetoile.hadoopunit.Component; +import fr.jetoile.hadoopunit.HadoopBootstrap; import fr.jetoile.hadoopunit.HadoopUnitConfig; import fr.jetoile.hadoopunit.exception.BootstrapException; +import fr.jetoile.hadoopunit.exception.NotFoundServiceException; import org.apache.commons.configuration.Configuration; import org.apache.commons.configuration.ConfigurationException; import org.apache.commons.configuration.PropertiesConfiguration; +import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.Console; +import java.util.Map; + public class MongoDbBootstrap implements Bootstrap { final public static String NAME = Component.MONGODB.name(); - final private Logger LOGGER = LoggerFactory.getLogger(MongoDbBootstrap.class); + static final private Logger LOGGER = LoggerFactory.getLogger(MongoDbBootstrap.class); private State state = State.STOPPED; @@ -73,6 +79,16 @@ private void loadConfig() throws BootstrapException { ip = configuration.getString(HadoopUnitConfig.MONGO_IP_KEY); } + @Override + public void loadConfig(Map configs) { + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.MONGO_PORT_KEY))) { + port = Integer.parseInt(configs.get(HadoopUnitConfig.MONGO_PORT_KEY)); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.MONGO_IP_KEY))) { + ip = configs.get(HadoopUnitConfig.MONGO_IP_KEY); + } + } + private void build() { mongodbLocalServer = new MongodbLocalServer.Builder() .setIp(ip) diff --git a/hadoop-unit-mongodb/src/main/resources/hadoop-unit-default.properties b/hadoop-unit-mongodb/src/main/resources/hadoop-unit-default.properties new file mode 100644 index 00000000..4c8e7332 --- /dev/null +++ b/hadoop-unit-mongodb/src/main/resources/hadoop-unit-default.properties @@ -0,0 +1,129 @@ +#HADOOP_HOME=/opt/hadoop + +# Zookeeper +zookeeper.temp.dir=/tmp/embedded_zk +zookeeper.host=127.0.0.1 +zookeeper.port=22010 + +# Hive +hive.scratch.dir=/tmp/hive_scratch_dir +hive.warehouse.dir=/tmp/warehouse_dir + +# Hive Metastore +hive.metastore.hostname=localhost +hive.metastore.port=20102 +hive.metastore.derby.db.dir=metastore_db + +# Hive Server2 +hive.server2.hostname=localhost +hive.server2.port=20103 + +# Hive Test +hive.test.database.name=default +hive.test.table.name=test_table + + +# HDFS +hdfs.namenode.port=20112 +hdfs.namenode.http.port=50070 +hdfs.temp.dir=/tmp/embedded_hdfs +hdfs.num.datanodes=1 +hdfs.enable.permissions=false +hdfs.format=true +hdfs.enable.running.user.as.proxy.user=true + +# HDFS Test +hdfs.test.file=/tmp/testing +hdfs.test.string=TESTING + + +# HBase +hbase.master.port=25111 +hbase.master.info.port=-1 +hbase.num.region.servers=1 +hbase.root.dir=/tmp/embedded_hbase +hbase.znode.parent=/hbase-unsecure +hbase.wal.replication.enabled=false + +# HBase Test +hbase.test.table.name=hbase_test_table +hbase.test.col.family.name=cf1 +hbase.test.col.qualifier.name=cq1 +hbase.test.num.rows.to.put=50 + +# Kafka +kafka.hostname=127.0.0.1 +kafka.port=20111 + +# Kafka Test +kafka.test.topic=testtopic +kafka.test.message.count=10 +kafka.test.broker.id=1 +kafka.test.temp.dir=embedded_kafka + +#SolR + SolRCloud +solr.dir=solr + +#SolR +solr.collection.internal.name=collection1_shard1_replica1 + +#SolRCloud +solr.collection.name=collection1 +solr.cloud.port=8983 + + + + + +# YARN +yarn.num.node.managers=1 +yarn.num.local.dirs=1 +yarn.num.log.dirs=1 +yarn.resource.manager.address=localhost:37001 +yarn.resource.manager.hostname=localhost +yarn.resource.manager.scheduler.address=localhost:37002 +yarn.resource.manager.resource.tracker.address=localhost:37003 +yarn.resource.manager.webapp.address=localhost:37004 +yarn.use.in.jvm.container.executor=false + +# MR +mr.job.history.address=localhost:37005 + +# Oozie +oozie.tmp.dir=/tmp/oozie_tmp +oozie.test.dir=/tmp/embedded_oozie +oozie.home.dir=/tmp/oozie_home +oozie.username=blah +oozie.groupname=testgroup +oozie.hdfs.share.lib.dir=/tmp/share_lib +oozie.share.lib.create=true +oozie.local.share.lib.cache.dir=/tmp/share_lib_cache +oozie.purge.local.share.lib.cache=false +oozie.sharelib.path=/home/khanh/github +oozie.sharelib.name=oozie-4.2.0.2.3.2.0-2950-distro.tar.gz +oozie.port=20113 +oozie.host=localhost + +# MongoDB +mongo.ip=127.0.0.1 +mongo.port=13333 +mongo.database.name=test_database +mongo.collection.name=test_collection + +# Cassandra +cassandra.ip=127.0.0.1 +cassandra.port=13433 +cassandra.temp.dir=/tmp/embedded_cassandra + +# ElasticSearch +elasticsearch.ip=127.0.0.1 +elasticsearch.http.port=14433 +elasticsearch.tcp.port=14533 +elasticsearch.temp.dir=/tmp/elasticsearch +elasticsearch.index.name=test_index +elasticsearch.cluster.name=elasticsearch + +# Neo4j +neo4j.ip=127.0.0.1 +neo4j.port=13533 +neo4j.temp.dir=/tmp/embedded_neo4j \ No newline at end of file diff --git a/hadoop-unit-mongodb/src/main/resources/logback.xml b/hadoop-unit-mongodb/src/main/resources/logback.xml new file mode 100755 index 00000000..8329aeb7 --- /dev/null +++ b/hadoop-unit-mongodb/src/main/resources/logback.xml @@ -0,0 +1,17 @@ + + + + %d{HH:mm:ss.SSS} %-5level %logger{36} - %msg%n + + + + + + + + + + + + + \ No newline at end of file diff --git a/hadoop-unit-neo4j/pom.xml b/hadoop-unit-neo4j/pom.xml index c7988da9..ec3adb7a 100644 --- a/hadoop-unit-neo4j/pom.xml +++ b/hadoop-unit-neo4j/pom.xml @@ -5,7 +5,7 @@ hadoop-unit fr.jetoile.hadoop - 1.6-SNAPSHOT + 2.0-SNAPSHOT 4.0.0 @@ -40,5 +40,4 @@ - \ No newline at end of file diff --git a/hadoop-unit-neo4j/src/main/java/fr/jetoile/hadoopunit/component/Neo4jBootstrap.java b/hadoop-unit-neo4j/src/main/java/fr/jetoile/hadoopunit/component/Neo4jBootstrap.java index 71d36329..0884af0d 100644 --- a/hadoop-unit-neo4j/src/main/java/fr/jetoile/hadoopunit/component/Neo4jBootstrap.java +++ b/hadoop-unit-neo4j/src/main/java/fr/jetoile/hadoopunit/component/Neo4jBootstrap.java @@ -16,12 +16,15 @@ import fr.jetoile.hadoopunit.Component; +import fr.jetoile.hadoopunit.HadoopBootstrap; import fr.jetoile.hadoopunit.HadoopUnitConfig; import fr.jetoile.hadoopunit.exception.BootstrapException; +import fr.jetoile.hadoopunit.exception.NotFoundServiceException; import org.apache.commons.configuration.Configuration; import org.apache.commons.configuration.ConfigurationException; import org.apache.commons.configuration.PropertiesConfiguration; import org.apache.commons.io.FileUtils; +import org.apache.commons.lang.StringUtils; import org.neo4j.cypher.javacompat.internal.GraphDatabaseCypherService; import org.neo4j.graphdb.GraphDatabaseService; import org.neo4j.graphdb.factory.GraphDatabaseFactory; @@ -29,13 +32,15 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.Console; import java.io.IOException; import java.nio.file.Paths; +import java.util.Map; public class Neo4jBootstrap implements Bootstrap { final public static String NAME = Component.NEO4J.name(); - final private Logger LOGGER = LoggerFactory.getLogger(Neo4jBootstrap.class); + static final private Logger LOGGER = LoggerFactory.getLogger(Neo4jBootstrap.class); private State state = State.STOPPED; @@ -80,6 +85,19 @@ private void loadConfig() throws BootstrapException { tmp = configuration.getString(HadoopUnitConfig.NEO4J_TEMP_DIR_KEY); } + @Override + public void loadConfig(Map configs) { + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.NEO4J_PORT_KEY))) { + port = Integer.parseInt(configs.get(HadoopUnitConfig.NEO4J_PORT_KEY)); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.NEO4J_IP_KEY))) { + ip = configs.get(HadoopUnitConfig.NEO4J_IP_KEY); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.NEO4J_TEMP_DIR_KEY))) { + tmp = configs.get(HadoopUnitConfig.NEO4J_TEMP_DIR_KEY); + } + } + private void build() { GraphDatabaseSettings.BoltConnector bolt = GraphDatabaseSettings.boltConnector( "0" ); diff --git a/hadoop-unit-neo4j/src/main/resources/hadoop-unit-default.properties b/hadoop-unit-neo4j/src/main/resources/hadoop-unit-default.properties new file mode 100644 index 00000000..4c8e7332 --- /dev/null +++ b/hadoop-unit-neo4j/src/main/resources/hadoop-unit-default.properties @@ -0,0 +1,129 @@ +#HADOOP_HOME=/opt/hadoop + +# Zookeeper +zookeeper.temp.dir=/tmp/embedded_zk +zookeeper.host=127.0.0.1 +zookeeper.port=22010 + +# Hive +hive.scratch.dir=/tmp/hive_scratch_dir +hive.warehouse.dir=/tmp/warehouse_dir + +# Hive Metastore +hive.metastore.hostname=localhost +hive.metastore.port=20102 +hive.metastore.derby.db.dir=metastore_db + +# Hive Server2 +hive.server2.hostname=localhost +hive.server2.port=20103 + +# Hive Test +hive.test.database.name=default +hive.test.table.name=test_table + + +# HDFS +hdfs.namenode.port=20112 +hdfs.namenode.http.port=50070 +hdfs.temp.dir=/tmp/embedded_hdfs +hdfs.num.datanodes=1 +hdfs.enable.permissions=false +hdfs.format=true +hdfs.enable.running.user.as.proxy.user=true + +# HDFS Test +hdfs.test.file=/tmp/testing +hdfs.test.string=TESTING + + +# HBase +hbase.master.port=25111 +hbase.master.info.port=-1 +hbase.num.region.servers=1 +hbase.root.dir=/tmp/embedded_hbase +hbase.znode.parent=/hbase-unsecure +hbase.wal.replication.enabled=false + +# HBase Test +hbase.test.table.name=hbase_test_table +hbase.test.col.family.name=cf1 +hbase.test.col.qualifier.name=cq1 +hbase.test.num.rows.to.put=50 + +# Kafka +kafka.hostname=127.0.0.1 +kafka.port=20111 + +# Kafka Test +kafka.test.topic=testtopic +kafka.test.message.count=10 +kafka.test.broker.id=1 +kafka.test.temp.dir=embedded_kafka + +#SolR + SolRCloud +solr.dir=solr + +#SolR +solr.collection.internal.name=collection1_shard1_replica1 + +#SolRCloud +solr.collection.name=collection1 +solr.cloud.port=8983 + + + + + +# YARN +yarn.num.node.managers=1 +yarn.num.local.dirs=1 +yarn.num.log.dirs=1 +yarn.resource.manager.address=localhost:37001 +yarn.resource.manager.hostname=localhost +yarn.resource.manager.scheduler.address=localhost:37002 +yarn.resource.manager.resource.tracker.address=localhost:37003 +yarn.resource.manager.webapp.address=localhost:37004 +yarn.use.in.jvm.container.executor=false + +# MR +mr.job.history.address=localhost:37005 + +# Oozie +oozie.tmp.dir=/tmp/oozie_tmp +oozie.test.dir=/tmp/embedded_oozie +oozie.home.dir=/tmp/oozie_home +oozie.username=blah +oozie.groupname=testgroup +oozie.hdfs.share.lib.dir=/tmp/share_lib +oozie.share.lib.create=true +oozie.local.share.lib.cache.dir=/tmp/share_lib_cache +oozie.purge.local.share.lib.cache=false +oozie.sharelib.path=/home/khanh/github +oozie.sharelib.name=oozie-4.2.0.2.3.2.0-2950-distro.tar.gz +oozie.port=20113 +oozie.host=localhost + +# MongoDB +mongo.ip=127.0.0.1 +mongo.port=13333 +mongo.database.name=test_database +mongo.collection.name=test_collection + +# Cassandra +cassandra.ip=127.0.0.1 +cassandra.port=13433 +cassandra.temp.dir=/tmp/embedded_cassandra + +# ElasticSearch +elasticsearch.ip=127.0.0.1 +elasticsearch.http.port=14433 +elasticsearch.tcp.port=14533 +elasticsearch.temp.dir=/tmp/elasticsearch +elasticsearch.index.name=test_index +elasticsearch.cluster.name=elasticsearch + +# Neo4j +neo4j.ip=127.0.0.1 +neo4j.port=13533 +neo4j.temp.dir=/tmp/embedded_neo4j \ No newline at end of file diff --git a/hadoop-unit-neo4j/src/main/resources/logback.xml b/hadoop-unit-neo4j/src/main/resources/logback.xml new file mode 100755 index 00000000..8329aeb7 --- /dev/null +++ b/hadoop-unit-neo4j/src/main/resources/logback.xml @@ -0,0 +1,17 @@ + + + + %d{HH:mm:ss.SSS} %-5level %logger{36} - %msg%n + + + + + + + + + + + + + \ No newline at end of file diff --git a/hadoop-unit-oozie/pom.xml b/hadoop-unit-oozie/pom.xml index 1d5b7694..1fba3402 100644 --- a/hadoop-unit-oozie/pom.xml +++ b/hadoop-unit-oozie/pom.xml @@ -5,7 +5,7 @@ hadoop-unit fr.jetoile.hadoop - 1.6-SNAPSHOT + 2.0-SNAPSHOT 4.0.0 @@ -51,13 +51,6 @@ io.dropwizard.metrics metrics-json - - - - - - - \ No newline at end of file diff --git a/hadoop-unit-oozie/src/main/java/fr/jetoile/hadoopunit/component/OozieBootstrap.java b/hadoop-unit-oozie/src/main/java/fr/jetoile/hadoopunit/component/OozieBootstrap.java index cba67126..eea60403 100644 --- a/hadoop-unit-oozie/src/main/java/fr/jetoile/hadoopunit/component/OozieBootstrap.java +++ b/hadoop-unit-oozie/src/main/java/fr/jetoile/hadoopunit/component/OozieBootstrap.java @@ -17,15 +17,15 @@ import com.github.sakserv.minicluster.impl.OozieLocalServer; import com.github.sakserv.minicluster.util.FileUtils; import fr.jetoile.hadoopunit.Component; -import fr.jetoile.hadoopunit.HadoopUnitConfig; import fr.jetoile.hadoopunit.HadoopBootstrap; +import fr.jetoile.hadoopunit.HadoopUnitConfig; import fr.jetoile.hadoopunit.HadoopUtils; import fr.jetoile.hadoopunit.exception.BootstrapException; import fr.jetoile.hadoopunit.exception.NotFoundServiceException; import org.apache.commons.configuration.Configuration; import org.apache.commons.configuration.ConfigurationException; import org.apache.commons.configuration.PropertiesConfiguration; -import org.apache.hadoop.fs.FileSystem; +import org.apache.commons.lang.StringUtils; import org.apache.hadoop.fs.FileUtil; import org.apache.hadoop.fs.Path; import org.apache.oozie.client.OozieClient; @@ -34,10 +34,10 @@ import java.io.File; import java.io.IOException; -import java.net.URI; import java.nio.file.Paths; import java.text.SimpleDateFormat; import java.util.Date; +import java.util.Map; public class OozieBootstrap implements Bootstrap { final public static String NAME = Component.OOZIE.name(); @@ -125,7 +125,6 @@ private void build() throws NotFoundServiceException { // hadoopConf.set("oozie.action.sharelib.for.shell", "true"); - hadoopConf.set("fs.defaultFS", "hdfs://" + configuration.getString(HadoopUnitConfig.HDFS_NAMENODE_HOST_KEY) + ":" + configuration.getString(HadoopUnitConfig.HDFS_NAMENODE_PORT_KEY)); hdfsDefaultFs = "hdfs://" + configuration.getString(HadoopUnitConfig.HDFS_NAMENODE_HOST_KEY) + ":" + configuration.getString(HadoopUnitConfig.HDFS_NAMENODE_PORT_KEY); @@ -151,7 +150,7 @@ private void build() throws NotFoundServiceException { .setOozieYarnResourceManagerAddress(oozieYarnResourceManagerAddress) .setOozieHdfsDefaultFs(hdfsDefaultFs) .setOozieConf(hadoopConf) - .setOozieHdfsShareLibDir("file://"+oozieShareLibExtractTempDir) + .setOozieHdfsShareLibDir("file://" + oozieShareLibExtractTempDir) // .setOozieHdfsShareLibDir(hdfsDefaultFs + "/" + oozieHdfsShareLibDir) .setOozieShareLibCreate(oozieShareLibCreate) // .setOozieLocalShareLibCacheDir(oozieShareLibExtractTempDir) @@ -163,7 +162,7 @@ private void build() throws NotFoundServiceException { } private void loadConfig() throws BootstrapException, NotFoundServiceException { - HadoopUtils.setHadoopHome(); + HadoopUtils.INSTANCE.setHadoopHome(); try { configuration = new PropertiesConfiguration(HadoopUnitConfig.DEFAULT_PROPS_FILE); @@ -194,12 +193,85 @@ private void loadConfig() throws BootstrapException, NotFoundServiceException { resourceManagerWebappAddress = configuration.getString(HadoopUnitConfig.YARN_RESOURCE_MANAGER_WEBAPP_ADDRESS_KEY); useInJvmContainerExecutor = configuration.getBoolean(HadoopUnitConfig.YARN_USE_IN_JVM_CONTAINER_EXECUTOR_KEY); - ooziePort = configuration.getInt(OOZIE_PORT); - oozieHost = configuration.getString(OOZIE_HOST); + ooziePort = configuration.getInt(HadoopUnitConfig.OOZIE_PORT); + oozieHost = configuration.getString(HadoopUnitConfig.OOZIE_HOST); - oozieShareLibPath = configuration.getString(OOZIE_SHARELIB_PATH_KEY); - oozieShareLibName = configuration.getString(OOZIE_SHARELIB_NAME_KEY); + oozieShareLibPath = configuration.getString(HadoopUnitConfig.OOZIE_SHARELIB_PATH_KEY); + oozieShareLibName = configuration.getString(HadoopUnitConfig.OOZIE_SHARELIB_NAME_KEY); + } + @Override + public void loadConfig(Map configs) { + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.OOZIE_TEST_DIR_KEY))) { + oozieTestDir = configs.get(HadoopUnitConfig.OOZIE_TEST_DIR_KEY); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.OOZIE_HOME_DIR_KEY))) { + oozieHomeDir = configs.get(HadoopUnitConfig.OOZIE_HOME_DIR_KEY); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.OOZIE_GROUPNAME_KEY))) { + oozieGroupname = configs.get(HadoopUnitConfig.OOZIE_GROUPNAME_KEY); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.YARN_RESOURCE_MANAGER_ADDRESS_KEY))) { + oozieYarnResourceManagerAddress = configs.get(HadoopUnitConfig.YARN_RESOURCE_MANAGER_ADDRESS_KEY); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.OOZIE_HDFS_SHARE_LIB_DIR_KEY))) { + oozieShareLibExtractTempDir = configs.get(HadoopUnitConfig.OOZIE_HDFS_SHARE_LIB_DIR_KEY); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.OOZIE_HDFS_SHARE_LIB_DIR_KEY))) { + oozieHdfsShareLibDir = configs.get(HadoopUnitConfig.OOZIE_HDFS_SHARE_LIB_DIR_KEY); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.OOZIE_SHARE_LIB_CREATE_KEY))) { + oozieShareLibCreate = Boolean.parseBoolean(configs.get(HadoopUnitConfig.OOZIE_SHARE_LIB_CREATE_KEY)); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.OOZIE_LOCAL_SHARE_LIB_CACHE_DIR_KEY))) { + oozieLocalShareLibCacheDir = configs.get(HadoopUnitConfig.OOZIE_LOCAL_SHARE_LIB_CACHE_DIR_KEY); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.OOZIE_PURGE_LOCAL_SHARE_LIB_CACHE_KEY))) { + ooziePurgeLocalShareLibCache = Boolean.parseBoolean(configs.get(HadoopUnitConfig.OOZIE_PURGE_LOCAL_SHARE_LIB_CACHE_KEY)); + } + + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.OOZIE_TMP_DIR_KEY))) { + oozieTmpDir = configs.get(HadoopUnitConfig.OOZIE_TMP_DIR_KEY); + } + + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.YARN_NUM_NODE_MANAGERS_KEY))) { + numNodeManagers = Integer.parseInt(configs.get(HadoopUnitConfig.YARN_NUM_NODE_MANAGERS_KEY)); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.MR_JOB_HISTORY_ADDRESS_KEY))) { + jobHistoryAddress = configs.get(HadoopUnitConfig.MR_JOB_HISTORY_ADDRESS_KEY); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.YARN_RESOURCE_MANAGER_ADDRESS_KEY))) { + resourceManagerAddress = configs.get(HadoopUnitConfig.YARN_RESOURCE_MANAGER_ADDRESS_KEY); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.YARN_RESOURCE_MANAGER_HOSTNAME_KEY))) { + resourceManagerHostname = configs.get(HadoopUnitConfig.YARN_RESOURCE_MANAGER_HOSTNAME_KEY); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.YARN_RESOURCE_MANAGER_SCHEDULER_ADDRESS_KEY))) { + resourceManagerSchedulerAddress = configs.get(HadoopUnitConfig.YARN_RESOURCE_MANAGER_SCHEDULER_ADDRESS_KEY); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.YARN_RESOURCE_MANAGER_RESOURCE_TRACKER_ADDRESS_KEY))) { + resourceManagerResourceTrackerAddress = configs.get(HadoopUnitConfig.YARN_RESOURCE_MANAGER_RESOURCE_TRACKER_ADDRESS_KEY); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.YARN_RESOURCE_MANAGER_WEBAPP_ADDRESS_KEY))) { + resourceManagerWebappAddress = configs.get(HadoopUnitConfig.YARN_RESOURCE_MANAGER_WEBAPP_ADDRESS_KEY); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.YARN_USE_IN_JVM_CONTAINER_EXECUTOR_KEY))) { + useInJvmContainerExecutor = Boolean.parseBoolean(configs.get(HadoopUnitConfig.YARN_USE_IN_JVM_CONTAINER_EXECUTOR_KEY)); + } + + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.OOZIE_PORT))) { + ooziePort = Integer.parseInt(configs.get(HadoopUnitConfig.OOZIE_PORT)); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.OOZIE_HOST))) { + oozieHost = configs.get(HadoopUnitConfig.OOZIE_HOST); + } + + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.OOZIE_SHARELIB_PATH_KEY))) { + oozieShareLibPath = configs.get(HadoopUnitConfig.OOZIE_SHARELIB_PATH_KEY); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.OOZIE_SHARELIB_NAME_KEY))) { + oozieShareLibName = configs.get(HadoopUnitConfig.OOZIE_SHARELIB_NAME_KEY); + } } @Override @@ -237,7 +309,7 @@ public Bootstrap stop() { mrLocalCluster.stop(true); cleanup(); } catch (Exception e) { - LOGGER.error("unable to stop hdfs", e); + LOGGER.error("unable to stop oozie", e); } state = State.STOPPED; LOGGER.info("{} is stopped", this.getClass().getName()); @@ -308,7 +380,7 @@ public void createShareLib() { } public String extractOozieTarFileToTempDir(File fullOozieTarFilePath) throws IOException { - File tempDir = File.createTempFile(SHARE_LIB_LOCAL_TEMP_PREFIX, "", Paths.get(oozieTmpDir).toFile()); + File tempDir = File.createTempFile(HadoopUnitConfig.SHARE_LIB_LOCAL_TEMP_PREFIX, "", Paths.get(oozieTmpDir).toFile()); tempDir.delete(); tempDir.mkdir(); tempDir.deleteOnExit(); @@ -319,7 +391,7 @@ public String extractOozieTarFileToTempDir(File fullOozieTarFilePath) throws IOE } public String extractOozieShareLibTarFileToTempDir(File fullOozieShareLibTarFilePath) throws IOException { - File tempDir = File.createTempFile(SHARE_LIB_LOCAL_TEMP_PREFIX, "", Paths.get(oozieTmpDir).toFile()); + File tempDir = File.createTempFile(HadoopUnitConfig.SHARE_LIB_LOCAL_TEMP_PREFIX, "", Paths.get(oozieTmpDir).toFile()); tempDir.delete(); tempDir.mkdir(); tempDir.deleteOnExit(); @@ -338,17 +410,4 @@ public String getTimestampDirectory() { Date date = new Date(); return dateFormat.format(date).toString(); } - - final public static void main(String... args) throws NotFoundServiceException { - - HadoopBootstrap bootstrap = HadoopBootstrap.INSTANCE; - - Runtime.getRuntime().addShutdownHook(new Thread() { - public void run() { - bootstrap.stopAll(); - } - }); - - bootstrap.add(Component.OOZIE).startAll(); - } } diff --git a/hadoop-unit-oozie/src/main/resources/hadoop-unit-default.properties b/hadoop-unit-oozie/src/main/resources/hadoop-unit-default.properties new file mode 100644 index 00000000..bbc0c6ca --- /dev/null +++ b/hadoop-unit-oozie/src/main/resources/hadoop-unit-default.properties @@ -0,0 +1,127 @@ +#HADOOP_HOME=/opt/hadoop + +# Zookeeper +zookeeper.temp.dir=/tmp/embedded_zk +zookeeper.host=127.0.0.1 +zookeeper.port=22010 + +# Hive +hive.scratch.dir=/tmp/hive_scratch_dir +hive.warehouse.dir=/tmp/warehouse_dir + +# Hive Metastore +hive.metastore.hostname=localhost +hive.metastore.port=20102 +hive.metastore.derby.db.dir=metastore_db + +# Hive Server2 +hive.server2.hostname=localhost +hive.server2.port=20103 + +# Hive Test +hive.test.database.name=default +hive.test.table.name=test_table + + +# HDFS +hdfs.namenode.host=localhost +hdfs.namenode.port=20112 +hdfs.namenode.http.port=50070 +hdfs.temp.dir=/tmp/embedded_hdfs +hdfs.num.datanodes=1 +hdfs.enable.permissions=false +hdfs.format=true +hdfs.enable.running.user.as.proxy.user=true + +# HDFS Test +hdfs.test.file=/tmp/testing +hdfs.test.string=TESTING + + +# HBase +hbase.master.port=25111 +hbase.master.info.port=-1 +hbase.num.region.servers=1 +hbase.root.dir=/tmp/embedded_hbase +hbase.znode.parent=/hbase-unsecure +hbase.wal.replication.enabled=false + +# HBase Test +hbase.test.table.name=hbase_test_table +hbase.test.col.family.name=cf1 +hbase.test.col.qualifier.name=cq1 +hbase.test.num.rows.to.put=50 + +# Kafka +kafka.hostname=127.0.0.1 +kafka.port=20111 + +# Kafka Test +kafka.test.topic=testtopic +kafka.test.message.count=10 +kafka.test.broker.id=1 +kafka.test.temp.dir=embedded_kafka + +#SolR + SolRCloud +solr.dir=solr + +#SolR +solr.collection.internal.name=collection1_shard1_replica1 + +#SolRCloud +solr.collection.name=collection1 +solr.cloud.port=8983 + + +# YARN +yarn.num.node.managers=1 +yarn.num.local.dirs=1 +yarn.num.log.dirs=1 +yarn.resource.manager.address=localhost:37001 +yarn.resource.manager.hostname=localhost +yarn.resource.manager.scheduler.address=localhost:37002 +yarn.resource.manager.resource.tracker.address=localhost:37003 +yarn.resource.manager.webapp.address=localhost:37004 +yarn.use.in.jvm.container.executor=false + +# MR +mr.job.history.address=localhost:37005 + +# Oozie +oozie.tmp.dir=/tmp/oozie_tmp +oozie.test.dir=/tmp/embedded_oozie +oozie.home.dir=/tmp/oozie_home +oozie.username=blah +oozie.groupname=testgroup +oozie.hdfs.share.lib.dir=/tmp/share_lib +oozie.share.lib.create=true +oozie.local.share.lib.cache.dir=/tmp/share_lib_cache +oozie.purge.local.share.lib.cache=false +oozie.sharelib.path=/home/khanh/github +oozie.sharelib.name=oozie-4.2.0.2.3.2.0-2950-distro.tar.gz +oozie.port=20113 +oozie.host=localhost + +# MongoDB +mongo.ip=127.0.0.1 +mongo.port=13333 +mongo.database.name=test_database +mongo.collection.name=test_collection + +# Cassandra +cassandra.ip=127.0.0.1 +cassandra.port=13433 +cassandra.temp.dir=/tmp/embedded_cassandra + +# ElasticSearch +elasticsearch.ip=127.0.0.1 +elasticsearch.http.port=14433 +elasticsearch.tcp.port=14533 +elasticsearch.temp.dir=/tmp/elasticsearch +elasticsearch.index.name=test_index +elasticsearch.cluster.name=elasticsearch + +# Neo4j +neo4j.ip=127.0.0.1 +neo4j.port=13533 +neo4j.temp.dir=/tmp/embedded_neo4j \ No newline at end of file diff --git a/hadoop-unit-solr/pom.xml b/hadoop-unit-solr/pom.xml index 40ffd349..172313b7 100644 --- a/hadoop-unit-solr/pom.xml +++ b/hadoop-unit-solr/pom.xml @@ -5,7 +5,7 @@ hadoop-unit fr.jetoile.hadoop - 1.6-SNAPSHOT + 2.0-SNAPSHOT 4.0.0 @@ -33,35 +33,6 @@ concurrentlinkedhashmap-lru - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/hadoop-unit-solr/src/main/java/fr/jetoile/hadoopunit/component/SolrBootstrap.java b/hadoop-unit-solr/src/main/java/fr/jetoile/hadoopunit/component/SolrBootstrap.java index bf9b8820..12ec9e14 100644 --- a/hadoop-unit-solr/src/main/java/fr/jetoile/hadoopunit/component/SolrBootstrap.java +++ b/hadoop-unit-solr/src/main/java/fr/jetoile/hadoopunit/component/SolrBootstrap.java @@ -14,12 +14,15 @@ package fr.jetoile.hadoopunit.component; import fr.jetoile.hadoopunit.Component; +import fr.jetoile.hadoopunit.HadoopBootstrap; import fr.jetoile.hadoopunit.HadoopUnitConfig; import fr.jetoile.hadoopunit.HadoopUtils; import fr.jetoile.hadoopunit.exception.BootstrapException; +import fr.jetoile.hadoopunit.exception.NotFoundServiceException; import org.apache.commons.configuration.Configuration; import org.apache.commons.configuration.ConfigurationException; import org.apache.commons.configuration.PropertiesConfiguration; +import org.apache.commons.lang.StringUtils; import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer; import org.apache.solr.core.CoreContainer; import org.slf4j.Logger; @@ -31,6 +34,7 @@ import java.io.IOException; import java.net.URLDecoder; import java.nio.file.Paths; +import java.util.Map; public class SolrBootstrap implements Bootstrap { final public static String NAME = Component.SOLR.name(); @@ -70,7 +74,7 @@ public String getProperties() { } private void loadConfig() throws BootstrapException { - HadoopUtils.setHadoopHome(); + HadoopUtils.INSTANCE.setHadoopHome(); try { configuration = new PropertiesConfiguration(HadoopUnitConfig.DEFAULT_PROPS_FILE); } catch (ConfigurationException e) { @@ -78,7 +82,16 @@ private void loadConfig() throws BootstrapException { } solrDirectory = configuration.getString(SOLR_DIR_KEY); solrCollectionInternalName = configuration.getString(SOLR_COLLECTION_INTERNAL_NAME); + } + @Override + public void loadConfig(Map configs) { + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.SOLR_DIR_KEY))) { + solrDirectory = configs.get(HadoopUnitConfig.SOLR_DIR_KEY); + } + if (StringUtils.isNotEmpty(configs.get(SOLR_COLLECTION_INTERNAL_NAME))) { + solrCollectionInternalName = configs.get(SOLR_COLLECTION_INTERNAL_NAME); + } } @Override @@ -148,4 +161,5 @@ private CoreContainer createCoreContainer(String solrHomeDirectory) throws Boots private CoreContainer createCoreContainer(String solrHomeDirectory, File solrXmlFile) { return CoreContainer.createAndLoad(Paths.get(solrHomeDirectory), solrXmlFile.toPath()); } + } diff --git a/hadoop-unit-standalone/hadoop-unit-standalone-solr/src/main/conf/hadoop-unit-default.properties b/hadoop-unit-solr/src/main/resources/hadoop-unit-default.properties similarity index 100% rename from hadoop-unit-standalone/hadoop-unit-standalone-solr/src/main/conf/hadoop-unit-default.properties rename to hadoop-unit-solr/src/main/resources/hadoop-unit-default.properties diff --git a/hadoop-unit-solr/src/main/resources/logback.xml b/hadoop-unit-solr/src/main/resources/logback.xml new file mode 100755 index 00000000..8329aeb7 --- /dev/null +++ b/hadoop-unit-solr/src/main/resources/logback.xml @@ -0,0 +1,17 @@ + + + + %d{HH:mm:ss.SSS} %-5level %logger{36} - %msg%n + + + + + + + + + + + + + \ No newline at end of file diff --git a/hadoop-unit-solrcloud/pom.xml b/hadoop-unit-solrcloud/pom.xml index b3547ca5..5f7e7aa2 100644 --- a/hadoop-unit-solrcloud/pom.xml +++ b/hadoop-unit-solrcloud/pom.xml @@ -5,7 +5,7 @@ hadoop-unit fr.jetoile.hadoop - 1.6-SNAPSHOT + 2.0-SNAPSHOT 4.0.0 @@ -39,4 +39,5 @@ concurrentlinkedhashmap-lru + \ No newline at end of file diff --git a/hadoop-unit-solrcloud/src/main/java/fr/jetoile/hadoopunit/component/SolrCloudBootstrap.java b/hadoop-unit-solrcloud/src/main/java/fr/jetoile/hadoopunit/component/SolrCloudBootstrap.java index bf808634..32f9186e 100644 --- a/hadoop-unit-solrcloud/src/main/java/fr/jetoile/hadoopunit/component/SolrCloudBootstrap.java +++ b/hadoop-unit-solrcloud/src/main/java/fr/jetoile/hadoopunit/component/SolrCloudBootstrap.java @@ -14,12 +14,13 @@ package fr.jetoile.hadoopunit.component; import fr.jetoile.hadoopunit.Component; +import fr.jetoile.hadoopunit.HadoopBootstrap; import fr.jetoile.hadoopunit.HadoopUnitConfig; import fr.jetoile.hadoopunit.HadoopUtils; import fr.jetoile.hadoopunit.exception.BootstrapException; -import org.apache.commons.configuration.Configuration; -import org.apache.commons.configuration.ConfigurationException; -import org.apache.commons.configuration.PropertiesConfiguration; +import fr.jetoile.hadoopunit.exception.NotFoundServiceException; +import org.apache.commons.configuration.*; +import org.apache.commons.lang.StringUtils; import org.apache.solr.client.solrj.embedded.JettySolrRunner; import org.apache.solr.client.solrj.impl.CloudSolrClient; import org.apache.solr.common.cloud.SolrZkClient; @@ -28,18 +29,22 @@ import org.slf4j.LoggerFactory; import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; +import java.io.InputStream; +import java.net.MalformedURLException; import java.net.URI; import java.net.URISyntaxException; +import java.net.URL; import java.nio.file.Paths; +import java.util.Map; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; public class SolrCloudBootstrap implements Bootstrap { final public static String NAME = Component.SOLRCLOUD.name(); - public static final String SOLR_DIR_KEY = "solr.dir"; - public static final String SOLR_COLLECTION_NAME = "solr.collection.name"; - public static final String SOLR_PORT = "solr.cloud.port"; - final private Logger LOGGER = LoggerFactory.getLogger(SolrCloudBootstrap.class); + final private static Logger LOGGER = LoggerFactory.getLogger(SolrCloudBootstrap.class); public static final int TIMEOUT = 10000; @@ -80,7 +85,17 @@ public String getProperties() { private void build() { File solrXml = null; try { - solrXml = new File(configuration.getClass().getClassLoader().getResource(solrDirectory + "/solr.xml").toURI()); + + URL url = ConfigurationUtils.locate(FileSystem.getDefaultFileSystem(), "", solrDirectory + "/solr.xml"); + + if (url == null) { + try { + url = new URL(solrDirectory + "/solr.xml"); + } catch (MalformedURLException e) { + LOGGER.error("unable to load solr config", e); + } + } + solrXml = new File(url.toURI()); } catch (URISyntaxException e) { LOGGER.error("unable to instanciate SolrCloudBootstrap", e); } @@ -92,17 +107,32 @@ private void build() { } private void loadConfig() throws BootstrapException { - HadoopUtils.setHadoopHome(); + HadoopUtils.INSTANCE.setHadoopHome(); try { configuration = new PropertiesConfiguration(HadoopUnitConfig.DEFAULT_PROPS_FILE); } catch (ConfigurationException e) { throw new BootstrapException("bad config", e); } - solrDirectory = configuration.getString(SOLR_DIR_KEY); - solrCollectionName = configuration.getString(SOLR_COLLECTION_NAME); - solrPort = configuration.getInt(SOLR_PORT); + solrDirectory = configuration.getString(HadoopUnitConfig.SOLR_DIR_KEY); + solrCollectionName = configuration.getString(HadoopUnitConfig.SOLR_COLLECTION_NAME); + solrPort = configuration.getInt(HadoopUnitConfig.SOLR_PORT); zkHostString = configuration.getString(HadoopUnitConfig.ZOOKEEPER_HOST_KEY) + ":" + configuration.getInt(HadoopUnitConfig.ZOOKEEPER_PORT_KEY); + } + @Override + public void loadConfig(Map configs) { + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.SOLR_DIR_KEY))) { + solrDirectory = configs.get(HadoopUnitConfig.SOLR_DIR_KEY); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.SOLR_COLLECTION_NAME))) { + solrCollectionName = configs.get(HadoopUnitConfig.SOLR_COLLECTION_NAME); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.SOLR_PORT))) { + solrPort = Integer.parseInt(configs.get(HadoopUnitConfig.SOLR_PORT)); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.ZOOKEEPER_HOST_KEY)) && StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.ZOOKEEPER_PORT_KEY))) { + zkHostString = configs.get(HadoopUnitConfig.ZOOKEEPER_HOST_KEY) + ":" + configs.get(HadoopUnitConfig.ZOOKEEPER_PORT_KEY); + } } @Override @@ -120,16 +150,6 @@ public Bootstrap start() { LOGGER.error("unable to add SolrCloudServer", e); } -// final ModifiableSolrParams params = new ModifiableSolrParams(); -// params.set(CoreAdminParams.ACTION, CollectionParams.CollectionAction.CREATE.name()); -// params.set(CoreAdminParams.NAME, solrCollectionName); -// params.set("numShards", 1); -// params.set("replicationFactor", 1); -// params.set("collection.configName", solrCollectionName); -// -// final QueryRequest request = new QueryRequest(params); -// request.setPath("/admin/collections"); -// getClient().request(request); try { Thread.sleep(1000); } catch (InterruptedException e) { @@ -146,44 +166,23 @@ private void populateZkWithCollectionInfo() { try { - URI solrDirectoryFile = solrServer.getClass().getClassLoader().getResource(solrDirectory + "/collection1/conf").toURI(); + URL url = ConfigurationUtils.locate(FileSystem.getDefaultFileSystem(), "", solrDirectory + "/collection1/conf"); + + if (url == null) { + try { + url = new URL(solrDirectory + "/collection1/conf"); + } catch (MalformedURLException e) { + LOGGER.error("unable to load solr config", e); + } + } + URI solrDirectoryFile = url.toURI(); + try (SolrZkClient zkClient = new SolrZkClient(zkHostString, TIMEOUT, 45000, null)) { ZkConfigManager manager = new ZkConfigManager(zkClient); manager.uploadConfigDir(Paths.get(solrDirectoryFile), solrCollectionName); } -// CuratorFramework client = CuratorFrameworkFactory.newClient(zkHostString, new RetryOneTime(300)); -// client.start(); -// File schema = new File(solrServer.getClass().getClassLoader().getResource(solrDirectory + "/collection1/conf/schema.xml").toURI()); -// File solrConfig = new File(solrServer.getClass().getClassLoader().getResource(solrDirectory + "/collection1/conf/solrconfig.xml").toURI()); -// File stopwords = new File(solrServer.getClass().getClassLoader().getResource(solrDirectory + "/collection1/conf/stopwords.txt").toURI()); -// File synonyms = new File(solrServer.getClass().getClassLoader().getResource(solrDirectory + "/collection1/conf/synonyms.txt").toURI()); -// File stopwords_en = new File(solrServer.getClass().getClassLoader().getResource(solrDirectory + "/collection1/conf/lang/stopwords_en.txt").toURI()); -// File protwords = new File(solrServer.getClass().getClassLoader().getResource(solrDirectory + "/collection1/conf/protwords.txt").toURI()); -// File currency = new File(solrServer.getClass().getClassLoader().getResource(solrDirectory + "/collection1/conf/currency.xml").toURI()); -// -// byte[] schemaContent = Files.readAllBytes(schema.toPath()); -// byte[] solrConfigContent = Files.readAllBytes(solrConfig.toPath()); -// byte[] stopwordsContent = Files.readAllBytes(stopwords.toPath()); -// byte[] synonymsContent = Files.readAllBytes(synonyms.toPath()); -// byte[] stopwordsEnContent = Files.readAllBytes(stopwords_en.toPath()); -// byte[] protwordsContent = Files.readAllBytes(protwords.toPath()); -// byte[] currencyContent = Files.readAllBytes(currency.toPath()); -// -// client.create().forPath("/configs"); -// client.create().forPath("/configs/collection1"); -// client.create().forPath("/configs/collection1/lang"); -// client.create().forPath("/configs/collection1/solrconfig.xml", solrConfigContent); -// client.create().forPath("/configs/collection1/schema.xml", schemaContent); -// client.create().forPath("/configs/collection1/stopwords.txt", stopwordsContent); -// client.create().forPath("/configs/collection1/synonyms.txt", synonymsContent); -// client.create().forPath("/configs/collection1/lang/stopwords_en.txt", stopwordsEnContent); -// client.create().forPath("/configs/collection1/protwords.txt", protwordsContent); -// client.create().forPath("/configs/collection1/currency.xml", currencyContent); -// -// client.close(); - } catch (URISyntaxException | IOException e) { LOGGER.error("unable to populate zookeeper", e); } @@ -216,5 +215,4 @@ public CloudSolrClient getClient() { return new CloudSolrClient(zkHostString); } - } diff --git a/hadoop-unit-solrcloud/src/main/resources/hadoop-unit-default.properties b/hadoop-unit-solrcloud/src/main/resources/hadoop-unit-default.properties new file mode 100644 index 00000000..ad8559d8 --- /dev/null +++ b/hadoop-unit-solrcloud/src/main/resources/hadoop-unit-default.properties @@ -0,0 +1,106 @@ +#HADOOP_HOME=/opt/hadoop + +# Zookeeper +zookeeper.temp.dir=/tmp/embedded_zk +zookeeper.host=127.0.0.1 +zookeeper.port=22010 + +# Hive +hive.scratch.dir=/tmp/hive_scratch_dir +hive.warehouse.dir=/tmp/warehouse_dir + +# Hive Metastore +hive.metastore.hostname=localhost +hive.metastore.port=20102 +hive.metastore.derby.db.dir=metastore_db + +# Hive Server2 +hive.server2.hostname=localhost +hive.server2.port=20103 + +# Hive Test +hive.test.database.name=default +hive.test.table.name=test_table + + +# HDFS +hdfs.namenode.port=20112 +hdfs.namenode.http.port=50070 +hdfs.temp.dir=/tmp/embedded_hdfs +hdfs.num.datanodes=1 +hdfs.enable.permissions=false +hdfs.format=true +hdfs.enable.running.user.as.proxy.user=true + +# HDFS Test +hdfs.test.file=/tmp/testing +hdfs.test.string=TESTING + + +# HBase +hbase.master.port=25111 +hbase.master.info.port=-1 +hbase.num.region.servers=1 +hbase.root.dir=/tmp/embedded_hbase +hbase.znode.parent=/hbase-unsecure +hbase.wal.replication.enabled=false + +# HBase Test +hbase.test.table.name=hbase_test_table +hbase.test.col.family.name=cf1 +hbase.test.col.qualifier.name=cq1 +hbase.test.num.rows.to.put=50 + +# Kafka +kafka.hostname=127.0.0.1 +kafka.port=20111 + +# Kafka Test +kafka.test.topic=testtopic +kafka.test.message.count=10 +kafka.test.broker.id=1 +kafka.test.temp.dir=embedded_kafka + +#SolR + SolRCloud +solr.dir=solr + +#SolR +solr.collection.internal.name=collection1_shard1_replica1 + +#SolRCloud +solr.collection.name=collection1 +solr.cloud.port=8983 + + +# YARN +yarn.num.node.managers=1 +yarn.num.local.dirs=1 +yarn.num.log.dirs=1 +yarn.resource.manager.address=localhost:37001 +yarn.resource.manager.hostname=localhost +yarn.resource.manager.scheduler.address=localhost:37002 +yarn.resource.manager.resource.tracker.address=localhost:37003 +yarn.resource.manager.webapp.address=localhost:37004 +yarn.use.in.jvm.container.executor=false + +# MR +mr.job.history.address=localhost:37005 + +# Oozie +oozie.test.dir=/tmp/embedded_oozie +oozie.home.dir=/tmp/oozie_home +oozie.username=blah +oozie.groupname=testgroup +oozie.hdfs.share.lib.dir=/tmp/share_lib +oozie.share.lib.create=true +oozie.local.share.lib.cache.dir=/tmp/share_lib_cache +oozie.purge.local.share.lib.cache=false +oozie.sharelib.path=/home/khanh/github +oozie.sharelib.name=oozie-4.2.0.2.3.2.0-2950-distro.tar.gz +oozie.port=20113 +oozie.host=localhost + +# Neo4j +neo4j.ip=127.0.0.1 +neo4j.port=13533 +neo4j.temp.dir=/tmp/embedded_neo4j \ No newline at end of file diff --git a/hadoop-unit-solrcloud/src/test/java/fr/jetoile/hadoopunit/component/SolrCloudBootstrapTest.java b/hadoop-unit-solrcloud/src/test/java/fr/jetoile/hadoopunit/component/SolrCloudBootstrapTest.java index 2f8034c6..e709f6b5 100644 --- a/hadoop-unit-solrcloud/src/test/java/fr/jetoile/hadoopunit/component/SolrCloudBootstrapTest.java +++ b/hadoop-unit-solrcloud/src/test/java/fr/jetoile/hadoopunit/component/SolrCloudBootstrapTest.java @@ -65,7 +65,7 @@ public static void tearDown() throws Exception { @Test public void solrCloudShouldStart() throws IOException, SolrServerException, KeeperException, InterruptedException, NotFoundServiceException { - String collectionName = configuration.getString(SolrCloudBootstrap.SOLR_COLLECTION_NAME); + String collectionName = configuration.getString(HadoopUnitConfig.SOLR_COLLECTION_NAME); // String zkHostString = configuration.getString(Config.ZOOKEEPER_HOST_KEY) + ":" + configuration.getInt(Config.ZOOKEEPER_PORT_KEY); // CloudSolrClient client = new CloudSolrClient(zkHostString); diff --git a/hadoop-unit-standalone/hadoop-unit-standalone-common/pom.xml b/hadoop-unit-standalone/hadoop-unit-standalone-common/pom.xml deleted file mode 100644 index d2c4d1a0..00000000 --- a/hadoop-unit-standalone/hadoop-unit-standalone-common/pom.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - hadoop-unit-standalone - fr.jetoile.hadoop - 1.6-SNAPSHOT - - 4.0.0 - - hadoop-unit-standalone-common - hadoop-unit-standalone-common - - \ No newline at end of file diff --git a/hadoop-unit-standalone/hadoop-unit-standalone-common/src/main/java/fr/jetoile/hadoopunit/HadoopStandaloneBootstrap.java b/hadoop-unit-standalone/hadoop-unit-standalone-common/src/main/java/fr/jetoile/hadoopunit/HadoopStandaloneBootstrap.java deleted file mode 100644 index 3cd82cd4..00000000 --- a/hadoop-unit-standalone/hadoop-unit-standalone-common/src/main/java/fr/jetoile/hadoopunit/HadoopStandaloneBootstrap.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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 fr.jetoile.hadoopunit; - -import fr.jetoile.hadoopunit.exception.BootstrapException; -import org.apache.commons.configuration.Configuration; -import org.apache.commons.configuration.ConfigurationException; -import org.apache.commons.configuration.PropertiesConfiguration; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.stream.Collectors; - -public class HadoopStandaloneBootstrap { - - final private static Logger LOGGER = LoggerFactory.getLogger(HadoopStandaloneBootstrap.class); - static private Configuration configuration; - - - public static void main(String[] args) throws BootstrapException { - try { - configuration = new PropertiesConfiguration("hadoop.properties"); - } catch (ConfigurationException e) { - throw new BootstrapException("bad config", e); - } - - HadoopBootstrap bootstrap = HadoopBootstrap.INSTANCE; - - - bootstrap.componentsToStart = bootstrap.componentsToStart.stream().filter(c -> - configuration.containsKey(c.getName().toLowerCase()) && configuration.getBoolean(c.getName().toLowerCase()) - ).collect(Collectors.toList()); - - bootstrap.componentsToStop = bootstrap.componentsToStop.stream().filter(c -> - configuration.containsKey(c.getName().toLowerCase()) && configuration.getBoolean(c.getName().toLowerCase()) - ).collect(Collectors.toList()); - - Runtime.getRuntime().addShutdownHook(new Thread() { - public void run() { - LOGGER.info("All services are going to be stopped"); - bootstrap.stopAll(); - } - }); - - bootstrap.startAll(); - - - } -} diff --git a/hadoop-unit-standalone/hadoop-unit-standalone-elasticsearch/pom.xml b/hadoop-unit-standalone/hadoop-unit-standalone-elasticsearch/pom.xml deleted file mode 100644 index 49f9cba0..00000000 --- a/hadoop-unit-standalone/hadoop-unit-standalone-elasticsearch/pom.xml +++ /dev/null @@ -1,167 +0,0 @@ - - - - hadoop-unit-standalone - fr.jetoile.hadoop - 1.6-SNAPSHOT - - 4.0.0 - - hadoop-unit-standalone-elasticsearch - hadoop-unit-standalone-elasticsearch - - - - fr.jetoile.hadoop - hadoop-unit-elasticsearch - - - - fr.jetoile.hadoop - hadoop-unit-standalone-common - - - - - - - - - maven-resources-plugin - - - copy-resources - validate - - copy-resources - - - - ${basedir}/target/appassembler-jsw/jsw/hadoop-unit-standalone-elasticsearch/conf - - - - src/main/conf - - - - - - - - - org.codehaus.mojo - appassembler-maven-plugin - - - - hadoop-bootstrap - package - - generate-daemons - - - ${project.build.directory}/appassembler-jsw - - flat - - src/main/conf - true - conf - logs - true - - - - ${project.name} - fr.jetoile.hadoopunit.HadoopStandaloneBootstrap - - - - jsw - - - - jsw - - linux-x86-32 - linux-x86-64 - windows-x86-32 - windows-x86-64 - macosx-universal-64 - - - - - configuration.directory.in.classpath.first - conf - - - - wrapper.logfile.maxsize - 100m - - - - - - - 256M - 2048M - - com.sun.management.jmxremote - com.sun.management.jmxremote.port=8199 - com.sun.management.jmxremote.authenticate=false - - com.sun.management.jmxremote.ssl=false - com.sun.management.jmxremote.local.only=false - - - - -Xdebug - - -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n - - -server - - - -XX:+HeapDumpOnOutOfMemoryError - - - - - - - - - - - - - - - maven-assembly-plugin - - - src/main/assembly/descriptor.xml - - false - - - - - assembly - package - - single - - - - - - - - - \ No newline at end of file diff --git a/hadoop-unit-standalone/hadoop-unit-standalone-elasticsearch/src/main/assembly/descriptor.xml b/hadoop-unit-standalone/hadoop-unit-standalone-elasticsearch/src/main/assembly/descriptor.xml deleted file mode 100644 index 1b8759e4..00000000 --- a/hadoop-unit-standalone/hadoop-unit-standalone-elasticsearch/src/main/assembly/descriptor.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - hadoop-bootstrap - - - tar.gz - - - - - - ${project.build.directory}/appassembler-jsw/jsw/${project.name} - / - - bin/${project.name} - bin/wrapper-linux-x86-32 - bin/wrapper-linux-x86-64 - - 640 - 750 - - - - - - - ${project.build.directory}/appassembler-jsw/jsw/${project.name}/bin/${project.name} - bin - 750 - - - ${project.build.directory}/appassembler-jsw/jsw/${project.name}/bin/wrapper-linux-x86-64 - - bin - 750 - - - - \ No newline at end of file diff --git a/hadoop-unit-standalone/hadoop-unit-standalone-elasticsearch/src/main/conf/hadoop.properties b/hadoop-unit-standalone/hadoop-unit-standalone-elasticsearch/src/main/conf/hadoop.properties deleted file mode 100755 index 3de0508e..00000000 --- a/hadoop-unit-standalone/hadoop-unit-standalone-elasticsearch/src/main/conf/hadoop.properties +++ /dev/null @@ -1,11 +0,0 @@ -zookeeper=true -hdfs=true -hivemeta=true -hiveserver2=true -kafka=true -hbase=true -#oozie=true -mongodb=true -cassandra=true -elasticsearch=true - diff --git a/hadoop-unit-standalone/hadoop-unit-standalone-elasticsearch/src/test/java/fr/jetoile/hadoopunit/integrationtest/ManualIntegrationBootstrapTest.java b/hadoop-unit-standalone/hadoop-unit-standalone-elasticsearch/src/test/java/fr/jetoile/hadoopunit/integrationtest/ManualIntegrationBootstrapTest.java deleted file mode 100644 index e945b54f..00000000 --- a/hadoop-unit-standalone/hadoop-unit-standalone-elasticsearch/src/test/java/fr/jetoile/hadoopunit/integrationtest/ManualIntegrationBootstrapTest.java +++ /dev/null @@ -1,407 +0,0 @@ -/* - * 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 fr.jetoile.hadoopunit.integrationtest; - - -import com.datastax.driver.core.Cluster; -import com.datastax.driver.core.Session; -import com.mongodb.*; -import fr.jetoile.hadoopunit.HadoopUnitConfig; -import fr.jetoile.hadoopunit.component.OozieBootstrap; -import fr.jetoile.hadoopunit.exception.BootstrapException; -import fr.jetoile.hadoopunit.exception.NotFoundServiceException; -import fr.jetoile.hadoopunit.test.hdfs.HdfsUtils; -import fr.jetoile.hadoopunit.test.kafka.KafkaConsumerUtils; -import fr.jetoile.hadoopunit.test.kafka.KafkaProducerUtils; -import org.apache.commons.configuration.Configuration; -import org.apache.commons.configuration.ConfigurationException; -import org.apache.commons.configuration.PropertiesConfiguration; -import org.apache.hadoop.fs.FSDataInputStream; -import org.apache.hadoop.fs.FSDataOutputStream; -import org.apache.hadoop.fs.FileSystem; -import org.apache.hadoop.fs.Path; -import org.apache.hadoop.hbase.HBaseConfiguration; -import org.apache.hadoop.hbase.HColumnDescriptor; -import org.apache.hadoop.hbase.HTableDescriptor; -import org.apache.hadoop.hbase.TableName; -import org.apache.hadoop.hbase.client.*; -import org.apache.hadoop.hbase.util.Bytes; -import org.apache.hadoop.security.UserGroupInformation; -import org.apache.oozie.client.OozieClient; -import org.apache.oozie.client.WorkflowJob; -import org.codehaus.jackson.map.ObjectMapper; -import org.codehaus.jettison.json.JSONException; -import org.codehaus.jettison.json.JSONObject; -import org.elasticsearch.action.get.GetResponse; -import org.elasticsearch.action.index.IndexResponse; -import org.elasticsearch.client.Client; -import org.elasticsearch.client.transport.TransportClient; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.transport.InetSocketTransportAddress; -import org.junit.*; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.*; -import java.net.*; -import java.sql.Connection; -import java.sql.*; -import java.util.List; -import java.util.Properties; - -import static junit.framework.TestCase.assertNotNull; -import static org.fest.assertions.Assertions.assertThat; -import static org.junit.Assert.assertEquals; - -@Ignore -public class ManualIntegrationBootstrapTest { - - static private Configuration configuration; - - static private Logger LOGGER = LoggerFactory.getLogger(ManualIntegrationBootstrapTest.class); - - - @BeforeClass - public static void setup() throws BootstrapException { - try { - configuration = new PropertiesConfiguration(HadoopUnitConfig.DEFAULT_PROPS_FILE); - } catch (ConfigurationException e) { - throw new BootstrapException("bad config", e); - } - } - - - @AfterClass - public static void tearDown() throws BootstrapException { - } - - @Test - public void kafkaShouldStart() throws Exception { - - // Producer - for (int i = 0; i < 10; i++) { - String payload = generateMessage(i); - KafkaProducerUtils.INSTANCE.produceMessages(configuration.getString(HadoopUnitConfig.KAFKA_TEST_TOPIC_KEY), String.valueOf(i), payload); - } - - - - // Consumer - KafkaConsumerUtils.INSTANCE.consumeMessagesWithNewApi(configuration.getString(HadoopUnitConfig.KAFKA_TEST_TOPIC_KEY), 10); - - // Assert num of messages produced = num of message consumed - Assert.assertEquals(configuration.getLong(HadoopUnitConfig.KAFKA_TEST_MESSAGE_COUNT_KEY), KafkaConsumerUtils.INSTANCE.getNumRead()); - } - - private String generateMessage(int i) { - JSONObject obj = new JSONObject(); - try { - obj.put("id", String.valueOf(i)); - obj.put("msg", "test-message" + 1); - } catch (JSONException e) { - e.printStackTrace(); - } - return obj.toString(); - } - - @Test - public void hiveServer2ShouldStart() throws InterruptedException, ClassNotFoundException, SQLException { - -// assertThat(Utils.available("127.0.0.1", 20103)).isFalse(); - - // Load the Hive JDBC driver - LOGGER.info("HIVE: Loading the Hive JDBC Driver"); - Class.forName("org.apache.hive.jdbc.HiveDriver"); - - // - // Create an ORC table and describe it - // - // Get the connection - Connection con = DriverManager.getConnection("jdbc:hive2://" + - configuration.getString(HadoopUnitConfig.HIVE_SERVER2_HOSTNAME_KEY) + ":" + - configuration.getInt(HadoopUnitConfig.HIVE_SERVER2_PORT_KEY) + "/" + - configuration.getString(HadoopUnitConfig.HIVE_TEST_DATABASE_NAME_KEY), - "user", - "pass"); - - // Create the DB - Statement stmt; - try { - String createDbDdl = "CREATE DATABASE IF NOT EXISTS " + - configuration.getString(HadoopUnitConfig.HIVE_TEST_DATABASE_NAME_KEY); - stmt = con.createStatement(); - LOGGER.info("HIVE: Running Create Database Statement: {}", createDbDdl); - stmt.execute(createDbDdl); - } catch (Exception e) { - e.printStackTrace(); - } - - // Drop the table incase it still exists - String dropDdl = "DROP TABLE " + configuration.getString(HadoopUnitConfig.HIVE_TEST_DATABASE_NAME_KEY) + "." + - configuration.getString(HadoopUnitConfig.HIVE_TEST_TABLE_NAME_KEY); - stmt = con.createStatement(); - LOGGER.info("HIVE: Running Drop Table Statement: {}", dropDdl); - stmt.execute(dropDdl); - - // Create the ORC table - String createDdl = "CREATE TABLE IF NOT EXISTS " + - configuration.getString(HadoopUnitConfig.HIVE_TEST_DATABASE_NAME_KEY) + "." + - configuration.getString(HadoopUnitConfig.HIVE_TEST_TABLE_NAME_KEY) + " (id INT, msg STRING) " + - "PARTITIONED BY (dt STRING) " + - "CLUSTERED BY (id) INTO 16 BUCKETS " + - "STORED AS ORC tblproperties(\"orc.compress\"=\"NONE\")"; - stmt = con.createStatement(); - LOGGER.info("HIVE: Running Create Table Statement: {}", createDdl); - stmt.execute(createDdl); - - // Issue a describe on the new table and display the output - LOGGER.info("HIVE: Validating Table was Created: "); - ResultSet resultSet = stmt.executeQuery("DESCRIBE FORMATTED " + - configuration.getString(HadoopUnitConfig.HIVE_TEST_TABLE_NAME_KEY)); - int count = 0; - while (resultSet.next()) { - ResultSetMetaData resultSetMetaData = resultSet.getMetaData(); - for (int i = 1; i <= resultSetMetaData.getColumnCount(); i++) { - System.out.print(resultSet.getString(i)); - } - System.out.println(); - count++; - } - assertEquals(33, count); - - // Drop the table - dropDdl = "DROP TABLE " + configuration.getString(HadoopUnitConfig.HIVE_TEST_DATABASE_NAME_KEY) + "." + - configuration.getString(HadoopUnitConfig.HIVE_TEST_TABLE_NAME_KEY); - stmt = con.createStatement(); - LOGGER.info("HIVE: Running Drop Table Statement: {}", dropDdl); - stmt.execute(dropDdl); - } - - - - @Test - public void hdfsShouldStart() throws Exception { - -// assertThat(Utils.available("127.0.0.1", configuration.getInt(Config.HDFS_NAMENODE_HTTP_PORT_KEY))).isFalse(); -// -// org.apache.hadoop.conf.Configuration conf = new org.apache.hadoop.conf.Configuration(); -// conf.set("fs.default.name", "hdfs://127.0.0.1:" + configuration.getInt(Config.HDFS_NAMENODE_PORT_KEY)); -// -// URI uri = URI.create ("hdfs://127.0.0.1:" + configuration.getInt(Config.HDFS_NAMENODE_PORT_KEY)); -// -// FileSystem hdfsFsHandle = FileSystem.get (uri, conf); - FileSystem hdfsFsHandle = HdfsUtils.INSTANCE.getFileSystem(); - - - FSDataOutputStream writer = hdfsFsHandle.create(new Path(configuration.getString(HadoopUnitConfig.HDFS_TEST_FILE_KEY))); - writer.writeUTF(configuration.getString(HadoopUnitConfig.HDFS_TEST_STRING_KEY)); - writer.close(); - - // Read the file and compare to test string - FSDataInputStream reader = hdfsFsHandle.open(new Path(configuration.getString(HadoopUnitConfig.HDFS_TEST_FILE_KEY))); - assertEquals(reader.readUTF(), configuration.getString(HadoopUnitConfig.HDFS_TEST_STRING_KEY)); - reader.close(); - hdfsFsHandle.close(); - - URL url = new URL( - String.format( "http://localhost:%s/webhdfs/v1?op=GETHOMEDIRECTORY&user.name=guest", - configuration.getInt( HadoopUnitConfig.HDFS_NAMENODE_HTTP_PORT_KEY ) ) ); - URLConnection connection = url.openConnection(); - connection.setRequestProperty( "Accept-Charset", "UTF-8" ); - BufferedReader response = new BufferedReader( new InputStreamReader( connection.getInputStream() ) ); - String line = response.readLine(); - response.close(); - assertThat("{\"Path\":\"/user/guest\"}").isEqualTo(line); - - } - - @Test - public void hBaseShouldStart() throws Exception { - - String tableName = configuration.getString(HadoopUnitConfig.HBASE_TEST_TABLE_NAME_KEY); - String colFamName = configuration.getString(HadoopUnitConfig.HBASE_TEST_COL_FAMILY_NAME_KEY); - String colQualiferName = configuration.getString(HadoopUnitConfig.HBASE_TEST_COL_QUALIFIER_NAME_KEY); - Integer numRowsToPut = configuration.getInt(HadoopUnitConfig.HBASE_TEST_NUM_ROWS_TO_PUT_KEY); - - org.apache.hadoop.conf.Configuration hbaseConfiguration = HBaseConfiguration.create(); - hbaseConfiguration.set("hbase.zookeeper.quorum", configuration.getString(HadoopUnitConfig.ZOOKEEPER_HOST_KEY)); - hbaseConfiguration.setInt("hbase.zookeeper.property.clientPort", configuration.getInt(HadoopUnitConfig.ZOOKEEPER_PORT_KEY)); - hbaseConfiguration.set("hbase.master", "127.0.0.1:" + configuration.getInt(HadoopUnitConfig.HBASE_MASTER_PORT_KEY)); - hbaseConfiguration.set("zookeeper.znode.parent", configuration.getString(HadoopUnitConfig.HBASE_ZNODE_PARENT_KEY)); - - - LOGGER.info("HBASE: Creating table {} with column family {}", tableName, colFamName); - createHbaseTable(tableName, colFamName, hbaseConfiguration); - - LOGGER.info("HBASE: Populate the table with {} rows.", numRowsToPut); - for (int i = 0; i < numRowsToPut; i++) { - putRow(tableName, colFamName, String.valueOf(i), colQualiferName, "row_" + i, hbaseConfiguration); - } - - LOGGER.info("HBASE: Fetching and comparing the results"); - for (int i = 0; i < numRowsToPut; i++) { - Result result = getRow(tableName, colFamName, String.valueOf(i), colQualiferName, hbaseConfiguration); - assertEquals("row_" + i, new String(result.value())); - } - - } - - - @Test - public void oozieShouldStart() throws Exception { - - LOGGER.info("OOZIE: Test Submit Workflow Start"); - - org.apache.hadoop.conf.Configuration conf = new org.apache.hadoop.conf.Configuration(); - conf.set("fs.default.name", "hdfs://127.0.0.1:" + configuration.getInt(HadoopUnitConfig.HDFS_NAMENODE_PORT_KEY)); - - URI uri = URI.create ("hdfs://127.0.0.1:" + configuration.getInt(HadoopUnitConfig.HDFS_NAMENODE_PORT_KEY)); - - FileSystem hdfsFs = FileSystem.get (uri, conf); - - OozieClient oozieClient = new OozieClient("http://" + configuration.getString(OozieBootstrap.OOZIE_HOST) + ":" + configuration.getInt(OozieBootstrap.OOZIE_PORT) + "/oozie"); - - Path appPath = new Path(hdfsFs.getHomeDirectory(), "testApp"); - hdfsFs.mkdirs(new Path(appPath, "lib")); - Path workflow = new Path(appPath, "workflow.xml"); - - //write workflow.xml - String wfApp = "" + - " " + - " " + - ""; - - Writer writer = new OutputStreamWriter(hdfsFs.create(workflow)); - writer.write(wfApp); - writer.close(); - - //write job.properties - Properties oozieConf = oozieClient.createConfiguration(); - oozieConf.setProperty(OozieClient.APP_PATH, workflow.toString()); - oozieConf.setProperty(OozieClient.USER_NAME, UserGroupInformation.getCurrentUser().getUserName()); - - //submit and check - final String jobId = oozieClient.submit(oozieConf); - WorkflowJob wf = oozieClient.getJobInfo(jobId); - Assert.assertNotNull(wf); - assertEquals(WorkflowJob.Status.PREP, wf.getStatus()); - - LOGGER.info("OOZIE: Workflow: {}", wf.toString()); - hdfsFs.close(); - - } - - private static void createHbaseTable(String tableName, String colFamily, - org.apache.hadoop.conf.Configuration configuration) throws Exception { - - final HBaseAdmin admin = new HBaseAdmin(configuration); - HTableDescriptor hTableDescriptor = new HTableDescriptor(TableName.valueOf(tableName)); - HColumnDescriptor hColumnDescriptor = new HColumnDescriptor(colFamily); - - hTableDescriptor.addFamily(hColumnDescriptor); - admin.createTable(hTableDescriptor); - } - - private static void putRow(String tableName, String colFamName, String rowKey, String colQualifier, String value, - org.apache.hadoop.conf.Configuration configuration) throws Exception { - HTable table = new HTable(configuration, tableName); - Put put = new Put(Bytes.toBytes(rowKey)); - put.add(Bytes.toBytes(colFamName), Bytes.toBytes(colQualifier), Bytes.toBytes(value)); - table.put(put); - table.flushCommits(); - table.close(); - } - - private static Result getRow(String tableName, String colFamName, String rowKey, String colQualifier, - org.apache.hadoop.conf.Configuration configuration) throws Exception { - Result result; - HTable table = new HTable(configuration, tableName); - Get get = new Get(Bytes.toBytes(rowKey)); - get.addColumn(Bytes.toBytes(colFamName), Bytes.toBytes(colQualifier)); - get.setMaxVersions(1); - result = table.get(get); - return result; - } - - - @Test - public void mongodbShouldStart() throws UnknownHostException { - MongoClient mongo = new MongoClient(configuration.getString(HadoopUnitConfig.MONGO_IP_KEY), configuration.getInt(HadoopUnitConfig.MONGO_PORT_KEY)); - - DB db = mongo.getDB(configuration.getString(HadoopUnitConfig.MONGO_DATABASE_NAME_KEY)); - DBCollection col = db.createCollection(configuration.getString(HadoopUnitConfig.MONGO_COLLECTION_NAME_KEY), - new BasicDBObject()); - - col.save(new BasicDBObject("testDoc", new java.util.Date())); - LOGGER.info("MONGODB: Number of items in collection: {}", col.count()); - assertEquals(1, col.count()); - - DBCursor cursor = col.find(); - while(cursor.hasNext()) { - LOGGER.info("MONGODB: Document output: {}", cursor.next()); - } - cursor.close(); - } - - @Test - public void cassandraShouldStart() throws NotFoundServiceException { - Cluster cluster = Cluster.builder() - .addContactPoints(configuration.getString(HadoopUnitConfig.CASSANDRA_IP_KEY)).withPort(configuration.getInt(HadoopUnitConfig.CASSANDRA_PORT_KEY)).build(); - Session session = cluster.connect(); - - session.execute("create KEYSPACE test WITH replication = {'class': 'SimpleStrategy' , 'replication_factor': '1' }"); - session.execute("CREATE TABLE test.test (user text, value text, PRIMARY KEY (user))"); - session.execute("insert into test.test(user, value) values('user1', 'value1')"); - session.execute("insert into test.test(user, value) values('user2', 'value2')"); - - com.datastax.driver.core.ResultSet execute = session.execute("select * from test.test"); - - List res = execute.all(); - assertEquals(res.size(), 2); - assertEquals(res.get(0).getString("user"), "user2"); - assertEquals(res.get(0).getString("value"), "value2"); - assertEquals(res.get(1).getString("user"), "user1"); - - } - - @Test - public void elasticSearchShouldStartWithRealDriver() throws NotFoundServiceException, IOException { - - Settings settings = Settings.builder() - .put("cluster.name", configuration.getString(HadoopUnitConfig.ELASTICSEARCH_CLUSTER_NAME)) - .build(); - Client client = TransportClient.builder().settings(settings).build() - .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(configuration.getString(HadoopUnitConfig.ELASTICSEARCH_IP_KEY)), configuration.getInt(HadoopUnitConfig.ELASTICSEARCH_TCP_PORT_KEY))); - - ObjectMapper mapper = new ObjectMapper(); - - Sample sample = new Sample("value2", 0.33, 3); - - String jsonString = mapper.writeValueAsString(sample); - - // indexing document - IndexResponse ir = client.prepareIndex("test_index", "type").setSource(jsonString).setId("2").execute().actionGet(); - client.admin().indices().prepareRefresh("test_index").execute().actionGet(); - - Assert.assertNotNull(ir); - - GetResponse gr = client.prepareGet("test_index", "type", "2").execute().actionGet(); - - Assert.assertNotNull(gr); - assertEquals(gr.getSourceAsString(), "{\"value\":\"value2\",\"size\":0.33,\"price\":3.0}"); - - } - -} diff --git a/hadoop-unit-standalone/hadoop-unit-standalone-solr/pom.xml b/hadoop-unit-standalone/hadoop-unit-standalone-solr/pom.xml deleted file mode 100644 index e78637fa..00000000 --- a/hadoop-unit-standalone/hadoop-unit-standalone-solr/pom.xml +++ /dev/null @@ -1,147 +0,0 @@ - - - - hadoop-unit-standalone - fr.jetoile.hadoop - 1.6-SNAPSHOT - - 4.0.0 - - hadoop-unit-standalone-solr - hadoop-unit-standalone-solr - - - - - fr.jetoile.hadoop - hadoop-unit-solr - - - - fr.jetoile.hadoop - hadoop-unit-solrcloud - - - - fr.jetoile.hadoop - hadoop-unit-standalone-common - - - - - - - - - org.codehaus.mojo - appassembler-maven-plugin - - - - hadoop-bootstrap - package - - generate-daemons - - - ${project.build.directory}/appassembler-jsw - - flat - - src/main/conf - true - conf - logs - true - - - - ${project.name} - fr.jetoile.hadoopunit.HadoopStandaloneBootstrap - - - - jsw - - - - jsw - - linux-x86-32 - linux-x86-64 - windows-x86-32 - windows-x86-64 - macosx-universal-64 - - - - - configuration.directory.in.classpath.first - conf - - - - wrapper.logfile.maxsize - 100m - - - - - - - 256M - 2048M - - com.sun.management.jmxremote - com.sun.management.jmxremote.port=8199 - com.sun.management.jmxremote.authenticate=false - - com.sun.management.jmxremote.ssl=false - com.sun.management.jmxremote.local.only=false - - - - -Xdebug - - -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n - - -server - -XX:+HeapDumpOnOutOfMemoryError - - - - - - - - - - - - - - - maven-assembly-plugin - - - src/main/assembly/descriptor.xml - - false - - - - - assembly - package - - single - - - - - - - - \ No newline at end of file diff --git a/hadoop-unit-standalone/hadoop-unit-standalone-solr/src/main/conf/hadoop.properties b/hadoop-unit-standalone/hadoop-unit-standalone-solr/src/main/conf/hadoop.properties deleted file mode 100755 index fc552931..00000000 --- a/hadoop-unit-standalone/hadoop-unit-standalone-solr/src/main/conf/hadoop.properties +++ /dev/null @@ -1,12 +0,0 @@ -zookeeper=true -hdfs=true -hivemeta=true -hiveserver2=true -kafka=true -hbase=true -solrcloud=true -#solr=true -#oozie=true -mongodb=true -cassandra=true - diff --git a/hadoop-unit-standalone/hadoop-unit-standalone-solr/src/test/java/fr/jetoile/hadoopunit/integrationtest/ManualIntegrationBootstrapTest.java b/hadoop-unit-standalone/hadoop-unit-standalone-solr/src/test/java/fr/jetoile/hadoopunit/integrationtest/ManualIntegrationBootstrapTest.java deleted file mode 100644 index 5ee3d145..00000000 --- a/hadoop-unit-standalone/hadoop-unit-standalone-solr/src/test/java/fr/jetoile/hadoopunit/integrationtest/ManualIntegrationBootstrapTest.java +++ /dev/null @@ -1,407 +0,0 @@ -/* - * 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 fr.jetoile.hadoopunit.integrationtest; - - -import com.datastax.driver.core.Cluster; -import com.datastax.driver.core.Session; -import com.mongodb.*; -import fr.jetoile.hadoopunit.HadoopUnitConfig; -import fr.jetoile.hadoopunit.component.OozieBootstrap; -import fr.jetoile.hadoopunit.component.SolrCloudBootstrap; -import fr.jetoile.hadoopunit.exception.BootstrapException; -import fr.jetoile.hadoopunit.exception.NotFoundServiceException; -import fr.jetoile.hadoopunit.test.hdfs.HdfsUtils; -import fr.jetoile.hadoopunit.test.kafka.KafkaConsumerUtils; -import fr.jetoile.hadoopunit.test.kafka.KafkaProducerUtils; -import org.apache.commons.configuration.Configuration; -import org.apache.commons.configuration.ConfigurationException; -import org.apache.commons.configuration.PropertiesConfiguration; -import org.apache.hadoop.fs.FSDataInputStream; -import org.apache.hadoop.fs.FSDataOutputStream; -import org.apache.hadoop.fs.FileSystem; -import org.apache.hadoop.fs.Path; -import org.apache.hadoop.hbase.HBaseConfiguration; -import org.apache.hadoop.hbase.HColumnDescriptor; -import org.apache.hadoop.hbase.HTableDescriptor; -import org.apache.hadoop.hbase.TableName; -import org.apache.hadoop.hbase.client.*; -import org.apache.hadoop.hbase.util.Bytes; -import org.apache.hadoop.security.UserGroupInformation; -import org.apache.oozie.client.OozieClient; -import org.apache.oozie.client.WorkflowJob; -import org.apache.solr.client.solrj.SolrServerException; -import org.apache.solr.client.solrj.impl.CloudSolrClient; -import org.apache.solr.common.SolrDocument; -import org.apache.solr.common.SolrInputDocument; -import org.apache.zookeeper.KeeperException; -import org.codehaus.jettison.json.JSONException; -import org.codehaus.jettison.json.JSONObject; -import org.junit.*; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.*; -import java.net.URI; -import java.net.URL; -import java.net.URLConnection; -import java.net.UnknownHostException; -import java.sql.Connection; -import java.sql.*; -import java.util.List; -import java.util.Properties; - -import static junit.framework.TestCase.assertNotNull; -import static org.fest.assertions.Assertions.assertThat; -import static org.junit.Assert.assertEquals; - -@Ignore -public class ManualIntegrationBootstrapTest { - - static private Configuration configuration; - - static private Logger LOGGER = LoggerFactory.getLogger(ManualIntegrationBootstrapTest.class); - - - @BeforeClass - public static void setup() throws BootstrapException { - try { - configuration = new PropertiesConfiguration(HadoopUnitConfig.DEFAULT_PROPS_FILE); - } catch (ConfigurationException e) { - throw new BootstrapException("bad config", e); - } - } - - - @AfterClass - public static void tearDown() throws BootstrapException { - } - - @Test - public void solrCloudShouldStart() throws IOException, SolrServerException, KeeperException, InterruptedException { - - String collectionName = configuration.getString(SolrCloudBootstrap.SOLR_COLLECTION_NAME); - - String zkHostString = configuration.getString(HadoopUnitConfig.ZOOKEEPER_HOST_KEY) + ":" + configuration.getInt(HadoopUnitConfig.ZOOKEEPER_PORT_KEY); - CloudSolrClient client = new CloudSolrClient(zkHostString); - - for (int i = 0; i < 1000; ++i) { - SolrInputDocument doc = new SolrInputDocument(); - doc.addField("cat", "book"); - doc.addField("id", "book-" + i); - doc.addField("name", "The Legend of the Hobbit part " + i); - client.add(collectionName, doc); - if (i % 100 == 0) client.commit(collectionName); // periodically flush - } - client.commit("collection1"); - - SolrDocument collection1 = client.getById(collectionName, "book-1"); - - assertNotNull(collection1); - - assertThat(collection1.getFieldValue("name")).isEqualTo("The Legend of the Hobbit part 1"); - - - client.close(); - } - - @Test - public void kafkaShouldStart() throws Exception { - - // Producer - for (int i = 0; i < 10; i++) { - String payload = generateMessage(i); - KafkaProducerUtils.INSTANCE.produceMessages(configuration.getString(HadoopUnitConfig.KAFKA_TEST_TOPIC_KEY), String.valueOf(i), payload); - } - - - // Consumer - KafkaConsumerUtils.INSTANCE.consumeMessagesWithNewApi(configuration.getString(HadoopUnitConfig.KAFKA_TEST_TOPIC_KEY), 10); - - // Assert num of messages produced = num of message consumed - Assert.assertEquals(configuration.getLong(HadoopUnitConfig.KAFKA_TEST_MESSAGE_COUNT_KEY), KafkaConsumerUtils.INSTANCE.getNumRead()); - } - - private String generateMessage(int i) { - JSONObject obj = new JSONObject(); - try { - obj.put("id", String.valueOf(i)); - obj.put("msg", "test-message" + 1); - } catch (JSONException e) { - e.printStackTrace(); - } - return obj.toString(); - } - - @Test - public void hiveServer2ShouldStart() throws InterruptedException, ClassNotFoundException, SQLException { - -// assertThat(Utils.available("127.0.0.1", 20103)).isFalse(); - - // Load the Hive JDBC driver - LOGGER.info("HIVE: Loading the Hive JDBC Driver"); - Class.forName("org.apache.hive.jdbc.HiveDriver"); - - // - // Create an ORC table and describe it - // - // Get the connection - Connection con = DriverManager.getConnection("jdbc:hive2://" + - configuration.getString(HadoopUnitConfig.HIVE_SERVER2_HOSTNAME_KEY) + ":" + - configuration.getInt(HadoopUnitConfig.HIVE_SERVER2_PORT_KEY) + "/" + - configuration.getString(HadoopUnitConfig.HIVE_TEST_DATABASE_NAME_KEY), - "user", - "pass"); - - // Create the DB - Statement stmt; - try { - String createDbDdl = "CREATE DATABASE IF NOT EXISTS " + - configuration.getString(HadoopUnitConfig.HIVE_TEST_DATABASE_NAME_KEY); - stmt = con.createStatement(); - LOGGER.info("HIVE: Running Create Database Statement: {}", createDbDdl); - stmt.execute(createDbDdl); - } catch (Exception e) { - e.printStackTrace(); - } - - // Drop the table incase it still exists - String dropDdl = "DROP TABLE " + configuration.getString(HadoopUnitConfig.HIVE_TEST_DATABASE_NAME_KEY) + "." + - configuration.getString(HadoopUnitConfig.HIVE_TEST_TABLE_NAME_KEY); - stmt = con.createStatement(); - LOGGER.info("HIVE: Running Drop Table Statement: {}", dropDdl); - stmt.execute(dropDdl); - - // Create the ORC table - String createDdl = "CREATE TABLE IF NOT EXISTS " + - configuration.getString(HadoopUnitConfig.HIVE_TEST_DATABASE_NAME_KEY) + "." + - configuration.getString(HadoopUnitConfig.HIVE_TEST_TABLE_NAME_KEY) + " (id INT, msg STRING) " + - "PARTITIONED BY (dt STRING) " + - "CLUSTERED BY (id) INTO 16 BUCKETS " + - "STORED AS ORC tblproperties(\"orc.compress\"=\"NONE\")"; - stmt = con.createStatement(); - LOGGER.info("HIVE: Running Create Table Statement: {}", createDdl); - stmt.execute(createDdl); - - // Issue a describe on the new table and display the output - LOGGER.info("HIVE: Validating Table was Created: "); - ResultSet resultSet = stmt.executeQuery("DESCRIBE FORMATTED " + - configuration.getString(HadoopUnitConfig.HIVE_TEST_TABLE_NAME_KEY)); - int count = 0; - while (resultSet.next()) { - ResultSetMetaData resultSetMetaData = resultSet.getMetaData(); - for (int i = 1; i <= resultSetMetaData.getColumnCount(); i++) { - System.out.print(resultSet.getString(i)); - } - System.out.println(); - count++; - } - assertEquals(33, count); - - // Drop the table - dropDdl = "DROP TABLE " + configuration.getString(HadoopUnitConfig.HIVE_TEST_DATABASE_NAME_KEY) + "." + - configuration.getString(HadoopUnitConfig.HIVE_TEST_TABLE_NAME_KEY); - stmt = con.createStatement(); - LOGGER.info("HIVE: Running Drop Table Statement: {}", dropDdl); - stmt.execute(dropDdl); - } - - - @Test - public void hdfsShouldStart() throws Exception { - -// assertThat(Utils.available("127.0.0.1", configuration.getInt(Config.HDFS_NAMENODE_HTTP_PORT_KEY))).isFalse(); -// -// org.apache.hadoop.conf.Configuration conf = new org.apache.hadoop.conf.Configuration(); -// conf.set("fs.default.name", "hdfs://127.0.0.1:" + configuration.getInt(Config.HDFS_NAMENODE_PORT_KEY)); -// -// URI uri = URI.create ("hdfs://127.0.0.1:" + configuration.getInt(Config.HDFS_NAMENODE_PORT_KEY)); -// -// FileSystem hdfsFsHandle = FileSystem.get (uri, conf); - FileSystem hdfsFsHandle = HdfsUtils.INSTANCE.getFileSystem(); - - - FSDataOutputStream writer = hdfsFsHandle.create(new Path(configuration.getString(HadoopUnitConfig.HDFS_TEST_FILE_KEY))); - writer.writeUTF(configuration.getString(HadoopUnitConfig.HDFS_TEST_STRING_KEY)); - writer.close(); - - // Read the file and compare to test string - FSDataInputStream reader = hdfsFsHandle.open(new Path(configuration.getString(HadoopUnitConfig.HDFS_TEST_FILE_KEY))); - assertEquals(reader.readUTF(), configuration.getString(HadoopUnitConfig.HDFS_TEST_STRING_KEY)); - reader.close(); - hdfsFsHandle.close(); - - URL url = new URL( - String.format("http://localhost:%s/webhdfs/v1?op=GETHOMEDIRECTORY&user.name=guest", - configuration.getInt(HadoopUnitConfig.HDFS_NAMENODE_HTTP_PORT_KEY))); - URLConnection connection = url.openConnection(); - connection.setRequestProperty("Accept-Charset", "UTF-8"); - BufferedReader response = new BufferedReader(new InputStreamReader(connection.getInputStream())); - String line = response.readLine(); - response.close(); - assertThat("{\"Path\":\"/user/guest\"}").isEqualTo(line); - - } - - @Test - public void hBaseShouldStart() throws Exception { - - String tableName = configuration.getString(HadoopUnitConfig.HBASE_TEST_TABLE_NAME_KEY); - String colFamName = configuration.getString(HadoopUnitConfig.HBASE_TEST_COL_FAMILY_NAME_KEY); - String colQualiferName = configuration.getString(HadoopUnitConfig.HBASE_TEST_COL_QUALIFIER_NAME_KEY); - Integer numRowsToPut = configuration.getInt(HadoopUnitConfig.HBASE_TEST_NUM_ROWS_TO_PUT_KEY); - - org.apache.hadoop.conf.Configuration hbaseConfiguration = HBaseConfiguration.create(); - hbaseConfiguration.set("hbase.zookeeper.quorum", configuration.getString(HadoopUnitConfig.ZOOKEEPER_HOST_KEY)); - hbaseConfiguration.setInt("hbase.zookeeper.property.clientPort", configuration.getInt(HadoopUnitConfig.ZOOKEEPER_PORT_KEY)); - hbaseConfiguration.set("hbase.master", "127.0.0.1:" + configuration.getInt(HadoopUnitConfig.HBASE_MASTER_PORT_KEY)); - hbaseConfiguration.set("zookeeper.znode.parent", configuration.getString(HadoopUnitConfig.HBASE_ZNODE_PARENT_KEY)); - - - LOGGER.info("HBASE: Creating table {} with column family {}", tableName, colFamName); - createHbaseTable(tableName, colFamName, hbaseConfiguration); - - LOGGER.info("HBASE: Populate the table with {} rows.", numRowsToPut); - for (int i = 0; i < numRowsToPut; i++) { - putRow(tableName, colFamName, String.valueOf(i), colQualiferName, "row_" + i, hbaseConfiguration); - } - - LOGGER.info("HBASE: Fetching and comparing the results"); - for (int i = 0; i < numRowsToPut; i++) { - Result result = getRow(tableName, colFamName, String.valueOf(i), colQualiferName, hbaseConfiguration); - assertEquals("row_" + i, new String(result.value())); - } - - } - - - @Test - public void oozieShouldStart() throws Exception { - - LOGGER.info("OOZIE: Test Submit Workflow Start"); - - org.apache.hadoop.conf.Configuration conf = new org.apache.hadoop.conf.Configuration(); - conf.set("fs.default.name", "hdfs://127.0.0.1:" + configuration.getInt(HadoopUnitConfig.HDFS_NAMENODE_PORT_KEY)); - - URI uri = URI.create("hdfs://127.0.0.1:" + configuration.getInt(HadoopUnitConfig.HDFS_NAMENODE_PORT_KEY)); - - FileSystem hdfsFs = FileSystem.get(uri, conf); - - OozieClient oozieClient = new OozieClient("http://" + configuration.getString(OozieBootstrap.OOZIE_HOST) + ":" + configuration.getInt(OozieBootstrap.OOZIE_PORT) + "/oozie"); - - Path appPath = new Path(hdfsFs.getHomeDirectory(), "testApp"); - hdfsFs.mkdirs(new Path(appPath, "lib")); - Path workflow = new Path(appPath, "workflow.xml"); - - //write workflow.xml - String wfApp = "" + - " " + - " " + - ""; - - Writer writer = new OutputStreamWriter(hdfsFs.create(workflow)); - writer.write(wfApp); - writer.close(); - - //write job.properties - Properties oozieConf = oozieClient.createConfiguration(); - oozieConf.setProperty(OozieClient.APP_PATH, workflow.toString()); - oozieConf.setProperty(OozieClient.USER_NAME, UserGroupInformation.getCurrentUser().getUserName()); - - //submit and check - final String jobId = oozieClient.submit(oozieConf); - WorkflowJob wf = oozieClient.getJobInfo(jobId); - Assert.assertNotNull(wf); - assertEquals(WorkflowJob.Status.PREP, wf.getStatus()); - - LOGGER.info("OOZIE: Workflow: {}", wf.toString()); - hdfsFs.close(); - - } - - private static void createHbaseTable(String tableName, String colFamily, - org.apache.hadoop.conf.Configuration configuration) throws Exception { - - final HBaseAdmin admin = new HBaseAdmin(configuration); - HTableDescriptor hTableDescriptor = new HTableDescriptor(TableName.valueOf(tableName)); - HColumnDescriptor hColumnDescriptor = new HColumnDescriptor(colFamily); - - hTableDescriptor.addFamily(hColumnDescriptor); - admin.createTable(hTableDescriptor); - } - - private static void putRow(String tableName, String colFamName, String rowKey, String colQualifier, String value, - org.apache.hadoop.conf.Configuration configuration) throws Exception { - HTable table = new HTable(configuration, tableName); - Put put = new Put(Bytes.toBytes(rowKey)); - put.add(Bytes.toBytes(colFamName), Bytes.toBytes(colQualifier), Bytes.toBytes(value)); - table.put(put); - table.flushCommits(); - table.close(); - } - - private static Result getRow(String tableName, String colFamName, String rowKey, String colQualifier, - org.apache.hadoop.conf.Configuration configuration) throws Exception { - Result result; - HTable table = new HTable(configuration, tableName); - Get get = new Get(Bytes.toBytes(rowKey)); - get.addColumn(Bytes.toBytes(colFamName), Bytes.toBytes(colQualifier)); - get.setMaxVersions(1); - result = table.get(get); - return result; - } - - - @Test - public void mongodbShouldStart() throws UnknownHostException { - MongoClient mongo = new MongoClient(configuration.getString(HadoopUnitConfig.MONGO_IP_KEY), configuration.getInt(HadoopUnitConfig.MONGO_PORT_KEY)); - - DB db = mongo.getDB(configuration.getString(HadoopUnitConfig.MONGO_DATABASE_NAME_KEY)); - DBCollection col = db.createCollection(configuration.getString(HadoopUnitConfig.MONGO_COLLECTION_NAME_KEY), - new BasicDBObject()); - - col.save(new BasicDBObject("testDoc", new java.util.Date())); - LOGGER.info("MONGODB: Number of items in collection: {}", col.count()); - assertEquals(1, col.count()); - - DBCursor cursor = col.find(); - while (cursor.hasNext()) { - LOGGER.info("MONGODB: Document output: {}", cursor.next()); - } - cursor.close(); - } - - @Test - public void cassandraShouldStart() throws NotFoundServiceException { - Cluster cluster = Cluster.builder() - .addContactPoints(configuration.getString(HadoopUnitConfig.CASSANDRA_IP_KEY)).withPort(configuration.getInt(HadoopUnitConfig.CASSANDRA_PORT_KEY)).build(); - Session session = cluster.connect(); - - session.execute("create KEYSPACE test WITH replication = {'class': 'SimpleStrategy' , 'replication_factor': '1' }"); - session.execute("CREATE TABLE test.test (user text, value text, PRIMARY KEY (user))"); - session.execute("insert into test.test(user, value) values('user1', 'value1')"); - session.execute("insert into test.test(user, value) values('user2', 'value2')"); - - com.datastax.driver.core.ResultSet execute = session.execute("select * from test.test"); - - List res = execute.all(); - assertEquals(res.size(), 2); - assertEquals(res.get(0).getString("user"), "user2"); - assertEquals(res.get(0).getString("value"), "value2"); - assertEquals(res.get(1).getString("user"), "user1"); - - } - -} diff --git a/hadoop-unit-standalone/hadoop-unit-standalone-solr/src/test/resources/hive-site.xml b/hadoop-unit-standalone/hadoop-unit-standalone-solr/src/test/resources/hive-site.xml deleted file mode 100755 index 459256db..00000000 --- a/hadoop-unit-standalone/hadoop-unit-standalone-solr/src/test/resources/hive-site.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - -hive.metastore.uris - -thrift://localhost:20102 - - - - - - - - - - - diff --git a/hadoop-unit-standalone/hadoop-unit-standalone-solr/src/test/resources/test.csv b/hadoop-unit-standalone/hadoop-unit-standalone-solr/src/test/resources/test.csv deleted file mode 100644 index 47ede0f1..00000000 --- a/hadoop-unit-standalone/hadoop-unit-standalone-solr/src/test/resources/test.csv +++ /dev/null @@ -1,3 +0,0 @@ -1;value1 -2;value2 -3;value3 \ No newline at end of file diff --git a/hadoop-unit-standalone/pom.xml b/hadoop-unit-standalone/pom.xml index 4aeac810..43d75ad4 100644 --- a/hadoop-unit-standalone/pom.xml +++ b/hadoop-unit-standalone/pom.xml @@ -5,78 +5,99 @@ hadoop-unit fr.jetoile.hadoop - 1.6-SNAPSHOT + 2.0-SNAPSHOT 4.0.0 hadoop-unit-standalone - pom - hadoop-unit-standalone - - hadoop-unit-standalone-solr - hadoop-unit-standalone-elasticsearch - hadoop-unit-standalone-common - + 3.1.0 + 1.0.0.v20140518 2.11.3 + 1.0.4 fr.jetoile.hadoop hadoop-unit-commons - - - org.slf4j - log4j-over-slf4j - - - fr.jetoile.hadoop - hadoop-unit-hbase + org.apache.commons + commons-lang3 + 3.4 - fr.jetoile.hadoop - hadoop-unit-hdfs + org.eclipse.aether + aether-api + ${aetherVersion} - - fr.jetoile.hadoop - hadoop-unit-hive + org.eclipse.aether + aether-spi + ${aetherVersion} - - fr.jetoile.hadoop - hadoop-unit-kafka + org.eclipse.aether + aether-util + ${aetherVersion} - - fr.jetoile.hadoop - hadoop-unit-oozie + org.eclipse.aether + aether-impl + ${aetherVersion} - - fr.jetoile.hadoop - hadoop-unit-zookeeper + org.eclipse.aether + aether-connector-basic + ${aetherVersion} - - fr.jetoile.hadoop - hadoop-unit-mongodb + org.eclipse.aether + aether-transport-file + ${aetherVersion} - - fr.jetoile.hadoop - hadoop-unit-cassandra + org.eclipse.aether + aether-transport-http + ${aetherVersion} - - commons-configuration - commons-configuration + org.apache.maven + maven-aether-provider + ${mavenVersion} + + + org.eclipse.sisu + org.eclipse.sisu.plexus + 0.1.1 + true + + + javax.enterprise + cdi-api + + + + + org.sonatype.sisu + sisu-guice + 3.1.6 + no_aop + true + + + aopalliance + aopalliance + + + com.google.code.findbugs + jsr305 + + @@ -95,6 +116,19 @@ fr.jetoile.hadoop hadoop-unit-client-hdfs test + + + log4j + log4j + + + + + + org.codehaus.jackson + jackson-core-asl + 1.9.11 + test @@ -103,6 +137,13 @@ test + + org.neo4j.driver + neo4j-java-driver + ${neo4j-java-driver.version} + test + + org.mongodb mongo-java-driver @@ -110,6 +151,181 @@ test + + org.apache.hbase + hbase-client + 1.2.3 + test + + + hadoop-auth + org.apache.hadoop + + + log4j + log4j + + + + + + org.apache.oozie + oozie-client + 4.2.0.2.4.2.0-258 + test + + + + com.datastax.cassandra + cassandra-driver-core + 3.0.0 + test + + + + org.elasticsearch + elasticsearch + test + + + + + org.codehaus.mojo + appassembler-maven-plugin + + + + hadoop-bootstrap + package + + generate-daemons + + + ${project.build.directory}/appassembler-jsw + + flat + + src/main/resources + true + conf + logs + true + + + + hadoop-unit-standalone + fr.jetoile.hadoopunit.HadoopStandaloneBootstrap + + + + jsw + + + + jsw + + linux-x86-32 + linux-x86-64 + windows-x86-32 + windows-x86-64 + macosx-universal-64 + + + + + configuration.directory.in.classpath.first + conf + + + + wrapper.logfile.maxsize + 100m + + + + + + + 256M + 2048M + + com.sun.management.jmxremote + com.sun.management.jmxremote.port=8199 + com.sun.management.jmxremote.authenticate=false + + com.sun.management.jmxremote.ssl=false + com.sun.management.jmxremote.local.only=false + + + + -Xdebug + + -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n + + -server + -XX:+HeapDumpOnOutOfMemoryError + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + maven-assembly-plugin + + + src/main/assembly/descriptor.xml + + false + + + + + assembly + package + + single + + + + + + \ No newline at end of file diff --git a/hadoop-unit-standalone/hadoop-unit-standalone-solr/src/main/assembly/descriptor.xml b/hadoop-unit-standalone/src/main/assembly/descriptor.xml similarity index 69% rename from hadoop-unit-standalone/hadoop-unit-standalone-solr/src/main/assembly/descriptor.xml rename to hadoop-unit-standalone/src/main/assembly/descriptor.xml index 1b8759e4..63e478bc 100644 --- a/hadoop-unit-standalone/hadoop-unit-standalone-solr/src/main/assembly/descriptor.xml +++ b/hadoop-unit-standalone/src/main/assembly/descriptor.xml @@ -1,7 +1,7 @@ - + xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd"> hadoop-bootstrap @@ -11,11 +11,16 @@ + + + + + - ${project.build.directory}/appassembler-jsw/jsw/${project.name} + ${project.build.directory}/appassembler-jsw/jsw/hadoop-unit-standalone / - bin/${project.name} + bin/hadoop-unit-standalone bin/wrapper-linux-x86-32 bin/wrapper-linux-x86-64 @@ -27,16 +32,15 @@ - ${project.build.directory}/appassembler-jsw/jsw/${project.name}/bin/${project.name} + ${project.build.directory}/appassembler-jsw/jsw/hadoop-unit-standalone/bin/hadoop-unit-standalone bin 750 - ${project.build.directory}/appassembler-jsw/jsw/${project.name}/bin/wrapper-linux-x86-64 + ${project.build.directory}/appassembler-jsw/jsw/hadoop-unit-standalone/bin/wrapper-linux-x86-64 bin 750 - \ No newline at end of file diff --git a/hadoop-unit-standalone/src/main/java/fr/jetoile/hadoopunit/ConsoleRepositoryListener.java b/hadoop-unit-standalone/src/main/java/fr/jetoile/hadoopunit/ConsoleRepositoryListener.java new file mode 100644 index 00000000..a34b3974 --- /dev/null +++ b/hadoop-unit-standalone/src/main/java/fr/jetoile/hadoopunit/ConsoleRepositoryListener.java @@ -0,0 +1,132 @@ +package fr.jetoile.hadoopunit; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ + +import org.eclipse.aether.AbstractRepositoryListener; +import org.eclipse.aether.RepositoryEvent; + +import java.io.PrintStream; + +/** + * A simplistic repository listener that logs events to the console. + */ +public class ConsoleRepositoryListener + extends AbstractRepositoryListener +{ + + private PrintStream out; + + public ConsoleRepositoryListener() + { + this( null ); + } + + public ConsoleRepositoryListener(PrintStream out ) + { + this.out = ( out != null ) ? out : System.out; + } + + public void artifactDeployed( RepositoryEvent event ) + { + out.println( "Deployed " + event.getArtifact() + " to " + event.getRepository() ); + } + + public void artifactDeploying( RepositoryEvent event ) + { + out.println( "Deploying " + event.getArtifact() + " to " + event.getRepository() ); + } + + public void artifactDescriptorInvalid( RepositoryEvent event ) + { + out.println( "Invalid artifact descriptor for " + event.getArtifact() + ": " + + event.getException().getMessage() ); + } + + public void artifactDescriptorMissing( RepositoryEvent event ) + { + out.println( "Missing artifact descriptor for " + event.getArtifact() ); + } + + public void artifactInstalled( RepositoryEvent event ) + { + out.println( "Installed " + event.getArtifact() + " to " + event.getFile() ); + } + + public void artifactInstalling( RepositoryEvent event ) + { + out.println( "Installing " + event.getArtifact() + " to " + event.getFile() ); + } + + public void artifactResolved( RepositoryEvent event ) + { + out.println( "Resolved artifact " + event.getArtifact() + " from " + event.getRepository() ); + } + + public void artifactDownloading( RepositoryEvent event ) + { + out.println( "Downloading artifact " + event.getArtifact() + " from " + event.getRepository() ); + } + + public void artifactDownloaded( RepositoryEvent event ) + { + out.println( "Downloaded artifact " + event.getArtifact() + " from " + event.getRepository() ); + } + + public void artifactResolving( RepositoryEvent event ) + { + out.println( "Resolving artifact " + event.getArtifact() ); + } + + public void metadataDeployed( RepositoryEvent event ) + { + out.println( "Deployed " + event.getMetadata() + " to " + event.getRepository() ); + } + + public void metadataDeploying( RepositoryEvent event ) + { + out.println( "Deploying " + event.getMetadata() + " to " + event.getRepository() ); + } + + public void metadataInstalled( RepositoryEvent event ) + { + out.println( "Installed " + event.getMetadata() + " to " + event.getFile() ); + } + + public void metadataInstalling( RepositoryEvent event ) + { + out.println( "Installing " + event.getMetadata() + " to " + event.getFile() ); + } + + public void metadataInvalid( RepositoryEvent event ) + { + out.println( "Invalid metadata " + event.getMetadata() ); + } + + public void metadataResolved( RepositoryEvent event ) + { + out.println( "Resolved metadata " + event.getMetadata() + " from " + event.getRepository() ); + } + + public void metadataResolving( RepositoryEvent event ) + { + out.println( "Resolving metadata " + event.getMetadata() + " from " + event.getRepository() ); + } + +} diff --git a/hadoop-unit-standalone/src/main/java/fr/jetoile/hadoopunit/ConsoleTransferListener.java b/hadoop-unit-standalone/src/main/java/fr/jetoile/hadoopunit/ConsoleTransferListener.java new file mode 100644 index 00000000..54016966 --- /dev/null +++ b/hadoop-unit-standalone/src/main/java/fr/jetoile/hadoopunit/ConsoleTransferListener.java @@ -0,0 +1,178 @@ +package fr.jetoile.hadoopunit; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ + +import org.eclipse.aether.transfer.AbstractTransferListener; +import org.eclipse.aether.transfer.MetadataNotFoundException; +import org.eclipse.aether.transfer.TransferEvent; +import org.eclipse.aether.transfer.TransferResource; + +import java.io.PrintStream; +import java.text.DecimalFormat; +import java.text.DecimalFormatSymbols; +import java.util.Locale; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +/** + * A simplistic transfer listener that logs uploads/downloads to the console. + */ +public class ConsoleTransferListener + extends AbstractTransferListener +{ + + private PrintStream out; + + private Map downloads = new ConcurrentHashMap(); + + private int lastLength; + + public ConsoleTransferListener() + { + this( null ); + } + + public ConsoleTransferListener(PrintStream out ) + { + this.out = ( out != null ) ? out : System.out; + } + + @Override + public void transferInitiated( TransferEvent event ) + { + String message = event.getRequestType() == TransferEvent.RequestType.PUT ? "Uploading" : "Downloading"; + + out.println( message + ": " + event.getResource().getRepositoryUrl() + event.getResource().getResourceName() ); + } + + @Override + public void transferProgressed( TransferEvent event ) + { + TransferResource resource = event.getResource(); + downloads.put( resource, Long.valueOf( event.getTransferredBytes() ) ); + + StringBuilder buffer = new StringBuilder( 64 ); + + for ( Map.Entry entry : downloads.entrySet() ) + { + long total = entry.getKey().getContentLength(); + long complete = entry.getValue().longValue(); + + buffer.append( getStatus( complete, total ) ).append( " " ); + } + + int pad = lastLength - buffer.length(); + lastLength = buffer.length(); + pad( buffer, pad ); + buffer.append( '\r' ); + + out.print( buffer ); + } + + private String getStatus( long complete, long total ) + { + if ( total >= 1024 ) + { + return toKB( complete ) + "/" + toKB( total ) + " KB "; + } + else if ( total >= 0 ) + { + return complete + "/" + total + " B "; + } + else if ( complete >= 1024 ) + { + return toKB( complete ) + " KB "; + } + else + { + return complete + " B "; + } + } + + private void pad( StringBuilder buffer, int spaces ) + { + String block = " "; + while ( spaces > 0 ) + { + int n = Math.min( spaces, block.length() ); + buffer.append( block, 0, n ); + spaces -= n; + } + } + + @Override + public void transferSucceeded( TransferEvent event ) + { + transferCompleted( event ); + + TransferResource resource = event.getResource(); + long contentLength = event.getTransferredBytes(); + if ( contentLength >= 0 ) + { + String type = ( event.getRequestType() == TransferEvent.RequestType.PUT ? "Uploaded" : "Downloaded" ); + String len = contentLength >= 1024 ? toKB( contentLength ) + " KB" : contentLength + " B"; + + String throughput = ""; + long duration = System.currentTimeMillis() - resource.getTransferStartTime(); + if ( duration > 0 ) + { + long bytes = contentLength - resource.getResumeOffset(); + DecimalFormat format = new DecimalFormat( "0.0", new DecimalFormatSymbols( Locale.ENGLISH ) ); + double kbPerSec = ( bytes / 1024.0 ) / ( duration / 1000.0 ); + throughput = " at " + format.format( kbPerSec ) + " KB/sec"; + } + + out.println( type + ": " + resource.getRepositoryUrl() + resource.getResourceName() + " (" + len + + throughput + ")" ); + } + } + + @Override + public void transferFailed( TransferEvent event ) + { + transferCompleted( event ); + + if ( !( event.getException() instanceof MetadataNotFoundException ) ) + { + event.getException().printStackTrace( out ); + } + } + + private void transferCompleted( TransferEvent event ) + { + downloads.remove( event.getResource() ); + + StringBuilder buffer = new StringBuilder( 64 ); + pad( buffer, lastLength ); + buffer.append( '\r' ); + out.print( buffer ); + } + + public void transferCorrupted( TransferEvent event ) + { + event.getException().printStackTrace( out ); + } + + protected long toKB( long bytes ) + { + return ( bytes + 1023 ) / 1024; + } + +} diff --git a/hadoop-unit-standalone/src/main/java/fr/jetoile/hadoopunit/HadoopStandaloneBootstrap.java b/hadoop-unit-standalone/src/main/java/fr/jetoile/hadoopunit/HadoopStandaloneBootstrap.java new file mode 100644 index 00000000..0b61b2c3 --- /dev/null +++ b/hadoop-unit-standalone/src/main/java/fr/jetoile/hadoopunit/HadoopStandaloneBootstrap.java @@ -0,0 +1,263 @@ +/* + * 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 fr.jetoile.hadoopunit; + +import fr.jetoile.hadoopunit.exception.BootstrapException; +import org.apache.commons.configuration.Configuration; +import org.apache.commons.configuration.ConfigurationException; +import org.apache.commons.configuration.PropertiesConfiguration; +import org.apache.commons.lang3.StringUtils; +import org.apache.log4j.WriterAppender; +import org.apache.maven.repository.internal.MavenRepositorySystemUtils; +import org.eclipse.aether.DefaultRepositorySystemSession; +import org.eclipse.aether.RepositorySystem; +import org.eclipse.aether.RepositorySystemSession; +import org.eclipse.aether.artifact.Artifact; +import org.eclipse.aether.artifact.DefaultArtifact; +import org.eclipse.aether.collection.CollectRequest; +import org.eclipse.aether.connector.basic.BasicRepositoryConnectorFactory; +import org.eclipse.aether.graph.Dependency; +import org.eclipse.aether.graph.DependencyFilter; +import org.eclipse.aether.impl.DefaultServiceLocator; +import org.eclipse.aether.repository.LocalRepository; +import org.eclipse.aether.repository.RemoteRepository; +import org.eclipse.aether.resolution.ArtifactResult; +import org.eclipse.aether.resolution.DependencyRequest; +import org.eclipse.aether.resolution.DependencyResolutionException; +import org.eclipse.aether.spi.connector.RepositoryConnectorFactory; +import org.eclipse.aether.spi.connector.transport.TransporterFactory; +import org.eclipse.aether.transport.file.FileTransporterFactory; +import org.eclipse.aether.transport.http.HttpTransporterFactory; +import org.eclipse.aether.util.artifact.JavaScopes; +import org.eclipse.aether.util.filter.DependencyFilterUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class HadoopStandaloneBootstrap { + + final private static Logger LOGGER = LoggerFactory.getLogger(HadoopStandaloneBootstrap.class); + static private Configuration configuration; + static private Configuration hadoopUnitConfiguration; + static private List componentsToStart = new ArrayList<>(); + static private List componentsToStop = new ArrayList<>(); + static private List componentsProperty = new ArrayList(); + + + public static RepositorySystem newRepositorySystem() { + DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator(); + locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class); + locator.addService(TransporterFactory.class, FileTransporterFactory.class); + locator.addService(TransporterFactory.class, HttpTransporterFactory.class); + + locator.setErrorHandler(new DefaultServiceLocator.ErrorHandler() { + @Override + public void serviceCreationFailed(Class type, Class impl, Throwable exception) { + exception.printStackTrace(); + } + }); + + return locator.getService(RepositorySystem.class); + } + + public static DefaultRepositorySystemSession newRepositorySystemSession(RepositorySystem system) { + DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession(); + + LocalRepository localRepo = new LocalRepository(hadoopUnitConfiguration.getString("maven.local.repo")); + session.setLocalRepositoryManager(system.newLocalRepositoryManager(session, localRepo)); + +// session.setTransferListener(new ConsoleTransferListener()); +// session.setRepositoryListener(new ConsoleRepositoryListener()); + + return session; + } + + public static List newRepositories(RepositorySystem system, RepositorySystemSession session) { + return new ArrayList<>(Arrays.asList(newCentralRepository())); + } + + private static RemoteRepository newCentralRepository() { + return new RemoteRepository.Builder("central", "default", hadoopUnitConfiguration.getString("maven.central.repo")).build(); + } + + public static void main(String[] args) throws BootstrapException, MalformedURLException, ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, DependencyResolutionException { + String homeDirectory = "."; + if (StringUtils.isNotEmpty(System.getenv("HADOOP_UNIT_HOME"))) { + homeDirectory = System.getenv("HADOOP_UNIT_HOME"); + } + LOGGER.debug("is using {} for local directory", homeDirectory); + + + try { + configuration = new PropertiesConfiguration("hadoop.properties"); + hadoopUnitConfiguration = new PropertiesConfiguration("hadoop-unit-default.properties"); + } catch (ConfigurationException e) { + throw new BootstrapException("bad config", e); + } + + Arrays.asList(Component.values()).stream().forEach(c -> { + if (configuration.containsKey(c.name().toLowerCase()) && configuration.getBoolean(c.name().toLowerCase())) { + componentsToStart.add(c); + } + }); + + RepositorySystem system = newRepositorySystem(); + DefaultRepositorySystemSession session = newRepositorySystemSession(system); + DependencyFilter classpathFilter = DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE); + + componentsToStart.stream().forEach(c -> { + Artifact artifact = new DefaultArtifact(hadoopUnitConfiguration.getString(c.getArtifactKey())); + CollectRequest collectRequest = new CollectRequest(); + collectRequest.setRoot(new Dependency(artifact, JavaScopes.COMPILE)); + collectRequest.setRepositories(newRepositories(system, session)); + + DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, classpathFilter); + + List artifactResults = null; + try { + artifactResults = system.resolveDependencies(session, dependencyRequest).getArtifactResults(); + } catch (DependencyResolutionException e) { + e.printStackTrace(); + } + + List artifacts = new ArrayList<>(); + artifactResults.stream().forEach(a -> + artifacts.add(a.getArtifact().getFile()) + ); + ComponentProperties componentProperties = loadAndRun(c.getKey(), c.getMainClass(), artifacts); + + componentsProperty.add(componentProperties); + componentsToStop.add(0, componentProperties); + }); + + + Runtime.getRuntime().addShutdownHook(new Thread() { + public void run() { + LOGGER.info("All services are going to be stopped"); + componentsToStop.stream().forEach(c -> { + if (c != null) { + try { + Method main = c.getMainClass().getMethod("stop"); + main.invoke(c.getInstance()); + } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { + LOGGER.error("unable to reflect main", e); + } + } + }); + } + }); + + + printBanner(); + } + + private static void printBanner() { + HadoopUtils.INSTANCE.printBanner(System.out); + componentsProperty.stream().forEach(c -> { + Object name = null; + Object prop = null; + + if (c != null) { + try { + Method main = c.getMainClass().getMethod("getName"); + name = main.invoke(c.getInstance()); + + main = c.getMainClass().getMethod("getProperties"); + prop = main.invoke(c.getInstance()); + } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { + LOGGER.error("unable to reflect main", e); + } + + System.out.println("\t\t - " + name + " " + prop); + } + }); + System.out.println(); + } + + private static ComponentProperties loadAndRun(String c, String className, List artifacts) { + List urls = new ArrayList(); + + urls.add(HadoopStandaloneBootstrap.class.getClassLoader().getResource("log4j.xml")); + urls.add(HadoopStandaloneBootstrap.class.getClassLoader().getResource("logback.xml")); + + if ("hiveserver2".equalsIgnoreCase(c)) { + urls.add(WriterAppender.class.getProtectionDomain().getCodeSource().getLocation()); + } + + if ("solrcloud".equalsIgnoreCase(c)) { + urls.add(HadoopStandaloneBootstrap.class.getClassLoader().getResource("solr")); + } + + artifacts.forEach(f -> { + try { + urls.add(f.toURL()); + } catch (MalformedURLException e) { + LOGGER.error("unable to find correct url for {}", f, e); + } + }); + + ClassLoader classloader = new URLClassLoader( + (URL[]) urls.toArray(new URL[0]), + ClassLoader.getSystemClassLoader().getParent()); + + // relative to that classloader, find the main class + Class mainClass = null; + try { + mainClass = classloader.loadClass(className); + } catch (ClassNotFoundException e) { + LOGGER.error("unable to load class", e); + } + Method main = null; + + + try { + Thread.currentThread().setContextClassLoader(classloader); + + Object o = mainClass.getConstructor().newInstance(); + main = mainClass.getMethod("start"); + main.invoke(o); + return new ComponentProperties(o, mainClass); + } catch (NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException e) { + LOGGER.error("unable to reflect main", e); + } + return null; + } + + private static class ComponentProperties { + private Object instance; + private Class mainClass; + + public ComponentProperties(Object instance, Class mainClass) { + this.instance = instance; + this.mainClass = mainClass; + } + + public Object getInstance() { + return instance; + } + + public Class getMainClass() { + return mainClass; + } + } +} diff --git a/hadoop-unit-standalone/src/main/resources/hadoop-unit-default.properties b/hadoop-unit-standalone/src/main/resources/hadoop-unit-default.properties new file mode 100644 index 00000000..885b1e95 --- /dev/null +++ b/hadoop-unit-standalone/src/main/resources/hadoop-unit-default.properties @@ -0,0 +1,147 @@ +#HADOOP_HOME=/opt/hadoop + +zookeeper.artifact=fr.jetoile.hadoop:hadoop-unit-zookeeper:2.0-SNAPSHOT +hdfs.artifact=fr.jetoile.hadoop:hadoop-unit-hdfs:2.0-SNAPSHOT +hivemeta.artifact=fr.jetoile.hadoop:hadoop-unit-hive:2.0-SNAPSHOT +hiveserver2.artifact=fr.jetoile.hadoop:hadoop-unit-hive:2.0-SNAPSHOT +kafka.artifact=fr.jetoile.hadoop:hadoop-unit-kafka:2.0-SNAPSHOT +hbase.artifact=fr.jetoile.hadoop:hadoop-unit-hbase:2.0-SNAPSHOT +oozie.artifact=fr.jetoile.hadoop:hadoop-unit-oozie:2.0-SNAPSHOT +solr.artifact=fr.jetoile.hadoop:hadoop-unit-solr:2.0-SNAPSHOT +solrcloud.artifact=fr.jetoile.hadoop:hadoop-unit-solrcloud:2.0-SNAPSHOT +cassandra.artifact=fr.jetoile.hadoop:hadoop-unit-cassandra:2.0-SNAPSHOT +mongodb.artifact=fr.jetoile.hadoop:hadoop-unit-mongodb:2.0-SNAPSHOT +elasticsearch.artifact=fr.jetoile.hadoop:hadoop-unit-elasticsearch:2.0-SNAPSHOT +neo4j.artifact=fr.jetoile.hadoop:hadoop-unit-neo4j:2.0-SNAPSHOT + +maven.central.repo=https://repo.maven.apache.org/maven2/ +maven.local.repo=/home/khanh/.m2/repository + +# Zookeeper +zookeeper.temp.dir=/tmp/embedded_zk +zookeeper.host=127.0.0.1 +zookeeper.port=22010 + +# Hive +hive.scratch.dir=/tmp/hive_scratch_dir +hive.warehouse.dir=/tmp/warehouse_dir + +# Hive Metastore +hive.metastore.hostname=localhost +hive.metastore.port=20102 +hive.metastore.derby.db.dir=metastore_db + +# Hive Server2 +hive.server2.hostname=localhost +hive.server2.port=20103 + +# Hive Test +hive.test.database.name=default +hive.test.table.name=test_table + + +# HDFS +hdfs.namenode.host=localhost +hdfs.namenode.port=20112 +hdfs.namenode.http.port=50070 +hdfs.temp.dir=/tmp/embedded_hdfs +hdfs.num.datanodes=1 +hdfs.enable.permissions=false +hdfs.format=true +hdfs.enable.running.user.as.proxy.user=true + +# HDFS Test +hdfs.test.file=/tmp/testing +hdfs.test.string=TESTING + + +# HBase +hbase.master.port=25111 +hbase.master.info.port=-1 +hbase.num.region.servers=1 +hbase.root.dir=/tmp/embedded_hbase +hbase.znode.parent=/hbase-unsecure +hbase.wal.replication.enabled=false + +# HBase Test +hbase.test.table.name=hbase_test_table +hbase.test.col.family.name=cf1 +hbase.test.col.qualifier.name=cq1 +hbase.test.num.rows.to.put=50 + +# Kafka +kafka.hostname=127.0.0.1 +kafka.port=20111 + +# Kafka Test +kafka.test.topic=testtopic +kafka.test.message.count=10 +kafka.test.broker.id=1 +kafka.test.temp.dir=embedded_kafka + +#SolR + SolRCloud +solr.dir=solr + +#SolR +solr.collection.internal.name=collection1_shard1_replica1 + +#SolRCloud +solr.collection.name=collection1 +solr.cloud.port=8983 + + + + + +# YARN +yarn.num.node.managers=1 +yarn.num.local.dirs=1 +yarn.num.log.dirs=1 +yarn.resource.manager.address=localhost:37001 +yarn.resource.manager.hostname=localhost +yarn.resource.manager.scheduler.address=localhost:37002 +yarn.resource.manager.resource.tracker.address=localhost:37003 +yarn.resource.manager.webapp.address=localhost:37004 +yarn.use.in.jvm.container.executor=false + +# MR +mr.job.history.address=localhost:37005 + +# Oozie +oozie.tmp.dir=/tmp/oozie_tmp +oozie.test.dir=/tmp/embedded_oozie +oozie.home.dir=/tmp/oozie_home +oozie.username=blah +oozie.groupname=testgroup +oozie.hdfs.share.lib.dir=/tmp/share_lib +oozie.share.lib.create=true +oozie.local.share.lib.cache.dir=/tmp/share_lib_cache +oozie.purge.local.share.lib.cache=false +oozie.sharelib.path=/home/khanh/github +oozie.sharelib.name=oozie-4.2.0.2.3.2.0-2950-distro.tar.gz +oozie.port=20113 +oozie.host=localhost + +# ElasticSearch +elasticsearch.ip=127.0.0.1 +elasticsearch.http.port=14433 +elasticsearch.tcp.port=14533 +elasticsearch.temp.dir=/tmp/elasticsearch +elasticsearch.index.name=test_index +elasticsearch.cluster.name=elasticsearch + +# MongoDB +mongo.ip=127.0.0.1 +mongo.port=13333 +mongo.database.name=test_database +mongo.collection.name=test_collection + +# Cassandra +cassandra.ip=127.0.0.1 +cassandra.port=13433 +cassandra.temp.dir=/tmp/embedded_cassandra + +# Neo4j +neo4j.ip=127.0.0.1 +neo4j.port=13533 +neo4j.temp.dir=/tmp/embedded_neo4j \ No newline at end of file diff --git a/hadoop-unit-standalone/src/main/resources/hadoop.properties b/hadoop-unit-standalone/src/main/resources/hadoop.properties new file mode 100755 index 00000000..d595f3b7 --- /dev/null +++ b/hadoop-unit-standalone/src/main/resources/hadoop.properties @@ -0,0 +1,13 @@ +zookeeper=true +hdfs=true +hivemeta=true +hiveserver2=true +#kafka=true +#hbase=true +#solrcloud=true +#oozie=true +#mongodb=true +#cassandra=true +#elasticsearch=true +#neo4j=true + diff --git a/hadoop-unit-standalone/src/main/resources/log4j.xml b/hadoop-unit-standalone/src/main/resources/log4j.xml new file mode 100644 index 00000000..ee21aca7 --- /dev/null +++ b/hadoop-unit-standalone/src/main/resources/log4j.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/hadoop-unit-standalone/src/main/resources/logback.xml b/hadoop-unit-standalone/src/main/resources/logback.xml new file mode 100755 index 00000000..8329aeb7 --- /dev/null +++ b/hadoop-unit-standalone/src/main/resources/logback.xml @@ -0,0 +1,17 @@ + + + + %d{HH:mm:ss.SSS} %-5level %logger{36} - %msg%n + + + + + + + + + + + + + \ No newline at end of file diff --git a/hadoop-unit-standalone/hadoop-unit-standalone-solr/src/main/conf/solr/collection1/conf/currency.xml b/hadoop-unit-standalone/src/main/resources/solr/collection1/conf/currency.xml similarity index 100% rename from hadoop-unit-standalone/hadoop-unit-standalone-solr/src/main/conf/solr/collection1/conf/currency.xml rename to hadoop-unit-standalone/src/main/resources/solr/collection1/conf/currency.xml diff --git a/hadoop-unit-standalone/hadoop-unit-standalone-solr/src/main/conf/solr/collection1/conf/lang/stopwords_en.txt b/hadoop-unit-standalone/src/main/resources/solr/collection1/conf/lang/stopwords_en.txt similarity index 100% rename from hadoop-unit-standalone/hadoop-unit-standalone-solr/src/main/conf/solr/collection1/conf/lang/stopwords_en.txt rename to hadoop-unit-standalone/src/main/resources/solr/collection1/conf/lang/stopwords_en.txt diff --git a/hadoop-unit-standalone/hadoop-unit-standalone-solr/src/main/conf/solr/collection1/conf/protwords.txt b/hadoop-unit-standalone/src/main/resources/solr/collection1/conf/protwords.txt similarity index 100% rename from hadoop-unit-standalone/hadoop-unit-standalone-solr/src/main/conf/solr/collection1/conf/protwords.txt rename to hadoop-unit-standalone/src/main/resources/solr/collection1/conf/protwords.txt diff --git a/hadoop-unit-standalone/hadoop-unit-standalone-solr/src/main/conf/solr/collection1/conf/schema.xml b/hadoop-unit-standalone/src/main/resources/solr/collection1/conf/schema.xml similarity index 100% rename from hadoop-unit-standalone/hadoop-unit-standalone-solr/src/main/conf/solr/collection1/conf/schema.xml rename to hadoop-unit-standalone/src/main/resources/solr/collection1/conf/schema.xml diff --git a/hadoop-unit-standalone/hadoop-unit-standalone-solr/src/main/conf/solr/collection1/conf/solrconfig.xml b/hadoop-unit-standalone/src/main/resources/solr/collection1/conf/solrconfig.xml similarity index 100% rename from hadoop-unit-standalone/hadoop-unit-standalone-solr/src/main/conf/solr/collection1/conf/solrconfig.xml rename to hadoop-unit-standalone/src/main/resources/solr/collection1/conf/solrconfig.xml diff --git a/hadoop-unit-standalone/hadoop-unit-standalone-solr/src/main/conf/solr/collection1/conf/stopwords.txt b/hadoop-unit-standalone/src/main/resources/solr/collection1/conf/stopwords.txt similarity index 100% rename from hadoop-unit-standalone/hadoop-unit-standalone-solr/src/main/conf/solr/collection1/conf/stopwords.txt rename to hadoop-unit-standalone/src/main/resources/solr/collection1/conf/stopwords.txt diff --git a/hadoop-unit-standalone/hadoop-unit-standalone-solr/src/main/conf/solr/collection1/conf/synonyms.txt b/hadoop-unit-standalone/src/main/resources/solr/collection1/conf/synonyms.txt similarity index 100% rename from hadoop-unit-standalone/hadoop-unit-standalone-solr/src/main/conf/solr/collection1/conf/synonyms.txt rename to hadoop-unit-standalone/src/main/resources/solr/collection1/conf/synonyms.txt diff --git a/hadoop-unit-standalone/hadoop-unit-standalone-solr/src/main/conf/solr/collection1/core.properties b/hadoop-unit-standalone/src/main/resources/solr/collection1/core.properties similarity index 100% rename from hadoop-unit-standalone/hadoop-unit-standalone-solr/src/main/conf/solr/collection1/core.properties rename to hadoop-unit-standalone/src/main/resources/solr/collection1/core.properties diff --git a/hadoop-unit-standalone/hadoop-unit-standalone-solr/src/main/conf/solr/solr.xml b/hadoop-unit-standalone/src/main/resources/solr/solr.xml similarity index 100% rename from hadoop-unit-standalone/hadoop-unit-standalone-solr/src/main/conf/solr/solr.xml rename to hadoop-unit-standalone/src/main/resources/solr/solr.xml diff --git a/hadoop-unit-standalone/src/test/java/com/google/common/base/Stopwatch.java b/hadoop-unit-standalone/src/test/java/com/google/common/base/Stopwatch.java new file mode 100644 index 00000000..7c6d8e0f --- /dev/null +++ b/hadoop-unit-standalone/src/test/java/com/google/common/base/Stopwatch.java @@ -0,0 +1,282 @@ +/* + * Copyright (C) 2008 The Guava 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.google.common.base; + +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkState; +import static java.util.concurrent.TimeUnit.MICROSECONDS; +import static java.util.concurrent.TimeUnit.MILLISECONDS; +import static java.util.concurrent.TimeUnit.NANOSECONDS; +import static java.util.concurrent.TimeUnit.SECONDS; + +import com.google.common.annotations.Beta; +import com.google.common.annotations.GwtCompatible; +import com.google.common.annotations.GwtIncompatible; + +import java.util.concurrent.TimeUnit; + +/** + * An object that measures elapsed time in nanoseconds. It is useful to measure + * elapsed time using this class instead of direct calls to {@link + * System#nanoTime} for a few reasons: + * + *
    + *
  • An alternate time source can be substituted, for testing or performance + * reasons. + *
  • As documented by {@code nanoTime}, the value returned has no absolute + * meaning, and can only be interpreted as relative to another timestamp + * returned by {@code nanoTime} at a different time. {@code Stopwatch} is a + * more effective abstraction because it exposes only these relative values, + * not the absolute ones. + *
+ * + *

Basic usage: + *

+ *   Stopwatch stopwatch = new Stopwatch().{@link #start start}();
+ *   doSomething();
+ *   stopwatch.{@link #stop stop}(); // optional
+ *
+ *   long millis = stopwatch.{@link #elapsedMillis elapsedMillis}();
+ *
+ *   log.info("that took: " + stopwatch); // formatted string like "12.3 ms"
+ * 
+ * + *

Stopwatch methods are not idempotent; it is an error to start or stop a + * stopwatch that is already in the desired state. + * + *

When testing code that uses this class, use the {@linkplain + * #Stopwatch(Ticker) alternate constructor} to supply a fake or mock ticker. + * This allows you to + * simulate any valid behavior of the stopwatch. + * + *

Note: This class is not thread-safe. + * + * @author Kevin Bourrillion + * @since 10.0 + */ + +/** + * for hbase test, guava 12 should be used because of conflict with cassandra driver + */ +@Beta +@GwtCompatible(emulated=true) +public final class Stopwatch { + private final Ticker ticker; + private boolean isRunning; + private long elapsedNanos; + private long startTick; + + /** + * Creates (but does not start) a new stopwatch using {@link System#nanoTime} + * as its time source. + */ + public Stopwatch() { + this(Ticker.systemTicker()); + } + + /** + * Creates (but does not start) a new stopwatch, using the specified time + * source. + */ + public Stopwatch(Ticker ticker) { + this.ticker = checkNotNull(ticker); + } + + /** + * Returns {@code true} if {@link #start()} has been called on this stopwatch, + * and {@link #stop()} has not been called since the last call to {@code + * start()}. + */ + public boolean isRunning() { + return isRunning; + } + + /** + * Starts the stopwatch. + * + * @return this {@code Stopwatch} instance + * @throws IllegalStateException if the stopwatch is already running. + */ + public Stopwatch start() { + checkState(!isRunning); + isRunning = true; + startTick = ticker.read(); + return this; + } + + /** + * Stops the stopwatch. Future reads will return the fixed duration that had + * elapsed up to this point. + * + * @return this {@code Stopwatch} instance + * @throws IllegalStateException if the stopwatch is already stopped. + */ + public Stopwatch stop() { + long tick = ticker.read(); + checkState(isRunning); + isRunning = false; + elapsedNanos += tick - startTick; + return this; + } + + /** + * Sets the elapsed time for this stopwatch to zero, + * and places it in a stopped state. + * + * @return this {@code Stopwatch} instance + */ + public Stopwatch reset() { + elapsedNanos = 0; + isRunning = false; + return this; + } + + private long elapsedNanos() { + return isRunning ? ticker.read() - startTick + elapsedNanos : elapsedNanos; + } + + /** + * Returns the current elapsed time shown on this stopwatch, expressed + * in the desired time unit, with any fraction rounded down. + * + *

Note that the overhead of measurement can be more than a microsecond, so + * it is generally not useful to specify {@link TimeUnit#NANOSECONDS} + * precision here. + */ + public long elapsedTime(TimeUnit desiredUnit) { + return desiredUnit.convert(elapsedNanos(), NANOSECONDS); + } + + /** + * Returns the current elapsed time shown on this stopwatch, expressed + * in milliseconds, with any fraction rounded down. This is identical to + * {@code elapsedTime(TimeUnit.MILLISECONDS}. + */ + public long elapsedMillis() { + return elapsedTime(MILLISECONDS); + } + + /** + * Returns a string representation of the current elapsed time; equivalent to + * {@code toString(4)} (four significant figures). + */ + @GwtIncompatible("String.format()") + @Override public String toString() { + return toString(4); + } + + /** + * Returns a string representation of the current elapsed time, choosing an + * appropriate unit and using the specified number of significant figures. + * For example, at the instant when {@code elapsedTime(NANOSECONDS)} would + * return {1234567}, {@code toString(4)} returns {@code "1.235 ms"}. + */ + @GwtIncompatible("String.format()") + public String toString(int significantDigits) { + long nanos = elapsedNanos(); + + TimeUnit unit = chooseUnit(nanos); + double value = (double) nanos / NANOSECONDS.convert(1, unit); + + // Too bad this functionality is not exposed as a regular method call + return String.format("%." + significantDigits + "g %s", + value, abbreviate(unit)); + } + + private static TimeUnit chooseUnit(long nanos) { + if (SECONDS.convert(nanos, NANOSECONDS) > 0) { + return SECONDS; + } + if (MILLISECONDS.convert(nanos, NANOSECONDS) > 0) { + return MILLISECONDS; + } + if (MICROSECONDS.convert(nanos, NANOSECONDS) > 0) { + return MICROSECONDS; + } + return NANOSECONDS; + } + + private static String abbreviate(TimeUnit unit) { + switch (unit) { + case NANOSECONDS: + return "ns"; + case MICROSECONDS: + return "\u03bcs"; // μs + case MILLISECONDS: + return "ms"; + case SECONDS: + return "s"; + default: + throw new AssertionError(); + } + } + + + /** + * Creates (but does not start) a new stopwatch using {@link System#nanoTime} + * as its time source. + * + * @since 15.0 + */ + public static Stopwatch createUnstarted() { + return new Stopwatch(); + } + + /** + * Creates (but does not start) a new stopwatch, using the specified time + * source. + * + * @since 15.0 + */ + public static Stopwatch createUnstarted(Ticker ticker) { + return new Stopwatch(ticker); + } + + /** + * Creates (and starts) a new stopwatch using {@link System#nanoTime} + * as its time source. + * + * @since 15.0 + */ + public static Stopwatch createStarted() { + return new Stopwatch().start(); + } + + /** + * Creates (and starts) a new stopwatch, using the specified time + * source. + * + * @since 15.0 + */ + public static Stopwatch createStarted(Ticker ticker) { + return new Stopwatch(ticker).start(); + } + + /** + * Returns the current elapsed time shown on this stopwatch, expressed + * in the desired time unit, with any fraction rounded down. + * + *

Note that the overhead of measurement can be more than a microsecond, so + * it is generally not useful to specify {@link TimeUnit#NANOSECONDS} + * precision here. + * + * @since 14.0 (since 10.0 as {@code elapsedTime()}) + */ + public long elapsed(TimeUnit desiredUnit) { + return desiredUnit.convert(elapsedNanos(), NANOSECONDS); + } +} \ No newline at end of file diff --git a/hadoop-unit-commons/src/main/java/com/google/common/io/Closeables.java b/hadoop-unit-standalone/src/test/java/com/google/common/io/Closeables.java similarity index 94% rename from hadoop-unit-commons/src/main/java/com/google/common/io/Closeables.java rename to hadoop-unit-standalone/src/test/java/com/google/common/io/Closeables.java index 3bf3fcc4..ffb1c051 100644 --- a/hadoop-unit-commons/src/main/java/com/google/common/io/Closeables.java +++ b/hadoop-unit-standalone/src/test/java/com/google/common/io/Closeables.java @@ -1,7 +1,3 @@ -// -// Source code recreated from a .class file by IntelliJ IDEA -// (powered by Fernflower decompiler) -// package com.google.common.io; @@ -68,4 +64,4 @@ public static void closeQuietly(@Nullable Closeable closeable) { logger.log(Level.SEVERE, "IOException should not have been thrown.", e); } } -} +} \ No newline at end of file diff --git a/hadoop-unit-standalone/hadoop-unit-standalone-elasticsearch/src/test/java/fr/jetoile/hadoopunit/integrationtest/IntegrationBootstrapTest.java b/hadoop-unit-standalone/src/test/java/fr/jetoile/hadoopunit/integrationtest/ManualIntegrationBootstrapTest.java similarity index 81% rename from hadoop-unit-standalone/hadoop-unit-standalone-elasticsearch/src/test/java/fr/jetoile/hadoopunit/integrationtest/IntegrationBootstrapTest.java rename to hadoop-unit-standalone/src/test/java/fr/jetoile/hadoopunit/integrationtest/ManualIntegrationBootstrapTest.java index ff903192..7dcd6262 100644 --- a/hadoop-unit-standalone/hadoop-unit-standalone-elasticsearch/src/test/java/fr/jetoile/hadoopunit/integrationtest/IntegrationBootstrapTest.java +++ b/hadoop-unit-standalone/src/test/java/fr/jetoile/hadoopunit/integrationtest/ManualIntegrationBootstrapTest.java @@ -19,9 +19,6 @@ import com.datastax.driver.core.Session; import com.mongodb.*; import fr.jetoile.hadoopunit.HadoopUnitConfig; -import fr.jetoile.hadoopunit.HadoopBootstrap; -import fr.jetoile.hadoopunit.Utils; -import fr.jetoile.hadoopunit.component.OozieBootstrap; import fr.jetoile.hadoopunit.exception.BootstrapException; import fr.jetoile.hadoopunit.exception.NotFoundServiceException; import fr.jetoile.hadoopunit.test.hdfs.HdfsUtils; @@ -43,6 +40,11 @@ import org.apache.hadoop.security.UserGroupInformation; import org.apache.oozie.client.OozieClient; import org.apache.oozie.client.WorkflowJob; +import org.apache.solr.client.solrj.SolrServerException; +import org.apache.solr.client.solrj.impl.CloudSolrClient; +import org.apache.solr.common.SolrDocument; +import org.apache.solr.common.SolrInputDocument; +import org.apache.zookeeper.KeeperException; import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jettison.json.JSONException; import org.codehaus.jettison.json.JSONObject; @@ -53,25 +55,30 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.transport.InetSocketTransportAddress; import org.junit.*; +import org.neo4j.driver.v1.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.*; import java.net.*; -import java.sql.Connection; import java.sql.*; -import java.util.*; -import java.util.Date; +import java.sql.Connection; +import java.sql.Driver; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; -import static junit.framework.TestCase.assertNotNull; import static org.fest.assertions.Assertions.assertThat; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; -public class IntegrationBootstrapTest { +@Ignore +public class ManualIntegrationBootstrapTest { static private Configuration configuration; - static private Logger LOGGER = LoggerFactory.getLogger(IntegrationBootstrapTest.class); + static private Logger LOGGER = LoggerFactory.getLogger(ManualIntegrationBootstrapTest.class); @BeforeClass @@ -81,14 +88,39 @@ public static void setup() throws BootstrapException { } catch (ConfigurationException e) { throw new BootstrapException("bad config", e); } - - HadoopBootstrap.INSTANCE.startAll(); } @AfterClass public static void tearDown() throws BootstrapException { - HadoopBootstrap.INSTANCE.stopAll(); + } + + @Test + public void solrCloudShouldStart() throws IOException, SolrServerException, KeeperException, InterruptedException { + + String collectionName = configuration.getString(HadoopUnitConfig.SOLR_COLLECTION_NAME); + + String zkHostString = configuration.getString(HadoopUnitConfig.ZOOKEEPER_HOST_KEY) + ":" + configuration.getInt(HadoopUnitConfig.ZOOKEEPER_PORT_KEY); + CloudSolrClient client = new CloudSolrClient(zkHostString); + + for (int i = 0; i < 1000; ++i) { + SolrInputDocument doc = new SolrInputDocument(); + doc.addField("cat", "book"); + doc.addField("id", "book-" + i); + doc.addField("name", "The Legend of the Hobbit part " + i); + client.add(collectionName, doc); + if (i % 100 == 0) client.commit(collectionName); // periodically flush + } + client.commit("collection1"); + + SolrDocument collection1 = client.getById(collectionName, "book-1"); + + assertNotNull(collection1); + + assertThat(collection1.getFieldValue("name")).isEqualTo("The Legend of the Hobbit part 1"); + + + client.close(); } @Test @@ -101,7 +133,6 @@ public void kafkaShouldStart() throws Exception { } - // Consumer KafkaConsumerUtils.INSTANCE.consumeMessagesWithNewApi(configuration.getString(HadoopUnitConfig.KAFKA_TEST_TOPIC_KEY), 10); @@ -121,7 +152,6 @@ private String generateMessage(int i) { } @Test - @Ignore public void hiveServer2ShouldStart() throws InterruptedException, ClassNotFoundException, SQLException { // assertThat(Utils.available("127.0.0.1", 20103)).isFalse(); @@ -198,12 +228,12 @@ public void hiveServer2ShouldStart() throws InterruptedException, ClassNotFoundE @Test public void hdfsShouldStart() throws Exception { - assertThat(Utils.available("127.0.0.1", configuration.getInt(HadoopUnitConfig.HDFS_NAMENODE_HTTP_PORT_KEY))).isFalse(); - +// assertThat(Utils.available("127.0.0.1", configuration.getInt(Config.HDFS_NAMENODE_HTTP_PORT_KEY))).isFalse(); +// // org.apache.hadoop.conf.Configuration conf = new org.apache.hadoop.conf.Configuration(); -// conf.set("fs.default.name", "hdfs://127.0.0.1:" + configuration.getInt(Config.HDFS_NAMENODE_PORT_KEY)); +// conf.set("fs.default.name", "hdfs://127.0.0.1:" + configuration.getInt(HadoopUnitConfig.HDFS_NAMENODE_PORT_KEY)); // -// URI uri = URI.create ("hdfs://127.0.0.1:" + configuration.getInt(Config.HDFS_NAMENODE_PORT_KEY)); +// URI uri = URI.create ("hdfs://127.0.0.1:" + configuration.getInt(HadoopUnitConfig.HDFS_NAMENODE_PORT_KEY)); // // FileSystem hdfsFsHandle = FileSystem.get (uri, conf); FileSystem hdfsFsHandle = HdfsUtils.INSTANCE.getFileSystem(); @@ -220,18 +250,17 @@ public void hdfsShouldStart() throws Exception { hdfsFsHandle.close(); URL url = new URL( - String.format( "http://localhost:%s/webhdfs/v1?op=GETHOMEDIRECTORY&user.name=guest", - configuration.getInt( HadoopUnitConfig.HDFS_NAMENODE_HTTP_PORT_KEY ) ) ); + String.format("http://localhost:%s/webhdfs/v1?op=GETHOMEDIRECTORY&user.name=guest", + configuration.getInt(HadoopUnitConfig.HDFS_NAMENODE_HTTP_PORT_KEY))); URLConnection connection = url.openConnection(); - connection.setRequestProperty( "Accept-Charset", "UTF-8" ); - BufferedReader response = new BufferedReader( new InputStreamReader( connection.getInputStream() ) ); + connection.setRequestProperty("Accept-Charset", "UTF-8"); + BufferedReader response = new BufferedReader(new InputStreamReader(connection.getInputStream())); String line = response.readLine(); response.close(); assertThat("{\"Path\":\"/user/guest\"}").isEqualTo(line); } - @Test public void hBaseShouldStart() throws Exception { @@ -263,18 +292,20 @@ public void hBaseShouldStart() throws Exception { } + @Test public void oozieShouldStart() throws Exception { + LOGGER.info("OOZIE: Test Submit Workflow Start"); org.apache.hadoop.conf.Configuration conf = new org.apache.hadoop.conf.Configuration(); conf.set("fs.default.name", "hdfs://127.0.0.1:" + configuration.getInt(HadoopUnitConfig.HDFS_NAMENODE_PORT_KEY)); - URI uri = URI.create ("hdfs://127.0.0.1:" + configuration.getInt(HadoopUnitConfig.HDFS_NAMENODE_PORT_KEY)); + URI uri = URI.create("hdfs://127.0.0.1:" + configuration.getInt(HadoopUnitConfig.HDFS_NAMENODE_PORT_KEY)); - FileSystem hdfsFs = FileSystem.get (uri, conf); + FileSystem hdfsFs = FileSystem.get(uri, conf); - OozieClient oozieClient = new OozieClient("http://" + configuration.getString(OozieBootstrap.OOZIE_HOST) + ":" + configuration.getInt(OozieBootstrap.OOZIE_PORT) + "/oozie"); + OozieClient oozieClient = new OozieClient("http://" + configuration.getString(HadoopUnitConfig.OOZIE_HOST) + ":" + configuration.getInt(HadoopUnitConfig.OOZIE_PORT) + "/oozie"); Path appPath = new Path(hdfsFs.getHomeDirectory(), "testApp"); hdfsFs.mkdirs(new Path(appPath, "lib")); @@ -298,7 +329,7 @@ public void oozieShouldStart() throws Exception { //submit and check final String jobId = oozieClient.submit(oozieConf); WorkflowJob wf = oozieClient.getJobInfo(jobId); - Assert.assertNotNull(wf); + assertNotNull(wf); assertEquals(WorkflowJob.Status.PREP, wf.getStatus()); LOGGER.info("OOZIE: Workflow: {}", wf.toString()); @@ -306,6 +337,39 @@ public void oozieShouldStart() throws Exception { } + private static void createHbaseTable(String tableName, String colFamily, + org.apache.hadoop.conf.Configuration configuration) throws Exception { + + final HBaseAdmin admin = new HBaseAdmin(configuration); + HTableDescriptor hTableDescriptor = new HTableDescriptor(TableName.valueOf(tableName)); + HColumnDescriptor hColumnDescriptor = new HColumnDescriptor(colFamily); + + hTableDescriptor.addFamily(hColumnDescriptor); + admin.createTable(hTableDescriptor); + } + + private static void putRow(String tableName, String colFamName, String rowKey, String colQualifier, String value, + org.apache.hadoop.conf.Configuration configuration) throws Exception { + HTable table = new HTable(configuration, tableName); + Put put = new Put(Bytes.toBytes(rowKey)); + put.add(Bytes.toBytes(colFamName), Bytes.toBytes(colQualifier), Bytes.toBytes(value)); + table.put(put); + table.flushCommits(); + table.close(); + } + + private static Result getRow(String tableName, String colFamName, String rowKey, String colQualifier, + org.apache.hadoop.conf.Configuration configuration) throws Exception { + Result result; + HTable table = new HTable(configuration, tableName); + Get get = new Get(Bytes.toBytes(rowKey)); + get.addColumn(Bytes.toBytes(colFamName), Bytes.toBytes(colQualifier)); + get.setMaxVersions(1); + result = table.get(get); + return result; + } + + @Test public void mongodbShouldStart() throws UnknownHostException { MongoClient mongo = new MongoClient(configuration.getString(HadoopUnitConfig.MONGO_IP_KEY), configuration.getInt(HadoopUnitConfig.MONGO_PORT_KEY)); @@ -314,12 +378,12 @@ public void mongodbShouldStart() throws UnknownHostException { DBCollection col = db.createCollection(configuration.getString(HadoopUnitConfig.MONGO_COLLECTION_NAME_KEY), new BasicDBObject()); - col.save(new BasicDBObject("testDoc", new Date())); + col.save(new BasicDBObject("testDoc", new java.util.Date())); LOGGER.info("MONGODB: Number of items in collection: {}", col.count()); assertEquals(1, col.count()); DBCursor cursor = col.find(); - while(cursor.hasNext()) { + while (cursor.hasNext()) { LOGGER.info("MONGODB: Document output: {}", cursor.next()); } cursor.close(); @@ -365,62 +429,42 @@ public void elasticSearchShouldStartWithRealDriver() throws NotFoundServiceExcep IndexResponse ir = client.prepareIndex("test_index", "type").setSource(jsonString).setId("2").execute().actionGet(); client.admin().indices().prepareRefresh("test_index").execute().actionGet(); - Assert.assertNotNull(ir); + assertNotNull(ir); GetResponse gr = client.prepareGet("test_index", "type", "2").execute().actionGet(); - Assert.assertNotNull(gr); + assertNotNull(gr); assertEquals(gr.getSourceAsString(), "{\"value\":\"value2\",\"size\":0.33,\"price\":3.0}"); } - private final Map headers = new HashMap(); - - protected HttpURLConnection createConnection(URL url, String method) throws IOException { - HttpURLConnection conn = (HttpURLConnection) url.openConnection(); - conn.setRequestMethod(method); - if (method.equals("POST") || method.equals("PUT")) { - conn.setDoOutput(true); - } - for (Map.Entry header : headers.entrySet()) { - conn.setRequestProperty(header.getKey(), header.getValue()); + @Test + public void neo4jShouldStartWithRealDriver() { + + org.neo4j.driver.v1.Driver driver = GraphDatabase.driver( + "bolt://localhost:13533", + Config.build() + .withEncryptionLevel(Config.EncryptionLevel.NONE) + .toConfig() + ); + + List results = new ArrayList<>(); + try (org.neo4j.driver.v1.Session session = driver.session()) { + session.run("CREATE (person:Person {name: {name}, title:'King'})", Values.parameters("name", "Arthur")); + + StatementResult result = session.run("MATCH (a:Person) WHERE a.name = 'Arthur' RETURN a.name AS name, a.title AS title"); + while (result.hasNext()) { + Record record = result.next(); + results.add(record); + LOGGER.debug(record.get("title").asString() + " " + record.get("name").asString()); + } } - return conn; - } - - private static void createHbaseTable(String tableName, String colFamily, - org.apache.hadoop.conf.Configuration configuration) throws Exception { - final HBaseAdmin admin = new HBaseAdmin(configuration); - HTableDescriptor hTableDescriptor = new HTableDescriptor(TableName.valueOf(tableName)); - HColumnDescriptor hColumnDescriptor = new HColumnDescriptor(colFamily); - - hTableDescriptor.addFamily(hColumnDescriptor); - admin.createTable(hTableDescriptor); + assertEquals(1, results.size()); + assertEquals("King", results.get(0).get("title").asString()); + assertEquals("Arthur", results.get(0).get("name").asString()); } - private static void putRow(String tableName, String colFamName, String rowKey, String colQualifier, String value, - org.apache.hadoop.conf.Configuration configuration) throws Exception { - HTable table = new HTable(configuration, tableName); - Put put = new Put(Bytes.toBytes(rowKey)); - put.add(Bytes.toBytes(colFamName), Bytes.toBytes(colQualifier), Bytes.toBytes(value)); - table.put(put); - table.flushCommits(); - table.close(); - } - - private static Result getRow(String tableName, String colFamName, String rowKey, String colQualifier, - org.apache.hadoop.conf.Configuration configuration) throws Exception { - Result result; - HTable table = new HTable(configuration, tableName); - Get get = new Get(Bytes.toBytes(rowKey)); - get.addColumn(Bytes.toBytes(colFamName), Bytes.toBytes(colQualifier)); - get.setMaxVersions(1); - result = table.get(get); - return result; - } - - } diff --git a/hadoop-unit-zookeeper/pom.xml b/hadoop-unit-zookeeper/pom.xml index ca676d96..9f16588c 100644 --- a/hadoop-unit-zookeeper/pom.xml +++ b/hadoop-unit-zookeeper/pom.xml @@ -5,7 +5,7 @@ hadoop-unit fr.jetoile.hadoop - 1.6-SNAPSHOT + 2.0-SNAPSHOT 4.0.0 @@ -24,4 +24,5 @@ hadoop-unit-commons + \ No newline at end of file diff --git a/hadoop-unit-zookeeper/src/main/java/fr/jetoile/hadoopunit/component/ZookeeperBootstrap.java b/hadoop-unit-zookeeper/src/main/java/fr/jetoile/hadoopunit/component/ZookeeperBootstrap.java index 3032e631..10a42e00 100644 --- a/hadoop-unit-zookeeper/src/main/java/fr/jetoile/hadoopunit/component/ZookeeperBootstrap.java +++ b/hadoop-unit-zookeeper/src/main/java/fr/jetoile/hadoopunit/component/ZookeeperBootstrap.java @@ -15,12 +15,15 @@ import com.github.sakserv.minicluster.impl.ZookeeperLocalCluster; import fr.jetoile.hadoopunit.Component; +import fr.jetoile.hadoopunit.HadoopBootstrap; import fr.jetoile.hadoopunit.HadoopUnitConfig; import fr.jetoile.hadoopunit.HadoopUtils; import fr.jetoile.hadoopunit.exception.BootstrapException; +import fr.jetoile.hadoopunit.exception.NotFoundServiceException; import org.apache.commons.configuration.Configuration; import org.apache.commons.configuration.ConfigurationException; import org.apache.commons.configuration.PropertiesConfiguration; +import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -28,11 +31,12 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.Map; public class ZookeeperBootstrap implements Bootstrap { final public static String NAME = Component.ZOOKEEPER.name(); - final private Logger LOGGER = LoggerFactory.getLogger(ZookeeperBootstrap.class); + final private static Logger LOGGER = LoggerFactory.getLogger(ZookeeperBootstrap.class); private ZookeeperLocalCluster zookeeperLocalCluster; @@ -69,7 +73,7 @@ public String getProperties() { } private void loadConfig() throws BootstrapException { - HadoopUtils.setHadoopHome(); + HadoopUtils.INSTANCE.setHadoopHome(); try { configuration = new PropertiesConfiguration(HadoopUnitConfig.DEFAULT_PROPS_FILE); } catch (ConfigurationException e) { @@ -81,6 +85,18 @@ private void loadConfig() throws BootstrapException { } + @Override + public void loadConfig(Map configs) { + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.ZOOKEEPER_PORT_KEY))) { + port = Integer.parseInt(configs.get(HadoopUnitConfig.ZOOKEEPER_PORT_KEY)); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.ZOOKEEPER_TEMP_DIR_KEY))) { + localDir = configs.get(HadoopUnitConfig.ZOOKEEPER_TEMP_DIR_KEY); + } + if (StringUtils.isNotEmpty(configs.get(HadoopUnitConfig.ZOOKEEPER_HOST_KEY))) { + host = configs.get(HadoopUnitConfig.ZOOKEEPER_HOST_KEY); + } + } private void init() { Path path = Paths.get(localDir); @@ -138,6 +154,4 @@ public Bootstrap stop() { public org.apache.hadoop.conf.Configuration getConfiguration() { throw new UnsupportedOperationException("the method getConfiguration can not be called on ZookeeperBootstrap"); } - - } diff --git a/hadoop-unit-zookeeper/src/main/resources/hadoop-unit-default.properties b/hadoop-unit-zookeeper/src/main/resources/hadoop-unit-default.properties new file mode 100644 index 00000000..ad8559d8 --- /dev/null +++ b/hadoop-unit-zookeeper/src/main/resources/hadoop-unit-default.properties @@ -0,0 +1,106 @@ +#HADOOP_HOME=/opt/hadoop + +# Zookeeper +zookeeper.temp.dir=/tmp/embedded_zk +zookeeper.host=127.0.0.1 +zookeeper.port=22010 + +# Hive +hive.scratch.dir=/tmp/hive_scratch_dir +hive.warehouse.dir=/tmp/warehouse_dir + +# Hive Metastore +hive.metastore.hostname=localhost +hive.metastore.port=20102 +hive.metastore.derby.db.dir=metastore_db + +# Hive Server2 +hive.server2.hostname=localhost +hive.server2.port=20103 + +# Hive Test +hive.test.database.name=default +hive.test.table.name=test_table + + +# HDFS +hdfs.namenode.port=20112 +hdfs.namenode.http.port=50070 +hdfs.temp.dir=/tmp/embedded_hdfs +hdfs.num.datanodes=1 +hdfs.enable.permissions=false +hdfs.format=true +hdfs.enable.running.user.as.proxy.user=true + +# HDFS Test +hdfs.test.file=/tmp/testing +hdfs.test.string=TESTING + + +# HBase +hbase.master.port=25111 +hbase.master.info.port=-1 +hbase.num.region.servers=1 +hbase.root.dir=/tmp/embedded_hbase +hbase.znode.parent=/hbase-unsecure +hbase.wal.replication.enabled=false + +# HBase Test +hbase.test.table.name=hbase_test_table +hbase.test.col.family.name=cf1 +hbase.test.col.qualifier.name=cq1 +hbase.test.num.rows.to.put=50 + +# Kafka +kafka.hostname=127.0.0.1 +kafka.port=20111 + +# Kafka Test +kafka.test.topic=testtopic +kafka.test.message.count=10 +kafka.test.broker.id=1 +kafka.test.temp.dir=embedded_kafka + +#SolR + SolRCloud +solr.dir=solr + +#SolR +solr.collection.internal.name=collection1_shard1_replica1 + +#SolRCloud +solr.collection.name=collection1 +solr.cloud.port=8983 + + +# YARN +yarn.num.node.managers=1 +yarn.num.local.dirs=1 +yarn.num.log.dirs=1 +yarn.resource.manager.address=localhost:37001 +yarn.resource.manager.hostname=localhost +yarn.resource.manager.scheduler.address=localhost:37002 +yarn.resource.manager.resource.tracker.address=localhost:37003 +yarn.resource.manager.webapp.address=localhost:37004 +yarn.use.in.jvm.container.executor=false + +# MR +mr.job.history.address=localhost:37005 + +# Oozie +oozie.test.dir=/tmp/embedded_oozie +oozie.home.dir=/tmp/oozie_home +oozie.username=blah +oozie.groupname=testgroup +oozie.hdfs.share.lib.dir=/tmp/share_lib +oozie.share.lib.create=true +oozie.local.share.lib.cache.dir=/tmp/share_lib_cache +oozie.purge.local.share.lib.cache=false +oozie.sharelib.path=/home/khanh/github +oozie.sharelib.name=oozie-4.2.0.2.3.2.0-2950-distro.tar.gz +oozie.port=20113 +oozie.host=localhost + +# Neo4j +neo4j.ip=127.0.0.1 +neo4j.port=13533 +neo4j.temp.dir=/tmp/embedded_neo4j \ No newline at end of file diff --git a/pom.xml b/pom.xml index 7d4201fc..a273d586 100755 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ fr.jetoile.hadoop hadoop-unit pom - 1.6-SNAPSHOT + 2.0-SNAPSHOT hadoop-unit https://github.com/jetoile/hadoop-unit @@ -115,7 +115,7 @@ 1.8 1.8 - 1.6-SNAPSHOT + ${project.version} 1.7.12 1.1.3 @@ -216,6 +216,10 @@ hadoop-unit-commons ${hadoop-unit.version} + + com.microsoft.windowsazure.storage + microsoft-windowsazure-storage-sdk + servlet-api javax.servlet @@ -359,32 +363,6 @@ org.apache.hadoop hadoop-common ${hadoop.version} - - - httpclient - org.apache.httpcomponents - - - servlet-api - javax.servlet - - - org.eclipse.jetty - jetty-util - - - guava - com.google.guava - - - log4j - log4j - - - slf4j-log4j12 - org.slf4j - - @@ -410,14 +388,6 @@ servlet-api javax.servlet - - log4j - log4j - - - slf4j-log4j12 - org.slf4j - @@ -446,22 +416,6 @@ org.apache.hadoop hadoop-annotations - - org.ow2.asm - asm - - - org.ow2.asm - asm-commons - - - jetty-util - org.eclipse.jetty - - - com.googlecode.concurrentlinkedhashmap - concurrentlinkedhashmap-lru - log4j log4j @@ -485,44 +439,6 @@ com.github.sakserv hadoop-mini-clusters-oozie ${hadoop-mini-clusters.version} - - - servlet-api - javax.servlet - - - metrics-core - com.codahale.metrics - - - metrics-json - com.codahale.metrics - - - metrics-jvm - com.codahale.metrics - - - hive-jdbc - org.apache.hive - - - log4j - log4j - - - slf4j-simple - org.slf4j - - - slf4j-log4j12 - org.slf4j - - - property-parser - com.github.sakserv - - @@ -606,14 +522,6 @@ hadoop-mini-clusters-hivemetastore ${hadoop-mini-clusters.version} - - log4j - log4j - - - slf4j-log4j12 - org.slf4j - @@ -622,10 +530,6 @@ hadoop-mini-clusters-hiveserver2 ${hadoop-mini-clusters.version} - - jetty-all - org.eclipse.jetty.aggregate - slf4j-log4j12 org.slf4j @@ -637,36 +541,12 @@ com.github.sakserv hadoop-mini-clusters-hdfs ${hadoop-mini-clusters.version} - - - servlet-api - javax.servlet - - - log4j - log4j - - - slf4j-log4j12 - org.slf4j - - - netty - io.netty - - com.github.sakserv hadoop-mini-clusters-hbase ${hadoop-mini-clusters.version} - - - servlet-api-2.5 - org.mortbay.jetty - - @@ -674,14 +554,6 @@ spark-solr ${spark-solr.version} - - org.ow2.asm - asm - - - org.ow2.asm - asm-commons - spark-mllib_2.10 org.apache.spark @@ -828,7 +700,7 @@ junit junit - 4.11 + 4.12 test diff --git a/sample/all/pom.xml b/sample/all/pom.xml new file mode 100644 index 00000000..25937859 --- /dev/null +++ b/sample/all/pom.xml @@ -0,0 +1,133 @@ + + + + sample + fr.jetoile.hadoop + 2.0-SNAPSHOT + + 4.0.0 + + all + + + 2.11.3 + + + + + fr.jetoile.hadoop + hadoop-unit-commons + + + org.slf4j + log4j-over-slf4j + + + org.mortbay.jetty + org.eclipse.jetty + + + org.eclipse.jetty + jetty-util + + + + + + fr.jetoile.hadoop + hadoop-unit-hbase + + + + fr.jetoile.hadoop + hadoop-unit-hdfs + + + + fr.jetoile.hadoop + hadoop-unit-hive + + + jetty-all + org.eclipse.jetty.aggregate + + + + + + fr.jetoile.hadoop + hadoop-unit-kafka + + + + fr.jetoile.hadoop + hadoop-unit-oozie + + + + fr.jetoile.hadoop + hadoop-unit-zookeeper + + + + fr.jetoile.hadoop + hadoop-unit-mongodb + + + + fr.jetoile.hadoop + hadoop-unit-cassandra + + + + fr.jetoile.hadoop + hadoop-unit-solrcloud + + + jetty-util + org.eclipse.jetty + + + + + + org.eclipse.jetty + jetty-util + + + + fr.jetoile.hadoop + hadoop-unit-client-kafka + test + + + + fr.jetoile.hadoop + hadoop-unit-client-solrcloud + test + + + + fr.jetoile.hadoop + hadoop-unit-client-hdfs + test + + + + fr.jetoile.hadoop + hadoop-unit-client-hive + test + + + + org.mongodb + mongo-java-driver + ${mongo-java-driver.version} + test + + + + + \ No newline at end of file diff --git a/hadoop-unit-standalone/hadoop-unit-standalone-solr/src/test/java/fr/jetoile/hadoopunit/integrationtest/IntegrationBootstrapTest.java b/sample/all/src/test/java/fr/jetoile/hadoopunit/integrationtest/IntegrationBootstrapTest.java similarity index 98% rename from hadoop-unit-standalone/hadoop-unit-standalone-solr/src/test/java/fr/jetoile/hadoopunit/integrationtest/IntegrationBootstrapTest.java rename to sample/all/src/test/java/fr/jetoile/hadoopunit/integrationtest/IntegrationBootstrapTest.java index d86b3533..6f5325ad 100644 --- a/hadoop-unit-standalone/hadoop-unit-standalone-solr/src/test/java/fr/jetoile/hadoopunit/integrationtest/IntegrationBootstrapTest.java +++ b/sample/all/src/test/java/fr/jetoile/hadoopunit/integrationtest/IntegrationBootstrapTest.java @@ -18,11 +18,9 @@ import com.datastax.driver.core.Cluster; import com.datastax.driver.core.Session; import com.mongodb.*; -import fr.jetoile.hadoopunit.HadoopUnitConfig; import fr.jetoile.hadoopunit.HadoopBootstrap; +import fr.jetoile.hadoopunit.HadoopUnitConfig; import fr.jetoile.hadoopunit.Utils; -import fr.jetoile.hadoopunit.component.OozieBootstrap; -import fr.jetoile.hadoopunit.component.SolrCloudBootstrap; import fr.jetoile.hadoopunit.exception.BootstrapException; import fr.jetoile.hadoopunit.exception.NotFoundServiceException; import fr.jetoile.hadoopunit.test.hdfs.HdfsUtils; @@ -59,13 +57,14 @@ import java.net.*; import java.sql.Connection; import java.sql.*; -import java.util.*; import java.util.Date; +import java.util.*; import static junit.framework.TestCase.assertNotNull; import static org.fest.assertions.Assertions.assertThat; import static org.junit.Assert.assertEquals; +@Ignore public class IntegrationBootstrapTest { static private Configuration configuration; @@ -93,7 +92,7 @@ public static void tearDown() throws BootstrapException { @Test public void solrCloudShouldStart() throws IOException, SolrServerException, KeeperException, InterruptedException { - String collectionName = configuration.getString(SolrCloudBootstrap.SOLR_COLLECTION_NAME); + String collectionName = configuration.getString(HadoopUnitConfig.SOLR_COLLECTION_NAME); String zkHostString = configuration.getString(HadoopUnitConfig.ZOOKEEPER_HOST_KEY) + ":" + configuration.getInt(HadoopUnitConfig.ZOOKEEPER_PORT_KEY); CloudSolrClient client = new CloudSolrClient(zkHostString); @@ -301,7 +300,7 @@ public void oozieShouldStart() throws Exception { FileSystem hdfsFs = FileSystem.get (uri, conf); - OozieClient oozieClient = new OozieClient("http://" + configuration.getString(OozieBootstrap.OOZIE_HOST) + ":" + configuration.getInt(OozieBootstrap.OOZIE_PORT) + "/oozie"); + OozieClient oozieClient = new OozieClient("http://" + configuration.getString(HadoopUnitConfig.OOZIE_HOST) + ":" + configuration.getInt(HadoopUnitConfig.OOZIE_PORT) + "/oozie"); Path appPath = new Path(hdfsFs.getHomeDirectory(), "testApp"); hdfsFs.mkdirs(new Path(appPath, "lib")); diff --git a/hadoop-unit-standalone/hadoop-unit-standalone-solr/src/test/resources/hadoop-unit-default.properties b/sample/all/src/test/resources/hadoop-unit-default.properties similarity index 100% rename from hadoop-unit-standalone/hadoop-unit-standalone-solr/src/test/resources/hadoop-unit-default.properties rename to sample/all/src/test/resources/hadoop-unit-default.properties diff --git a/hadoop-unit-standalone/hadoop-unit-standalone-elasticsearch/src/test/resources/hive-site.xml b/sample/all/src/test/resources/hive-site.xml similarity index 100% rename from hadoop-unit-standalone/hadoop-unit-standalone-elasticsearch/src/test/resources/hive-site.xml rename to sample/all/src/test/resources/hive-site.xml diff --git a/hadoop-unit-standalone/hadoop-unit-standalone-solr/src/test/resources/solr/collection1/conf/currency.xml b/sample/all/src/test/resources/solr/collection1/conf/currency.xml similarity index 100% rename from hadoop-unit-standalone/hadoop-unit-standalone-solr/src/test/resources/solr/collection1/conf/currency.xml rename to sample/all/src/test/resources/solr/collection1/conf/currency.xml diff --git a/hadoop-unit-standalone/hadoop-unit-standalone-solr/src/test/resources/solr/collection1/conf/lang/stopwords_en.txt b/sample/all/src/test/resources/solr/collection1/conf/lang/stopwords_en.txt similarity index 100% rename from hadoop-unit-standalone/hadoop-unit-standalone-solr/src/test/resources/solr/collection1/conf/lang/stopwords_en.txt rename to sample/all/src/test/resources/solr/collection1/conf/lang/stopwords_en.txt diff --git a/hadoop-unit-standalone/hadoop-unit-standalone-solr/src/test/resources/solr/collection1/conf/protwords.txt b/sample/all/src/test/resources/solr/collection1/conf/protwords.txt similarity index 100% rename from hadoop-unit-standalone/hadoop-unit-standalone-solr/src/test/resources/solr/collection1/conf/protwords.txt rename to sample/all/src/test/resources/solr/collection1/conf/protwords.txt diff --git a/hadoop-unit-standalone/hadoop-unit-standalone-solr/src/test/resources/solr/collection1/conf/schema.xml b/sample/all/src/test/resources/solr/collection1/conf/schema.xml similarity index 100% rename from hadoop-unit-standalone/hadoop-unit-standalone-solr/src/test/resources/solr/collection1/conf/schema.xml rename to sample/all/src/test/resources/solr/collection1/conf/schema.xml diff --git a/hadoop-unit-standalone/hadoop-unit-standalone-solr/src/test/resources/solr/collection1/conf/solrconfig.xml b/sample/all/src/test/resources/solr/collection1/conf/solrconfig.xml similarity index 100% rename from hadoop-unit-standalone/hadoop-unit-standalone-solr/src/test/resources/solr/collection1/conf/solrconfig.xml rename to sample/all/src/test/resources/solr/collection1/conf/solrconfig.xml diff --git a/hadoop-unit-standalone/hadoop-unit-standalone-solr/src/test/resources/solr/collection1/conf/stopwords.txt b/sample/all/src/test/resources/solr/collection1/conf/stopwords.txt similarity index 100% rename from hadoop-unit-standalone/hadoop-unit-standalone-solr/src/test/resources/solr/collection1/conf/stopwords.txt rename to sample/all/src/test/resources/solr/collection1/conf/stopwords.txt diff --git a/hadoop-unit-standalone/hadoop-unit-standalone-solr/src/test/resources/solr/collection1/conf/synonyms.txt b/sample/all/src/test/resources/solr/collection1/conf/synonyms.txt similarity index 100% rename from hadoop-unit-standalone/hadoop-unit-standalone-solr/src/test/resources/solr/collection1/conf/synonyms.txt rename to sample/all/src/test/resources/solr/collection1/conf/synonyms.txt diff --git a/hadoop-unit-standalone/hadoop-unit-standalone-solr/src/test/resources/solr/collection1/core.properties b/sample/all/src/test/resources/solr/collection1/core.properties similarity index 100% rename from hadoop-unit-standalone/hadoop-unit-standalone-solr/src/test/resources/solr/collection1/core.properties rename to sample/all/src/test/resources/solr/collection1/core.properties diff --git a/hadoop-unit-standalone/hadoop-unit-standalone-solr/src/test/resources/solr/solr.xml b/sample/all/src/test/resources/solr/solr.xml similarity index 100% rename from hadoop-unit-standalone/hadoop-unit-standalone-solr/src/test/resources/solr/solr.xml rename to sample/all/src/test/resources/solr/solr.xml diff --git a/hadoop-unit-standalone/hadoop-unit-standalone-elasticsearch/src/test/resources/test.csv b/sample/all/src/test/resources/test.csv similarity index 100% rename from hadoop-unit-standalone/hadoop-unit-standalone-elasticsearch/src/test/resources/test.csv rename to sample/all/src/test/resources/test.csv diff --git a/sample/kafka-spark-streaming/pom.xml b/sample/kafka-spark-streaming/pom.xml index 3f20c3e2..c467f505 100644 --- a/sample/kafka-spark-streaming/pom.xml +++ b/sample/kafka-spark-streaming/pom.xml @@ -5,7 +5,7 @@ sample fr.jetoile.hadoop - 1.6-SNAPSHOT + 2.0-SNAPSHOT 4.0.0 @@ -70,4 +70,66 @@ + + + + org.apache.maven.plugins + maven-surefire-plugin + + + **/*IntegrationTest.java + + + + + integration-test + + test + + integration-test + + + none + + + **/*IntegrationTest.java + + + + + + + + hadoop-unit-maven-plugin + fr.jetoile.hadoop + ${hadoop-unit.version} + + + start + + embedded-start + + pre-integration-test + + + + /home/khanh/.m2/repository + https://repo.maven.apache.org/maven2/ + + + ZOOKEEPER + fr.jetoile.hadoop:hadoop-unit-zookeeper:${hadoop-unit.version} + + + KAFKA + fr.jetoile.hadoop:hadoop-unit-kafka:${hadoop-unit.version} + + + + + + + + + \ No newline at end of file diff --git a/sample/kafka-spark-streaming/src/test/java/fr/jetoile/hadoopunit/sample/kafka/SparkKafkaIntegrationTest.java b/sample/kafka-spark-streaming/src/test/java/fr/jetoile/hadoopunit/sample/kafka/SparkKafkaIntegrationTest.java index e3791bea..30c11455 100644 --- a/sample/kafka-spark-streaming/src/test/java/fr/jetoile/hadoopunit/sample/kafka/SparkKafkaIntegrationTest.java +++ b/sample/kafka-spark-streaming/src/test/java/fr/jetoile/hadoopunit/sample/kafka/SparkKafkaIntegrationTest.java @@ -40,7 +40,6 @@ import java.util.*; import java.util.regex.Pattern; -@Ignore public class SparkKafkaIntegrationTest implements Serializable { private static Configuration configuration; @@ -50,6 +49,7 @@ public static void setUp() throws ConfigurationException { configuration = new PropertiesConfiguration(HadoopUnitConfig.DEFAULT_PROPS_FILE); } + @Ignore @Test public void stark_should_read_kafka() { diff --git a/sample/kafka-stream/pom.xml b/sample/kafka-stream/pom.xml index 178d8476..d18e7509 100644 --- a/sample/kafka-stream/pom.xml +++ b/sample/kafka-stream/pom.xml @@ -5,7 +5,7 @@ sample fr.jetoile.hadoop - 1.6-SNAPSHOT + 2.0-SNAPSHOT 4.0.0 @@ -49,4 +49,64 @@ + + + + org.apache.maven.plugins + maven-surefire-plugin + + + **/*IntegrationTest.java + + + + + integration-test + + test + + integration-test + + + none + + + **/*IntegrationTest.java + + + + + + + + hadoop-unit-maven-plugin + fr.jetoile.hadoop + ${hadoop-unit.version} + + + start + + embedded-start + + pre-integration-test + + + + /home/khanh/.m2/repository + https://repo.maven.apache.org/maven2/ + + + ZOOKEEPER + fr.jetoile.hadoop:hadoop-unit-zookeeper:${hadoop-unit.version} + + + KAFKA + fr.jetoile.hadoop:hadoop-unit-kafka:${hadoop-unit.version} + + + + + + + \ No newline at end of file diff --git a/sample/kafka-stream/src/test/java/fr/jetoile/hadoopunit/sample/kafka/KafkaStreamsJobTest.java b/sample/kafka-stream/src/test/java/fr/jetoile/hadoopunit/sample/kafka/KafkaStreamsJobIntegrationTest.java similarity index 97% rename from sample/kafka-stream/src/test/java/fr/jetoile/hadoopunit/sample/kafka/KafkaStreamsJobTest.java rename to sample/kafka-stream/src/test/java/fr/jetoile/hadoopunit/sample/kafka/KafkaStreamsJobIntegrationTest.java index 3eb63815..ed4f69b1 100644 --- a/sample/kafka-stream/src/test/java/fr/jetoile/hadoopunit/sample/kafka/KafkaStreamsJobTest.java +++ b/sample/kafka-stream/src/test/java/fr/jetoile/hadoopunit/sample/kafka/KafkaStreamsJobIntegrationTest.java @@ -27,8 +27,7 @@ import static org.junit.Assert.*; -@Ignore -public class KafkaStreamsJobTest { +public class KafkaStreamsJobIntegrationTest { private static Configuration configuration; diff --git a/sample/kafka-stream/src/test/java/fr/jetoile/hadoopunit/sample/kafka/KafkaStreamsJobWithUnitTest.java b/sample/kafka-stream/src/test/java/fr/jetoile/hadoopunit/sample/kafka/KafkaStreamsJobWithUnitTest.java index 874c5ffe..341ece7d 100644 --- a/sample/kafka-stream/src/test/java/fr/jetoile/hadoopunit/sample/kafka/KafkaStreamsJobWithUnitTest.java +++ b/sample/kafka-stream/src/test/java/fr/jetoile/hadoopunit/sample/kafka/KafkaStreamsJobWithUnitTest.java @@ -24,8 +24,10 @@ import org.codehaus.jettison.json.JSONObject; import org.junit.AfterClass; import org.junit.BeforeClass; +import org.junit.Ignore; import org.junit.Test; +@Ignore public class KafkaStreamsJobWithUnitTest { private static Configuration configuration; diff --git a/sample/kafka-stream/src/test/java/fr/jetoile/hadoopunit/sample/kafka/KafkaStreamsPipelineJobTest.java b/sample/kafka-stream/src/test/java/fr/jetoile/hadoopunit/sample/kafka/KafkaStreamsPipelineJobIntegrationTest.java similarity index 97% rename from sample/kafka-stream/src/test/java/fr/jetoile/hadoopunit/sample/kafka/KafkaStreamsPipelineJobTest.java rename to sample/kafka-stream/src/test/java/fr/jetoile/hadoopunit/sample/kafka/KafkaStreamsPipelineJobIntegrationTest.java index 5c7ad7f0..07985960 100644 --- a/sample/kafka-stream/src/test/java/fr/jetoile/hadoopunit/sample/kafka/KafkaStreamsPipelineJobTest.java +++ b/sample/kafka-stream/src/test/java/fr/jetoile/hadoopunit/sample/kafka/KafkaStreamsPipelineJobIntegrationTest.java @@ -28,7 +28,7 @@ import org.junit.Test; @Ignore -public class KafkaStreamsPipelineJobTest { +public class KafkaStreamsPipelineJobIntegrationTest { private static Configuration configuration; diff --git a/sample/kafka-stream/src/test/java/fr/jetoile/hadoopunit/sample/kafka/KafkaStreamsPipelineJobWithUnitTest.java b/sample/kafka-stream/src/test/java/fr/jetoile/hadoopunit/sample/kafka/KafkaStreamsPipelineJobWithUnitTest.java index 2bbe79f9..13a95589 100644 --- a/sample/kafka-stream/src/test/java/fr/jetoile/hadoopunit/sample/kafka/KafkaStreamsPipelineJobWithUnitTest.java +++ b/sample/kafka-stream/src/test/java/fr/jetoile/hadoopunit/sample/kafka/KafkaStreamsPipelineJobWithUnitTest.java @@ -25,6 +25,7 @@ import org.codehaus.jettison.json.JSONObject; import org.junit.*; +@Ignore public class KafkaStreamsPipelineJobWithUnitTest { private static Configuration configuration; diff --git a/sample/parquet-spark/pom.xml b/sample/parquet-spark/pom.xml index 6a439fd5..9dfcfbb4 100644 --- a/sample/parquet-spark/pom.xml +++ b/sample/parquet-spark/pom.xml @@ -5,7 +5,7 @@ sample fr.jetoile.hadoop - 1.6-SNAPSHOT + 2.0-SNAPSHOT 4.0.0 @@ -47,12 +47,22 @@ jackson-databind com.fasterxml.jackson.core + + slf4j-log4j12 + org.slf4j + org.apache.spark spark-hive_2.10 + + + slf4j-log4j12 + org.slf4j + + @@ -64,18 +74,105 @@ fr.jetoile.hadoop hadoop-unit-commons test + + + slf4j-log4j12 + org.slf4j + + fr.jetoile.hadoop hadoop-unit-client-hdfs test + + + slf4j-log4j12 + org.slf4j + + fr.jetoile.hadoop hadoop-unit-client-hive + + + slf4j-log4j12 + org.slf4j + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + **/*IntegrationTest.java + + + + + integration-test + + test + + integration-test + + + none + + + **/*IntegrationTest.java + + + + + + + + hadoop-unit-maven-plugin + fr.jetoile.hadoop + ${hadoop-unit.version} + + + start + + embedded-start + + pre-integration-test + + + + /home/khanh/.m2/repository + https://repo.maven.apache.org/maven2/ + + + HDFS + fr.jetoile.hadoop:hadoop-unit-hdfs:${hadoop-unit.version} + + + ZOOKEEPER + fr.jetoile.hadoop:hadoop-unit-zookeeper:${hadoop-unit.version} + + + HIVEMETA + fr.jetoile.hadoop:hadoop-unit-hive:${hadoop-unit.version} + + + HIVESERVER2 + fr.jetoile.hadoop:hadoop-unit-hive:${hadoop-unit.version} + + + + + + + + \ No newline at end of file diff --git a/sample/parquet-spark/src/test/java/fr/jetoile/hadoopunit/sample/SparkJobTest.java b/sample/parquet-spark/src/test/java/fr/jetoile/hadoopunit/sample/SparkJobIntegrationTest.java similarity index 96% rename from sample/parquet-spark/src/test/java/fr/jetoile/hadoopunit/sample/SparkJobTest.java rename to sample/parquet-spark/src/test/java/fr/jetoile/hadoopunit/sample/SparkJobIntegrationTest.java index 3d1f8baa..3adc54ab 100644 --- a/sample/parquet-spark/src/test/java/fr/jetoile/hadoopunit/sample/SparkJobTest.java +++ b/sample/parquet-spark/src/test/java/fr/jetoile/hadoopunit/sample/SparkJobIntegrationTest.java @@ -45,10 +45,9 @@ import static com.ninja_squad.dbsetup.Operations.sql; import static org.fest.assertions.Assertions.assertThat; -@Ignore -public class SparkJobTest { +public class SparkJobIntegrationTest { - static private Logger LOGGER = LoggerFactory.getLogger(SparkJobTest.class); + static private Logger LOGGER = LoggerFactory.getLogger(SparkJobIntegrationTest.class); private static Configuration configuration; @@ -86,7 +85,7 @@ public void before() throws IOException, URISyntaxException { fileSystem.mkdirs(new Path("/khanh/test")); fileSystem.mkdirs(new Path("/khanh/test_parquet")); - fileSystem.copyFromLocalFile(new Path(SparkJobTest.class.getClassLoader().getResource("test.csv").toURI()), new Path("/khanh/test/test.csv")); + fileSystem.copyFromLocalFile(new Path(SparkJobIntegrationTest.class.getClassLoader().getResource("test.csv").toURI()), new Path("/khanh/test/test.csv")); new HiveSetup(HiveConnectionUtils.INSTANCE.getDestination(), Operations.sequenceOf(CREATE_TABLES)).launch(); } @@ -101,6 +100,7 @@ public void clean() throws IOException { @Test + @Ignore public void upload_file_into_hdfs_and_map_hive_should_success() throws SQLException { Statement stmt = HiveConnectionUtils.INSTANCE.getConnection().createStatement(); diff --git a/sample/pom.xml b/sample/pom.xml index e64cb9c0..d7ac175b 100644 --- a/sample/pom.xml +++ b/sample/pom.xml @@ -5,7 +5,7 @@ hadoop-unit fr.jetoile.hadoop - 1.6-SNAPSHOT + 2.0-SNAPSHOT 4.0.0 pom @@ -16,6 +16,7 @@ parquet-spark kafka-stream spark-streaming-cassandra + all sample diff --git a/sample/solr-parquet-spark/pom.xml b/sample/solr-parquet-spark/pom.xml index 0f8b8acb..9e00e1f3 100644 --- a/sample/solr-parquet-spark/pom.xml +++ b/sample/solr-parquet-spark/pom.xml @@ -5,13 +5,12 @@ sample fr.jetoile.hadoop - 1.6-SNAPSHOT + 2.0-SNAPSHOT 4.0.0 solr-parquet-spark - org.slf4j @@ -48,23 +47,112 @@ com.lucidworks.spark spark-solr + + + log4j + log4j + + + + + + com.databricks + spark-csv_2.10 + 1.5.0 fr.jetoile.hadoop hadoop-unit-commons test + + + log4j + log4j + + fr.jetoile.hadoop hadoop-unit-client-hdfs test + + + log4j + log4j + + - - fr.jetoile.hadoop - hadoop-unit-client-hive - + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + **/*IntegrationTest.java + + + + + integration-test + + test + + integration-test + + + none + + + **/*IntegrationTest.java + + + + + + + + hadoop-unit-maven-plugin + fr.jetoile.hadoop + ${hadoop-unit.version} + + + start + + embedded-start + + pre-integration-test + + + + /home/khanh/.m2/repository + https://repo.maven.apache.org/maven2/ + + + HDFS + fr.jetoile.hadoop:hadoop-unit-hdfs:${hadoop-unit.version} + + + ZOOKEEPER + fr.jetoile.hadoop:hadoop-unit-zookeeper:${hadoop-unit.version} + + + SOLRCLOUD + fr.jetoile.hadoop:hadoop-unit-solrcloud:${hadoop-unit.version} + + file://${project.basedir}/src/test/resources/solr + + + + + + + + + \ No newline at end of file diff --git a/sample/solr-parquet-spark/src/test/java/fr/jetoile/hadoopunit/sample/ParquetToSolrJobTest.java b/sample/solr-parquet-spark/src/test/java/fr/jetoile/hadoopunit/sample/ParquetToSolrJobIntegrationTest.java similarity index 62% rename from sample/solr-parquet-spark/src/test/java/fr/jetoile/hadoopunit/sample/ParquetToSolrJobTest.java rename to sample/solr-parquet-spark/src/test/java/fr/jetoile/hadoopunit/sample/ParquetToSolrJobIntegrationTest.java index af6dc519..96d24f65 100644 --- a/sample/solr-parquet-spark/src/test/java/fr/jetoile/hadoopunit/sample/ParquetToSolrJobTest.java +++ b/sample/solr-parquet-spark/src/test/java/fr/jetoile/hadoopunit/sample/ParquetToSolrJobIntegrationTest.java @@ -14,14 +14,10 @@ package fr.jetoile.hadoopunit.sample; -import com.ninja_squad.dbsetup.Operations; -import com.ninja_squad.dbsetup.operation.Operation; import fr.jetoile.hadoopunit.HadoopUnitConfig; import fr.jetoile.hadoopunit.exception.BootstrapException; import fr.jetoile.hadoopunit.exception.NotFoundServiceException; import fr.jetoile.hadoopunit.test.hdfs.HdfsUtils; -import fr.jetoile.hadoopunit.test.hive.HiveConnectionUtils; -import fr.jetoile.hadoopunit.test.hive.HiveSetup; import org.apache.commons.configuration.Configuration; import org.apache.commons.configuration.ConfigurationException; import org.apache.commons.configuration.PropertiesConfiguration; @@ -33,8 +29,11 @@ import org.apache.spark.SparkConf; import org.apache.spark.api.java.JavaSparkContext; import org.apache.spark.sql.DataFrame; -import org.apache.spark.sql.hive.HiveContext; -import org.junit.*; +import org.apache.spark.sql.SQLContext; +import org.junit.After; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -42,22 +41,16 @@ import java.net.URISyntaxException; import java.sql.SQLException; -import static com.ninja_squad.dbsetup.Operations.sequenceOf; -import static com.ninja_squad.dbsetup.Operations.sql; import static junit.framework.TestCase.assertNotNull; import static org.fest.assertions.Assertions.assertThat; -@Ignore -public class ParquetToSolrJobTest { +public class ParquetToSolrJobIntegrationTest { - static private Logger LOGGER = LoggerFactory.getLogger(ParquetToSolrJobTest.class); + static private Logger LOGGER = LoggerFactory.getLogger(ParquetToSolrJobIntegrationTest.class); private static Configuration configuration; - public static Operation CREATE_TABLES = null; - public static Operation DROP_TABLES = null; - @BeforeClass public static void setUp() throws BootstrapException, SQLException, ClassNotFoundException, NotFoundServiceException { @@ -67,19 +60,6 @@ public static void setUp() throws BootstrapException, SQLException, ClassNotFoun throw new BootstrapException("bad config", e); } - CREATE_TABLES = - sequenceOf(sql("CREATE EXTERNAL TABLE IF NOT EXISTS default.test(id INT, value STRING) " + - " ROW FORMAT DELIMITED FIELDS TERMINATED BY ';'" + - " STORED AS TEXTFILE" + - " LOCATION 'hdfs://localhost:" + configuration.getInt(HadoopUnitConfig.HDFS_NAMENODE_PORT_KEY) + "/khanh/test'"), - sql("CREATE EXTERNAL TABLE IF NOT EXISTS default.test_parquet(id INT, value STRING) " + - " ROW FORMAT DELIMITED FIELDS TERMINATED BY ';'" + - " STORED AS PARQUET" + - " LOCATION 'hdfs://localhost:" + configuration.getInt(HadoopUnitConfig.HDFS_NAMENODE_PORT_KEY) + "/khanh/test_parquet'")); - - DROP_TABLES = - sequenceOf(sql("DROP TABLE IF EXISTS default.test"), - sql("DROP TABLE IF EXISTS default.test_parquet")); } @Before @@ -88,15 +68,11 @@ public void before() throws IOException, URISyntaxException { fileSystem.mkdirs(new Path("/khanh/test")); fileSystem.mkdirs(new Path("/khanh/test_parquet")); - fileSystem.copyFromLocalFile(new Path(ParquetToSolrJobTest.class.getClassLoader().getResource("test.csv").toURI()), new Path("/khanh/test/test.csv")); - - new HiveSetup(HiveConnectionUtils.INSTANCE.getDestination(), Operations.sequenceOf(CREATE_TABLES)).launch(); + fileSystem.copyFromLocalFile(new Path(ParquetToSolrJobIntegrationTest.class.getClassLoader().getResource("test.csv").toURI()), new Path("/khanh/test/test.csv")); } @After public void clean() throws IOException { - new HiveSetup(HiveConnectionUtils.INSTANCE.getDestination(), Operations.sequenceOf(DROP_TABLES)).launch(); - FileSystem fileSystem = HdfsUtils.INSTANCE.getFileSystem(); fileSystem.delete(new Path("/khanh"), true); } @@ -110,12 +86,14 @@ public void spark_should_read_parquet_file_and_index_into_solr() throws IOExcept .setAppName("test"); JavaSparkContext context = new JavaSparkContext(conf); - - //read hive-site from classpath - HiveContext hiveContext = new HiveContext(context.sc()); - - DataFrame sql = hiveContext.sql("SELECT * FROM default.test"); - sql.write().parquet("hdfs://localhost:" + configuration.getInt(HadoopUnitConfig.HDFS_NAMENODE_PORT_KEY) + "/khanh/test_parquet/file.parquet"); + SQLContext sqlContext = new SQLContext(context); + DataFrame df = sqlContext.read() + .format("com.databricks.spark.csv") + .option("header", "true") // Use first line of all files as header + .option("inferSchema", "true") // Automatically infer data types + .load("hdfs://localhost:" + configuration.getInt(HadoopUnitConfig.HDFS_NAMENODE_PORT_KEY) + "/khanh/test/test.csv"); + + df.write().parquet("hdfs://localhost:" + configuration.getInt(HadoopUnitConfig.HDFS_NAMENODE_PORT_KEY) + "/khanh/test_parquet/file.parquet"); FileSystem fileSystem = HdfsUtils.INSTANCE.getFileSystem(); assertThat(fileSystem.exists(new Path("hdfs://localhost:" + configuration.getInt(HadoopUnitConfig.HDFS_NAMENODE_PORT_KEY) + "/khanh/test_parquet/file.parquet"))).isTrue(); diff --git a/sample/solr-parquet-spark/src/test/resources/solr/collection1/conf/currency.xml b/sample/solr-parquet-spark/src/test/resources/solr/collection1/conf/currency.xml new file mode 100644 index 00000000..3a9c58af --- /dev/null +++ b/sample/solr-parquet-spark/src/test/resources/solr/collection1/conf/currency.xml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sample/solr-parquet-spark/src/test/resources/solr/collection1/conf/lang/stopwords_en.txt b/sample/solr-parquet-spark/src/test/resources/solr/collection1/conf/lang/stopwords_en.txt new file mode 100644 index 00000000..2c164c0b --- /dev/null +++ b/sample/solr-parquet-spark/src/test/resources/solr/collection1/conf/lang/stopwords_en.txt @@ -0,0 +1,54 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You 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. + +# a couple of test stopwords to test that the words are really being +# configured from this file: +stopworda +stopwordb + +# Standard english stop words taken from Lucene's StopAnalyzer +a +an +and +are +as +at +be +but +by +for +if +in +into +is +it +no +not +of +on +or +such +that +the +their +then +there +these +they +this +to +was +will +with diff --git a/sample/solr-parquet-spark/src/test/resources/solr/collection1/conf/protwords.txt b/sample/solr-parquet-spark/src/test/resources/solr/collection1/conf/protwords.txt new file mode 100644 index 00000000..1dfc0abe --- /dev/null +++ b/sample/solr-parquet-spark/src/test/resources/solr/collection1/conf/protwords.txt @@ -0,0 +1,21 @@ +# The ASF licenses this file to You 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. + +#----------------------------------------------------------------------- +# Use a protected word file to protect against the stemmer reducing two +# unrelated words to the same base word. + +# Some non-words that normally won't be encountered, +# just to test that they won't be stemmed. +dontstems +zwhacky + diff --git a/sample/solr-parquet-spark/src/test/resources/solr/collection1/conf/schema.xml b/sample/solr-parquet-spark/src/test/resources/solr/collection1/conf/schema.xml new file mode 100644 index 00000000..a5083977 --- /dev/null +++ b/sample/solr-parquet-spark/src/test/resources/solr/collection1/conf/schema.xml @@ -0,0 +1,748 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + id + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sample/solr-parquet-spark/src/test/resources/solr/collection1/conf/solrconfig.xml b/sample/solr-parquet-spark/src/test/resources/solr/collection1/conf/solrconfig.xml new file mode 100644 index 00000000..3de5587f --- /dev/null +++ b/sample/solr-parquet-spark/src/test/resources/solr/collection1/conf/solrconfig.xml @@ -0,0 +1,1823 @@ + + + + + + + + + 5.3.0 + + + + + + + + + + + + + + + + + + + + + ${solr.data.dir:} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${solr.lock.type:none} + + + + + + + + + + + + + + + + true + + + + + + + + + + + + + + + + ${solr.ulog.dir:} + + + + + ${solr.autoCommit.maxTime:15000} + false + + + + + + ${solr.autoSoftCommit.maxTime:-1} + + + + + + + + + + + + + + + + 1024 + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + + 20 + + + 200 + + + + + + + + + + + + static firstSearcher warming in solrconfig.xml + + + + + + false + + + 2 + + + + + + + + + + + + + + + + + + + + + + + explicit + 10 + + + + + + + + + + + + + + explicit + 10 + text + + + inStock:true + + + + + + + explicit + json + true + text + + + + + + + + + + {!xport} + xsort + false + + + + query + + + + + + + + + + + + explicit + + + velocity + browse + layout + Solritas + + + edismax + + text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4 + title^10.0 description^5.0 keywords^5.0 author^2.0 resourcename^1.0 + + 100% + *:* + 10 + *,score + + + text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4 + title^10.0 description^5.0 keywords^5.0 author^2.0 resourcename^1.0 + + text,features,name,sku,id,manu,cat,title,description,keywords,author,resourcename + 3 + + + on + true + cat + manu_exact + content_type + author_s + ipod + GB + 1 + cat,inStock + after + price + 0 + 600 + 50 + popularity + 0 + 10 + 3 + manufacturedate_dt + NOW/YEAR-10YEARS + NOW + +1YEAR + before + after + + + on + content features title name + true + html + <b> + </b> + 0 + title + 0 + name + 3 + 200 + content + 750 + + + on + false + 5 + 2 + 5 + true + true + 5 + 3 + + + + + spellcheck + + + + + + + + + text + + + + + + + _src_ + + true + + + + + + + + + + true + ignored_ + + + true + links + ignored_ + + + + + + + + + + + + + + + + + + + + + + explicit + true + + + + + + + + + text_general + + + + + + default + text + solr.DirectSolrSpellChecker + + internal + + 0.5 + + 2 + + 1 + + 5 + + 4 + + 0.01 + + + + + + wordbreak + solr.WordBreakSolrSpellChecker + name + true + true + 10 + + + + + + + + + + + + + + + + + default + wordbreak + on + true + 10 + 5 + 5 + true + true + 10 + 5 + + + spellcheck + + + + + + + mySuggester + FuzzyLookupFactory + DocumentDictionaryFactory + cat + price + string + + + + + + true + 10 + + + suggest + + + --> + + + + + + + + + true + + + tvComponent + + + + + + + lingo + + + org.carrot2.clustering.lingo.LingoClusteringAlgorithm + + + clustering/carrot2 + + + + + stc + org.carrot2.clustering.stc.STCClusteringAlgorithm + + + + + kmeans + org.carrot2.clustering.kmeans.BisectingKMeansClusteringAlgorithm + + + + + + + true + true + + name + + id + + features + + true + + + + false + + + edismax + + text^0.5 features^1.0 name^1.2 sku^1.5 id^10.0 manu^1.1 cat^1.4 + + *:* + 10 + *,score + + + clustering + + + + + + + + + + true + false + + + terms + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 100 + + + + + + + + 70 + + 0.5 + + [-\w ,/\n\"']{20,200} + + + + + + + ]]> + ]]> + + + + + + + + + + + + + + + + + + + + + + + + ,, + ,, + ,, + ,, + ,]]> + ]]> + + + + + + 10 + .,!? + + + + + + + WORD + + + en + US + + + + + + + + + + + + + + + + + + + + + + ${velocity.template.base.dir:} + + + + + + 5 + + + + + + + + + + + + + + + + + + *:* + + + diff --git a/sample/solr-parquet-spark/src/test/resources/solr/collection1/conf/stopwords.txt b/sample/solr-parquet-spark/src/test/resources/solr/collection1/conf/stopwords.txt new file mode 100644 index 00000000..ae1e83ee --- /dev/null +++ b/sample/solr-parquet-spark/src/test/resources/solr/collection1/conf/stopwords.txt @@ -0,0 +1,14 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You 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. diff --git a/sample/solr-parquet-spark/src/test/resources/solr/collection1/conf/synonyms.txt b/sample/solr-parquet-spark/src/test/resources/solr/collection1/conf/synonyms.txt new file mode 100644 index 00000000..7f721283 --- /dev/null +++ b/sample/solr-parquet-spark/src/test/resources/solr/collection1/conf/synonyms.txt @@ -0,0 +1,29 @@ +# The ASF licenses this file to You 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. + +#----------------------------------------------------------------------- +#some test synonym mappings unlikely to appear in real input text +aaafoo => aaabar +bbbfoo => bbbfoo bbbbar +cccfoo => cccbar cccbaz +fooaaa,baraaa,bazaaa + +# Some synonym groups specific to this example +GB,gib,gigabyte,gigabytes +MB,mib,megabyte,megabytes +Television, Televisions, TV, TVs +#notice we use "gib" instead of "GiB" so any WordDelimiterFilter coming +#after us won't split it into two words. + +# Synonym mappings can be used for spelling correction too +pixima => pixma + diff --git a/sample/solr-parquet-spark/src/test/resources/solr/collection1/core.properties b/sample/solr-parquet-spark/src/test/resources/solr/collection1/core.properties new file mode 100644 index 00000000..2d3491d9 --- /dev/null +++ b/sample/solr-parquet-spark/src/test/resources/solr/collection1/core.properties @@ -0,0 +1,5 @@ +numShards=1 +name=collection1_shard1_replica1 +shard=shard1 +collection=collection1 +coreNodeName=core_node1 diff --git a/sample/solr-parquet-spark/src/test/resources/solr/solr.xml b/sample/solr-parquet-spark/src/test/resources/solr/solr.xml new file mode 100644 index 00000000..6e835c9d --- /dev/null +++ b/sample/solr-parquet-spark/src/test/resources/solr/solr.xml @@ -0,0 +1,45 @@ + + + + + + + + + ${host:} + ${jetty.port:8983} + ${hostContext:solr} + ${zkClientTimeout:15000} + ${genericCoreNodeNames:true} + + + + ${socketTimeout:0} + ${connTimeout:0} + + + \ No newline at end of file diff --git a/sample/solr-parquet-spark/src/test/resources/test.csv b/sample/solr-parquet-spark/src/test/resources/test.csv index 47ede0f1..7ebf9617 100644 --- a/sample/solr-parquet-spark/src/test/resources/test.csv +++ b/sample/solr-parquet-spark/src/test/resources/test.csv @@ -1,3 +1,4 @@ -1;value1 -2;value2 -3;value3 \ No newline at end of file +id,value +1,value1 +2,value2 +3,value3 \ No newline at end of file diff --git a/sample/spark-streaming-cassandra/pom.xml b/sample/spark-streaming-cassandra/pom.xml index f30e2613..08b13ea9 100644 --- a/sample/spark-streaming-cassandra/pom.xml +++ b/sample/spark-streaming-cassandra/pom.xml @@ -5,7 +5,7 @@ sample fr.jetoile.hadoop - 1.6-SNAPSHOT + 2.0-SNAPSHOT 4.0.0 @@ -91,4 +91,70 @@ + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + **/*IntegrationTest.java + + + + + integration-test + + test + + integration-test + + + none + + + **/*IntegrationTest.java + + + + + + + + hadoop-unit-maven-plugin + fr.jetoile.hadoop + ${hadoop-unit.version} + + + start + + embedded-start + + pre-integration-test + + + + /home/khanh/.m2/repository + https://repo.maven.apache.org/maven2/ + + + ZOOKEEPER + fr.jetoile.hadoop:hadoop-unit-zookeeper:${hadoop-unit.version} + + + KAFKA + fr.jetoile.hadoop:hadoop-unit-kafka:${hadoop-unit.version} + + + CASSANDRA + fr.jetoile.hadoop:hadoop-unit-cassandra:${hadoop-unit.version} + + + + + + + + \ No newline at end of file diff --git a/sample/spark-streaming-cassandra/src/test/java/fr/jetoile/hadoopunit/sample/SparkKafkaIntegrationTest.java b/sample/spark-streaming-cassandra/src/test/java/fr/jetoile/hadoopunit/sample/SparkKafkaIntegrationIntegrationTest.java similarity index 98% rename from sample/spark-streaming-cassandra/src/test/java/fr/jetoile/hadoopunit/sample/SparkKafkaIntegrationTest.java rename to sample/spark-streaming-cassandra/src/test/java/fr/jetoile/hadoopunit/sample/SparkKafkaIntegrationIntegrationTest.java index 34d8bc50..63c4a567 100644 --- a/sample/spark-streaming-cassandra/src/test/java/fr/jetoile/hadoopunit/sample/SparkKafkaIntegrationTest.java +++ b/sample/spark-streaming-cassandra/src/test/java/fr/jetoile/hadoopunit/sample/SparkKafkaIntegrationIntegrationTest.java @@ -23,12 +23,11 @@ import java.util.List; import java.util.concurrent.ThreadLocalRandom; -@Ignore -public class SparkKafkaIntegrationTest { +public class SparkKafkaIntegrationIntegrationTest { private static Configuration configuration; - private static final Logger LOGGER = LoggerFactory.getLogger(SparkKafkaIntegrationTest.class); + private static final Logger LOGGER = LoggerFactory.getLogger(SparkKafkaIntegrationIntegrationTest.class); private static final FastDateFormat DATE_FORMATTER = FastDateFormat.getInstance("MM/dd/yyyy HH:mm:ss.SSS");