X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.acorn%2Fsrc%2Forg%2Fsimantics%2Facorn%2Flru%2FClusterStreamChunk.java;h=29d211374e901f516e94d35e5324c422df2dfa97;hb=refs%2Fchanges%2F90%2F1690%2F3;hp=23cbfb1ce9cf2cbd1c8871e25dcc3216b2594aa0;hpb=c41f5d003bd0e73989f0f71cdd01a2a63b3b626d;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.acorn/src/org/simantics/acorn/lru/ClusterStreamChunk.java b/bundles/org.simantics.acorn/src/org/simantics/acorn/lru/ClusterStreamChunk.java index 23cbfb1ce..29d211374 100644 --- a/bundles/org.simantics.acorn/src/org/simantics/acorn/lru/ClusterStreamChunk.java +++ b/bundles/org.simantics.acorn/src/org/simantics/acorn/lru/ClusterStreamChunk.java @@ -7,6 +7,8 @@ import java.util.ArrayList; import org.simantics.acorn.ClusterManager; import org.simantics.acorn.Persistable; +import org.simantics.acorn.exception.AcornAccessVerificationException; +import org.simantics.acorn.exception.IllegalAcornStateException; import org.simantics.acorn.internal.ClusterChange; import org.simantics.acorn.internal.UndoClusterUpdateProcessor; import org.simantics.compressions.CompressionCodec; @@ -31,15 +33,15 @@ public class ClusterStreamChunk extends LRUObject im public ArrayList operations = new ArrayList(); // Stub - public ClusterStreamChunk(ClusterManager manager, LRU LRU, Path readDir, String id, int offset, int length) { - super(LRU, id, readDir, "clusterStream", offset, length, false, false); + public ClusterStreamChunk(ClusterManager manager, LRU LRU, Path readDir, String id, int offset, int length) throws AcornAccessVerificationException { + super(LRU, manager.getFileCache(), id, readDir, "clusterStream", offset, length, false, false); this.manager = manager; LRU.map(this); } // Creation - public ClusterStreamChunk(ClusterManager manager, LRU LRU, String id) { - super(LRU, id, LRU.getDirectory(), "clusterStream", true, true); + public ClusterStreamChunk(ClusterManager manager, LRU LRU, String id) throws AcornAccessVerificationException { + super(LRU, manager.getFileCache(), id, LRU.getDirectory(), "clusterStream", true, true); this.manager = manager; LRU.insert(this, accessTime); } @@ -51,8 +53,8 @@ public class ClusterStreamChunk extends LRUObject im makeResident(true); ClusterUpdateOperation op = operations.get(chunkOffset); - if(op == null) throw new IllegalStateException("Cluster Update Operation " + ccsId + " was not found."); - if(op.ccs == null) throw new IllegalStateException("Cluster ChangeSet " + ccsId + " was not found."); + if(op == null) throw new IllegalAcornStateException("Cluster Update Operation " + ccsId + " was not found."); + if(op.ccs == null) throw new IllegalAcornStateException("Cluster ChangeSet " + ccsId + " was not found."); UndoClusterUpdateProcessor proc = new UndoClusterUpdateProcessor(clusters, this, op.ccs); if(proc.version != ClusterChange.VERSION) @@ -69,9 +71,9 @@ public class ClusterStreamChunk extends LRUObject im } - public void addOperation(ClusterUpdateOperation op) { + public void addOperation(ClusterUpdateOperation op) throws IllegalAcornStateException { if(committed) - throw new IllegalStateException(); + throw new IllegalAcornStateException("Cannot add operation " + op + " to " + this + " if commited == true"); operations.add(op); size += op.data.length; // if(isCommitted()) { @@ -93,7 +95,7 @@ public class ClusterStreamChunk extends LRUObject im } @Override - public boolean canBePersisted() { + public boolean canBePersisted() throws AcornAccessVerificationException { if(!super.canBePersisted()) return false; if(!isCommitted()) return false; for(ClusterUpdateOperation op : operations) { @@ -213,7 +215,7 @@ public class ClusterStreamChunk extends LRUObject im private static StreamDecompressor decompressor = new StreamDecompressor(); @Override - public void fromFile(byte[] data_) { + public void fromFile(byte[] data_) throws IllegalAcornStateException, AcornAccessVerificationException { try { @@ -271,17 +273,13 @@ public class ClusterStreamChunk extends LRUObject im } } - operations.add(op); - } - } catch (IOException e) { - - throw new IllegalStateException(e); - - } - + throw new IllegalAcornStateException(e); + } catch (IllegalAcornStateException | AcornAccessVerificationException e) { + throw e; + } } @Override