-
- workingDirectory = dbFolder.resolve(Integer.toString(mainState.headDir));
- Files.createDirectories(workingDirectory);
-
- csLRU = new LRU<Long, ChangeSetInfo>("Change Set", workingDirectory);
- streamLRU = new LRU<String, ClusterStreamChunk>("Cluster Stream", workingDirectory);
- clusterLRU = new ClusterLRU(this, "Cluster", workingDirectory);
- fileLRU = new LRU<String, FileInfo>("External Value", workingDirectory);
-
- acquireAll();
-
- // Clusters
- for (String clusterKey : state.clusters) {
- String[] parts1 = clusterKey.split("#");
- String[] parts = parts1[0].split("\\.");
- long first = new BigInteger(parts[0], 16).longValue();
- long second = new BigInteger(parts[1], 16).longValue();
- ClusterUID uuid = ClusterUID.make(first, second);
- Path readDir = dbFolder.resolve(parts1[1]);
- int offset = Integer.parseInt(parts1[2]);
- int length = Integer.parseInt(parts1[3]);
- clusterLRU.map(new ClusterInfo(this, clusterLRU, readDir, uuid, offset, length));
- }
- // Files
- for (String fileKey : state.files) {
-// System.err.println("loadFile: " + fileKey);
- String[] parts = fileKey.split("#");
- Path readDir = dbFolder.resolve(parts[1]);
- int offset = Integer.parseInt(parts[2]);
- int length = Integer.parseInt(parts[3]);
- FileInfo info = new FileInfo(fileLRU, readDir, parts[0], offset, length);
- fileLRU.map(info);
- }
- // Update chunks
- for (String fileKey : state.stream) {
-// System.err.println("loadStream: " + fileKey);
- String[] parts = fileKey.split("#");
- Path readDir = dbFolder.resolve(parts[1]);
- int offset = Integer.parseInt(parts[2]);
- int length = Integer.parseInt(parts[3]);
- ClusterStreamChunk info = new ClusterStreamChunk(this,
- streamLRU, readDir, parts[0], offset, length);
- streamLRU.map(info);
- }
- // Change sets
- for (String fileKey : state.cs) {
- String[] parts = fileKey.split("#");
- Path readDir = dbFolder.resolve(parts[1]);
- Long revisionId = Long.parseLong(parts[0]);
- int offset = Integer.parseInt(parts[2]);
- int length = Integer.parseInt(parts[3]);
- ChangeSetInfo info = new ChangeSetInfo(csLRU, readDir, revisionId, offset, length);
- csLRU.map(info);
+ try {
+ workingDirectory = dbFolder.resolve(Integer.toString(mainState.headDir));
+ Files.createDirectories(workingDirectory);
+
+ csLRU = new LRU<Long, ChangeSetInfo>(this, "Change Set", workingDirectory);
+ streamLRU = new LRU<String, ClusterStreamChunk>(this, "Cluster Stream", workingDirectory);
+ clusterLRU = new ClusterLRU(this, "Cluster", workingDirectory);
+ fileLRU = new LRU<String, FileInfo>(this, "External Value", workingDirectory);
+
+ acquireAll();
+
+ // Clusters
+ for (String clusterKey : state.clusters) {
+ String[] parts1 = clusterKey.split("#");
+ String[] parts = parts1[0].split("\\.");
+ long first = new BigInteger(parts[0], 16).longValue();
+ long second = new BigInteger(parts[1], 16).longValue();
+ ClusterUID uuid = ClusterUID.make(first, second);
+ Path readDir = dbFolder.resolve(parts1[1]);
+ int offset = Integer.parseInt(parts1[2]);
+ int length = Integer.parseInt(parts1[3]);
+ clusterLRU.map(new ClusterInfo(this, clusterLRU, readDir, uuid, offset, length));
+ }
+ // Files
+ for (String fileKey : state.files) {
+ // System.err.println("loadFile: " + fileKey);
+ String[] parts = fileKey.split("#");
+ Path readDir = dbFolder.resolve(parts[1]);
+ int offset = Integer.parseInt(parts[2]);
+ int length = Integer.parseInt(parts[3]);
+ FileInfo info = new FileInfo(fileLRU, readDir, parts[0], offset, length);
+ fileLRU.map(info);
+ }
+ // Update chunks
+ for (String fileKey : state.stream) {
+ // System.err.println("loadStream: " + fileKey);
+ String[] parts = fileKey.split("#");
+ Path readDir = dbFolder.resolve(parts[1]);
+ int offset = Integer.parseInt(parts[2]);
+ int length = Integer.parseInt(parts[3]);
+ ClusterStreamChunk info = new ClusterStreamChunk(this,
+ streamLRU, readDir, parts[0], offset, length);
+ streamLRU.map(info);
+ }
+ // Change sets
+ for (String fileKey : state.cs) {
+ String[] parts = fileKey.split("#");
+ Path readDir = dbFolder.resolve(parts[1]);
+ Long revisionId = Long.parseLong(parts[0]);
+ int offset = Integer.parseInt(parts[2]);
+ int length = Integer.parseInt(parts[3]);
+ ChangeSetInfo info = new ChangeSetInfo(csLRU, readDir, revisionId, offset, length);
+ csLRU.map(info);
+ }
+
+ releaseAll();
+ } catch (IllegalAcornStateException | AcornAccessVerificationException e) {
+ // ROLLBACK ONE DIR UNTIL WE ARE FINE!
+ throw new IOException(e);