001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.fabric.netty.server;
016    
017    import com.liferay.portal.fabric.netty.fileserver.CompressionLevel;
018    import com.liferay.portal.kernel.util.StringBundler;
019    import com.liferay.portal.kernel.util.SystemProperties;
020    import com.liferay.portal.util.PropsValues;
021    
022    import java.io.Serializable;
023    
024    import java.nio.file.Path;
025    import java.nio.file.Paths;
026    
027    /**
028     * @author Shuyang Zhou
029     */
030    public class NettyFabricServerConfig implements Serializable {
031    
032            public int getBossGroupThreadCount() {
033                    return PropsValues.PORTAL_FABRIC_SERVER_BOSS_GROUP_THREAD_COUNT;
034            }
035    
036            public CompressionLevel getFileServerFolderCompressionLevel() {
037                    return CompressionLevel.getCompressionLevel(
038                            PropsValues.
039                                    PORTAL_FABRIC_SERVER_FILE_SERVER_FOLDER_COMPRESSION_LEVEL);
040            }
041    
042            public int getFileServerGroupThreadCount() {
043                    return PropsValues.PORTAL_FABRIC_SERVER_FILE_SERVER_GROUP_THREAD_COUNT;
044            }
045    
046            public String getNettyFabricServerHost() {
047                    return PropsValues.PORTAL_FABRIC_SERVER_HOST;
048            }
049    
050            public int getNettyFabricServerPort() {
051                    return PropsValues.PORTAL_FABRIC_SERVER_PORT;
052            }
053    
054            public int getRegistrationGroupThreadCount() {
055                    return PropsValues.PORTAL_FABRIC_SERVER_REGISTRATION_GROUP_THREAD_COUNT;
056            }
057    
058            public long getRepositoryGetFileTimeout() {
059                    return PropsValues.PORTAL_FABRIC_SERVER_REPOSITORY_GET_FILE_TIMEOUT;
060            }
061    
062            public Path getRepositoryParentPath() {
063                    return Paths.get(
064                            SystemProperties.get(SystemProperties.TMP_DIR),
065                            PropsValues.PORTAL_FABRIC_SERVER_REPOSITORY_PARENT_FOLDER);
066            }
067    
068            public int getRPCGroupThreadCount() {
069                    return PropsValues.PORTAL_FABRIC_SERVER_RPC_GROUP_THREAD_COUNT;
070            }
071    
072            public long getRPCRelayTimeout() {
073                    return PropsValues.PORTAL_FABRIC_SERVER_RPC_RELAY_TIMEOUT;
074            }
075    
076            public long getShutdownQuietPeriod() {
077                    return PropsValues.PORTAL_FABRIC_SHUTDOWN_QUIET_PERIOD;
078            }
079    
080            public long getShutdownTimeout() {
081                    return PropsValues.PORTAL_FABRIC_SHUTDOWN_TIMEOUT;
082            }
083    
084            public int getWorkerGroupThreadCount() {
085                    return PropsValues.PORTAL_FABRIC_SERVER_WORKER_GROUP_THREAD_COUNT;
086            }
087    
088            public long getWorkerStartupTimeout() {
089                    return PropsValues.PORTAL_FABRIC_SERVER_WORKER_STARTUP_TIMEOUT;
090            }
091    
092            @Override
093            public String toString() {
094                    StringBundler sb = new StringBundler(29);
095    
096                    sb.append("{bossGroupThreadCount=");
097                    sb.append(getBossGroupThreadCount());
098                    sb.append(", fileServerFolderCompressionLevel=");
099                    sb.append(getFileServerFolderCompressionLevel());
100                    sb.append(", fileServerGroupThreadCount=");
101                    sb.append(getFileServerGroupThreadCount());
102                    sb.append(", nettyFabricServerHost=");
103                    sb.append(getNettyFabricServerHost());
104                    sb.append(", nettyFabricServerPort=");
105                    sb.append(getNettyFabricServerPort());
106                    sb.append(", registrationGroupThreadCount=");
107                    sb.append(getRegistrationGroupThreadCount());
108                    sb.append(", repositoryGetFileTimeout=");
109                    sb.append(getRepositoryGetFileTimeout());
110                    sb.append(", repositoryParentPath=");
111                    sb.append(getRepositoryParentPath());
112                    sb.append(", rpcGroupThreadCount=");
113                    sb.append(getRPCGroupThreadCount());
114                    sb.append(", rpcRelayTimeout=");
115                    sb.append(getRPCRelayTimeout());
116                    sb.append(", workerGroupThreadCount=");
117                    sb.append(getWorkerGroupThreadCount());
118                    sb.append(", workerStartupTimeout=");
119                    sb.append(getWorkerStartupTimeout());
120                    sb.append(", shutdownQuietPeriod=");
121                    sb.append(getShutdownQuietPeriod());
122                    sb.append(", shutdownTimeout=");
123                    sb.append(getShutdownTimeout());
124                    sb.append("}");
125    
126                    return sb.toString();
127            }
128    
129            private static final long serialVersionUID = 1L;
130    
131    }