}
}
- synchronized void replaceCluster(ClusterI cluster) {
- //printMaps("replaceCluster");
+ synchronized void replaceCluster(ClusterI cluster_) {
+ ClusterImpl cluster = (ClusterImpl) cluster_;
checkCollect();
int clusterKey = cluster.getClusterKey();
- ClusterI existing = clusterArray[clusterKey];
+ ClusterImpl existing = (ClusterImpl) clusterArray[clusterKey];
if (existing.hasVirtual())
cluster.markVirtual();
- long existingImportance = existing.getImportance();
- if (existingImportance != 0)
- importanceMap.remove(existingImportance);
+ if (existing.cc != null) {
+ if (existing.isLoaded()) {
+ // This shall be promoted to actual exception in the future -
+ // for now, minimal changes
+ new Exception("Trying to replace cluster with pending changes " + existing.getClusterUID())
+ .printStackTrace();
+ } else {
+ // Adopt changes to loaded cluster
+ cluster.cc = existing.cc;
+ cluster.cc.adopt(cluster);
+ cluster.foreignLookup = existing.foreignLookup;
+ cluster.change = existing.change;
+ }
+ }
+
+ importanceMap.remove(existing.getImportance());
if (collectorPolicy != null)
collectorPolicy.removed((ClusterImpl)existing);
public boolean execute(int clusterKey) {
ClusterImpl proxy = clusterArray[clusterKey];
ClusterUID clusterUID = proxy.getClusterUID();
- System.err.println("writeOnlyInvalidate " + clusterUID);
clusters.freeProxy(proxy);
return true;
}
System.err.println("value " + cc.getValueIndex()[i] + " changed.");
}
}
- final void refreshImportance(ClusterImpl c) {
+ final synchronized void refreshImportance(ClusterImpl c) {
if (c.isWriteOnly())
return;
}
@SuppressWarnings("unchecked")
- public final <T extends ClusterI> T getClusterByResourceKey(final int resourceKey) {
+ public synchronized final <T extends ClusterI> T getClusterByResourceKey(final int resourceKey) {
int clusterKey = ClusterTraitsBase.getClusterKeyFromResourceKeyNoThrow(resourceKey);
if (ClusterTraitsBase.isVirtualClusterKey(clusterKey))
throw new RuntimeException("Tried to get a persistent cluster for a virtual resource.");
int ims = importanceMap.size();
int ihms = countImportantClusters();
-// System.out.format("[%s] Validating ClusterTable: byteSize=%d, hashMap=%d/%d, importanceMap=%d%n",
-// place, sizeInBytes, ihms, clusters.hashMap.size(), ims);
+// System.out.format("[ClusterTable.%s] Validating: byteSize=%d (%d MB), hashMap=%d/%d, importanceMap=%d%n",
+// place, sizeInBytes, sizeInBytes / (1024*1024), ihms, clusters.hashMap.size(), ims);
int i = clusterArray.length;
long size = 0;