001
014
015 package com.liferay.portal.fabric.netty.client;
016
017 import com.liferay.portal.fabric.netty.fileserver.CompressionLevel;
018 import com.liferay.portal.kernel.util.GetterUtil;
019 import com.liferay.portal.kernel.util.PropsKeys;
020 import com.liferay.portal.kernel.util.StringBundler;
021 import com.liferay.portal.kernel.util.SystemProperties;
022
023 import java.io.File;
024 import java.io.Serializable;
025
026 import java.nio.file.Path;
027
028 import java.util.Properties;
029
030
033 public class NettyFabricClientConfig implements Serializable {
034
035 public NettyFabricClientConfig(String id, Properties properties) {
036 _id = id;
037 _properties = properties;
038
039 _repositoryFolder = new File(
040 SystemProperties.get(SystemProperties.TMP_DIR),
041 "NettyFabricClient-repository-" + id);
042 }
043
044 public int getEventLoopGroupThreadCount() {
045 return GetterUtil.getInteger(
046 _properties.getProperty(
047 PropsKeys.PORTAL_FABRIC_CLIENT_EVENT_LOOP_GROUP_THREAD_COUNT),
048 1);
049 }
050
051 public int getExecutionGroupThreadCount() {
052 return GetterUtil.getInteger(
053 _properties.getProperty(
054 PropsKeys.PORTAL_FABRIC_CLIENT_EXECUTION_GROUP_THREAD_COUNT),
055 1);
056 }
057
058 public int getExecutionTimeout() {
059 return GetterUtil.getInteger(
060 _properties.getProperty(
061 PropsKeys.PORTAL_FABRIC_CLIENT_EXECUTION_TIMEOUT),
062 600000);
063 }
064
065 public CompressionLevel getFileServerFolderCompressionLevel() {
066 return CompressionLevel.getCompressionLevel(
067 GetterUtil.getInteger(
068 _properties.getProperty(
069 PropsKeys.PORTAL_FABRIC_CLIENT_FILE_SERVER_FOLDER_COMPRESSION_LEVEL),
070 1));
071 }
072
073 public int getFileServerGroupThreadCount() {
074 return GetterUtil.getInteger(
075 _properties.getProperty(
076 PropsKeys.PORTAL_FABRIC_CLIENT_FILE_SERVER_GROUP_THREAD_COUNT),
077 1);
078 }
079
080 public String getNettyFabricServerHost() {
081 return GetterUtil.getString(
082 _properties.getProperty(PropsKeys.PORTAL_FABRIC_SERVER_HOST),
083 "localhost");
084 }
085
086 public int getNettyFabricServerPort() {
087 return GetterUtil.getInteger(
088 _properties.getProperty(PropsKeys.PORTAL_FABRIC_SERVER_PORT), 8923);
089 }
090
091 public int getReconnectCount() {
092 return GetterUtil.getInteger(
093 _properties.getProperty(
094 PropsKeys.PORTAL_FABRIC_CLIENT_RECONNECT_COUNT),
095 3);
096 }
097
098 public long getReconnectInterval() {
099 return GetterUtil.getInteger(
100 _properties.getProperty(
101 PropsKeys.PORTAL_FABRIC_CLIENT_RECONNECT_INTERVAL),
102 10000);
103 }
104
105 public long getRepositoryGetFileTimeout() {
106 return GetterUtil.getLong(
107 _properties.getProperty(
108 PropsKeys.PORTAL_FABRIC_CLIENT_REPOSITORY_GET_FILE_TIMEOUT),
109 600000);
110 }
111
112 public Path getRepositoryPath() {
113 return _repositoryFolder.toPath();
114 }
115
116 public int getRPCGroupThreadCount() {
117 return GetterUtil.getInteger(
118 _properties.getProperty(
119 PropsKeys.PORTAL_FABRIC_CLIENT_RPC_GROUP_THREAD_COUNT),
120 1);
121 }
122
123 public long getShutdownQuietPeriod() {
124 return GetterUtil.getLong(
125 _properties.getProperty(
126 PropsKeys.PORTAL_FABRIC_SHUTDOWN_QUIET_PERIOD),
127 1);
128 }
129
130 public long getShutdownTimeout() {
131 return GetterUtil.getLong(
132 _properties.getProperty(PropsKeys.PORTAL_FABRIC_SHUTDOWN_TIMEOUT),
133 1);
134 }
135
136 @Override
137 public String toString() {
138 StringBundler sb = new StringBundler(31);
139
140 sb.append("{eventLoopGroupThreadCount=");
141 sb.append(getEventLoopGroupThreadCount());
142 sb.append(", executionGroupThreadCount=");
143 sb.append(getExecutionGroupThreadCount());
144 sb.append(", executionTimeout=");
145 sb.append(getExecutionTimeout());
146 sb.append(", fileServerFolderCompressionLevel=");
147 sb.append(getFileServerFolderCompressionLevel());
148 sb.append(", fileServerGroupThreadCount=");
149 sb.append(getFileServerGroupThreadCount());
150 sb.append(", id=");
151 sb.append(_id);
152 sb.append(", nettyFabricServetHost=");
153 sb.append(getNettyFabricServerHost());
154 sb.append(", nettyFabricServerPort=");
155 sb.append(getNettyFabricServerPort());
156 sb.append(", reconnectCount=");
157 sb.append(getReconnectCount());
158 sb.append(", reconnectInterval=");
159 sb.append(getReconnectInterval());
160 sb.append(", repositoryGetFileTimeout=");
161 sb.append(getRepositoryGetFileTimeout());
162 sb.append(", repositoryPath=");
163 sb.append(getRepositoryPath());
164 sb.append(", rpcGroupThreadCount=");
165 sb.append(getRPCGroupThreadCount());
166 sb.append(", shutdownQuietPeriod=");
167 sb.append(getShutdownQuietPeriod());
168 sb.append(", shutdownTimeout=");
169 sb.append(getShutdownTimeout());
170 sb.append("}");
171
172 return sb.toString();
173 }
174
175 private static final long serialVersionUID = 1L;
176
177 private final String _id;
178 private final Properties _properties;
179 private final File _repositoryFolder;
180
181 }