⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 transaction.java

📁 Java的面向对象数据库系统的源代码
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
                ObjectContainer oldContainerWithThatName = env.storeManager.containerForName(this, name);

                if (oldContainerWithThatName != null) {
                    oldContainerWithThatName.unpin();
                    throw new PermissionDeniedException("Root object name '" + name + "' already exists.");
                }

                env.storeManager.nameContainer(this, container, name);
            } finally {
                releaseObject(container);
            }
        } catch (OzoneRemoteException e) {
            throw e;
        } catch (Exception e) {
            env.logWriter.newEntry(this, "nameObject()", e, LogWriter.WARN);
            throw new OzoneInternalException(e.toString(), e);
        }
    }

    public DxSet objectNames() throws Exception {
        if (env.logWriter.hasTarget(LogWriter.DEBUG3)) {
            env.logWriter.newEntry(this, "objectNames()", LogWriter.DEBUG3);
        }

        // check (and wait) if a thread runs exclusively;
        env.transactionManager.checkExclusion();

        try {
            return env.storeManager.objectNames(this);

        } catch (OzoneRemoteException e) {
            throw e;
        } catch (Exception e) {
            env.logWriter.newEntry(this, "objectNames()", e, LogWriter.WARN);
            throw new OzoneInternalException(e.toString(), e);
        }
    }

    public OzoneProxy objectForName(String name) throws Exception {
        if (env.logWriter.hasTarget(LogWriter.DEBUG3)) {
            env.logWriter.newEntry(this, "objectForName()", LogWriter.DEBUG3);
        }

        // check (and wait) if a thread runs exclusively;
        env.transactionManager.checkExclusion();

        try {
            ObjectContainer container = env.storeManager.containerForName(this, name);
            if (container != null) {
                try {
                    return container.ozoneProxy();
                } finally {
                    container.unpin();
                }
            } else {
                return null;
            }
        } catch (OzoneRemoteException e) {
            throw e;
        } catch (Exception e) {
            env.logWriter.newEntry(this, "objectForName()", e, LogWriter.WARN);
            throw new OzoneInternalException(e.toString(), e);
        }
    }

    public OzoneProxy objectForID(ObjectID id) throws Exception {
        if (env.logWriter.hasTarget(LogWriter.DEBUG3)) {
            env.logWriter.newEntry(this, "objectForID()", LogWriter.DEBUG3);
        }

        // check (and wait) if a thread runs exclusively;
        env.transactionManager.checkExclusion();

        try {
            /*
            ObjectContainer container = env.storeManager.containerForID( this, id );
            if (container != null) {
                return container.ozoneProxy();
            } else {
                return null;
            }
            */
            ObjectContainer container = env.storeManager.containerForID(this, id);
            if (container != null) {
                try {
                    return container.ozoneProxy();
                } finally {
                    container.unpin();
                }
            } else {
                return null;
            }
        } catch (OzoneRemoteException e) {
            throw e;
        } catch (Exception e) {
            env.logWriter.newEntry(this, "objectForID()", e, LogWriter.WARN);
            throw new OzoneInternalException(e.toString());
        }
    }

    public void sleep(long millis) {
        try {
            sleeping = true;

            if (false) {
                Thread.currentThread().sleep(millis);
            } else {
                synchronized (this) {
                    this.wait(millis);
                }
            }
        } catch (Exception e) {
            env.logWriter.newEntry(this, "caught while sleeping", e, LogWriter.ERROR);
        } finally {
            sleeping = false;
        }
    }

    protected boolean isSleeping() {
        return sleeping;
    }


    public TransactionID taID() {
        return taID;
    }


    public boolean equals(Object obj) {
        return hashCode() == obj.hashCode();
    }


    public String toString() {
//      return "ta[" + (byte)taID.value() + "]";
        return "ta[id=" + taID + ",blocker=" + blocker + "]";
    }


    public void finalize() throws Throwable {
        env.logWriter.newEntry(this, this + ".finalize()", LogWriter.DEBUG3);
    }

    public SimpleArrayList getCallStack() {
        return callStack;
    }

    public TransactionManager getManager() {
        return env.transactionManager;
    }
}


class FixHack extends Transaction {

    FixHack(TransactionID taID) {
        super(taID);
    }

    public synchronized void stop() {
        throw new RuntimeException("should not be called here");
    }

    public void reset() {
        // do nothing
    }

