當前位置: 首頁>>代碼示例>>Java>>正文


Java PersistException類代碼示例

本文整理匯總了Java中com.amazon.carbonado.PersistException的典型用法代碼示例。如果您正苦於以下問題:Java PersistException類的具體用法?Java PersistException怎麽用?Java PersistException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


PersistException類屬於com.amazon.carbonado包,在下文中一共展示了PersistException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: updateBlock

import com.amazon.carbonado.PersistException; //導入依賴的package包/類
private void updateBlock() throws PersistException {
    if (mStoredBlock != null) {
        byte[] blockData = mBlockData;
        if (blockData.length != mBlockLength) {
            byte[] truncated = new byte[mBlockLength];
            System.arraycopy(blockData, 0, truncated, 0, truncated.length);
            blockData = truncated;
        }
        mStoredBlock.setData(blockData);
        if (mDoInsert) {
            mStoredBlock.insert();
            mDoInsert = false;
        } else {
            mStoredBlock.update();
        }
    }
}
 
開發者ID:Carbonado,項目名稱:Carbonado,代碼行數:18,代碼來源:LobEngine.java

示例2: nextIntValue

import com.amazon.carbonado.PersistException; //導入依賴的package包/類
/**
 * Returns the next value from the sequence, which may wrap negative if all
 * positive values are exhausted. When sequence wraps back to initial
 * value, the sequence is fully exhausted, and an exception is thrown to
 * indicate this.
 *
 * <p>Note: this method throws PersistException even for fetch failures
 * since this method is called by insert operations. Insert operations can
 * only throw a PersistException.
 *
 * @throws PersistException for fetch/persist failure or if sequence is
 * exhausted for int values.
 */
@Override
public int nextIntValue() throws PersistException {
    try {
        synchronized (mStoredSequence) {
            long initial = mStoredSequence.getInitialValue();
            if (initial >= 0x100000000L) {
                throw new PersistException
                    ("Sequence initial value too large to support 32-bit ints: " +
                     mStoredSequence.getName() + ", initial: " + initial);
            }
            long next = nextUnadjustedValue();
            if (next >= Long.MIN_VALUE + 0x100000000L) {
                // Everytime we throw this exception, a long sequence value
                // has been lost. This seems fairly benign.
                throw new PersistException
                    ("Sequence exhausted for 32-bit ints: " + mStoredSequence.getName() +
                     ", next: " + (next + Long.MIN_VALUE + initial));
            }
            return (int) (next + Long.MIN_VALUE + initial);
        }
    } catch (FetchException e) {
        throw e.toPersistException();
    }
}
 
開發者ID:Carbonado,項目名稱:Carbonado,代碼行數:38,代碼來源:SequenceValueGenerator.java

示例3: store

import com.amazon.carbonado.PersistException; //導入依賴的package包/類
public void store(S storable, byte[] key, byte[] value) throws PersistException {
    TransactionScope<Txn> scope = mStorage.localTransactionScope();
    // Lock out shutdown task.
    scope.getLock().lock();
    try {
        try {
            if (!mStorage.db_put(scope.getTxn(), key, value)) {
                throw new PersistException("Failed");
            }
        } catch (Throwable e) {
            throw mStorage.toPersistException(e);
        }
    } finally {
        scope.getLock().unlock();
    }
}
 
開發者ID:Carbonado,項目名稱:Carbonado,代碼行數:17,代碼來源:BDBStorage.java

示例4: beforeInsert

import com.amazon.carbonado.PersistException; //導入依賴的package包/類
@Override
public Object beforeInsert(Transaction txn, S storable) throws PersistException {
    if (isLocallyDisabled()) {
        return null;
    }

    TriggerStates<S> triggerStates = null;
    Trigger<? super S>[] triggers = mTriggers;

    for (int i=triggers.length; --i>=0; ) {
        Object state = triggers[i].beforeInsert(txn, storable);
        if (state != null) {
            if (triggerStates == null) {
                triggerStates = new TriggerStates<S>(triggers);
            }
            triggerStates.mStates[i] = state;
        }
    }

    return triggerStates == null ? triggers : triggerStates;
}
 
開發者ID:Carbonado,項目名稱:Carbonado,代碼行數:22,代碼來源:TriggerManager.java

示例5: beforeTryUpdate

import com.amazon.carbonado.PersistException; //導入依賴的package包/類
@Override
public Object beforeTryUpdate(Transaction txn, S storable) throws PersistException {
    if (isLocallyDisabled()) {
        return null;
    }

    TriggerStates<S> triggerStates = null;
    Trigger<? super S>[] triggers = mTriggers;

    for (int i=triggers.length; --i>=0; ) {
        Object state = triggers[i].beforeTryUpdate(txn, storable);
        if (state != null) {
            if (triggerStates == null) {
                triggerStates = new TriggerStates<S>(triggers);
            }
            triggerStates.mStates[i] = state;
        }
    }

    return triggerStates == null ? triggers : triggerStates;
}
 
