I have a scenario where I hit a cacheRefresh.do URL from an HTTP Client. It reaches App Server A, A refreshes its own cache and then sends a request (I am using URLConnection) to App Server B,to refresh its cache. (I know its a bad design, but we are out of option)
Now when my request is refresh small cache(small response time) , everything looks fine, I get a 200.
But when my request is to refresh large cache, I get a 400.
Server A and B do get refreshed in this case as well, but why do I get a 400 back as response? Any idea ?
Below is the controller code:
@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));
}
Request Header:
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
Request Body:
Content-Type: application/x-www-form-urlencoded
Content-Length: 134
action=SPECIFIC&refreshPartnerInstanceCache=true&cacheKeys=xxxx&cacheKeys=xxx&Refresh=yyyy
Thanks!