当前位置: 首页>>代码示例>>Java>>正文


Java FetchException.toPersistException方法代码示例

本文整理汇总了Java中com.amazon.carbonado.FetchException.toPersistException方法的典型用法代码示例。如果您正苦于以下问题:Java FetchException.toPersistException方法的具体用法?Java FetchException.toPersistException怎么用?Java FetchException.toPersistException使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.amazon.carbonado.FetchException的用法示例。


在下文中一共展示了FetchException.toPersistException方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deleteAll

import com.amazon.carbonado.FetchException; //导入方法依赖的package包/类
@Override
public void deleteAll(Controller controller) throws PersistException {
    Transaction txn = enterTransaction(IsolationLevel.READ_COMMITTED);
    try {
        Cursor<S> cursor = fetch(controller);
        try {
            while (cursor.hasNext()) {
                cursor.next().tryDelete();
            }
        } finally {
            cursor.close();
        }
        if (txn != null) {
            txn.commit();
        }
    } catch (FetchException e) {
        throw e.toPersistException();
    } finally {
        if (txn != null) {
            txn.exit();
        }
    }
}
 
开发者ID:Carbonado,项目名称:Carbonado,代码行数:24,代码来源:StandardQuery.java

示例2: createDependentIndexEntries

import com.amazon.carbonado.FetchException; //导入方法依赖的package包/类
private void createDependentIndexEntries(S storable, List<Storable> dependentIndexEntries)
    throws PersistException
{
    try {
        Transaction txn = mFetcher.enterTransaction();
        try {
            // Make sure write lock is acquired when reading dependencies
            // since they might be updated later. Locks are held after this
            // transaction exits since it is nested in the trigger's transaction.
            txn.setForUpdate(true);

            Cursor<D> dependencies = mFetcher.fetchDependenentStorables(storable);
            try {
                while (dependencies.hasNext()) {
                    mFetcher.createIndexEntries(dependencies.next(), dependentIndexEntries);
                }
            } finally {
                dependencies.close();
            }
        } finally {
            txn.exit();
        }
    } catch (FetchException e) {
        throw e.toPersistException();
    }
}
 
开发者ID:Carbonado,项目名称:Carbonado,代码行数:27,代码来源:DerivedIndexesTrigger.java

示例3: deleteLob

import com.amazon.carbonado.FetchException; //导入方法依赖的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

示例4: setBlobValue

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

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

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

    try {
        setBlobValue(locator, data.openInputStream(0, 0));
    } catch (FetchException e) {
        throw e.toPersistException();
    }
}
 
开发者ID:Carbonado,项目名称:Carbonado,代码行数:34,代码来源:LobEngine.java

示例5: setClobValue

import com.amazon.carbonado.FetchException; //导入方法依赖的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

示例6: nextIntValue

import com.amazon.carbonado.FetchException; //导入方法依赖的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

示例7: insert

import com.amazon.carbonado.FetchException; //导入方法依赖的package包/类
void insert() throws PersistException {
    try {
        mStoredLayoutProperty.insert();
    } catch (UniqueConstraintException e) {
        // If existing record logically matches, update to allow replication.
        StoredLayoutProperty existing = mStoredLayoutProperty.prepare();
        mStoredLayoutProperty.copyPrimaryKeyProperties(existing);
        try {
            existing.load();
        } catch (FetchException e2) {
            throw e2.toPersistException();
        }
        if (!equals(new LayoutProperty(existing))) {
            throw e;
        }
        mStoredLayoutProperty.setVersionNumber(existing.getVersionNumber());
        mStoredLayoutProperty.update();
    }
}
 
开发者ID:Carbonado,项目名称:Carbonado,代码行数:20,代码来源:LayoutProperty.java

示例8: tryDeleteOne

import com.amazon.carbonado.FetchException; //导入方法依赖的package包/类
@Override
public boolean tryDeleteOne(Controller controller) throws PersistException {
    Transaction txn = enterTransaction(IsolationLevel.READ_COMMITTED);
    try {
        Cursor<S> cursor = fetch(controller);
        boolean result;
        try {
            if (cursor.hasNext()) {
                S obj = cursor.next();
                if (cursor.hasNext()) {
                    throw new PersistMultipleException(toString());
                }
                result = obj.tryDelete();
            } else {
                return false;
            }
        } finally {
            cursor.close();
        }
        if (txn != null) {
            txn.commit();
        }
        return result;
    } catch (FetchException e) {
        throw e.toPersistException();
    } finally {
        if (txn != null) {
            txn.exit();
        }
    }
}
 
开发者ID:Carbonado,项目名称:Carbonado,代码行数:32,代码来源:StandardQuery.java

示例9: insertIndexEntry

import com.amazon.carbonado.FetchException; //导入方法依赖的package包/类
/** Assumes caller is in a transaction */
private boolean insertIndexEntry(final S userStorable, final Storable indexEntry)
    throws PersistException
{
    if (indexEntry.tryInsert()) {
        return true;
    }

    // If index entry already exists, then index might be corrupt.
    try {
        Storable freshIndexEntry = mIndexEntryStorage.prepare();
        mAccessor.copyFromMaster(freshIndexEntry, userStorable);
        freshIndexEntry.load();
        indexEntry.copyVersionProperty(freshIndexEntry);
        if (freshIndexEntry.equals(indexEntry)) {
            // Existing entry is fine.
            return true;

        } else {
            S freshMasterEntry = mMasterStorage.prepare();
            mAccessor.copyToMasterPrimaryKey(freshIndexEntry, freshMasterEntry);
            
            if (!freshMasterEntry.tryLoad()) {
                // Existing entry for alternate key is bogus. Delete it.
                freshIndexEntry.delete();
                indexEntry.insert();
                return true;
            }
        }

    } catch (FetchException e) {
        throw e.toPersistException();
    }

    return false;
}
 
