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

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

The newest version!
/*
 * 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 jakarta.xml.bind.annotation.*;
import org.nervousync.beans.core.BeanObject;
import org.nervousync.cache.commons.CacheGlobals;
import org.nervousync.cache.enumeration.ClusterMode;
import org.nervousync.commons.Globals;
import org.nervousync.security.factory.SecureConfig;

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

/**
 * 

Cache configure JavaBean

*

缓存配置JavaBean

* * @author Steven Wee [email protected] * @version $Revision : 1.0 $ $Date: Apr 25, 2017 3:09:14 PM $ */ @XmlType(name = "cache_config", namespace = "https://nervousync.org/schemas/cache") @XmlRootElement(name = "cache_config", namespace = "https://nervousync.org/schemas/cache") @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; /** * Secure config information * 安全配置定义 */ @XmlElement(name = "secure_config", namespace = "https://nervousync.org/schemas/secure") private SecureConfig secureConfig; /** * 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; /** * Cluster mode * 集群模式 */ @XmlElement(name = "cluster_mode") private String clusterMode = ClusterMode.Singleton.toString(); /** * Master name * 主服务器名称 */ @XmlElement(name = "master_name") private String masterName = Globals.DEFAULT_VALUE_STRING; /** * 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; /** *

Constructor for Cache config.

*

缓存配置JavaBean的构造器

*/ 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(final 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(final String secureName) { this.secureName = secureName; } /** * Gets secure config. * * @return the secure config */ public SecureConfig getSecureConfig() { return secureConfig; } /** * Sets secure config. * * @param secureConfig the secure config */ public void setSecureConfig(SecureConfig secureConfig) { this.secureConfig = secureConfig; } /** *

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(final 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(final 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(final 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(final 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(final 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(final 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(final 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(final int maximumClient) { this.maximumClient = maximumClient; } /** *

Retrieve cluster mode

*

读取集群类型

* * @return Cluster mode * 集群类型 */ public String getClusterMode() { return clusterMode; } /** *

Configure cluster mode

*

设置集群类型

* * @param clusterMode Cluster mode * 集群类型 * @see org.nervousync.cache.enumeration.ClusterMode */ public void setClusterMode(final String clusterMode) { this.clusterMode = clusterMode; } /** *

Retrieve cluster master name

*

读取集群主服务器名称

* * @return Master name * 主服务器名称 */ public String getMasterName() { return masterName; } /** *

Configure master name

*

设置集群主服务器名称

* * @param masterName Master name * 主服务器名称 */ public void setMasterName(final String masterName) { this.masterName = masterName; } /** *

Cache server configure JavaBean

*

缓存服务器配置JavaBean

* * @author Steven Wee [email protected] * @version $Revision: 1.0 $ $Date: Apr 25, 2017 3:09:14 PM $ */ @XmlType(name = "server_config", namespace = "https://nervousync.org/schemas/cache") @XmlRootElement(name = "server_config", namespace = "https://nervousync.org/schemas/cache") @XmlAccessorType(XmlAccessType.NONE) public static final class ServerConfig 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; /** *

Default constructor

*

默认构造方法

*/ public ServerConfig() { 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(final String serverAddress, final int serverPort) { return (this.serverAddress.equalsIgnoreCase(serverAddress) && this.serverPort == serverPort); } /** *

Match given server configure is same as current config information

*

比对指定的服务器配置信息是否与当前配置信息一致

* Match boolean. * * @param serverConfig Cache server configure information * 缓存服务器配置信息 * * @return Match result * 比对结果 */ public boolean match(final ServerConfig serverConfig) { if (serverConfig == null) { return Boolean.FALSE; } return this.serverAddress.equalsIgnoreCase(serverConfig.getServerAddress()) && this.serverPort == serverConfig.getServerPort(); } /** *

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(final 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(final 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(final int serverWeight) { this.serverWeight = serverWeight; } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy