Search in sources :

Example 1 with MaximumRetriesExceededException

use of teammates.common.util.retry.MaximumRetriesExceededException in project teammates by TEAMMATES.

the class DataMigrationForFeedbackResponseCommentSearchDocument method invokePutDocumentsWithRetry.

/**
 * Reflects private static method {@link SearchManager#putDocumentsWithRetry}.
 *
 * @throws PutException when only non-transient errors are encountered.
 * @throws MaximumRetriesExceededException with list of failed {@link Document}s as final data and
 *         final {@link com.google.appengine.api.search.OperationResult}'s message as final message,
 *         if operation fails after maximum retries.
 */
private static void invokePutDocumentsWithRetry(String indexName, List<Document> documents) throws PutException, MaximumRetriesExceededException {
    try {
        Method method = SearchManager.class.getDeclaredMethod("putDocumentsWithRetry", String.class, List.class);
        method.setAccessible(true);
        method.invoke(null, indexName, documents);
    } catch (NoSuchMethodException | IllegalAccessException e) {
        throw new RuntimeException(e);
    } catch (InvocationTargetException e) {
        Throwable originalException = e.getCause();
        if (originalException instanceof PutException) {
            throw (PutException) originalException;
        } else if (originalException instanceof MaximumRetriesExceededException) {
            throw (MaximumRetriesExceededException) originalException;
        } else {
            throw new RuntimeException(e);
        }
    }
}
Also used : MaximumRetriesExceededException(teammates.common.util.retry.MaximumRetriesExceededException) PutException(com.google.appengine.api.search.PutException) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

PutException (com.google.appengine.api.search.PutException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 MaximumRetriesExceededException (teammates.common.util.retry.MaximumRetriesExceededException)1