public long synchronizeData(final Cache<Object, Object> cache) throws CacheException {
int threads = Runtime.getRuntime().availableProcessors();
ComponentRegistry cr = cache.getAdvancedCache().getComponentRegistry();
CacheLoaderManager loaderManager = cr.getComponent(CacheLoaderManager.class);
List<RemoteCacheStore> stores = loaderManager.getCacheLoaders(RemoteCacheStore.class);
Marshaller marshaller = new GenericJBossMarshaller();
byte[] knownKeys;
try {
knownKeys = marshaller.objectToByteBuffer(MIGRATION_MANAGER_HOT_ROD_KNOWN_KEYS);
} catch (Exception e) {
throw new CacheException(e);
}
for (RemoteCacheStore store : stores) {
final RemoteCache<Object, Object> storeCache = store.getRemoteCache();
if (storeCache.containsKey(knownKeys)) {
RemoteCacheStoreConfig storeConfig = (RemoteCacheStoreConfig) store.getCacheStoreConfig();
if (!storeConfig.isHotRodWrapping()) {
throw log.remoteStoreNoHotRodWrapping(cache.getName());
}
Set<byte[]> keys;
try {
keys = (Set<byte[]>) marshaller.objectFromByteBuffer((byte[])storeCache.get(knownKeys));
} catch (Exception e) {
throw new CacheException(e);
}
ExecutorService es = Executors.newFixedThreadPool(threads);