use of com.google.api.gax.rpc.AbortedException in project java-spanner by googleapis.
the class PartitionedDmlTransactionTest method testExecuteStreamingPartitionedUpdateAbortedAndThenDeadlineExceeded.
@Test
public void testExecuteStreamingPartitionedUpdateAbortedAndThenDeadlineExceeded() {
PartialResultSet p1 = PartialResultSet.newBuilder().setResumeToken(resumeToken).build();
ServerStream<PartialResultSet> stream1 = mock(ServerStream.class);
Iterator<PartialResultSet> iterator = mock(Iterator.class);
when(iterator.hasNext()).thenReturn(true, true, false);
when(iterator.next()).thenReturn(p1).thenThrow(new AbortedException("transaction aborted", null, GrpcStatusCode.of(Code.ABORTED), true));
when(stream1.iterator()).thenReturn(iterator);
when(rpc.executeStreamingPartitionedDml(Mockito.eq(executeRequestWithoutResumeToken), anyMap(), any(Duration.class))).thenReturn(stream1);
when(ticker.read()).thenReturn(0L, 1L, TimeUnit.NANOSECONDS.convert(10L, TimeUnit.MINUTES));
SpannerException e = assertThrows(SpannerException.class, () -> tx.executeStreamingPartitionedUpdate(Statement.of(sql), Duration.ofMinutes(10)));
assertEquals(ErrorCode.DEADLINE_EXCEEDED, e.getErrorCode());
verify(rpc, times(2)).beginTransaction(any(BeginTransactionRequest.class), anyMap());
verify(rpc).executeStreamingPartitionedDml(Mockito.eq(executeRequestWithoutResumeToken), anyMap(), any(Duration.class));
}
use of com.google.api.gax.rpc.AbortedException in project jade-data-repo by DataBiosphere.
the class FireStoreDirectoryDao method updateDirectoryEntry.
// Non-transactional update of a directory entry
void updateDirectoryEntry(Firestore firestore, String collectionId, FireStoreDirectoryEntry entry) {
try {
DocumentReference newRef = getDocRef(firestore, collectionId, entry);
ApiFuture<WriteResult> writeFuture = newRef.set(entry);
writeFuture.get();
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
throw new FileSystemExecutionException("updateDirectoryEntry - execution interrupted", ex);
} catch (AbortedException | ExecutionException ex) {
throw handleExecutionException("updateDirectoryEntry", ex);
}
}
use of com.google.api.gax.rpc.AbortedException in project jade-data-repo by DataBiosphere.
the class FireStoreDirectoryDao method lookupByFilePath.
private DocumentSnapshot lookupByFilePath(Firestore firestore, String collectionId, String lookupPath, Transaction xn) {
try {
DocumentReference docRef = firestore.collection(collectionId).document(encodePathAsFirestoreDocumentName(lookupPath));
ApiFuture<DocumentSnapshot> docSnapFuture = xn.get(docRef);
return docSnapFuture.get();
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
throw new FileSystemExecutionException("lookupByEntryPath - execution interrupted", ex);
} catch (AbortedException | ExecutionException ex) {
throw handleExecutionException("lookupByEntryPath", ex);
}
}
use of com.google.api.gax.rpc.AbortedException in project jade-data-repo by DataBiosphere.
the class FireStoreDirectoryDao method storeDirectoryEntry.
// Non-transactional store of a directory entry
private void storeDirectoryEntry(Firestore firestore, String collectionId, FireStoreDirectoryEntry entry) {
try {
DocumentReference newRef = getDocRef(firestore, collectionId, entry);
ApiFuture<DocumentSnapshot> newSnapFuture = newRef.get();
DocumentSnapshot newSnap = newSnapFuture.get();
if (!newSnap.exists()) {
ApiFuture<WriteResult> writeFuture = newRef.set(entry);
writeFuture.get();
}
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
throw new FileSystemExecutionException("storeDirectoryEntry - execution interrupted", ex);
} catch (AbortedException | ExecutionException ex) {
throw handleExecutionException("storeDirectoryEntry", ex);
}
}
use of com.google.api.gax.rpc.AbortedException in project jade-data-repo by DataBiosphere.
the class FireStoreDirectoryDao method lookupByPathNoXn.
// Non-transactional lookup of an entry
private DocumentSnapshot lookupByPathNoXn(Firestore firestore, String collectionId, String lookupPath) {
try {
DocumentReference docRef = firestore.collection(collectionId).document(encodePathAsFirestoreDocumentName(lookupPath));
ApiFuture<DocumentSnapshot> docSnapFuture = docRef.get();
return docSnapFuture.get();
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
throw new FileSystemExecutionException("lookupByPathNoXn - execution interrupted", ex);
} catch (AbortedException | ExecutionException ex) {
throw handleExecutionException("lookupByPathNoXn", ex);
}
}
Aggregations