Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
9444a25d
Commit
9444a25d
authored
Mar 18, 2015
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.2.x'
parents
8d89f8fc
0a38b9b3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
14 deletions
+33
-14
ElasticsearchAutoConfiguration.java
...nfigure/elasticsearch/ElasticsearchAutoConfiguration.java
+13
-4
ElasticsearchProperties.java
.../autoconfigure/elasticsearch/ElasticsearchProperties.java
+9
-6
ElasticsearchAutoConfigurationTests.java
...re/elasticsearch/ElasticsearchAutoConfigurationTests.java
+10
-3
appendix-application-properties.adoc
...cs/src/main/asciidoc/appendix-application-properties.adoc
+1
-1
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/ElasticsearchAutoConfiguration.java
View file @
9444a25d
...
@@ -16,6 +16,8 @@
...
@@ -16,6 +16,8 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
elasticsearch
;
package
org
.
springframework
.
boot
.
autoconfigure
.
elasticsearch
;
import
java.util.Properties
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.apache.commons.logging.LogFactory
;
import
org.elasticsearch.client.Client
;
import
org.elasticsearch.client.Client
;
...
@@ -75,8 +77,9 @@ public class ElasticsearchAutoConfiguration implements DisposableBean {
...
@@ -75,8 +77,9 @@ public class ElasticsearchAutoConfiguration implements DisposableBean {
}
}
private
Client
createNodeClient
()
throws
Exception
{
private
Client
createNodeClient
()
throws
Exception
{
ImmutableSettings
.
Builder
settings
=
ImmutableSettings
.
settingsBuilder
().
put
(
ImmutableSettings
.
Builder
settings
=
ImmutableSettings
.
settingsBuilder
()
"http.enabled"
,
String
.
valueOf
(
false
));
.
put
(
"http.enabled"
,
String
.
valueOf
(
false
))
.
put
(
this
.
properties
.
getProperties
());
Node
node
=
new
NodeBuilder
().
settings
(
settings
)
Node
node
=
new
NodeBuilder
().
settings
(
settings
)
.
clusterName
(
this
.
properties
.
getClusterName
()).
local
(
true
).
node
();
.
clusterName
(
this
.
properties
.
getClusterName
()).
local
(
true
).
node
();
this
.
releasable
=
node
;
this
.
releasable
=
node
;
...
@@ -85,15 +88,21 @@ public class ElasticsearchAutoConfiguration implements DisposableBean {
...
@@ -85,15 +88,21 @@ public class ElasticsearchAutoConfiguration implements DisposableBean {
private
Client
createTransportClient
()
throws
Exception
{
private
Client
createTransportClient
()
throws
Exception
{
TransportClientFactoryBean
factory
=
new
TransportClientFactoryBean
();
TransportClientFactoryBean
factory
=
new
TransportClientFactoryBean
();
factory
.
setClusterName
(
this
.
properties
.
getClusterName
());
factory
.
setClusterNodes
(
this
.
properties
.
getClusterNodes
());
factory
.
setClusterNodes
(
this
.
properties
.
getClusterNodes
());
factory
.
set
ClientTransportSniff
(
this
.
properties
.
getClientTransportSniff
());
factory
.
set
Properties
(
createProperties
());
factory
.
afterPropertiesSet
();
factory
.
afterPropertiesSet
();
TransportClient
client
=
factory
.
getObject
();
TransportClient
client
=
factory
.
getObject
();
this
.
releasable
=
client
;
this
.
releasable
=
client
;
return
client
;
return
client
;
}
}
private
Properties
createProperties
()
{
Properties
properties
=
new
Properties
();
properties
.
put
(
"cluster.name"
,
this
.
properties
.
getClusterName
());
properties
.
putAll
(
this
.
properties
.
getProperties
());
return
properties
;
}
@Override
@Override
public
void
destroy
()
throws
Exception
{
public
void
destroy
()
throws
Exception
{
if
(
this
.
releasable
!=
null
)
{
if
(
this
.
releasable
!=
null
)
{
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/ElasticsearchProperties.java
View file @
9444a25d
...
@@ -16,6 +16,9 @@
...
@@ -16,6 +16,9 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
elasticsearch
;
package
org
.
springframework
.
boot
.
autoconfigure
.
elasticsearch
;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
/**
/**
...
@@ -40,9 +43,9 @@ public class ElasticsearchProperties {
...
@@ -40,9 +43,9 @@ public class ElasticsearchProperties {
private
String
clusterNodes
;
private
String
clusterNodes
;
/**
/**
* A
llow the client to sniff for other members of the cluster.
* A
dditional properties used to configure the client
*/
*/
private
boolean
clientTransportSniff
=
true
;
private
Map
<
String
,
String
>
properties
=
new
HashMap
<
String
,
String
>()
;
public
String
getClusterName
()
{
public
String
getClusterName
()
{
return
this
.
clusterName
;
return
this
.
clusterName
;
...
@@ -60,12 +63,12 @@ public class ElasticsearchProperties {
...
@@ -60,12 +63,12 @@ public class ElasticsearchProperties {
this
.
clusterNodes
=
clusterNodes
;
this
.
clusterNodes
=
clusterNodes
;
}
}
public
boolean
getClientTransportSniff
()
{
public
Map
<
String
,
String
>
getProperties
()
{
return
this
.
clientTransportSniff
;
return
this
.
properties
;
}
}
public
void
set
ClientTransportSniff
(
boolean
clientTransportSniff
)
{
public
void
set
Properties
(
Map
<
String
,
String
>
properties
)
{
this
.
clientTransportSniff
=
clientTransportSniff
;
this
.
properties
=
properties
;
}
}
}
}
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/elasticsearch/ElasticsearchAutoConfigurationTests.java
View file @
9444a25d
...
@@ -27,7 +27,9 @@ import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfigurati
...
@@ -27,7 +27,9 @@ import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfigurati
import
org.springframework.boot.test.EnvironmentTestUtils
;
import
org.springframework.boot.test.EnvironmentTestUtils
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
static
org
.
hamcrest
.
Matchers
.
equalTo
;
import
static
org
.
hamcrest
.
Matchers
.
instanceOf
;
import
static
org
.
hamcrest
.
Matchers
.
instanceOf
;
import
static
org
.
hamcrest
.
Matchers
.
is
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
static
org
.
junit
.
Assert
.
assertThat
;
...
@@ -52,11 +54,16 @@ public class ElasticsearchAutoConfigurationTests {
...
@@ -52,11 +54,16 @@ public class ElasticsearchAutoConfigurationTests {
@Test
@Test
public
void
createNodeClient
()
{
public
void
createNodeClient
()
{
this
.
context
=
new
AnnotationConfigApplicationContext
(
this
.
context
=
new
AnnotationConfigApplicationContext
();
PropertyPlaceholderAutoConfiguration
.
class
,
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.data.elasticsearch.properties.foo.bar:baz"
);
this
.
context
.
register
(
PropertyPlaceholderAutoConfiguration
.
class
,
ElasticsearchAutoConfiguration
.
class
);
ElasticsearchAutoConfiguration
.
class
);
this
.
context
.
refresh
();
assertEquals
(
1
,
this
.
context
.
getBeanNamesForType
(
Client
.
class
).
length
);
assertEquals
(
1
,
this
.
context
.
getBeanNamesForType
(
Client
.
class
).
length
);
assertThat
(
this
.
context
.
getBean
(
Client
.
class
),
instanceOf
(
NodeClient
.
class
));
Client
client
=
this
.
context
.
getBean
(
Client
.
class
);
assertThat
(
client
,
instanceOf
(
NodeClient
.
class
));
assertThat
(((
NodeClient
)
client
).
settings
().
get
(
"foo.bar"
),
is
(
equalTo
(
"baz"
)));
}
}
@Test
@Test
...
...
spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc
View file @
9444a25d
...
@@ -349,9 +349,9 @@ content into your application; rather pick only the properties that you need.
...
@@ -349,9 +349,9 @@ content into your application; rather pick only the properties that you need.
spring.data.solr.repositories.enabled=true # if spring data repository support is enabled
spring.data.solr.repositories.enabled=true # if spring data repository support is enabled
# ELASTICSEARCH ({sc-spring-boot-autoconfigure}/elasticsearch/ElasticsearchProperties.{sc-ext}[ElasticsearchProperties])
# ELASTICSEARCH ({sc-spring-boot-autoconfigure}/elasticsearch/ElasticsearchProperties.{sc-ext}[ElasticsearchProperties])
spring.data.elasticsearch.client-transport-sniff=true # Allow the client to sniff for other members of the cluster
spring.data.elasticsearch.cluster-name= # The cluster name (defaults to elasticsearch)
spring.data.elasticsearch.cluster-name= # The cluster name (defaults to elasticsearch)
spring.data.elasticsearch.cluster-nodes= # The address(es) of the server node (comma-separated; if not specified starts a client node)
spring.data.elasticsearch.cluster-nodes= # The address(es) of the server node (comma-separated; if not specified starts a client node)
spring.data.elasticsearch.properties.*= # Additional properties used to configure the client
spring.data.elasticsearch.repositories.enabled=true # if spring data repository support is enabled
spring.data.elasticsearch.repositories.enabled=true # if spring data repository support is enabled
# DATA REST ({spring-data-rest-javadoc}/core/config/RepositoryRestConfiguration.{dc-ext}[RepositoryRestConfiguration])
# DATA REST ({spring-data-rest-javadoc}/core/config/RepositoryRestConfiguration.{dc-ext}[RepositoryRestConfiguration])
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment