001/* 002 * Copyright 2012-2018 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.boot.autoconfigure.couchbase; 018 019import java.time.Duration; 020import java.util.List; 021 022import org.springframework.boot.context.properties.ConfigurationProperties; 023import org.springframework.util.StringUtils; 024 025/** 026 * Configuration properties for Couchbase. 027 * 028 * @author EddĂș MelĂ©ndez 029 * @author Stephane Nicoll 030 * @author Yulin Qin 031 * @since 1.4.0 032 */ 033@ConfigurationProperties(prefix = "spring.couchbase") 034public class CouchbaseProperties { 035 036 /** 037 * Couchbase nodes (host or IP address) to bootstrap from. 038 */ 039 private List<String> bootstrapHosts; 040 041 private final Bucket bucket = new Bucket(); 042 043 private final Env env = new Env(); 044 045 public List<String> getBootstrapHosts() { 046 return this.bootstrapHosts; 047 } 048 049 public void setBootstrapHosts(List<String> bootstrapHosts) { 050 this.bootstrapHosts = bootstrapHosts; 051 } 052 053 public Bucket getBucket() { 054 return this.bucket; 055 } 056 057 public Env getEnv() { 058 return this.env; 059 } 060 061 public static class Bucket { 062 063 /** 064 * Name of the bucket to connect to. 065 */ 066 private String name = "default"; 067 068 /** 069 * Password of the bucket. 070 */ 071 private String password = ""; 072 073 public String getName() { 074 return this.name; 075 } 076 077 public void setName(String name) { 078 this.name = name; 079 } 080 081 public String getPassword() { 082 return this.password; 083 } 084 085 public void setPassword(String password) { 086 this.password = password; 087 } 088 089 } 090 091 public static class Env { 092 093 private final Endpoints endpoints = new Endpoints(); 094 095 private final Ssl ssl = new Ssl(); 096 097 private final Timeouts timeouts = new Timeouts(); 098 099 public Endpoints getEndpoints() { 100 return this.endpoints; 101 } 102 103 public Ssl getSsl() { 104 return this.ssl; 105 } 106 107 public Timeouts getTimeouts() { 108 return this.timeouts; 109 } 110 111 } 112 113 public static class Endpoints { 114 115 /** 116 * Number of sockets per node against the key/value service. 117 */ 118 private int keyValue = 1; 119 120 /** 121 * Query (N1QL) service configuration. 122 */ 123 private final CouchbaseService queryservice = new CouchbaseService(); 124 125 /** 126 * View service configuration. 127 */ 128 private final CouchbaseService viewservice = new CouchbaseService(); 129 130 public int getKeyValue() { 131 return this.keyValue; 132 } 133 134 public void setKeyValue(int keyValue) { 135 this.keyValue = keyValue; 136 } 137 138 public CouchbaseService getQueryservice() { 139 return this.queryservice; 140 } 141 142 public CouchbaseService getViewservice() { 143 return this.viewservice; 144 } 145 146 public static class CouchbaseService { 147 148 /** 149 * Minimum number of sockets per node. 150 */ 151 private int minEndpoints = 1; 152 153 /** 154 * Maximum number of sockets per node. 155 */ 156 private int maxEndpoints = 1; 157 158 public int getMinEndpoints() { 159 return this.minEndpoints; 160 } 161 162 public void setMinEndpoints(int minEndpoints) { 163 this.minEndpoints = minEndpoints; 164 } 165 166 public int getMaxEndpoints() { 167 return this.maxEndpoints; 168 } 169 170 public void setMaxEndpoints(int maxEndpoints) { 171 this.maxEndpoints = maxEndpoints; 172 } 173 174 } 175 176 } 177 178 public static class Ssl { 179 180 /** 181 * Whether to enable SSL support. Enabled automatically if a "keyStore" is 182 * provided unless specified otherwise. 183 */ 184 private Boolean enabled; 185 186 /** 187 * Path to the JVM key store that holds the certificates. 188 */ 189 private String keyStore; 190 191 /** 192 * Password used to access the key store. 193 */ 194 private String keyStorePassword; 195 196 public Boolean getEnabled() { 197 return (this.enabled != null) ? this.enabled 198 : StringUtils.hasText(this.keyStore); 199 } 200 201 public void setEnabled(Boolean enabled) { 202 this.enabled = enabled; 203 } 204 205 public String getKeyStore() { 206 return this.keyStore; 207 } 208 209 public void setKeyStore(String keyStore) { 210 this.keyStore = keyStore; 211 } 212 213 public String getKeyStorePassword() { 214 return this.keyStorePassword; 215 } 216 217 public void setKeyStorePassword(String keyStorePassword) { 218 this.keyStorePassword = keyStorePassword; 219 } 220 221 } 222 223 public static class Timeouts { 224 225 /** 226 * Bucket connections timeouts. 227 */ 228 private Duration connect = Duration.ofMillis(5000); 229 230 /** 231 * Blocking operations performed on a specific key timeout. 232 */ 233 private Duration keyValue = Duration.ofMillis(2500); 234 235 /** 236 * N1QL query operations timeout. 237 */ 238 private Duration query = Duration.ofMillis(7500); 239 240 /** 241 * Socket connect connections timeout. 242 */ 243 private Duration socketConnect = Duration.ofMillis(1000); 244 245 /** 246 * Regular and geospatial view operations timeout. 247 */ 248 private Duration view = Duration.ofMillis(7500); 249 250 public Duration getConnect() { 251 return this.connect; 252 } 253 254 public void setConnect(Duration connect) { 255 this.connect = connect; 256 } 257 258 public Duration getKeyValue() { 259 return this.keyValue; 260 } 261 262 public void setKeyValue(Duration keyValue) { 263 this.keyValue = keyValue; 264 } 265 266 public Duration getQuery() { 267 return this.query; 268 } 269 270 public void setQuery(Duration query) { 271 this.query = query; 272 } 273 274 public Duration getSocketConnect() { 275 return this.socketConnect; 276 } 277 278 public void setSocketConnect(Duration socketConnect) { 279 this.socketConnect = socketConnect; 280 } 281 282 public Duration getView() { 283 return this.view; 284 } 285 286 public void setView(Duration view) { 287 this.view = view; 288 } 289 290 } 291 292}