@@ -26,26 +26,29 @@ public class CommandDecoder extends ByteToMessageDecoder {
2626 private byte [][] bytes ;
2727 private int index = 0 ;
2828
29- private int commandDecodeMaxBatchSize = Constants .Server .commandDecodeMaxBatchSize ;
30- private int commandDecodeBufferInitializerSize = Constants .Server .commandDecodeBufferInitializerSize ;
29+ private static int commandDecodeMaxBatchSize = Constants .Server .commandDecodeMaxBatchSize ;
30+ private static int commandDecodeBufferInitializerSize = Constants .Server .commandDecodeBufferInitializerSize ;
31+
32+ static {
33+ updateConf ();
34+ ProxyDynamicConf .registerCallback (CommandDecoder ::updateConf );
35+ }
3136
3237 public CommandDecoder () {
3338 super ();
34- updateConf ();
35- ProxyDynamicConf .registerCallback (this ::updateConf );
36- this .commands = new ArrayList <>(this .commandDecodeBufferInitializerSize );
39+ this .commands = new ArrayList <>(CommandDecoder .commandDecodeBufferInitializerSize );
3740 }
3841
39- private void updateConf () {
42+ private static void updateConf () {
4043 int commandDecodeMaxBatchSize = ProxyDynamicConf .getInt ("command.decode.max.batch.size" , Constants .Server .commandDecodeMaxBatchSize );
41- if (commandDecodeMaxBatchSize > 0 && commandDecodeMaxBatchSize != this .commandDecodeMaxBatchSize ) {
42- logger .info ("command.decode.max.batch.size updated, {} -> {}" , this .commandDecodeMaxBatchSize , commandDecodeMaxBatchSize );
43- this .commandDecodeMaxBatchSize = commandDecodeMaxBatchSize ;
44+ if (commandDecodeMaxBatchSize > 0 && commandDecodeMaxBatchSize != CommandDecoder .commandDecodeMaxBatchSize ) {
45+ logger .info ("command.decode.max.batch.size updated, {} -> {}" , CommandDecoder .commandDecodeMaxBatchSize , commandDecodeMaxBatchSize );
46+ CommandDecoder .commandDecodeMaxBatchSize = commandDecodeMaxBatchSize ;
4447 }
4548 int commandDecodeBufferInitializerSize = ProxyDynamicConf .getInt ("command.decode.buffer.initializer.size" , Constants .Server .commandDecodeBufferInitializerSize );
46- if (commandDecodeBufferInitializerSize > 0 && commandDecodeBufferInitializerSize != this .commandDecodeBufferInitializerSize ) {
47- logger .info ("command.decode.buffer.initializer.size updated, {} -> {}" , this .commandDecodeBufferInitializerSize , commandDecodeBufferInitializerSize );
48- this .commandDecodeBufferInitializerSize = commandDecodeBufferInitializerSize ;
49+ if (commandDecodeBufferInitializerSize > 0 && commandDecodeBufferInitializerSize != CommandDecoder .commandDecodeBufferInitializerSize ) {
50+ logger .info ("command.decode.buffer.initializer.size updated, {} -> {}" , CommandDecoder .commandDecodeBufferInitializerSize , commandDecodeBufferInitializerSize );
51+ CommandDecoder .commandDecodeBufferInitializerSize = commandDecodeBufferInitializerSize ;
4952 }
5053 }
5154
0 commit comments