📄 classicstore.java
字号:
// You can redistribute this software and/or modify it under the terms of
// the Ozone Core License version 1 published by ozone-db.org.
//
// The original code and portions created by SMB are
// Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
//
// $Id$
package org.ozoneDB.core.storage.classicStore;
import org.ozoneDB.OzoneCompatible;
import org.ozoneDB.PermissionDeniedException;
import org.ozoneDB.ObjectNotFoundException;
import org.ozoneDB.DxLib.DxSet;
import org.ozoneDB.DxLib.DxBag;
import org.ozoneDB.DxLib.DxIterator;
import org.ozoneDB.core.*;
import org.ozoneDB.core.storage.classicStore.ClassicObjectContainer;
import org.ozoneDB.util.LogWriter;
import java.io.IOException;
/**
* ClassicStore acts as the mediator (director) of the classicStore module
* especially for ClusterSpace, ObjectSpace, PersistentSpace. Currently it
* serves only as container for the references but this should change in the
* future to decouple class implementations.
*
* @author <a href="http://www.softwarebuero.de/">SMB</a>
*/
public final class ClassicStore extends ServerComponent implements StoreManager {
/** */
protected Env env;
protected ObjectSpace objectSpace;
/** */
public ClassicStore(Env env) {
super(env);
}
/** */
public void init( Env _env ) {
env = _env;
objectSpace = new ObjectSpace( _env );
}
public void save() throws Exception {
// do nothing for now...
}
/** */
public void startup() throws Exception {
env.logWriter.newEntry( this, "startup...", LogWriter.INFO );
objectSpace.startup();
}
/** */
public void shutdown() throws Exception {
env.logWriter.newEntry( this, "shutdown...", LogWriter.INFO );
objectSpace.shutdown();
}
/**
* Creates a new object container and initializes it with the specified
* target object. The new container is immediatly accessible from the calling
* transaction via containerByID but it is not joined to this transaction.
* It needs to be joined and commited afterwards.
*
* Iff this method returns normally, the returned container is pinned and thus has to be unpinned.
* Iff this method returns normally, the returned container is locked with the given lock level.
*
* @param ta
* @param target
* @param objID
* @param permissions
* @param lockLevel
* @return An container-proxy for the created container.
*/
public ObjectContainer newContainerAndLock(Transaction ta, OzoneCompatible target, ObjectID objID,
Permissions permissions, int lockLevel) throws Exception {
return objectSpace.newContainer( ta, target, objID, permissions );
}
public Object newTransactionData() {
throw new RuntimeException("not yet implemented");
}
/**
* Update lock level of the given container according to the level of the
* containers lock object.
*/
public void updateLockLevel(Transaction ta, ObjectContainer container) throws IOException {
throw new RuntimeException("not yet implemented");
}
/**
* @param ta the running transaction
* @return a String array of the all object names defined
*/
public DxSet objectNames(Transaction ta) {
throw new RuntimeException("not yet implemented");
}
public ObjectContainer containerForID(Transaction ta, ObjectID id) throws ObjectNotFoundException, IOException, ClassNotFoundException {
return objectSpace.objectForID( id );
}
/**
* @param name The object name to search for.
* @param ta
* @return The object container for the name or null.
*/
public ObjectContainer containerForName(Transaction ta, String name) throws Exception {
return objectSpace.objectForName( name );
}
/**
* Force the Store to make a guess which objects are used together with the
* container with the specified id.
* @param id The ObjectID if the container.
*/
public DxBag clusterOfID(ObjectID id) throws Exception {
throw new RuntimeException("not yet implemented");
}
public DxIterator objectIDIterator() {
throw new RuntimeException("not yet implemented");
}
/**
Tells this StoreManager to report every named object to the garbage collector.
*/
public void reportNamedObjectsToGarbageCollector() {
throw new RuntimeException("not yet implemented");
}
/**
* @param ta
* @param container
* @param name
*/
public void nameContainer( Transaction ta, ObjectContainer container, String name ) throws PermissionDeniedException {
try {
objectSpace.nameObject( container, name );
} catch (ClassicStoreException e) {
throw new PermissionDeniedException( e.toString() );
}
}
// /** */
// public void join( Transaction ta, ObjectContainer container, int lockLevel ) throws Exception {
// //System.out.println ("join: " + container.id());
// ClassicObjectContainer classicCon = (ClassicObjectContainer)container;
// classicCon.upgradeLockLevel( ta, lockLevel );
//
// ta.idTable.addForKey( classicCon, classicCon.id() );
// }
public Transaction createTransaction(Env env, User user) {
return new ClassicTransaction(env, user);
}
/**
* @param ta Transaction that will be commited.
*/
public void prepareCommitTransaction( Transaction ta ) {
objectSpace.prepareCommitObjects((ClassicTransaction) ta );
}
/** */
public void commitTransaction( Transaction ta ) {
objectSpace.commitObjects( ta );
}
/**
* @param ta ID of the comitting transaction.
*/
public void abortTransaction( Transaction ta ) {
try {
objectSpace.abortObjects((ClassicTransaction) ta );
} catch (Exception e) {
env.logWriter.newEntry( this, "Abort of transaction " + ta.taID() + " failed !\n" + e, LogWriter.ERROR );
}
}
/** */
public void upgradeLockLevel( Transaction ta, ObjectContainer container, int lockLevel ) throws Exception {
((ClassicObjectContainer)container).upgradeLockLevel( ta, lockLevel );
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -