Skip to content

Add support for Kerberized Elasticsearch #1244

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 207 commits into from
Feb 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
207 commits
Select commit Hold shift + click to select a range
a7174e1
Add MiniKDC fixture.
jbaiera Jul 26, 2018
788905f
Playing with spnego stuff
jbaiera May 14, 2018
3736174
Add MiniKDC fixture to itest instead of test.
jbaiera Jul 31, 2018
5642af9
Add manager for state of Negotiate based authentication.
jbaiera Jul 31, 2018
9e8820f
Handle token data given in the negotiator's send method better.
jbaiera Aug 3, 2018
1d444c5
Add SPNEGO based auth scheme for HTTP Client.
jbaiera Aug 3, 2018
5d9b126
Add suite of Kerberos based tests.
jbaiera Aug 3, 2018
b961b69
Add test case for wrong server principal name
jbaiera Aug 6, 2018
d6f7655
Allow for reverse resolution of host names for use in principal names.
jbaiera Aug 6, 2018
6e2fe2b
Make sure that host specific principals work with the negotiator.
jbaiera Aug 6, 2018
793147c
Bolster the test coverage and clarify some error statements.
jbaiera Aug 7, 2018
805ec98
Add stubs and early classes for Token Authentication.
jbaiera Aug 8, 2018
a0619ea
Add requests to create, refresh, and cancel EsTokens.
jbaiera Aug 9, 2018
6e44239
Discard unneeded class
jbaiera Aug 9, 2018
c478686
Add deserialization code to EsToken.
jbaiera Aug 9, 2018
41576c6
Add token renewer implementation.
jbaiera Aug 9, 2018
ef4ef00
Refactor TokenCredentials to use EsToken.
jbaiera Aug 9, 2018
eaddc1b
Prefix TokenAuthScheme and TokenCredentialProvider with ES.
jbaiera Aug 9, 2018
7b27c39
Remove prototyping class.
jbaiera Aug 10, 2018
7bd31bc
Add service loader entry for EsTokenIdentifier.
jbaiera Aug 10, 2018
c802ea5
Wrap the usage of UGI in the connector.
jbaiera Aug 10, 2018
5d25afb
Add a service name for Hadoop tokens
jbaiera Aug 10, 2018
b07d66a
Add user provider registration all over the place.
jbaiera Aug 14, 2018
b2e52a1
Fix comment tags
jbaiera Aug 14, 2018
3888232
Missed a few spots that should register the user provider.
jbaiera Aug 14, 2018
11d8546
Never pass null as extra config file for the ES Fixture
jbaiera Aug 16, 2018
58acf0e
Use a configuration to provide the MiniKDC version.
jbaiera Aug 16, 2018
d76cf62
Add an independent MiniKdcFixture to be used with ES.
jbaiera Aug 16, 2018
d08b5c8
Add a QA package for standalone testing.
jbaiera Aug 16, 2018
cb38ccc
Wire up the SPNEGO authentication code to the client.
jbaiera Aug 17, 2018
22d21ab
Enable token authentication on test cluster
jbaiera Aug 20, 2018
e7d84c3
Add base jdk user and user provider classes.
jbaiera Aug 20, 2018
577b3bf
Wire up the token authentication sensing and add basic auth test.
jbaiera Aug 20, 2018
274c268
Add todo item
jbaiera Aug 21, 2018
d865b93
Perform GSS Context cleanup and add mutual auth
jbaiera Aug 28, 2018
0239f9a
Replace token cred provider with regular credential
jbaiera Aug 28, 2018
28c57a1
Always close the auth scheme if it is closeable.
jbaiera Aug 28, 2018
6fc19ff
Add preemptive Token Authentication
jbaiera Aug 29, 2018
53c983c
Remove unneeded setting for user principal
jbaiera Aug 31, 2018
97d9e6f
Remove most uses of remoteClusterVersion in favor of EsAssume
jbaiera Aug 31, 2018
d559f64
Fix EsMajorVersion equals method
jbaiera Aug 31, 2018
25a0d04
Fix a static field in Hadoop that is breaking integration tests.
jbaiera Sep 5, 2018
9a2469f
Discover more cluster information at start up.
jbaiera Sep 5, 2018
64797e5
Use the cluster information in the settings to select ES tokens.
jbaiera Sep 5, 2018
8b68e33
Fix compile errors
jbaiera Sep 6, 2018
e800fff
Add tests for user impls and look up tokens by cluster name in JDK impl
jbaiera Sep 6, 2018
88a361d
Remove default user provider class name.
jbaiera Sep 6, 2018
ca67d6f
More default user provider removal
jbaiera Sep 6, 2018
3df1a0a
Change the token expires-in field to be expire-time.
jbaiera Sep 6, 2018
2c5237a
First pass of standing up an honest Hadoop integration test instance.
jbaiera Sep 18, 2018
d6b1776
Operationalize entire Hadoop cluster fixtures
jbaiera Sep 20, 2018
f2f0c4a
Merge branch 'master' into feature-kerberos
jbaiera Oct 25, 2018
32dfd7e
Ditch the role descriptor inheritance.
jbaiera Oct 25, 2018
633aa43
Move all the configuration objects to a different package.
jbaiera Oct 25, 2018
4b8455e
Have each service descriptor configure its own download.
jbaiera Oct 25, 2018
b8e266d
Add Hiveserver to the list of available services.
jbaiera Oct 30, 2018
ebe8472
First step of removing daemon commands.
jbaiera Oct 31, 2018
46f32f3
Preliminary removal of all daemonizing settings.
jbaiera Oct 31, 2018
702c9ce
Remove package path and distro. Not really needed.
jbaiera Oct 31, 2018
8a25fea
Clean up ApacheMirrorDownload Task
jbaiera Oct 31, 2018
1393386
If VerifyChecksums fails, we should print the discrepancy.
jbaiera Oct 31, 2018
9cbc2a2
Use service conf for download and artifact name
jbaiera Oct 31, 2018
4f7f3d8
Use instance conf for homeDir name
jbaiera Oct 31, 2018
65bf38f
Fix a usage of instance conf for homeDir name
jbaiera Oct 31, 2018
cf72b3c
Allow for gateway roles
jbaiera Oct 31, 2018
cd46fa5
Add the Spark (on YARN) services to the fixture.
jbaiera Oct 31, 2018
9c1dc82
Add the Pig serivce to fixture.
jbaiera Nov 1, 2018
39d1f3b
Add a dummy process for testing cluster startup and teardown
jbaiera Nov 1, 2018
b9c5455
Breakout configuration steps per service
jbaiera Nov 1, 2018
1118a9f
Move HDFS and YARN under the mr package.
jbaiera Nov 1, 2018
773b356
Add a settings container
jbaiera Nov 2, 2018
5a8c51e
Generate settings files using multiple file names
jbaiera Nov 2, 2018
371afeb
Update Version constructors
jbaiera Nov 2, 2018
10fc6a4
Remove HDFS and YARN in favor of just HADOOP
jbaiera Nov 7, 2018
9014a1b
Clean up dead code
jbaiera Nov 7, 2018
426592d
Move ServiceDescriptor impls to services package
jbaiera Nov 7, 2018
cdf9c4a
Drop the base directory from the finalizeEnv call.
jbaiera Nov 8, 2018
87e4604
Add a DfsCopyTask
jbaiera Nov 8, 2018
3b18fe9
Allow getting confs by descriptors.
jbaiera Nov 8, 2018
5344160
Change scriptDir to just use InstanceConfiguration.
jbaiera Nov 8, 2018
64a6ca7
Fix datanode data directory property name
jbaiera Nov 8, 2018
8764a05
More todos
jbaiera Nov 8, 2018
9105fe0
Fix up the DfsCopy task
jbaiera Nov 8, 2018
4932338
Standardize on using the descriptors for configs internally.
jbaiera Nov 8, 2018
fad93b8
Add cluster tasks to the cluster conf
jbaiera Nov 8, 2018
4abe886
Add MapReduceExecTask to the available cluster build tasks
jbaiera Nov 9, 2018
43215be
Add HiveBeeline task to the available cluster build tasks
jbaiera Nov 9, 2018
c3d088c
Rename DfsCopy and HadoopMRJob
jbaiera Nov 10, 2018
4b2e34e
Rename to and from methods on dfs copy
jbaiera Nov 10, 2018
cb4e8c2
Create an abstract cluster task that has a cluster conf in it.
jbaiera Nov 10, 2018
98cc0c9
Add PigScript task to Gradle and test build.
jbaiera Nov 12, 2018
fff6f9e
Update task action names
jbaiera Nov 13, 2018
e4ff054
Add a SparkApp task as part of the available cluster tasks
jbaiera Nov 13, 2018
da8f8dd
Remove ServiceIdentifier, replace with InstanceConfiguration.
jbaiera Nov 13, 2018
b0a59f7
Big cleanup of code and comments
jbaiera Nov 13, 2018
951a5ff
Add a configuration test mr job
jbaiera Nov 14, 2018
0a959dc
Fix role descriptor usages after service identifier removal
jbaiera Nov 14, 2018
2611c18
Add generic job configurations to the MR Job task.
jbaiera Nov 14, 2018
93e541c
Remove original word count program and add an elasticsearch load job
jbaiera Nov 14, 2018
bfa3850
Add a breakout to Elasticsearch's cluster conf
jbaiera Nov 14, 2018
b9fc486
Set tasks as part of a hadoopFixture group
jbaiera Nov 14, 2018
6ce9739
successfully load data from HDFS into ES
jbaiera Nov 14, 2018
4778d99
Version should use canonical file paths to determine jar file paths.
jbaiera Nov 16, 2018
98e1d6f
Spark now loads data to ES successfully
jbaiera Nov 16, 2018
4e30a5a
DFS Copy task should create parent directories on HDFS
jbaiera Nov 16, 2018
b8d0059
Add lib jars to Beeline task.
jbaiera Nov 16, 2018
4a0ae95
Add lib jars to Pig jobs
jbaiera Nov 16, 2018
41df3a5
Add the Pig and Hive tasks back in to load data into ES.
jbaiera Nov 16, 2018
f078bc3
Include the java options in the environment of start up tasks
jbaiera Nov 28, 2018
1c07a11
Make specifying file level settings easier in DSL.
jbaiera Nov 28, 2018
d7dda96
Add ssl-server.xml file to list of configuration files
jbaiera Nov 28, 2018
a0aabe2
Add a throw away keystore to enable SSL startup in Hadoop
jbaiera Nov 28, 2018
b499ea0
Restructure build file with first steps to kerberizing cluster.
jbaiera Nov 28, 2018
661d086
Generify the config closure types to clear gradle warnings.
jbaiera Nov 28, 2018
cdd43fd
Fix up cluster DSL
jbaiera Nov 28, 2018
b58451a
For some reason the token credential class had junit in it.
jbaiera Nov 29, 2018
dc1a363
Kerberize HDFS fixture.
jbaiera Nov 29, 2018
2c27e28
Kerberize Map Reduce load job.
jbaiera Nov 30, 2018
8035302
Kerberize Spark load job.
jbaiera Dec 3, 2018
33695a6
First attempt at Kerberizing Hive.
jbaiera Dec 5, 2018
b062837
Kerberizing Hive continues
jbaiera Dec 6, 2018
c00fabf
Kerberizing Pig
jbaiera Dec 6, 2018
79ae4e1
Move clusterTask methods to ProcessConfiguration class
jbaiera Dec 6, 2018
24b9dd9
Add history server to hadoop roles.
jbaiera Dec 6, 2018
2d42d45
Heavily refactor formation tasks for cluster task changes
jbaiera Dec 6, 2018
70b6927
Add executedOn property to AbstractClusterTask
jbaiera Dec 6, 2018
b5a7261
Add history server configuration to the build file
jbaiera Dec 6, 2018
575e166
Squash some fixme's and todos
jbaiera Dec 6, 2018
6d9ff53
Add TokenUtil class for obtaining and caching tokens for Hadoop.
jbaiera Jan 8, 2019
b4b15a7
Add AuthenticationMethod and new authentication method setting.
jbaiera Jan 9, 2019
a44fc4f
Extend the UserProvider into an abstract class.
jbaiera Jan 9, 2019
d16cb93
Clean up TokenUtil method signatures
jbaiera Jan 9, 2019
d3f50d3
CommonsHttpTransport should respect the new auth setting.
jbaiera Jan 9, 2019
e8f7225
Add getClusterInfoOrNull method to settings.
jbaiera Jan 9, 2019
d560b7e
Add User API for adding credentials to MR jobs.
jbaiera Jan 9, 2019
4c299d3
Fix compilation and runtime errors
jbaiera Jan 10, 2019
6e5c794
Explicitly set the http addresses
jbaiera Jan 10, 2019
93755bb
Add groovy code for waiting on URL's to be available.
jbaiera Jan 11, 2019
33bdf87
Add the ability to get an http URI for testing from ServiceDescriptor.
jbaiera Jan 11, 2019
6ec22eb
Add wait tasks to each hadoop service.
jbaiera Jan 11, 2019
7b90f40
Merge branch 'master' into feature-kerberos
jbaiera Jan 14, 2019
44e7b8c
Get jobs to compile and run again after merge.
jbaiera Jan 14, 2019
4230845
Code cleanup
jbaiera Jan 14, 2019
4d24bde
Add token hand off point to Hive Storage Handler
jbaiera Jan 14, 2019
4830813
Add data retrieval from ES in MR and Spark for testing purposes
jbaiera Jan 14, 2019
3e709bc
Update EsToken with contents of new API Keys
jbaiera Jan 23, 2019
bfbf164
Convert EsTokenAuthScheme to be EsApiKeyAuthScheme
jbaiera Jan 23, 2019
59105b6
Generate key name
jbaiera Jan 23, 2019
a369a08
Fix broken test.
jbaiera Jan 23, 2019
6120939
Add token hand off code to Pig
jbaiera Jan 23, 2019
ee67ed4
Add token hand off code to Spark
jbaiera Jan 24, 2019
e7f499d
Merge branch 'master' into feature-kerberos
jbaiera Jan 25, 2019
14eab8a
Fix compile errors after merge
jbaiera Jan 25, 2019
31ebb73
Add a configuration task that adds role mappings for kerberos principals
jbaiera Jan 25, 2019
5c4ca25
Fix some other compilation errors related to merging master.
jbaiera Jan 28, 2019
6ed68e9
Add ability to get all ES tokens from User
jbaiera Jan 28, 2019
41de1b3
Add test for Token Renewer service loading
jbaiera Jan 28, 2019
6b4d15c
Add token hand off to Cascading.
jbaiera Jan 28, 2019
d141955
Fix field order bug in obtaining EsToken
jbaiera Jan 28, 2019
1c346fd
Fix bug in retrieving auth method from settings.
jbaiera Jan 28, 2019
ffa49a7
Use Spark 2.3.2 in test fixture since 2.3.1 is gone.
jbaiera Jan 28, 2019
b2603ec
Add major version to the EsToken object
jbaiera Jan 28, 2019
a32531c
Add token hand off to test MR jobs.
jbaiera Jan 28, 2019
f961dde
Add major version to EsToken construction
jbaiera Jan 28, 2019
715cf09
Update the token renewer to allow cancelling tokens.
jbaiera Jan 28, 2019
db85633
Add support for Proxy Users
jbaiera Jan 29, 2019
3bdd456
Add the ability to create native users, and proxiers during setup
jbaiera Jan 29, 2019
ea88ae4
Add some debug statements to EsMapReduceUtil
jbaiera Jan 29, 2019
aa96350
Make TokenUtil sensitive to the new Proxy based auth case.
jbaiera Jan 29, 2019
b81b7dc
Update CommonsHttpTransport to allow for proxy based authentication.
jbaiera Jan 29, 2019
059ba64
Update the token retrieval for Hive.
jbaiera Jan 29, 2019
c83898a
Add kerberos settings to the load_to_es hive script.
jbaiera Jan 29, 2019
48f7087
Add toString methods to the User implementations.
jbaiera Jan 30, 2019
195a0fb
Get Spark jobs running with token hand off
jbaiera Jan 30, 2019
596c4ff
Add kerberos settings to pig load job
jbaiera Jan 30, 2019
e17cab4
When executing a request, always wrap it in the current subject.
jbaiera Jan 30, 2019
f3c5802
Discover cluster info during setup of EsStorage functions.
jbaiera Jan 30, 2019
ca93efa
Add hive script to read data back out of ES
jbaiera Jan 30, 2019
b778c87
Add Pig script to read data back out of ES
jbaiera Jan 30, 2019
2ea3abf
Make the KeytabLogin process use a logger instead of prints
jbaiera Jan 30, 2019
31510d7
Enable Kerberos and API Token auth in qa build script.
jbaiera Jan 30, 2019
733897d
Get SPNEGO tests passing again
jbaiera Jan 30, 2019
34478fc
Implement test for SPNEGO to token handoff.
jbaiera Jan 30, 2019
b993afe
Add keytab login to LoginUtil
jbaiera Jan 31, 2019
bc38daf
Move LoginUtil to common security package
jbaiera Jan 31, 2019
b429ab8
Make ClusterInfo et. al. serializable.
jbaiera Jan 31, 2019
5c4effb
Fix failing test
jbaiera Jan 31, 2019
8aaec09
Extend TestSpout so that it can be used more plainly
jbaiera Feb 4, 2019
9aed7e7
Add trace statements to JdkUserProvider
jbaiera Feb 4, 2019
5bd40b8
Discover cluster info in bolt and spout constructors.
jbaiera Feb 4, 2019
084978e
Add a Storm Autocredential implementation for ES
jbaiera Feb 4, 2019
afa6b53
Add integration test load and store jobs for Storm
jbaiera Feb 4, 2019
9773452
Create a testing uber jar for storm on kerberos
jbaiera Feb 4, 2019
a0dc9ac
Set topology tick tuple settings on itest
jbaiera Feb 4, 2019
1aa580c
Consolidate EsBolt constructors
jbaiera Feb 4, 2019
baa8ce9
Remove unused method and todo
jbaiera Feb 4, 2019
e5bc464
Upgrade to Storm 1.0.6
jbaiera Feb 4, 2019
33f82ce
Check renewal time before getting new ES Token in Storm
jbaiera Feb 4, 2019
5e72a4d
Remove todo in AutoElasticsearch.
jbaiera Feb 4, 2019
f12e332
Remove cluster discovery from bolt and spout constructors.
jbaiera Feb 4, 2019
0064f2e
Clarify log statement
jbaiera Feb 4, 2019
8ae4945
Downgrade todo items
jbaiera Feb 4, 2019
76bbeb7
Add user method for initializing credentials for EsTaps.
jbaiera Feb 4, 2019
600d201
Add load and store jobs for Cascading testing on Kerberos
jbaiera Feb 4, 2019
115ed94
Wire up kerberos based tests for Cascading into the qa cluster
jbaiera Feb 4, 2019
9339397
Todo cleanups
jbaiera Feb 5, 2019
582a4c7
build file cleanups and add file output verification tests.
jbaiera Feb 5, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ class BuildPlugin implements Plugin<Project> {
exclude group: "org.elasticsearch", module: "elasticsearch-core"
exclude group: "org.elasticsearch", module: "elasticsearch-secure-sm"
}

testRuntime "org.slf4j:slf4j-log4j12:1.7.6"
testRuntime "org.apache.logging.log4j:log4j-api:${project.ext.log4jVersion}"
testRuntime "org.apache.logging.log4j:log4j-core:${project.ext.log4jVersion}"
Expand All @@ -224,6 +225,11 @@ class BuildPlugin implements Plugin<Project> {
testRuntime "com.vividsolutions:jts:1.13"

// TODO: Remove when we merge ITests to test dirs
itestCompile("org.apache.hadoop:hadoop-minikdc:${project.ext.minikdcVersion}") {
// For some reason, the dependencies that are pulled in with MiniKDC have multiple resource files
// that cause issues when they are loaded. We exclude the ldap schema data jar to get around this.
exclude group: "org.apache.directory.api", module: "api-ldap-schema-data"
}
itestCompile project.sourceSets.main.output
itestCompile project.configurations.testCompile
itestCompile project.configurations.provided
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package org.elasticsearch.hadoop.gradle.fixture

import org.elasticsearch.gradle.BuildPlugin
import org.elasticsearch.gradle.Version
import org.elasticsearch.gradle.test.ClusterConfiguration
import org.elasticsearch.gradle.test.ClusterFormationTasks
import org.elasticsearch.gradle.test.NodeInfo
import org.elasticsearch.hadoop.gradle.util.PlaceholderTask
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.execution.TaskExecutionAdapter
import org.gradle.api.tasks.TaskState
import org.gradle.util.ConfigureUtil

import java.nio.charset.StandardCharsets
import java.nio.file.Files
Expand All @@ -27,6 +28,26 @@ import java.util.stream.Stream
*/
class ElasticsearchFixturePlugin implements Plugin<Project> {

static class ElasticsearchCluster {

Project project
ClusterConfiguration configuration
List<Task> tasks = []

ElasticsearchCluster(Project project) {
this.project = project
this.configuration = new ClusterConfiguration(project)
}

void clusterConf(Closure configClosure) {
ConfigureUtil.configure(configClosure, configuration)
}

void addTask(Task task) {
tasks.add(task)
}
}

@Override
void apply(Project project) {

Expand Down Expand Up @@ -55,7 +76,9 @@ class ElasticsearchFixturePlugin implements Plugin<Project> {
Task clusterInit = project.tasks.create(name: "esCluster#init", dependsOn: project.testClasses)
integrationTest.dependsOn(clusterInit)

ClusterConfiguration clusterConfig = project.extensions.create("esCluster", ClusterConfiguration.class, project)
ElasticsearchCluster cluster = project.extensions.create("esCluster", ElasticsearchCluster.class, project)
cluster.tasks.add(integrationTest)
ClusterConfiguration clusterConfig = cluster.configuration

// default settings:
clusterConfig.clusterName = "elasticsearch-fixture"
Expand Down Expand Up @@ -96,18 +119,21 @@ class ElasticsearchFixturePlugin implements Plugin<Project> {
// Also write a script to a file for use in tests
File scriptsDir = new File(project.buildDir, 'scripts')
scriptsDir.mkdirs()
File script
File script = null
if (majorVersion <= 2) {
scriptsDir.mkdirs()
script = new File(scriptsDir, "increment.groovy").setText("ctx._source.counter+=1", 'UTF-8')
} else if (majorVersion == 5) {
scriptsDir.mkdirs()
script = new File(scriptsDir, "increment.painless").setText("ctx._source.counter = ctx._source.getOrDefault('counter', 0) + 1", 'UTF-8')
}
clusterConfig.extraConfigFile("script", script)
if (script != null) {
clusterConfig.extraConfigFile("script", script)
}

project.gradle.projectsEvaluated {
List<NodeInfo> nodes = ClusterFormationTasks.setup(project, "esCluster", integrationTest, clusterConfig)
Task clusterMain = new PlaceholderTask()
List<NodeInfo> nodes = ClusterFormationTasks.setup(project, "esCluster", clusterMain, clusterConfig)
project.tasks.getByPath("esCluster#wait").doLast {
integrationTest.systemProperty('tests.rest.cluster', "${nodes.collect{it.httpUri()}.join(",")}")
}
Expand All @@ -123,11 +149,19 @@ class ElasticsearchFixturePlugin implements Plugin<Project> {
}
}
}
integrationTest.doFirst {
project.gradle.addListener(logDumpListener)
}
integrationTest.doLast {
project.gradle.removeListener(logDumpListener)
for (Task clusterTask : cluster.tasks) {
for (Object dependency : clusterMain.taskDeps) {
clusterTask.dependsOn(dependency)
}
for (Object finalizer : clusterMain.taskFinalizers) {
clusterTask.finalizedBy(finalizer)
}
clusterTask.doFirst {
project.gradle.addListener(logDumpListener)
}
clusterTask.doLast {
project.gradle.removeListener(logDumpListener)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch 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.
*/

package org.elasticsearch.hadoop.gradle.fixture.hadoop

class ConfigFormats {

static Closure<String> hadoopXML() {
return { Map conf ->
String props = conf.collect { key, value ->
"<property>\n\t\t<name>${key}</name>\n\t\t<value>${value}</value>\n\t</property>"
}.join("\n\t")
return "<configuration>\n\t${props}\n</configuration>"
}
}

static Closure<String> propertyFile() {
return { Map conf ->
conf.collect { key, value ->
"${key}=${value}"
}.join("\n")
}
}

static Closure<String> whiteSpaced() {
return { Map conf ->
conf.collect { key, value ->
"${key} ${value}"
}.join("\n")
}
}
}
Loading