開發者ID:Carbonado,項目名稱:Carbonado,代碼行數:22,代碼來源:TriggerManager.java

示例6: deleteLob

import com.amazon.carbonado.PersistException; //導入依賴的package包/類
/**
 * Deletes Lob data, freeing up all space consumed by it.
 */
public void deleteLob(long locator) throws PersistException {
    if (locator == 0) {
        return;
    }

    Transaction txn = mRepo.enterTransaction(IsolationLevel.READ_COMMITTED);
    try {
        StoredLob lob = mLobStorage.prepare();
        lob.setLocator(locator);
        if (lob.tryDelete()) {
            try {
                mLobBlockStorage.query("locator = ?").with(lob.getLocator()).deleteAll();
            } catch (FetchException e) {
                throw e.toPersistException();
            }
        }
        txn.commit();
    } finally {
        txn.exit();
    }
}
 
開發者ID:Carbonado,項目名稱:Carbonado,代碼行數:25,代碼來源:LobEngine.java

示例7: beforeTryInsert

import com.amazon.carbonado.PersistException; //導入依賴的package包/類
@Override
public Object beforeTryInsert(S storable) throws PersistException {
    if (isLocallyDisabled()) {
        return null;
    }

    TriggerStates<S> triggerStates = null;
    Trigger<? super S>[] triggers = mTriggers;

    for (int i=triggers.length; --i>=0; ) {
        Object state = triggers[i].beforeTryInsert(storable);
        if (state != null) {
            if (triggerStates == null) {
                triggerStates = new TriggerStates<S>(triggers);
            }
            triggerStates.mStates[i] = state;
        }
    }

    return triggerStates == null ? triggers : triggerStates;
}
 
開發者ID:Carbonado,項目名稱:Carbonado,代碼行數:22,代碼來源:TriggerManager.java

示例8: beforeDelete

import com.amazon.carbonado.PersistException; //導入依賴的package包/類
@Override
public Object beforeDelete(S storable) throws PersistException {
    if (isLocallyDisabled()) {
        return null;
    }

    TriggerStates<S> triggerStates = null;
    Trigger<? super S>[] triggers = mTriggers;

    for (int i=triggers.length; --i>=0; ) {
        Object state = triggers[i].beforeDelete(storable);
        if (state != null) {
            if (triggerStates == null) {
                triggerStates = new TriggerStates<S>(triggers);
            }
            triggerStates.mStates[i] = state;
        }
    }

    return triggerStates == null ? triggers : triggerStates;
}
 
開發者ID:Carbonado,項目名稱:Carbonado,代碼行數:22,代碼來源:TriggerManager.java

示例9: toPersistException

import com.amazon.carbonado.PersistException; //導入依賴的package包/類
/**
 * Transforms the given throwable into an appropriate persist exception. If
 * it already is a persist exception, it is simply casted.
 *
 * @param e required exception to transform
 * @return PersistException, never null
 */
public PersistException toPersistException(Throwable e) {
    PersistException pe = transformIntoPersistException(e);
    if (pe != null) {
        return pe;
    }

    Throwable cause = e.getCause();
    if (cause != null) {
        pe = transformIntoPersistException(cause);
        if (pe != null) {
            return pe;
        }
    } else {
        cause = e;
    }

    return new PersistException(cause);
}
 
開發者ID:Carbonado,項目名稱:Carbonado,代碼行數:26,代碼來源:ExceptionTransformer.java

示例10: reset

import com.amazon.carbonado.PersistException; //導入依賴的package包/類
/**
 * Reset the sequence.
 *
 * @param initialValue first value produced by sequence
 */
public void reset(int initialValue) throws FetchException, PersistException {
    synchronized (mStoredSequence) {
        Transaction txn = mRepository.enterTopTransaction(null);
        txn.setForUpdate(true);
        try {
            boolean doUpdate = mStoredSequence.tryLoad();
            mStoredSequence.setInitialValue(initialValue);
            // Start as small as possible to allow signed long comparisons to work.
            mStoredSequence.setNextValue(Long.MIN_VALUE);
            if (doUpdate) {
                mStoredSequence.update();
            } else {
                mStoredSequence.insert();
            }
            txn.commit();
            mHasReservedValues = false;
        } finally {
            txn.exit();
        }
    }
}
 
開發者ID:Carbonado,項目名稱:Carbonado,代碼行數:27,代碼來源:SequenceValueGenerator.java

示例11: beforeTryDelete

