public void add(String clientIp, String query, int type, String answer) { DoubleKeyMap<String, Integer, String> stringIntegerStringDoubleKeyMap = container.get(clientIp); if (stringIntegerStringDoubleKeyMap == null) { stringIntegerStringDoubleKeyMap = new DoubleKeyMap<String, Integer, String>(ConcurrentHashMap.class); container.put(clientIp, stringIntegerStringDoubleKeyMap); } stringIntegerStringDoubleKeyMap.put(query, type, answer); }
/* * (non-Javadoc) * * @see * us.codecraft.blackhole.answer.AnswerProvider#getAnswer(java.lang.String, * int) */ @Override public String getAnswer(String query, int type) { String ip = RequestContext.getClientIp(); DoubleKeyMap<String, Integer, String> stringIntegerStringDoubleKeyMap = container.get(ip); if (stringIntegerStringDoubleKeyMap == null) { return null; } return stringIntegerStringDoubleKeyMap.get(query, type); }