@Override
    public void doAfterResponse(String remoteAddr, RemotingCommand request, RemotingCommand response) {
        if (RequestCode.GET_ROUTEINFO_BY_TOPIC != request.getCode()) {
            return;
        }
        if (response == null || response.getBody() == null || ResponseCode.SUCCESS != response.getCode()) {
            return;
        }
        boolean zoneMode = Boolean.parseBoolean(request.getExtFields().get(MixAll.ZONE_MODE));
        if (!zoneMode) {
            return;
        }
        String zoneName = request.getExtFields().get(MixAll.ZONE_NAME);
        if (StringUtils.isBlank(zoneName)) {
            return;
        }
        TopicRouteData topicRouteData = RemotingSerializable.decode(response.getBody(), TopicRouteData.class);
        response.setBody(filterByZoneName(topicRouteData, zoneName).encode());
    }
@Test
    public void testDoAfterResponseWithValidZoneFiltering() throws Exception {
        HashMap<String, String> extFields = new HashMap<>();
        extFields.put(MixAll.ZONE_MODE, "true");
        extFields.put(MixAll.ZONE_NAME,"zone1");
        RemotingCommand request = RemotingCommand.createRequestCommand(105,null);
        request.setExtFields(extFields);
        RemotingCommand response = RemotingCommand.createResponseCommand(null);
        response.setCode(ResponseCode.SUCCESS);
        TopicRouteData topicRouteData = createSampleTopicRouteData();
        response.setBody(RemotingSerializable.encode(topicRouteData));
        zoneRouteRPCHook.doAfterResponse("", request, response);

        HashMap<Long,String> brokeraddrs = new HashMap<>();
        brokeraddrs.put(MixAll.MASTER_ID,"127.0.0.1:10911");
        topicRouteData.getBrokerDatas().get(0).setBrokerAddrs(brokeraddrs);
        response.setBody(RemotingSerializable.encode(topicRouteData));
        zoneRouteRPCHook.doAfterResponse("", request, response);

        topicRouteData.getQueueDatas().add(createQueueData("BrokerB"));
        HashMap<Long,String> brokeraddrsB = new HashMap<>();
        brokeraddrsB.put(MixAll.MASTER_ID,"127.0.0.1:10912");
        BrokerData brokerData1 = createBrokerData("BrokerB","zone2",brokeraddrsB);
        BrokerData brokerData2 = createBrokerData("BrokerC","zone1",null);
        topicRouteData.getBrokerDatas().add(brokerData1);
        topicRouteData.getBrokerDatas().add(brokerData2);
        response.setBody(RemotingSerializable.encode(topicRouteData));
        zoneRouteRPCHook.doAfterResponse("", request, response);

        topicRouteData.getFilterServerTable().put("127.0.0.1:10911",new ArrayList<>());
        response.setBody(RemotingSerializable.encode(topicRouteData));
        zoneRouteRPCHook.doAfterResponse("", request, response);
        Assert.assertEquals(1,RemotingSerializable
                .decode(response.getBody(), TopicRouteData.class)
                .getFilterServerTable()
                .size());

        topicRouteData.getFilterServerTable().put("127.0.0.1:10912",new ArrayList<>());
        response.setBody(RemotingSerializable.encode(topicRouteData));
        zoneRouteRPCHook.doAfterResponse("", request, response);
        Assert.assertEquals(1,RemotingSerializable
                .decode(response.getBody(), TopicRouteData.class)
                .getFilterServerTable()
                .size());
    }