import com.amazon.carbonado.PersistException; //導入依賴的package包/類
@Override
public Object beforeTryDelete(Transaction txn, S storable) throws PersistException {
    if (isLocallyDisabled()) {
        return null;
    }

    TriggerStates<S> triggerStates = null;
    Trigger<? super S>[] triggers = mTriggers;

    for (int i=triggers.length; --i>=0; ) {
        Object state = triggers[i].beforeTryDelete(txn, storable);
        if (state != null) {
            if (triggerStates == null) {
                triggerStates = new TriggerStates<S>(triggers);
            }
            triggerStates.mStates[i] = state;
        }
    }

    return triggerStates == null ? triggers : triggerStates;
}
 
開發者ID:Carbonado,項目名稱:Carbonado,代碼行數:22,代碼來源:TriggerManager.java

示例12: tryInsert

import com.amazon.carbonado.PersistException; //導入依賴的package包/類
public boolean tryInsert(S storable, byte[] key, byte[] value) throws PersistException {
    TransactionScope<Txn> scope = mStorage.localTransactionScope();
    Object result;
    // Lock out shutdown task.
    scope.getLock().lock();
    try {
        try {
            result = mStorage.db_putNoOverwrite(scope.getTxn(), key, value);
        } catch (Throwable e) {
            throw mStorage.toPersistException(e);
        }
    } finally {
        scope.getLock().unlock();
    }
    if (result == KEY_EXIST) {
        return false;
    }
    if (result != SUCCESS) {
        throw new PersistException("Failed");
    }
    return true;
}
 
開發者ID:Carbonado,項目名稱:Carbonado,代碼行數:23,代碼來源:BDBStorage.java

示例13: transformIntoPersistException

import com.amazon.carbonado.PersistException; //導入依賴的package包/類
@Override
protected PersistException transformIntoPersistException(Throwable e) {
    PersistException pe = super.transformIntoPersistException(e);
    if (pe != null) {
        return pe;
    }
    if (e instanceof LockFailureException) {
        if (e instanceof LockTimeoutException) {
            if (e instanceof DeadlockException) {
                String message = messageFrom((DeadlockException) e);
                return message == null ? new PersistDeadlockException(e)
                    : new PersistDeadlockException(message);
            }
            return new PersistTimeoutException(e);
        }
        if (e instanceof LockInterruptedException) {
            return new PersistInterruptedException(e);
        }
    }
    if (e instanceof UnmodifiableReplicaException) {
        return new PersistDeniedException(e);
    }
    return null;
}
 
開發者ID:Carbonado,項目名稱:CarbonadoTupl,代碼行數:25,代碼來源:TuplExceptionTransformer.java

示例14: createSequenceValueProducer

import com.amazon.carbonado.PersistException; //導入依賴的package包/類
/**
 * @since 1.2
 */
SequenceValueProducer createSequenceValueProducer(String name) 
    throws RepositoryException
{
    if (name == null) {
        throw new IllegalArgumentException("Sequence name is null");
    }
    String format = getSequenceSelectStatement();
    if (format != null && format.length() > 0 && !isForceStoredSequence()) {
        String sequenceQuery = String.format(format, name);
        return new JDBCSequenceValueProducer(mRepo, sequenceQuery);
    } else {
        try {
            return new SequenceValueGenerator(mRepo, name);
        } catch (UnsupportedTypeException e) {
            if (e.getType() != StoredSequence.class) {
                throw e;
            }
            throw new PersistException
                ("Native sequences are not currently supported for \"" +
                 mRepo.getDatabaseProductName() + "\". Instead, define a table named " +
                 "CARBONADO_SEQUENCE as required by " + StoredSequence.class.getName() + '.');
        }
    }
}
 
開發者ID:Carbonado,項目名稱:Carbonado,代碼行數:28,代碼來源:JDBCSupportStrategy.java

示例15: setClobValue

import com.amazon.carbonado.PersistException; //導入依賴的package包/類
/**
 * Stores a value into a Clob, replacing anything that was there
 * before. Passing null deletes the Clob, which is a convenience for
 * auto-generated code that may call this method.
 *
 * @param locator lob locator as created by createNewClob
 * @param data source of data for Clob, which may be null to delete
 * @throws IllegalArgumentException if locator is zero
 */
public void setClobValue(long locator, Clob data) throws PersistException, IOException {
    if (data == null) {
        deleteLob(locator);
        return;
    }

    if (locator == 0) {
        throw new IllegalArgumentException("Cannot use locator zero");
    }

    if (data instanceof ClobImpl) {
        BlobImpl impl = ((ClobImpl) data).getWrappedBlob();
        if (impl.getEnclosing() == this && impl.mLocator == locator) {
            // Blob is ours and locator is the same, so nothing to do.
            return;
        }
    }

    try {
        setClobValue(locator, data.openReader(0, 0));
    } catch (FetchException e) {
        throw e.toPersistException();
    }
}
 
開發者ID:Carbonado,項目名稱:Carbonado,代碼行數:34,代碼來源:LobEngine.java


注:本文中的com.amazon.carbonado.PersistException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。