public long synchronizeData(final Cache<Object, Object> cache) throws CacheException {
int threads = Runtime.getRuntime().availableProcessors();
ComponentRegistry cr = cache.getAdvancedCache().getComponentRegistry();
PersistenceManager loaderManager = cr.getComponent(PersistenceManager.class);
Set<RemoteStore> stores = loaderManager.getStores(RemoteStore.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 (RemoteStore store : stores) {
final RemoteCache<Object, Object> storeCache = store.getRemoteCache();
if (storeCache.containsKey(knownKeys)) {
RemoteStoreConfiguration storeConfig = store.getConfiguration();
if (!storeConfig.hotRodWrapping()) {
throw log.remoteStoreNoHotRodWrapping(cache.getName());
}
Set<Object> keys;
try {
keys = (Set<Object>) marshaller.objectFromByteBuffer((byte[])storeCache.get(knownKeys));
} catch (Exception e) {
throw new CacheException(e);
}
ExecutorService es = Executors.newFixedThreadPool(threads);