@Test public void testProcessRequest_UnregisterBroker() throws RemotingCommandException, NoSuchFieldException, IllegalAccessException { ChannelHandlerContext ctx = mock(ChannelHandlerContext.class); when(ctx.channel()).thenReturn(null); RemotingCommand regRequest = genSampleRegisterCmd(true); defaultRequestProcessor.processRequest(ctx, regRequest); RemotingCommand unregRequest = genSampleRegisterCmd(false); RemotingCommand unregResponse = defaultRequestProcessor.processRequest(ctx, unregRequest); assertThat(unregResponse.getCode()).isEqualTo(ResponseCode.SUCCESS); assertThat(unregResponse.getRemark()).isNull(); RouteInfoManager routes = namesrvController.getRouteInfoManager(); Field brokerAddrTable = RouteInfoManager.class.getDeclaredField("brokerAddrTable"); brokerAddrTable.setAccessible(true); assertThat((Map) brokerAddrTable.get(routes)).isNotEmpty(); }
@Override public RemotingCommand processRequest(ChannelHandlerContext ctx,RemotingCommand request) throws RemotingCommandException { if (log.isDebugEnabled()) { log.debug("receive request, {} {} {}", request.getCode(), RemotingHelper.parseChannelRemoteAddr(ctx.channel()), request); } switch (request.getCode()) { case RequestCode.REGISTER_MANAGE: return this.registerBrokerWithFilterServer(ctx, request); case RequestCode.UNREGISTER_MANAGE: return this.unregisterBroker(ctx, request); case RequestCode.GET_MANAGE_CLUSTER_INFO: return this.getBrokerClusterInfo(ctx, request); default: break; } return null; }
DefaultRequestProcessor implements NettyRequestProcessor { @Override public RemotingCommand processRequest(ChannelHandlerContext ctx,RemotingCommand request) throws RemotingCommandException { if (log.isDebugEnabled()) { log.debug("receive request, {} {} {}", request.getCode(), RemotingHelper.parseChannelRemoteAddr(ctx.channel()), request); } switch (request.getCode()) { case RequestCode.REGISTER_MANAGE: return this.registerBrokerWithFilterServer(ctx, request); case RequestCode.UNREGISTER_MANAGE: return this.unregisterBroker(ctx, request); case RequestCode.GET_MANAGE_CLUSTER_INFO: return this.getBrokerClusterInfo(ctx, request); default: break; } return null; } }
DefaultRequestProcessor implements NettyRequestProcessor { @Override public RemotingCommand processRequest(ChannelHandlerContext ctx,RemotingCommand request) throws RemotingCommandException { if (log.isDebugEnabled()) { log.debug("receive request, {} {} {}", request.getCode(), RemotingHelper.parseChannelRemoteAddr(ctx.channel()), request); } switch (request.getCode()) { case RequestCode.REGISTER_MANAGE: return this.registerBrokerWithFilterServer(ctx, request); case RequestCode.UNREGISTER_MANAGE: return this.unregisterBroker(ctx, request); case RequestCode.GET_MANAGE_CLUSTER_INFO: return this.getBrokerClusterInfo(ctx, request); default: break; } return null; } DefaultRequestProcessor(NameSrvController namesrvController); }
DefaultRequestProcessor implements NettyRequestProcessor { @Override public RemotingCommand processRequest(ChannelHandlerContext ctx,RemotingCommand request) throws RemotingCommandException { if (log.isDebugEnabled()) { log.debug("receive request, {} {} {}", request.getCode(), RemotingHelper.parseChannelRemoteAddr(ctx.channel()), request); } switch (request.getCode()) { case RequestCode.REGISTER_MANAGE: return this.registerBrokerWithFilterServer(ctx, request); case RequestCode.UNREGISTER_MANAGE: return this.unregisterBroker(ctx, request); case RequestCode.GET_MANAGE_CLUSTER_INFO: return this.getBrokerClusterInfo(ctx, request); default: break; } return null; } DefaultRequestProcessor(NameSrvController namesrvController); @Override RemotingCommand processRequest(ChannelHandlerContext ctx,RemotingCommand request); @Override boolean rejectRequest(); RemotingCommand registerBrokerWithFilterServer(ChannelHandlerContext ctx, RemotingCommand request); RemotingCommand unregisterBroker(ChannelHandlerContext ctx,RemotingCommand request); }
DefaultRequestProcessor implements NettyRequestProcessor { @Override public RemotingCommand processRequest(ChannelHandlerContext ctx,RemotingCommand request) throws RemotingCommandException { if (log.isDebugEnabled()) { log.debug("receive request, {} {} {}", request.getCode(), RemotingHelper.parseChannelRemoteAddr(ctx.channel()), request); } switch (request.getCode()) { case RequestCode.REGISTER_MANAGE: return this.registerBrokerWithFilterServer(ctx, request); case RequestCode.UNREGISTER_MANAGE: return this.unregisterBroker(ctx, request); case RequestCode.GET_MANAGE_CLUSTER_INFO: return this.getBrokerClusterInfo(ctx, request); default: break; } return null; } DefaultRequestProcessor(NameSrvController namesrvController); @Override RemotingCommand processRequest(ChannelHandlerContext ctx,RemotingCommand request); @Override boolean rejectRequest(); RemotingCommand registerBrokerWithFilterServer(ChannelHandlerContext ctx, RemotingCommand request); RemotingCommand unregisterBroker(ChannelHandlerContext ctx,RemotingCommand request);  }