HTTP クライアントから cacheRefresh.do URL にヒットするシナリオがあります。アプリ サーバー A に到達すると、A は自身のキャッシュを更新し、リクエスト (私は URLConnection を使用しています) をアプリ サーバー B に送信してキャッシュを更新します。(設計が悪いことは承知していますが、選択の余地はありません)
私のリクエストが refresh small cache(small response time) である場合、すべて問題ないように見え、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
ありがとう!