X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.acorn%2Fsrc%2Forg%2Fsimantics%2Facorn%2Flru%2FClusterUpdateOperation.java;h=c23821b7973c51b8e0a8828c7fc66b3e894c4d08;hp=40a44bc43bc17e85c1114b3bae21aee53bb6573d;hb=d9a9d77c7024260e3e3b3a8558ddc84b2a8b99b3;hpb=0144ba232323a0e4f7ec8fe0681a150faafd7caf diff --git a/bundles/org.simantics.acorn/src/org/simantics/acorn/lru/ClusterUpdateOperation.java b/bundles/org.simantics.acorn/src/org/simantics/acorn/lru/ClusterUpdateOperation.java index 40a44bc43..c23821b79 100644 --- a/bundles/org.simantics.acorn/src/org/simantics/acorn/lru/ClusterUpdateOperation.java +++ b/bundles/org.simantics.acorn/src/org/simantics/acorn/lru/ClusterUpdateOperation.java @@ -2,6 +2,8 @@ package org.simantics.acorn.lru; import org.simantics.acorn.ClusterManager; import org.simantics.acorn.cluster.ClusterImpl; +import org.simantics.acorn.exception.AcornAccessVerificationException; +import org.simantics.acorn.exception.IllegalAcornStateException; import org.simantics.acorn.internal.ClusterChange; import org.simantics.acorn.internal.ClusterChange2; import org.simantics.acorn.internal.ClusterUpdateProcessor; @@ -21,7 +23,7 @@ final public class ClusterUpdateOperation { public ClusterChangeSet ccs; boolean finished = false; - public ClusterUpdateOperation(ClusterManager manager, byte[] data) { + public ClusterUpdateOperation(ClusterManager manager, byte[] data) throws IllegalAcornStateException, AcornAccessVerificationException { long cuid1 = Bytes.readLE8(data, 8); long cuid2 = Bytes.readLE8(data, 16); @@ -30,20 +32,19 @@ final public class ClusterUpdateOperation { this.uid = ClusterUID.make(cuid1, cuid2); this.data = data; this.info = manager.clusterLRU.getOrCreate(uid, true); - } public void finish() { finished = true; } - public void scheduled(String ccsInfoId) { + public void scheduled(String ccsInfoId) throws AcornAccessVerificationException, IllegalAcornStateException { ccs = new ClusterChangeSet(ccsInfoId, uid); chunk = ccs.getChunk(manager); manager.addIntoCurrentChangeSet(ccsInfoId); } - public void run() { + public void run() throws AcornAccessVerificationException, IllegalAcornStateException { ClusterUpdateOperation op = null; byte[] data = null; chunk.acquireMutex(); @@ -51,15 +52,13 @@ final public class ClusterUpdateOperation { chunk.makeResident(); op = chunk.operations.get(ccs.chunkOffset); data = op.data; - } catch (Throwable t) { - throw new IllegalStateException(t); } finally { chunk.releaseMutex(); } op.runWithData(data); } - public void runWithData(byte[] data) { + public void runWithData(byte[] data) throws IllegalAcornStateException, AcornAccessVerificationException { try { int version = Bytes.readLE4(data, 4); @@ -74,12 +73,13 @@ final public class ClusterUpdateOperation { processor.process(cluster); manager.update(uid, cluster); } else { - throw new IllegalStateException(); + throw new IllegalAcornStateException("unsupported clusterChange version " + version); } + } catch (IllegalAcornStateException | AcornAccessVerificationException e) { + throw e; } catch (Throwable t) { - t.printStackTrace(); + throw new IllegalAcornStateException(t); } - } @Override