helpful progress reporting
[IRC.git] / Robust / Transactions / src / file / factory / TransactionLocalFileAttributes.java
1 /*
2  * To change this template, choose Tools | Templates
3  * and open the template in the editor.
4  */
5 package dstm2.file.factory;
6
7 import java.io.FileDescriptor;
8 import java.io.IOException;
9 import java.io.RandomAccessFile;
10 import java.util.SortedSet;
11 import java.util.TreeMap;
12 import java.util.Vector;
13 import java.util.concurrent.atomic.AtomicInteger;
14 import java.util.concurrent.locks.ReentrantLock;
15 import java.util.logging.Level;
16 import java.util.logging.Logger;
17
18 /**
19  *
20  * @author navid
21  */
22 public class TransactionLocalFileAttributes {
23
24     //public int recordedversion;
25     public Adapter adapter;
26     
27     public boolean to_be_created = false;
28     RandomAccessFile f;
29     private boolean validatelocaloffset = true;
30     public boolean writetoabsoluteoffset = false;
31     public int writetoabsoluteoffsetfromhere = -1;
32     public ReentrantLock offsetlock;
33     //Vector<Integer> startoffset; 
34     //Vector<Byte[]> data;
35     //Vector<Integer> occupiedblocks;
36     // private Vector readoccupiedblocks;
37     //private Vector writeoccupiedblocks;
38     // private Vector startoffset; 
39     // private Vector data;
40     //private TreeMap<Range, Byte[]> writtendata;
41     private TreeMap writtendata;
42     //private TreeMap<Integer, MODE> accesesblocks;
43     private TreeMap accesedblocks;
44     //private TreeMap<Integer, Integer> blockversions;
45     private TreeMap blockversions;
46     
47     
48     public Offset currentcommitedoffset;
49     private final long copylocaloffset;
50     private final long copycurrentfilesize;
51     private long localoffset;
52     private long filelength;
53
54
55     public boolean isValidatelocaloffset() {
56         return validatelocaloffset;
57     }
58
59     public void setValidatelocaloffset(boolean validatelocaloffset) {
60         this.validatelocaloffset = validatelocaloffset;
61     }
62
63     public long getFilelength() {
64         return filelength;
65     }
66
67     public void setFilelength(long filelength) {
68         this.filelength = filelength;
69     }
70
71     public long getLocaloffset() {
72         return localoffset;
73     }
74
75     public void setLocaloffset(long localoffset) {
76         this.localoffset = localoffset;
77     }
78     
79     //public MODE accessmode;
80
81     public TreeMap getAccesedblocks() {
82         return accesedblocks;
83     }
84
85     public TreeMap getBlockversions() {
86         return blockversions;
87     }
88
89     public long getCopycurrentfilesize() {
90         return copycurrentfilesize;
91     }
92
93     public long getCopylocaloffset() {
94         return copylocaloffset;
95     }
96     
97
98     /*    public Vector getData() {
99     return data;
100     }
101     
102     public Vector getReadoccupiedblocks() {
103     return readoccupiedblocks;
104     }
105     
106     public Vector getWriteoccupiedblocks() {
107     return writeoccupiedblocks;
108     }
109      */
110
111     /*    public Vector getStartoffset() {
112     return startoffset;
113     }
114      */
115     public TransactionLocalFileAttributes(Adapter adapter, boolean to_be_created, /*TransactionLocalFileAttributes.MODE mode,*/ RandomAccessFile f, ReentrantLock offsetlock, Offset currentcommitedoffset) {
116
117             this.adapter = adapter;
118             this.localoffset = currentcommitedoffset.getOffsetnumber();
119             this.copylocaloffset = this.localoffset;
120             this.currentcommitedoffset = currentcommitedoffset;
121             this.filelength = adapter.commitedfilesize.get();
122             this.copycurrentfilesize = this.filelength;
123             this.to_be_created = to_be_created;
124             this.f = f;
125             //this.filelength = filelength;
126             writtendata = new TreeMap();
127             validatelocaloffset = false;
128             this.offsetlock = offsetlock;
129             
130             //readoccupiedblocks = new Vector();
131             //writeoccupiedblocks = new Vector();
132             //accessmode = mode;
133             //recordedversion = adapter.version.get();
134             //startoffset = new Vector();
135             //data = new Vector();
136             //readoccupiedblocks = new Vector();
137             //writeoccupiedblocks = new Vector();
138     }
139
140     public TreeMap getWrittendata() {
141         return writtendata;
142     }
143 }