开发者ID:Carbonado,项目名称:Carbonado,代码行数:37,代码来源:ManagedIndex.java

示例10: beforeDelete

import com.amazon.carbonado.FetchException; //导入方法依赖的package包/类
@Override
public Object beforeDelete(S storable) throws PersistException {
    try {
        if (storable.copy().tryLoad()) {
            return createDependentIndexEntries(storable);
        }
    } catch (FetchException e) {
        throw e.toPersistException();
    }
    return null;
}
 
开发者ID:Carbonado,项目名称:Carbonado,代码行数:12,代码来源:DerivedIndexesTrigger.java

示例11: beforeUpdate

import com.amazon.carbonado.FetchException; //导入方法依赖的package包/类
@Override
public Object beforeUpdate(S storable) throws PersistException {
    // Return old storable for afterUpdate.
    S copy = (S) storable.copy();
    try {
        if (copy.tryLoad()) {
            return copy;
        }
    } catch (FetchException e) {
        throw e.toPersistException();
    }
    // If this point is reached, then afterUpdate is not called because
    // update will fail.
    return null;
}
 
开发者ID:Carbonado,项目名称:Carbonado,代码行数:16,代码来源:IndexesTrigger.java

示例12: beforeDelete

import com.amazon.carbonado.FetchException; //导入方法依赖的package包/类
@Override
public Object beforeDelete(S storable) throws PersistException {
    S existing = (S) storable.copy();
    try {
        if (!existing.tryLoad()) {
            existing = null;
        }
        return existing;
    } catch (FetchException e) {
        throw e.toPersistException();
    }
}
 
开发者ID:Carbonado,项目名称:Carbonado,代码行数:13,代码来源:LobEngineTrigger.java

示例13: insert

import com.amazon.carbonado.FetchException; //导入方法依赖的package包/类
void insert(boolean readOnly, int generation) throws PersistException {
    if (mAllProperties == null) {
        throw new IllegalStateException();
    }

    mStoredLayout.setGeneration(generation);

    if (readOnly) {
        return;
    }

    try {
        mStoredLayout.insert();
    } catch (UniqueConstraintException e) {
        // If existing record logically matches, update to allow replication.
        StoredLayout existing = mStoredLayout.prepare();
        mStoredLayout.copyPrimaryKeyProperties(existing);
        try {
            existing.load();
        } catch (FetchException e2) {
            throw e2.toPersistException();
        }
        if (existing.getGeneration() != generation ||
            !existing.getStorableTypeName().equals(getStorableTypeName()) ||
            !Arrays.equals(existing.getExtraData(), mStoredLayout.getExtraData()))
        {
            throw e;
        }
        mStoredLayout.setVersionNumber(existing.getVersionNumber());
        mStoredLayout.update();
    }

    for (LayoutProperty property : mAllProperties) {
        property.insert();
    }
}
 
开发者ID:Carbonado,项目名称:Carbonado,代码行数:37,代码来源:Layout.java

示例14: beforeUpdate

import com.amazon.carbonado.FetchException; //导入方法依赖的package包/类
@Override
public Object beforeUpdate(S storable) throws PersistException {
    // For each dirty lob property, capture it in case update fails. All
    // lob updates are made in this method.

    int length = mLobProperties.length;
    Object[] userLobs = new Object[length];
    S existing = null;

    for (int i=0; i<length; i++) {
        LobProperty<Lob> prop = mLobProperties[i];
        if (!storable.isPropertyDirty(prop.mName)) {
            continue;
        }

        try {
            if (existing == null && (existing = loadExisting(storable)) == null) {
                // Update will fail so don't touch lobs.
                return null;
            }
        } catch (FetchException e) {
            throw e.toPersistException();
        }

        Object userLob = storable.getPropertyValue(prop.mName);
        userLobs[i] = userLob;
        Lob existingLob = (Lob) existing.getPropertyValue(prop.mName);
        if (userLob == null) {
            if (existingLob != null) {
                // User is setting existing lob to null, so delete it.
                mEngine.deleteLob(existingLob);
            }
        } else {
            if (existingLob == null) {
                // User is setting a lob that has no locator yet, so make one.
                existingLob = prop.createNewLob(mBlockSize);
            }
            prop.setLobValue(mEngine.getLocator(existingLob), (Lob) userLob);
            storable.setPropertyValue(prop.mName, existingLob);
        }
    }

    return userLobs;
}
 
开发者ID:Carbonado,项目名称:Carbonado,代码行数:45,代码来源:LobEngineTrigger.java

示例15: nextLongValue

import com.amazon.carbonado.FetchException; //导入方法依赖的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.
 */
public long nextLongValue() throws PersistException {
    try {
        synchronized (mStoredSequence) {
            return nextUnadjustedValue() + Long.MIN_VALUE + mStoredSequence.getInitialValue();
        }
    } catch (FetchException e) {
        throw e.toPersistException();
    }
}
 
开发者ID:Carbonado,项目名称:Carbonado,代码行数:22,代码来源:SequenceValueGenerator.java


注:本文中的com.amazon.carbonado.FetchException.toPersistException方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。