本文整理汇总了Java中com.orientechnologies.common.concur.ONeedRetryException类的典型用法代码示例。如果您正苦于以下问题:Java ONeedRetryException类的具体用法?Java ONeedRetryException怎么用?Java ONeedRetryException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ONeedRetryException类属于com.orientechnologies.common.concur包,在下文中一共展示了ONeedRetryException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createSnapshot
import com.orientechnologies.common.concur.ONeedRetryException; //导入依赖的package包/类
@Transactional(retryOn = { ONeedRetryException.class })
@Override
public void createSnapshot(String id, SnapshotComponentSelector selector) throws IOException {
StorageTx tx = UnitOfWork.currentTx();
StorageFacet storageFacet = facet(StorageFacet.class);
Bucket bucket = tx.findBucket(getRepository());
Component component = tx.createComponent(bucket, getRepository().getFormat()).name(id);
tx.saveComponent(component);
for (SnapshotItem item : collectSnapshotItems(selector)) {
String assetName = createAssetPath(id, item.specifier.path);
Asset asset = tx.createAsset(bucket, component).name(assetName);
try (final TempBlob streamSupplier = storageFacet.createTempBlob(item.content.openInputStream(), FacetHelper.hashAlgorithms)) {
AssetBlob blob = tx.createBlob(item.specifier.path, streamSupplier, FacetHelper.hashAlgorithms, null,
FacetHelper.determineContentType(item), true);
tx.attachBlob(asset, blob);
}
finally {
item.content.close();
}
tx.saveAsset(asset);
}
}
示例2: getSnapshotFile
import com.orientechnologies.common.concur.ONeedRetryException; //导入依赖的package包/类
@Transactional(retryOn = { ONeedRetryException.class })
@Override
public Content getSnapshotFile(String id, String path) throws IOException {
StorageTx tx = UnitOfWork.currentTx();
Bucket bucket = tx.findBucket(getRepository());
Component component = tx.findComponentWithProperty(P_NAME, id, bucket);
if (component == null) {
return null;
}
final Asset asset = tx.findAssetWithProperty(P_NAME, createAssetPath(id, path), component);
if (asset == null) {
return null;
}
if (asset.markAsDownloaded()) {
tx.saveAsset(asset);
}
final Blob blob = tx.requireBlob(asset.requireBlobRef());
return FacetHelper.toContent(asset, blob);
}
示例3: execute
import com.orientechnologies.common.concur.ONeedRetryException; //导入依赖的package包/类
/**
* Execute operation within transaction and propagate/translate exceptions.
*/
private <T> T execute(final Operation<T> operation) throws JobPersistenceException {
try {
synchronized (monitor) {
return inTx(databaseInstance)
.retryOn(ONeedRetryException.class, ORecordNotFoundException.class)
.throwing(JobPersistenceException.class)
.call(operation::execute);
}
}
catch (Exception e) {
log.warn("Execution failed", e);
Throwables.propagateIfPossible(e, JobPersistenceException.class);
throw new JobPersistenceException(e.toString(), e);
}
}
示例4: acquireNextTriggers
import com.orientechnologies.common.concur.ONeedRetryException; //导入依赖的package包/类
@Override
public List<OperableTrigger> acquireNextTriggers(final long noLaterThan,
final int maxCount,
final long timeWindow)
throws JobPersistenceException
{
try {
synchronized (monitor) {
return inTx(databaseInstance)
.retryOn(ONeedRetryException.class, ORecordNotFoundException.class)
.call(db -> doAcquireNextTriggers(db, noLaterThan, maxCount, timeWindow));
}
}
catch (RuntimeException e) {
acquireNextTriggersSummarizer.log("Problem acquiring next triggers", e);
try {
Thread.sleep(10); // introduce small delay, otherwise quartz will immediately try again
}
catch (InterruptedException ignore) { // NOSONAR
// ignored
}
throw new JobPersistenceException(e.toString(), e);
}
}
示例5: updateTaskStatus
import com.orientechnologies.common.concur.ONeedRetryException; //导入依赖的package包/类
/**
* Update the status of task.status to newStatus. Update will be applied to database and the task object.
* @param newStatus
* @param task
* @return
* @throws ObjectNotFoundException
* @throws NdexException
*/
public Task updateTaskStatus(Status newStatus, Task task) throws ObjectNotFoundException, NdexException {
ODocument doc = this.getRecordByUUID(task.getExternalId(), NdexClasses.Task);
Status s = Status.valueOf((String)doc.field(NdexClasses.Task_P_status));
if ( s != newStatus ) {
for (int retry = 0; retry < NdexDatabase.maxRetries; ++retry) {
try {
doc.fields(NdexClasses.Task_P_status, newStatus,
NdexClasses.ExternalObj_mTime, new Date()).save();
break;
} catch(ONeedRetryException e) {
doc.reload();
}
}
}
task.setStatus(newStatus);
return task;
}
示例6: purgeTask
import com.orientechnologies.common.concur.ONeedRetryException; //导入依赖的package包/类
public int purgeTask (UUID taskID) throws ObjectNotFoundException, NdexException {
ODocument d = this.getRecordByUUID(taskID, NdexClasses.Task);
boolean isDeleted = d.field(NdexClasses.ExternalObj_isDeleted);
if ( isDeleted ) {
OrientVertex v = graph.getVertex(d);
for (int retry = 0; retry < NdexDatabase.maxRetries; ++retry) {
try {
v.remove();
break;
} catch(ONeedRetryException e) {
logger.warning("Write conflict when deleting task. Error: " + e.getMessage() +
"\nRetry ("+ retry + ") deleting task " + taskID.toString() );
v.reload();
}
}
return 1;
}
throw new NdexException ("Only deleted tasks can be purged.");
}
示例7: cleanupDeleteNetwork
import com.orientechnologies.common.concur.ONeedRetryException; //导入依赖的package包/类
/**
* Delete up to CLEANUP_BATCH_SIZE vertices in a network. This function is for cleaning up a logically
* deleted network in the database.
* @param uuid
* @return Number of vertices being deleted. If the returned number is negative, it means the elements
* of the network are not completely deleted yet, and the number of vertices deleted are abs(returned number).
* @throws ObjectNotFoundException
* @throws NdexException
*/
public int cleanupDeleteNetwork(String uuid) throws ObjectNotFoundException, NdexException {
ODocument networkDoc = getRecordByUUID(UUID.fromString(uuid), NdexClasses.Network);
int count = cleanupNetworkElements(networkDoc);
if ( count >= CLEANUP_BATCH_SIZE) {
return (-1) * count;
}
// remove the network node.
networkDoc.reload();
for (int retry = 0; retry < NdexDatabase.maxRetries; ++retry) {
try {
graph.removeVertex(graph.getVertex(networkDoc));
break;
} catch(ONeedRetryException e) {
logger.warning("Retry: "+ e.getMessage());
networkDoc.reload();
}
}
return count++;
}
示例8: cleanupElement
import com.orientechnologies.common.concur.ONeedRetryException; //导入依赖的package包/类
private int cleanupElement(ODocument doc, int currentCount) {
int counter = currentCount;
doc.reload();
for (int retry = 0; retry < NdexDatabase.maxRetries; ++retry) {
try {
graph.removeVertex(graph.getVertex(doc));
break;
} catch(ONeedRetryException e) {
logger.warning("Retry: "+ e.getMessage());
doc.reload();
}
}
counter ++;
if ( counter % 2000 == 0 ) {
graph.commit();
if (counter % 10000 == 0 ) {
logger.info("Deleted " + counter + " vertexes from network during cleanup.");
}
}
return counter;
}
示例9: doInTXWithRetry
import com.orientechnologies.common.concur.ONeedRetryException; //导入依赖的package包/类
public void doInTXWithRetry(DBOperation operation, int maxRetries) throws Exception {
OrientGraph graph = graph();
for (int retry = 0; retry < maxRetries; ++retry) {
try {
operation.execute(graph);
graph.commit();
break;
} catch (ONeedRetryException e) {
// SOMEONE HAVE UPDATE THE INVOICE VERTEX AT THE SAME TIME, RETRY IT
}
}
}
示例10: doIndicateVerified
import com.orientechnologies.common.concur.ONeedRetryException; //导入依赖的package包/类
@Transactional(retryOn = { ONeedRetryException.class })
protected void doIndicateVerified(Content content, CacheInfo cacheInfo, String assetPath) {
StorageTx tx = UnitOfWork.currentTx();
Bucket bucket = tx.findBucket(getRepository());
Asset asset = Content.findAsset(tx, bucket, content);
if (asset == null) {
asset = tx.findAssetWithProperty(P_NAME, assetPath, bucket);
}
if (asset == null) {
return;
}
CacheInfo.applyToAsset(asset, cacheInfo);
tx.saveAsset(asset);
}
示例11: deleteSnapshot
import com.orientechnologies.common.concur.ONeedRetryException; //导入依赖的package包/类
@Transactional(retryOn = { ONeedRetryException.class })
@Override
public void deleteSnapshot(String id) throws IOException {
StorageTx tx = UnitOfWork.currentTx();
Bucket bucket = tx.findBucket(getRepository());
Component component = tx.findComponentWithProperty(P_NAME, id, bucket);
if (component == null) {
return;
}
tx.deleteComponent(component);
}
示例12: createComponentNode
import com.orientechnologies.common.concur.ONeedRetryException; //导入依赖的package包/类
@Override
@Guarded(by = STARTED)
public void createComponentNode(final String repositoryName, final List<String> path, final Component component) {
inTxRetry(databaseInstance)
// handle case where assets try to create the exact same component-level path at once
.retryOn(ONeedRetryException.class, ORecordDuplicatedException.class)
.run(db -> entityAdapter.createComponentNode(db, repositoryName, path, component));
}
示例13: createAssetNode
import com.orientechnologies.common.concur.ONeedRetryException; //导入依赖的package包/类
@Override
@Guarded(by = STARTED)
public void createAssetNode(final String repositoryName, final List<String> path, final Asset asset) {
inTxRetry(databaseInstance)
// handle case where an asset and its component try to create the exact same path at once
.retryOn(ONeedRetryException.class, ORecordDuplicatedException.class)
.run(db -> entityAdapter.createAssetNode(db, repositoryName, path, asset));
}
示例14: isRetryException
import com.orientechnologies.common.concur.ONeedRetryException; //导入依赖的package包/类
/**
* Searching for {@link com.orientechnologies.common.concur.ONeedRetryException} in exception hierarchy.
*
* @param th thrown exception
* @return true if retry could be performed
*/
private boolean isRetryException(final Throwable th) {
Throwable current = th;
boolean res = false;
while (current != null) {
if (current instanceof ONeedRetryException) {
res = true;
break;
}
current = current.getCause();
}
return res;
}
示例15: deleteTask
import com.orientechnologies.common.concur.ONeedRetryException; //导入依赖的package包/类
public int deleteTask (UUID taskID) throws ObjectNotFoundException, NdexException {
ODocument d = this.getRecordByUUID(taskID, NdexClasses.Task);
for (int retry = 0; retry < NdexDatabase.maxRetries; ++retry) {
try {
d.fields(NdexClasses.ExternalObj_isDeleted, true,
NdexClasses.ExternalObj_mTime, new Date()).save();
break;
} catch(ONeedRetryException e) {
d.reload();
}
}
return 1;
}