1
我有一个场景,我从HTTP客户端中点击了一个cacheRefresh.do URL。 它到达App Server A,刷新其自己的缓存,然后向App Server B发送请求(我正在使用URLConnection)来刷新其缓存。 (我知道它的一个不好的设计,但我们走出选项)当服务器向另一台服务器发起长HTTP请求时出现HTTP 400错误
现在,当我的要求是刷新小的高速缓存(小响应时间),一切都看起来不错,我得到一个200
但是,当我的请求是刷新大缓存,我得到一个400.
服务器A和B在这种情况下也得到刷新,但为什么我得到一个400作为回应?任何想法 ?
下面是控制器代码:
@SuppressWarnings("unused")
public ModelAndView handleRequest(final HttpServletRequest request, final HttpServletResponse response)
throws Exception {
final long cacheRefreshStartTime = System.currentTimeMillis();
final String action = request.getParameter("action");
// Init to 74 since this is the static length that will be appended.
final StringBuffer result = new StringBuffer(74);
final String[] cacheKeys = request.getParameterValues("cacheKeys");
String[] cacheElement = request.getParameterValues("cacheElement");
final String refreshByKeyRegion = request.getParameter("refreshByKeyRegion");
final String refreshByKeyRegionKeys = request.getParameter("refreshByKeyRegionKeys");
final String refreshPartnerInstanceCache = request.getParameter("refreshPartnerInstanceCache");
LOG.debug(" cacheKeys for refresh " + Arrays.toString(cacheKeys));
try {
if (action.equalsIgnoreCase("ALL")) {
performancLogger.info("Cache Refresh requested action=" + action);
this.refreshAllCache();
} else if (action.equalsIgnoreCase("SPECIFIC")) {
performancLogger.info("Cache Refresh requested action=" + action + " keys="
+ Arrays.toString(cacheKeys));
this.refreshSpecificCache(cacheKeys);
} else if (action.equalsIgnoreCase("cacheElement")) {
if (refreshByKeyRegion != null && refreshByKeyRegion.length() > 0 && refreshByKeyRegionKeys != null
&& refreshByKeyRegionKeys.length() > 0) {
cacheElement = new String[] { refreshByKeyRegion + "," + refreshByKeyRegionKeys };
}
performancLogger.info("Cache Refresh requested action=" + action + " element="
+ Arrays.toString(cacheElement));
this.refreshCacheElements(cacheElement);
}
if (!request.getServerName().contains("localhost") && refreshPartnerInstanceCache != null
&& refreshPartnerInstanceCache.equals("true")) {
refreshPartnerInstanceCache(request);
}
result.append("Cache refresh completed successfully.");
if (cacheKeys != null) {
result.append(" Keys - ");
result.append(this.formatArrayAsString(cacheKeys));
}
} catch (final Exception e) {
result.append("Cache refresh failed.");
if (cacheKeys != null) {
result.append(" Keys - ");
result.append(this.formatArrayAsString(cacheKeys));
}
}
if (action != null) {
performancLogger.info("Cache Refresh competed total refresh time = "
+ formatElapsedTime(System.currentTimeMillis() - cacheRefreshStartTime));
}
return new ModelAndView(IVRControllerNames.CACHE_REFRESH_STANDARD_VIEW, "displayInfo", this
.getDisplayInfo(result));
}
请求头:
POST xxxxx.do HTTP/1.1
Host: xxxxx
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Referer: http://xxx/yyy/zzz/cacheView.do
Cookie: JSESSIONID=xxxxx.x.x
请求正文:
Content-Type: application/x-www-form-urlencoded
Content-Length: 134
action=SPECIFIC&refreshPartnerInstanceCache=true&cacheKeys=xxxx&cacheKeys=xxx&Refresh=yyyy
谢谢!
您可以发布您的请求的一些代码以及AppServers用它做什么? – 2012-04-09 18:57:19
@PlínioPantaleão:在问题中添加了以上代码片段。请记住,如果我发送请求以仅刷新2或3个缓存,则它可以正常工作。但如果我请求长时间处理(如刷新7-8或更高的缓存)。那是我面临这个问题的时候。我相信这与我最初的请求获得超时或某事有关,不确定? – user620339 2012-04-09 21:00:27