All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.nervousync.cache.config.CacheConfig Maven / Gradle / Ivy

/*
 * Licensed to the Nervousync Studio (NSYC) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF 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.nervousync.cache.config;

import java.util.ArrayList;
import java.util.List;

import jakarta.xml.bind.annotation.*;

import org.nervousync.beans.core.BeanObject;
import org.nervousync.cache.commons.CacheGlobals;
import org.nervousync.commons.core.Globals;

/**
 * Cache server configure
 *
 * @author Steven Wee	[email protected]
 * @version $Revision : 1.0 $ $Date: Apr 25, 2017 3:09:14 PM $
 */
@XmlType(name = "cache_config", namespace = "https://cache.nervousync.org/configure")
@XmlRootElement(name = "cache_config", namespace = "https://cache.nervousync.org/configure")
@XmlAccessorType(XmlAccessType.NONE)
public final class CacheConfig extends BeanObject {

	/**
	 * 
	 */
	private static final long serialVersionUID = -6700233652090948759L;

	/**
	 * Cache provider name
	 * 缓存适配器名称
	 */
	@XmlElement(name = "provider_name")
	private String providerName                    = Globals.DEFAULT_VALUE_STRING;
	/**
	 * Secure name
	 * 安全配置名称
	 */
	@XmlElement(name = "secure_name")
	private String secureName					   = Globals.DEFAULT_VALUE_STRING;
	/**
	 * Connect timeout
	 * 连接超时时间
	 */
	@XmlElement(name = "connect_timeout")
	private int connectTimeout						= CacheGlobals.DEFAULT_CONNECTION_TIMEOUT;
	/**
	 * Connect retry count
	 * 连接超时重试次数
	 */
	@XmlElement(name = "retry_count")
	private int retryCount                          = CacheGlobals.DEFAULT_RETRY_COUNT;
	/**
	 * Default expire time
	 * 默认过期时间
	 */
	@XmlElement(name = "expire_time")
	private int expireTime							= CacheGlobals.DEFAULT_EXPIRE_TIME;
	/**
	 * Client pool size
	 * 连接池大小
	 */
	@XmlElement(name = "client_pool_size")
	private int clientPoolSize						= CacheGlobals.DEFAULT_CLIENT_POOL_SIZE;
	/**
	 * Limit size of generated client instance
	 * 客户端实例阈值
	 */
	@XmlElement(name = "maximum_client")
	private int maximumClient						= CacheGlobals.DEFAULT_MAXIMUM_CLIENT;
	/**
	 * Authenticate username
	 */
	@XmlElement(name = "username")
	private String userName = Globals.DEFAULT_VALUE_STRING;
	/**
	 * Authenticate password
	 */
	@XmlElement(name = "password")
	private String passWord = Globals.DEFAULT_VALUE_STRING;
	/**
	 * Cache server list
	 * 缓存服务器列表
	 */
	@XmlElementWrapper(name = "server_config_list")
	@XmlElement(name = "server_config")
	private List serverConfigList;

	/**
	 * Instantiates a new Cache config.
	 */
	public CacheConfig() {
		this.serverConfigList = new ArrayList<>();
	}

