1414import com .netease .nim .camellia .redis .proxy .netty .CamelliaRedisProxyServer ;
1515import com .netease .nim .camellia .redis .proxy .conf .GlobalRedisProxyEnv ;
1616import com .netease .nim .camellia .redis .base .resource .RedisResourceUtil ;
17+ import com .netease .nim .camellia .redis .proxy .plugin .ProxyBeanFactory ;
1718import io .netty .channel .ChannelFuture ;
1819import org .slf4j .Logger ;
1920import org .slf4j .LoggerFactory ;
@@ -31,32 +32,32 @@ public class CamelliaRedisProxyStarter {
3132 private static final AtomicBoolean starting = new AtomicBoolean (false );
3233 private static final AtomicBoolean startOk = new AtomicBoolean (false );
3334
34- private static final CamelliaServerProperties camelliaServerProperties = new CamelliaServerProperties ();
35+ private static final CamelliaServerProperties properties = new CamelliaServerProperties ();
3536
3637 public static void start () {
37- start (0 , null );
38+ start (0 , null , null );
3839 }
3940
4041 public static void start (boolean enableConsole ) {
4142 if (enableConsole ) {
42- start (Constants .Server .consolePort , new ConsoleServiceAdaptor ());
43+ start (Constants .Server .consolePort , new ConsoleServiceAdaptor (), null );
4344 } else {
4445 start ();
4546 }
4647 }
4748
4849 public static void start (int consolePort ) {
49- start (consolePort , new ConsoleServiceAdaptor ());
50+ start (consolePort , new ConsoleServiceAdaptor (), null );
5051 }
5152
52- public static void start (int consolePort , ConsoleService consoleService ) {
53+ public static void start (int consolePort , ConsoleService consoleService , ProxyBeanFactory proxyBeanFactory ) {
5354 if (starting .compareAndSet (false , true )) {
5455 try {
5556 if (startOk .get ()) {
5657 logger .warn ("CamelliaRedisProxyServer has started" );
5758 return ;
5859 }
59- ServerConf .init (camelliaServerProperties , -1 , null , null );
60+ ServerConf .init (properties , -1 , null , proxyBeanFactory );
6061
6162 CamelliaRedisProxyServer server = new CamelliaRedisProxyServer ();
6263 server .start ();
@@ -83,31 +84,34 @@ public static void start(int consolePort, ConsoleService consoleService) {
8384 * 获取监控数据
8485 * @return monitor string
8586 */
86- public static String getRedisProxyMonitorString () {
87+ public static Stats getStats () {
8788 try {
88- Stats stats = ProxyMonitorCollector .getStats ();
89- return StatsJsonConverter .converter (stats );
89+ return ProxyMonitorCollector .getStats ();
9090 } catch (Exception e ) {
91- logger .error ("getRedisProxyMonitorString error" , e );
92- return "" ;
91+ logger .error ("getStats error" , e );
92+ return null ;
9393 }
9494 }
9595
9696 public static boolean isStart () {
9797 return startOk .get ();
9898 }
9999
100+ public static CamelliaServerProperties getProperties () {
101+ return properties ;
102+ }
103+
100104 public static void updatePort (int port ) {
101- camelliaServerProperties .getConfig ().put ("port" , String .valueOf (port ));
105+ properties .getConfig ().put ("port" , String .valueOf (port ));
102106 }
103107
104108 public static void updatePassword (String password ) {
105- camelliaServerProperties .getConfig ().put ("password" , password );
109+ properties .getConfig ().put ("password" , password );
106110 }
107111
108112 public static void updateRouteConf (String conf ) {
109113 ResourceTable resourceTable = ReadableResourceTableUtil .parseTable (conf );
110114 RedisResourceUtil .checkResourceTable (resourceTable );
111- camelliaServerProperties .getConfig ().put ("route.conf" , conf );
115+ properties .getConfig ().put ("route.conf" , conf );
112116 }
113117}
0 commit comments