SimpleRetrySyncFailureHandler.java revision 6c48312a132cb29f83b7b1b6bc87db4d7901f88e
/*
* Copyright 2013 ForgeRock, AS.
*
* The contents of this file are subject to the terms of the Common Development and
* Distribution License (the License). You may not use this file except in compliance with the
* License.
*
* You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
* specific language governing permission and limitations under the License.
*
* When distributing Covered Software, include this CDDL Header Notice in each file and include
* the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
* Header, with the fields enclosed by brackets [] replaced by your own identifying
* information: "Portions copyright [year] [name of copyright owner]".
*/
/**
* A simple sync failure handler that counts retries.
*
* @author brmiller
*/
public class SimpleRetrySyncFailureHandler implements SyncFailureHandler {
/** Logger */
/** how many times to retry live sync of a particular sync token */
private final int syncFailureRetries;
/** the handler to call after the retries are exhausted */
private final SyncFailureHandler postRetryHandler;
/** current token being retried */
private Object currentSyncToken;
/** number of retries on current token */
private int currentRetries;
/**
* Construct the SyncFailureHandler.
*
* @param syncFailureRetries the number of retries
*/
this.syncFailureRetries = syncFailureRetries;
this.postRetryHandler = postRetryHandler;
}
/**
* Handle sync failure by counting retries on this sync token, passing to
* (optional) post-retry handler when retries are exceeded.
*
* @param syncFailure contains sync failure data
* @param failureCause the cause of the sync failure
* @throws SyncHandlerException when retries are not exceeded
*/
throws SyncHandlerException {
if (token == currentSyncToken) {
}
else {
currentRetries = 0;
}
if (currentRetries >= syncFailureRetries) {
} else {
}
}
}