    protected void setDeadlockWaitTimeMaximum(long to) {
        throw new RuntimeException("should not be called here");
    }

    protected long getDeadlockWaitTimeMaximum() {
        throw new RuntimeException("should not be called here");
    }

    protected long increaseDeadlockWaitTimeMaximum() {
        throw new RuntimeException("should not be called here");
    }

    public void setDeadlocked(boolean to) {
        throw new RuntimeException("should not be called here");
    }

    public boolean isDeadlocked() {
        throw new RuntimeException("should not be called here");
    }

    public int status() {
        throw new RuntimeException("should not be called here");
    }

    public User owner() {
        throw new RuntimeException("should not be called here");
    }

    public int maxLockLevel() {
        throw new RuntimeException("should not be called here");
    }

    public void releaseObject(ObjectContainer objectContainer) {
        throw new RuntimeException("should not be called here");
    }

    protected void callOnPassivateIfNeeded(ObjectContainer container) {
        throw new RuntimeException("should not be called here");
    }

    public ObjectContainer acquireObject(ObjectID id, int lockLevel) throws ObjectNotFoundException, IOException, ClassNotFoundException, TransactionException, TransactionError {
        throw new RuntimeException("should not be called here");
    }

    protected void callOnActivateIfNeeded(ObjectContainer container) {
        throw new RuntimeException("should not be called here");
    }

    protected ObjectContainer acquireContainer(ObjectContainer container, int lockLevel) throws PermissionError, TransactionException, TransactionError, IOException, ObjectNotFoundException, ClassNotFoundException {
        throw new RuntimeException("should not be called here");
    }

    public void requireWriteLockingCallByUser(ObjectContainer container) {
        throw new RuntimeException("should not be called here");
    }

    public boolean performCommand(DbCommand command) {
        throw new RuntimeException("should not be called here");
    }

    public synchronized void prepareCommit() throws IOException, ClassNotFoundException {
        throw new RuntimeException("should not be called here");
    }

    public synchronized void commit() throws IOException, ClassNotFoundException {
        throw new RuntimeException("should not be called here");
    }

    public synchronized void abort(DbCommand command) throws IOException, ClassNotFoundException {
        throw new RuntimeException("should not be called here");
    }

    public Lockable blockedBy() {
        throw new RuntimeException("should not be called here");
    }

    public boolean isBlocked() {
        throw new RuntimeException("should not be called here");
    }

    public ObjectContainer createObject(String className, int access, String name, String sig, Object[] args, ObjectID id) throws Exception, org.ozoneDB.OzoneObjectException {
        throw new RuntimeException("should not be called here");
    }

    public ObjectContainer copyObject(ObjectID id) throws Exception {
        throw new RuntimeException("should not be called here");
    }

    public void deleteObject(ObjectID id) throws ObjectNotFoundException, IOException, ClassNotFoundException, TransactionException, TransactionError, OzoneRemoteException, OzoneInternalException, OzoneObjectException {
        throw new RuntimeException("should not be called here");
    }

    public Object invokeObject(ObjectID id, String methodName, String sig, Object[] args, int lockLevel) throws Exception, org.ozoneDB.OzoneObjectException {
        throw new RuntimeException("should not be called here");
    }

    public Object invokeObject(ObjectID id, int methodIndex, Object[] args, int lockLevel) throws Exception, org.ozoneDB.OzoneObjectException {
        throw new RuntimeException("should not be called here");
    }

    public void nameObject(ObjectID id, String name) throws Exception {
        throw new RuntimeException("should not be called here");
    }

    public DxSet objectNames() throws Exception {
        throw new RuntimeException("should not be called here");
    }

    public OzoneProxy objectForName(String name) throws Exception {
        throw new RuntimeException("should not be called here");
    }

    public OzoneProxy objectForID(ObjectID id) throws Exception {
        throw new RuntimeException("should not be called here");
    }

    public void sleep(long millis) {
        throw new RuntimeException("should not be called here");
    }

    protected boolean isSleeping() {
        throw new RuntimeException("should not be called here");
    }

    public TransactionID taID() {
        return taID;
    }

    public boolean equals(Object obj) {
        throw new RuntimeException("should not be called here");
    }

    public SimpleArrayList getCallStack() {
        throw new RuntimeException("should not be called here");
    }

    public TransactionManager getManager() {
        throw new RuntimeException("should not be called here");
    }
}

// :indentSize=4:tabSize=4:noTabs=true:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -