本文整理汇总了Java中com.amazon.carbonado.FetchException类的典型用法代码示例。如果您正苦于以下问题:Java FetchException类的具体用法?Java FetchException怎么用?Java FetchException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FetchException类属于com.amazon.carbonado包,在下文中一共展示了FetchException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toString
import com.amazon.carbonado.FetchException; //导入依赖的package包/类
@Override
public String toString() {
StringBuilder b = new StringBuilder();
b.append("Layout {type=").append(getStorableTypeName());
b.append(", generation=").append(getGeneration());
b.append(", properties={");
try {
List<LayoutProperty> props = getAllProperties();
for (int i=0; i<props.size(); i++) {
if (i > 0) {
b.append(", ");
}
b.append(props.get(i));
}
} catch (FetchException e) {
b.append(e.toString());
}
b.append("}}");
return b.toString();
}
示例2: continueCheck
import com.amazon.carbonado.FetchException; //导入依赖的package包/类
private void continueCheck(byte count) {
if (count == 0) {
try {
Query.Controller controller = mController;
if (controller != null) {
controller.continueCheck();
}
if (mStop) {
throw new FetchInterruptedException("Shutting down");
}
} catch (FetchException e) {
close();
throw new UndeclaredThrowableException(e);
}
}
}
示例3: getBlockData
import com.amazon.carbonado.FetchException; //导入依赖的package包/类
private byte[] getBlockData() throws IOException {
while (mStoredBlock == null || mBlockNumber > mStoredBlock.getBlockNumber()) {
try {
if (!mCursor.hasNext()) {
mStoredBlock = null;
return null;
}
mStoredBlock = mCursor.next();
} catch (FetchException e) {
try {
close();
} catch (IOException e2) {
// Don't care.
}
throw toIOException(e);
}
}
if (mBlockNumber < mStoredBlock.getBlockNumber()) {
return null;
}
return mStoredBlock.getData();
}
示例4: appendColumn
import com.amazon.carbonado.FetchException; //导入依赖的package包/类
public void appendColumn(JoinNode jn, ChainedProperty<?> chained)
throws FetchException
{
String alias;
if (jn == null) {
alias = null;
} else {
alias = jn.findAliasFor(chained);
}
if (alias != null) {
mLiteralBuilder.append(alias);
mLiteralBuilder.append('.');
}
StorableProperty<?> property = chained.getLastProperty();
JDBCStorableProperty<?> jProperty;
try {
jProperty = mRepository.getJDBCStorableProperty(property);
} catch (RepositoryException e) {
throw mRepository.toFetchException(e);
}
if (jProperty.isJoin()) {
throw new UnsupportedOperationException
("Join property doesn't have a corresponding column: " + chained);
}
mLiteralBuilder.append(jProperty.getColumnName());
}
示例5: tryLoadOne
import com.amazon.carbonado.FetchException; //导入依赖的package包/类
@Override
public S tryLoadOne(Controller controller) throws FetchException {
Cursor<S> cursor = fetch(controller);
try {
if (cursor.hasNext()) {
S obj = cursor.next();
if (cursor.hasNext()) {
throw new FetchMultipleException(toString());
}
return obj;
} else {
return null;
}
} finally {
cursor.close();
}
}
示例6: getGeneration
import com.amazon.carbonado.FetchException; //导入依赖的package包/类
/**
* Returns the layout for a particular generation of this layout's type.
*
* @throws FetchNoneException if generation not found
*/
public Layout getGeneration(int generation) throws FetchNoneException, FetchException {
try {
Storage<StoredLayoutEquivalence> equivStorage =
mLayoutFactory.mRepository.storageFor(StoredLayoutEquivalence.class);
StoredLayoutEquivalence equiv = equivStorage.prepare();
equiv.setStorableTypeName(getStorableTypeName());
equiv.setGeneration(generation);
if (equiv.tryLoad()) {
generation = equiv.getMatchedGeneration();
}
} catch (RepositoryException e) {
throw e.toFetchException();
}
return new Layout(mLayoutFactory, getStoredLayoutByGeneration(generation));
}
示例7: returnReservedValues
import com.amazon.carbonado.FetchException; //导入依赖的package包/类
/**
* Allow any unused reserved values to be returned for re-use. If the
* repository is shared by other processes, then reserved values might not
* be returnable.
*
* <p>This method should be called during the shutdown process of a
* repository, although calling it does not invalidate this
* SequenceValueGenerator. If getNextValue is called again, it will reserve
* values again.
*
* @return true if reserved values were returned
*/
public boolean returnReservedValues() throws FetchException, PersistException {
synchronized (mStoredSequence) {
if (mHasReservedValues) {
Transaction txn = mRepository.enterTopTransaction(null);
txn.setForUpdate(true);
try {
// Compare known StoredSequence with current persistent
// one. If same, then reserved values can be returned.
StoredSequence current = mStorage.prepare();
current.setName(mStoredSequence.getName());
if (current.tryLoad() && current.equals(mStoredSequence)) {
mStoredSequence.setNextValue(mNextValue + mIncrement);
mStoredSequence.update();
txn.commit();
mHasReservedValues = false;
return true;
}
} finally {
txn.exit();
}
}
}
return false;
}
示例8: toNext
import com.amazon.carbonado.FetchException; //导入依赖的package包/类
/**
* Move the cursor to the next available entry, incrementing by the amount
* given. The actual amount incremented is returned. If the amount is less
* then requested, the cursor must be positioned after the last available
* entry. Subclasses may wish to override this method with a faster
* implementation.
*
* <p>Calling to toNext(1) is equivalent to calling toNext().
*
* @param amount positive amount to advance
* @return actual amount advanced
* @throws IllegalStateException if cursor is not opened
*/
protected int toNext(int amount) throws FetchException {
if (amount <= 1) {
return (amount <= 0) ? 0 : (toNext() ? 1 : 0);
}
int count = 0;
disableKeyAndValue();
try {
while (amount > 0) {
if (toNext()) {
count++;
amount--;
} else {
break;
}
}
} finally {
enableKeyAndValue();
}
return count;
}
示例9: getInternalBlobForFetch
import com.amazon.carbonado.FetchException; //导入依赖的package包/类
java.sql.Blob getInternalBlobForFetch() throws FetchException {
if (mBlob == null) {
if ((mBlob = mLoader.load(mRepo)) == null) {
throw new FetchNoneException("Blob value is null");
}
try {
JDBCTransaction txn = mRepo.localTransactionScope().getTxn();
if (txn != null) {
txn.register(this);
}
} catch (Exception e) {
throw mRepo.toFetchException(e);
}
}
return mBlob;
}
示例10: transformIntoFetchException
import com.amazon.carbonado.FetchException; //导入依赖的package包/类
@Override
protected FetchException transformIntoFetchException(Throwable e) {
FetchException fe = super.transformIntoFetchException(e);
if (fe != null) {
return fe;
}
if (e instanceof DatabaseException) {
handleIfPanic(e);
if (isTimeout(e)) {
return new FetchTimeoutException(e);
}
if (isDeadlock(e)) {
return new FetchDeadlockException(e);
}
}
return null;
}
示例11: toPrevious
import com.amazon.carbonado.FetchException; //导入依赖的package包/类
/**
* Move the cursor to the previous available entry, decrementing by the
* amount given. The actual amount decremented is returned. If the amount
* is less then requested, the cursor must be positioned before the first
* available entry. Subclasses may wish to override this method with a
* faster implementation.
*
* <p>Calling to toPrevious(1) is equivalent to calling toPrevious().
*
* @param amount positive amount to retreat
* @return actual amount retreated
* @throws IllegalStateException if cursor is not opened
*/
protected int toPrevious(int amount) throws FetchException {
if (amount <= 1) {
return (amount <= 0) ? 0 : (toPrevious() ? 1 : 0);
}
int count = 0;
disableKeyAndValue();
try {
while (amount > 0) {
if (toPrevious()) {
count++;
amount--;
} else {
break;
}
}
} finally {
enableKeyAndValue();
}
return count;
}
示例12: 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();
}
}
示例13: openInputStream
import com.amazon.carbonado.FetchException; //导入依赖的package包/类
public InputStream openInputStream(long pos) throws FetchException {
if (pos < 0) {
throw new IllegalArgumentException("Position is negative: " + pos);
}
StoredLob lob = mStoredLob;
Transaction txn = mRepo.enterTransaction(IsolationLevel.READ_COMMITTED);
if (lob == null) {
lob = mLobStorage.prepare();
lob.setLocator(mLocator);
try {
lob.load();
} catch (FetchException e) {
try {
txn.exit();
} catch (PersistException e2) {
// Don't care.
}
if (e instanceof FetchNoneException) {
throw new FetchNoneException("Lob deleted: " + this);
}
throw e;
}
}
return new Input(lob, pos, txn);
}
示例14: fetchOne
import com.amazon.carbonado.FetchException; //导入依赖的package包/类
@Override
public Cursor<S> fetchOne(StorableIndex<S> index,
Object[] identityValues,
Query.Controller controller)
throws FetchException
{
// Note: Controller is never called.
byte[] key = mStorableCodec.encodePrimaryKey(identityValues);
byte[] value = mSupport.tryLoad(null, key);
if (value == null) {
return EmptyCursor.the();
}
return new SingletonCursor<S>(mStorableCodec.instantiate(key, value));
}
示例15: or
import com.amazon.carbonado.FetchException; //导入依赖的package包/类
@Override
public Query<S> or(Filter<S> filter) throws FetchException {
if (mFilter == null) {
throw new IllegalStateException("Query is already guaranteed to fetch everything");
}
if (getBlankParameterCount() > 0) {
throw new IllegalStateException("Blank parameters exist in query: " + this);
}
Filter<S> newFilter = mFilter.or(filter);
FilterValues<S> newValues = newFilter.initialFilterValues();
if (mValues != null) {
newValues = newValues.withValues(mValues.getSuppliedValues());
}
return createQuery(newFilter, newValues, mOrdering, mHints);
}