	/**
	 * 

Retrieve cache provider name

*

读取缓存适配器名称

* * @return Cache provider name * 缓存适配器名称 */ public String getProviderName() { return providerName; } /** *

Configure cache provider

*

设置缓存适配器

* * @param providerName Cache provider name * 缓存适配器名称 */ public void setProviderName(String providerName) { this.providerName = providerName; } /** *

Retrieve secure name

*

读取用于保护密码的安全配置名称

* * @return Secure name * 安全配置名称 */ public String getSecureName() { return secureName; } /** *

Configure secure name for protect password

*

设置用于保护密码的安全配置名称

* * @param secureName Secure name * 安全配置名称 */ public void setSecureName(String secureName) { this.secureName = secureName; } /** *

Retrieve cache server authorization username

*

获取缓存服务器的用户名

* * @return Cache server username * 缓存服务器用户名 */ public String getUserName() { return userName; } /** *

Configure cache server authorization username

*

设置缓存服务器的用户名

* * @param userName Cache server username * 缓存服务器用户名 */ public void setUserName(String userName) { this.userName = userName; } /** *

Retrieve cache server authorization password

*

获取缓存服务器的密码

* * @return Cache server password * 缓存服务器密码 */ public String getPassWord() { return passWord; } /** *

Configure cache server authorization password

*

设置缓存服务器的密码

* * @param passWord Cache server password * 缓存服务器密码 */ public void setPassWord(String passWord) { this.passWord = passWord; } /** *

Retrieve cache server config list

*

读取缓存服务器列表

* * @return Cache server list * 缓存服务器列表 */ public List getServerConfigList() { return serverConfigList; } /** *

Configure cache server config list

*

设置缓存服务器列表

* * @param serverConfigList Cache server list * 缓存服务器列表 */ public void setServerConfigList(List serverConfigList) { this.serverConfigList = serverConfigList; } /** *

Retrieve server connect timeout

*

读取缓存服务器的连接超时时间

* * @return Connect timeout * 连接超时时间 */ public int getConnectTimeout() { return connectTimeout; } /** *

Configure server connect timeout

*

设置缓存服务器的连接超时时间

* * @param connectTimeout Connect timeout * 连接超时时间 */ public void setConnectTimeout(int connectTimeout) { this.connectTimeout = connectTimeout; } /** *

Retrieve server connect retry count

*

读取缓存服务器的连接超时重试次数

* * @return Connect retry count * 连接超时重试次数 */ public int getRetryCount() { return retryCount; } /** *

Configure server connect retry count

*

设置缓存服务器的连接超时时间

* * @param retryCount Connect retry count * 连接超时重试次数 */ public void setRetryCount(int retryCount) { this.retryCount = retryCount; } /** *

Retrieve default expire time

*

读取缓存的默认过期时间

* * @return Default expire time * 默认过期时间 */ public int getExpireTime() { return expireTime; } /** *

Configure default expire time, setting -1 for never expire

*

设置缓存的默认过期时间,设置为-1则永不过期

* * @param expireTime Default expire time * 默认过期时间 */ public void setExpireTime(int expireTime) { this.expireTime = expireTime; } /** *

Retrieve connect client pool size

*

读取客户端连接池的大小

* * @return Client pool size * 连接池大小 */ public int getClientPoolSize() { return clientPoolSize; } /** *

Configure connect client pool size

*

设置客户端连接池的大小

* * @param clientPoolSize Client pool size * 连接池大小 */ public void setClientPoolSize(int clientPoolSize) { this.clientPoolSize = clientPoolSize; } /** *

Retrieve limit size of generated client instance

*

读取允许创建的客户端实例阈值

* * @return Limit size of generated client instance * 客户端实例阈值 */ public int getMaximumClient() { return maximumClient; } /** *

Configure limit size of generated client instance

*

设置允许创建的客户端实例阈值

* * @param maximumClient Limit size of generated client instance * 客户端实例阈值 */ public void setMaximumClient(int maximumClient) { this.maximumClient = maximumClient; } @XmlType(name = "cache_server") @XmlRootElement(name = "cache_server") @XmlAccessorType(XmlAccessType.NONE) public static final class CacheServer extends BeanObject { /** * */ private static final long serialVersionUID = -9179968915973853412L; /** * Server address */ @XmlElement(name = "server_address") private String serverAddress; /** * Server port number */ @XmlElement(name = "server_port") private int serverPort; /** * Server weight */ @XmlElement(name = "server_weight") private int serverWeight; /** * Is read only status */ @XmlElement(name = "read_only") private boolean readOnly = Boolean.FALSE; /** *

Default constructor

*

默认构造方法

*/ public CacheServer() { this.serverAddress = Globals.DEFAULT_VALUE_STRING; this.serverPort = Globals.DEFAULT_VALUE_INT; this.serverWeight = CacheGlobals.DEFAULT_CACHE_SERVER_WEIGHT; } /** *

Match given server address/port is same as current config information

*

比对指定的服务器地址/端口是否与当前配置信息一致

* * @param serverAddress Cache server address * 缓存服务器地址 * @param serverPort Cache server port * 缓存服务器端口号 * @return Match result * 比对结果 */ public boolean match(String serverAddress, int serverPort) { return (this.serverAddress.equalsIgnoreCase(serverAddress) && this.serverPort == serverPort); } /** *

Retrieve cache server address

*

读取缓存服务器地址

* * @return Cache server address * 缓存服务器地址 */ public String getServerAddress() { return serverAddress; } /** *

Configure cache server address

*

设置缓存服务器地址

* * @param serverAddress Cache server address * 缓存服务器地址 */ public void setServerAddress(String serverAddress) { this.serverAddress = serverAddress; } /** *

Retrieve cache server port

*

读取缓存服务器端口号

* * @return Cache server port * 缓存服务器端口号 */ public int getServerPort() { return serverPort; } /** *

Configure cache server port

*

设置缓存服务器端口

* * @param serverPort Cache server port * 缓存服务器端口号 */ public void setServerPort(int serverPort) { this.serverPort = serverPort; } /** *

Retrieve cache server weight

*

获取缓存服务器权重值

* * @return Cache server weight * 缓存服务器权重值 */ public int getServerWeight() { return serverWeight; } /** *

Configure cache server weight

*

设置缓存服务器权重值

* * @param serverWeight Cache server weight * 缓存服务器权重值 */ public void setServerWeight(int serverWeight) { this.serverWeight = serverWeight; } /** *

Retrieve cache server read only status

*

获取缓存服务器只读状态

* * @return Cache server read only status * 缓存服务器只读状态 */ public boolean isReadOnly() { return readOnly; } /** *

Configure cache server read only status

*

设置缓存服务器只读状态

* * @param readOnly Cache server read only status * 缓存服务器只读状态 */ public void setReadOnly(boolean readOnly) { this.readOnly = readOnly; } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy