X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.db.procore%2Fsrc%2Ffi%2Fvtt%2Fsimantics%2Fprocore%2Finternal%2FClusterTable.java;fp=bundles%2Forg.simantics.db.procore%2Fsrc%2Ffi%2Fvtt%2Fsimantics%2Fprocore%2Finternal%2FClusterTable.java;h=07df23df8a07a95527e40a4018c966bb4ed6ad1e;hp=6cab018a6f4beadde5859f94fc86de4b75638a92;hb=7e66fdd1670687a56d8ef980d14d83bfc5f16583;hpb=7057e920b41f05ea4a98d904abbc708d7f131fa2 diff --git a/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/ClusterTable.java b/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/ClusterTable.java index 6cab018a6..07df23df8 100644 --- a/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/ClusterTable.java +++ b/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/ClusterTable.java @@ -27,7 +27,6 @@ import org.simantics.db.Database; import org.simantics.db.Database.Session.ClusterChanges; import org.simantics.db.DevelopmentKeys; import org.simantics.db.SessionVariables; -import org.simantics.db.common.utils.Logger; import org.simantics.db.exception.ClusterDoesNotExistException; import org.simantics.db.exception.DatabaseException; import org.simantics.db.exception.ResourceNotFoundException; @@ -48,6 +47,7 @@ import org.simantics.db.service.ClusterCollectorPolicy; import org.simantics.db.service.ClusterCollectorPolicy.CollectorCluster; import org.simantics.db.service.ClusterUID; import org.simantics.utils.Development; +import org.slf4j.LoggerFactory; import fi.vtt.simantics.procore.DebugPolicy; import fi.vtt.simantics.procore.internal.ClusterControlImpl.ClusterStateImpl; @@ -61,6 +61,8 @@ import gnu.trove.set.hash.TIntHashSet; public final class ClusterTable implements IClusterTable { + private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(ClusterTable.class); + private static final boolean VALIDATE_SIZE = false; int maximumBytes = 128 * 1024 * 1024; @@ -280,7 +282,7 @@ public final class ClusterTable implements IClusterTable { ClusterImpl cluster = ClusterImpl.make(clusterUID, clusterKey, sessionImpl.clusterTranslator); clusters.create(cluster); if (!cluster.isLoaded()) - Logger.defaultLogError(new Exception("Bug in ClusterTable.makeCluster(long, boolean), cluster not loaded")); + LOGGER.error("", new Exception("Bug in ClusterTable.makeCluster(long, boolean), cluster not loaded")); importanceMap.put(cluster.getImportance(), new ImportanceEntry(cluster)); if (VALIDATE_SIZE) validateSize("makeCluster"); @@ -320,7 +322,7 @@ public final class ClusterTable implements IClusterTable { clusters.replace((ClusterImpl)cluster); if (!cluster.isLoaded()) - Logger.defaultLogError(new Exception("Bug in ClusterTable.replaceCluster(ClusterI), cluster not loaded")); + LOGGER.error("", new Exception("Bug in ClusterTable.replaceCluster(ClusterI), cluster not loaded")); importanceMap.put(cluster.getImportance(), new ImportanceEntry((ClusterImpl)cluster)); if(collectorPolicy != null) collectorPolicy.added((ClusterImpl)cluster); @@ -396,7 +398,7 @@ public final class ClusterTable implements IClusterTable { result += cluster.getCachedSize(); } } catch (Throwable t) { - Logger.defaultLogError(t); + LOGGER.error("Could not calculate size", t); } } return true; @@ -696,12 +698,12 @@ public final class ClusterTable implements IClusterTable { final long getClusterIdByResourceKeyNoThrow(final int resourceKey) { int clusterKey = ClusterTraitsBase.getClusterKeyFromResourceKeyNoThrow(resourceKey); if (ClusterTraitsBase.isVirtualClusterKey(clusterKey)) { - Logger.defaultLogError("Tried to get a persistent cluster for a virtual resource. key=" + resourceKey); + LOGGER.error("Tried to get a persistent cluster for a virtual resource. key=" + resourceKey); return 0; } ClusterI c = clusterArray[clusterKey]; if (c == null) { - Logger.defaultLogError("No cluster for key " + resourceKey); + LOGGER.error("No cluster for key " + resourceKey); return 0; } return c.getClusterId(); @@ -759,14 +761,14 @@ public final class ClusterTable implements IClusterTable { collectorPolicy.removed(oldCluster); clusters.replace(newCluster); if (!newCluster.isLoaded()) - Logger.defaultLogError(new Exception("Bug in ClusterTable.refresh, cluster not loaded")); + LOGGER.error("", new Exception("Bug in ClusterTable.refresh, cluster not loaded")); importanceMap.put(newCluster.getImportance(), new ImportanceEntry(newCluster)); if (collectorPolicy != null) collectorPolicy.added(newCluster); // Now we have fetched the new cluster but to emulate effects of the changes in it we fetch the cluster changes from server. refreshCluster(csid, session, oldCluster, clusterUID[i], newCluster.clusterId, clusterKey); } catch (Throwable t) { - Logger.defaultLogError("Failed to load cluster in refresh.", t); + LOGGER.error("Failed to load cluster in refresh.", t); } } if (VALIDATE_SIZE) @@ -803,7 +805,7 @@ public final class ClusterTable implements IClusterTable { try { cc = session.graphSession.getClusterChanges(clusterUID, csid); } catch (Exception e) { - Logger.defaultLogError("Could not get cluster changes. cluster=" + clusterUID, e); + LOGGER.error("Could not get cluster changes. cluster=" + clusterUID, e); release(clusterId); return; } @@ -840,7 +842,7 @@ public final class ClusterTable implements IClusterTable { // System.err.println("refreshImportance " + c.getClusterId() + " => " + newImportance); c.setImportance(newImportance); if (!c.isLoaded()) - Logger.defaultLogError(new Exception("Bug in ClusterTable.refreshImportance(ClusterImpl), cluster not loaded")); + LOGGER.error("", new Exception("Bug in ClusterTable.refreshImportance(ClusterImpl), cluster not loaded")); importanceMap.put(c.getImportance(), new ImportanceEntry(c)); if(collectorPolicy != null) collectorPolicy.added(c); @@ -889,7 +891,7 @@ public final class ClusterTable implements IClusterTable { cluster = load2(cs.getClusterId(), cs.getClusterKey()); } } catch (DatabaseException e) { - Logger.defaultLogError(e); + LOGGER.error("Could not load cluster", e); if (DebugPolicy.REPORT_CLUSTER_EVENTS) e.printStackTrace(); String msg = "Failed to load cluster " + cs.getClusterUID();// + " resourceId=" + (((cs.getClusterId() << 16 + (resourceKey & 65535)))); @@ -913,7 +915,7 @@ public final class ClusterTable implements IClusterTable { return (T) c; } if (!(c instanceof ClusterSmall)) { - Logger.defaultLogError("Proxy must be instance of ClusterSmall"); + LOGGER.error("Proxy must be instance of ClusterSmall"); return null; } return ensureLoaded((T)c); @@ -933,7 +935,7 @@ public final class ClusterTable implements IClusterTable { return (T) c; } if (!(c instanceof ClusterSmall)) { - Logger.defaultLogError("Proxy must be instance of ClusterSmall"); + LOGGER.error("Proxy must be instance of ClusterSmall"); return null; } ClusterI cluster; @@ -947,7 +949,7 @@ public final class ClusterTable implements IClusterTable { int resourceIndex = resourceKey & ClusterTraitsBase.getResourceIndexFromResourceKeyNoThrow(resourceKey); long resourceId = ClusterTraitsBase.createResourceIdNoThrow(cs.getClusterId(), resourceIndex); String msg = "Failed to load cluster " + cs.getClusterUID() + " for resource key " + resourceKey + " resourceIndex=" + resourceIndex + " resourceId=" + resourceId; - Logger.defaultLogError(msg, e); + LOGGER.error(msg, e); c.setDeleted(true, null); return (T)c; } @@ -993,7 +995,7 @@ public final class ClusterTable implements IClusterTable { try { s.acquire(); } catch (InterruptedException e) { - Logger.defaultLogError(e); + LOGGER.error("unable to acquire", e); } if (null != ex[0]) throw ex[0]; @@ -1096,7 +1098,7 @@ public final class ClusterTable implements IClusterTable { } catch (Throwable t) { // It's totally legal to call for non-existing cluster. // Sometimes this indicates an error, though. - Logger.getDefault().logInfo("Load cluster failed.", t); + LOGGER.error("Load cluster failed", t); if (t instanceof DatabaseException) e = (DatabaseException) t; else