001/* 002 * (C) Copyright 2014 Nuxeo SA (http://nuxeo.com/) and contributors. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl-2.1.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014 * Contributors: 015 * bdelbosc 016 */ 017 018package org.nuxeo.elasticsearch.config; 019 020import java.io.Serializable; 021 022import org.nuxeo.common.xmap.annotation.XNode; 023import org.nuxeo.common.xmap.annotation.XObject; 024 025/** 026 * XMap descriptor to configure a remote Elasticsearch connection 027 */ 028@XObject(value = "elasticSearchRemote") 029public class ElasticSearchRemoteConfig implements Serializable { 030 031 private static final long serialVersionUID = 1L; 032 033 @XNode("@enabled") 034 protected boolean isEnabled = true; 035 036 @XNode("@clusterName") 037 protected String clusterName; 038 039 @XNode("@addressList") 040 protected String addressList; 041 042 @XNode("@clientTransportSniff") 043 protected boolean clientTransportSniff = false; 044 045 @XNode("@clientTransportIgnoreClusterName") 046 protected boolean clientTransportIgnoreClusterName = false; 047 048 @XNode("@clientTransportPingTimeout") 049 protected String clientTransportPingTimeout = "5s"; 050 051 @XNode("@clientTransportNodesSamplerInterval") 052 protected String clientTransportNodesSamplerInterval = "5s"; 053 054 public String getClusterName() { 055 return clusterName; 056 } 057 058 public void setClusterName(String clusterName) { 059 this.clusterName = clusterName; 060 } 061 062 public String[] getAddresses() { 063 if (addressList != null) { 064 return addressList.split(","); 065 } 066 return null; 067 } 068 069 public boolean isIgnoreClusterName() { 070 return clientTransportIgnoreClusterName; 071 } 072 073 public boolean isClusterSniff() { 074 return clientTransportSniff; 075 } 076 077 public String getPingTimeout() { 078 return clientTransportPingTimeout; 079 } 080 081 public String getSamplerInterval() { 082 return clientTransportNodesSamplerInterval; 083 } 084 085 public boolean isEnabled() { 086 return isEnabled; 087 } 088 089 public void setEnabled(boolean isEnabled) { 090 this.isEnabled = isEnabled; 091 } 092 093 @Override 094 public String toString() { 095 if (isEnabled()) { 096 return String.format("EsRemoteConfig(%s, [%s])", getClusterName(), addressList); 097 } 098 return "EsRemoteConfig disabled"; 099 } 100}