1 9 package org.ozoneDB.core.storage.classicStore; 10 11 import org.ozoneDB.OzoneCompatible; 12 import org.ozoneDB.PermissionDeniedException; 13 import org.ozoneDB.ObjectNotFoundException; 14 import org.ozoneDB.DxLib.DxSet; 15 import org.ozoneDB.DxLib.DxBag; 16 import org.ozoneDB.DxLib.DxIterator; 17 import org.ozoneDB.core.*; 18 import org.ozoneDB.core.storage.classicStore.ClassicObjectContainer; 19 import org.ozoneDB.util.LogWriter; 20 21 import java.io.IOException ; 22 23 24 32 public final class ClassicStore extends ServerComponent implements StoreManager { 33 34 protected Env env; 35 protected ObjectSpace objectSpace; 36 37 38 39 public ClassicStore(Env env) { 40 super(env); 41 } 42 43 44 45 public void init( Env _env ) { 46 env = _env; 47 objectSpace = new ObjectSpace( _env ); 48 } 49 50 public void save() throws Exception { 51 } 53 54 55 public void startup() throws Exception { 56 env.logWriter.newEntry( this, "startup...", LogWriter.INFO ); 57 objectSpace.startup(); 58 } 59 60 61 62 public void shutdown() throws Exception { 63 env.logWriter.newEntry( this, "shutdown...", LogWriter.INFO ); 64 objectSpace.shutdown(); 65 } 66 67 83 public ObjectContainer newContainerAndLock(Transaction ta, OzoneCompatible target, ObjectID objID, 84 Permissions permissions, int lockLevel) throws Exception { 85 return objectSpace.newContainer( ta, target, objID, permissions ); 86 } 87 88 89 public Object newTransactionData() { 90 throw new RuntimeException ("not yet implemented"); 91 } 92 93 97 public void updateLockLevel(Transaction ta, ObjectContainer container) throws IOException { 98 throw new RuntimeException ("not yet implemented"); 99 } 100 101 105 public DxSet objectNames(Transaction ta) { 106 throw new RuntimeException ("not yet implemented"); 107 } 108 109 public ObjectContainer containerForID(Transaction ta, ObjectID id) throws ObjectNotFoundException, IOException , ClassNotFoundException { 110 return objectSpace.objectForID( id ); 111 } 112 113 118 public ObjectContainer containerForName(Transaction ta, String name) throws Exception { 119 return objectSpace.objectForName( name ); 120 } 121 122 127 public DxBag clusterOfID(ObjectID id) throws Exception { 128 throw new RuntimeException ("not yet implemented"); 129 } 130 131 public DxIterator objectIDIterator() { 132 throw new RuntimeException ("not yet implemented"); 133 } 134 135 138 public void reportNamedObjectsToGarbageCollector() { 139 throw new RuntimeException ("not yet implemented"); 140 } 141 142 143 148 public void nameContainer( Transaction ta, ObjectContainer container, String name ) throws PermissionDeniedException { 149 try { 150 objectSpace.nameObject( container, name ); 151 } catch (ClassicStoreException e) { 152 throw new PermissionDeniedException( e.toString() ); 153 } 154 } 155 156 157 166 public Transaction createTransaction(Env env, User user) { 167 return new ClassicTransaction(env, user); 168 } 169 170 173 public void prepareCommitTransaction( Transaction ta ) { 174 objectSpace.prepareCommitObjects((ClassicTransaction) ta ); 175 } 176 177 178 179 public void commitTransaction( Transaction ta ) { 180 objectSpace.commitObjects( ta ); 181 } 182 183 184 187 public void abortTransaction( Transaction ta ) { 188 try { 189 objectSpace.abortObjects((ClassicTransaction) ta ); 190 } catch (Exception e) { 191 env.logWriter.newEntry( this, "Abort of transaction " + ta.taID() + " failed !\n" + e, LogWriter.ERROR ); 192 } 193 } 194 195 196 197 public void upgradeLockLevel( Transaction ta, ObjectContainer container, int lockLevel ) throws Exception { 198 ((ClassicObjectContainer)container).upgradeLockLevel( ta, lockLevel ); 199 } 200 } 201 | Popular Tags |