@Override
public Response handle(final CacheRpcCommand cmd, Address origin) throws Throwable {
cmd.setOrigin(origin);
String cacheName = cmd.getCacheName();
ComponentRegistry cr = gcr.getNamedComponentRegistry(cacheName);
if (cr == null) {
if (embeddedCacheManager.getGlobalConfiguration().isStrictPeerToPeer()) {
// lets see if the cache is *defined* and perhaps just not started.
if (isDefined(cacheName)) {
log.waitForCacheToStart();
long giveupTime = System.currentTimeMillis() + 30000; // arbitrary (?) wait time for caches to start
while (cr == null && System.currentTimeMillis() < giveupTime) {
Thread.sleep(100);
cr = gcr.getNamedComponentRegistry(cacheName);
}
}
}
if (cr == null) {
if (log.isInfoEnabled()) log.namedCacheDoesNotExist(cacheName);
return new ExceptionResponse(new NamedCacheNotFoundException(cacheName, "Cannot process command " + cmd + " on node " + transport.getAddress()));
}
}
final Configuration localConfig = cr.getComponent(Configuration.class);
cmd.injectComponents(localConfig, cr);
return handleWithRetry(cmd);
}