mirror of
https://github.com/spring-projects/spring-data-elasticsearch.git
synced 2025-07-08 11:32:45 +00:00
Cluster Name config in Transport Client
This commit is contained in:
parent
af97fdb7d4
commit
b421cb5044
@ -41,6 +41,9 @@ public class TransportClientFactoryBean implements FactoryBean<TransportClient>,
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(TransportClientFactoryBean.class);
|
||||
private String clusterNodes;
|
||||
private String clusterName;
|
||||
private Boolean enableHttp;
|
||||
private Boolean clientTransportSniff;
|
||||
private TransportClient client;
|
||||
private Properties properties;
|
||||
static final String COLON = ":";
|
||||
@ -96,13 +99,29 @@ public class TransportClientFactoryBean implements FactoryBean<TransportClient>,
|
||||
if (properties != null) {
|
||||
return settingsBuilder().put(properties).build();
|
||||
}
|
||||
return settingsBuilder().put("client.transport.sniff", true).build();
|
||||
return settingsBuilder()
|
||||
.put("cluster.name", clusterName)
|
||||
.put("client.transport.sniff", clientTransportSniff)
|
||||
.put("http.enabled", enableHttp)
|
||||
.build();
|
||||
}
|
||||
|
||||
public void setClusterNodes(String clusterNodes) {
|
||||
this.clusterNodes = clusterNodes;
|
||||
}
|
||||
|
||||
public void setClusterName(String clusterName) {
|
||||
this.clusterName = clusterName;
|
||||
}
|
||||
|
||||
public void setEnableHttp(Boolean enableHttp) {
|
||||
this.enableHttp = enableHttp;
|
||||
}
|
||||
|
||||
public void setClientTransportSniff(Boolean clientTransportSniff) {
|
||||
this.clientTransportSniff = clientTransportSniff;
|
||||
}
|
||||
|
||||
public void setProperties(Properties properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
@ -42,6 +42,9 @@ public class TransportClientBeanDefinitionParser extends AbstractBeanDefinitionP
|
||||
|
||||
private void setClusterNodes(Element element, BeanDefinitionBuilder builder) {
|
||||
builder.addPropertyValue("clusterNodes", element.getAttribute("cluster-nodes"));
|
||||
builder.addPropertyValue("clusterName", element.getAttribute("cluster-name"));
|
||||
builder.addPropertyValue("enableHttp", Boolean.valueOf(element.getAttribute("http-enabled")));
|
||||
builder.addPropertyValue("clientTransportSniff", Boolean.valueOf(element.getAttribute("client-transport-sniff")));
|
||||
}
|
||||
|
||||
private AbstractBeanDefinition getSourcedBeanDefinition(BeanDefinitionBuilder builder, Element source,
|
||||
|
@ -44,9 +44,21 @@
|
||||
<xsd:complexType>
|
||||
<xsd:complexContent>
|
||||
<xsd:extension base="beans:identifiedType">
|
||||
<xsd:attribute name="local" type="xsd:boolean" default="false"/>
|
||||
<xsd:attribute name="cluster-name" type="xsd:string" default="elasticsearch"/>
|
||||
<xsd:attribute name="http-enabled" type="xsd:boolean" default="true"/>
|
||||
<xsd:attribute name="local" type="xsd:boolean" default="false">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[local here means local on the JVM (well, actually class loader) level, meaning that two local servers started within the same JVM will discover themselves and form a cluster]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="cluster-name" type="xsd:string" default="elasticsearch">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[Name of the cluster in which this instance of node client will connect to]]> </xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="http-enabled" type="xsd:boolean" default="true">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[to enable or desable http port]]> </xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
</xsd:extension>
|
||||
</xsd:complexContent>
|
||||
</xsd:complexType>
|
||||
@ -67,6 +79,21 @@
|
||||
<xsd:documentation><![CDATA[The comma delimited list of host:port entries to use for elasticsearch cluster.]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="cluster-name" type="xsd:string" default="elasticsearch">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[Name of the cluster in which this instance of node client will connect to]]> </xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="http-enabled" type="xsd:boolean" default="true">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[to enable or desable http port]]> </xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="client-transport-sniff" type="xsd:boolean" default="true">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[The client allows to sniff the rest of the cluster, and add those into its list of machines to use.]]> </xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
</xsd:extension>
|
||||
</xsd:complexContent>
|
||||
</xsd:complexType>
|
||||
|
Loading…
x
Reference in New Issue
Block a user