![JAR search and dependency download from the Maven repository](/logo.png)
fr.whimtrip.ext.jwhtscrapper.service.base.RequestSynchronizer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of whimtrip-ext-scrapper Show documentation
Show all versions of whimtrip-ext-scrapper Show documentation
Fully featured highly pluggable and customizable Java scrapping framework
The newest version!
package fr.whimtrip.ext.jwhtscrapper.service.base;
import fr.whimtrip.ext.jwhtscrapper.intfr.HttpMetrics;
import fr.whimtrip.ext.jwhtscrapper.service.holder.HttpManagerConfig;
import fr.whimtrip.ext.jwhtscrapper.enm.StatusRange;
/**
* Part of project jwht-scrapper
* Created on 28/07/18
*
*
* Any request synchronizer implementing class will help every concurrent
* access to the underlying httpclient to be synchronyzed on the same object
* instance to ensure no two requests are performed without the required
* {@link HttpManagerConfig#getAwaitBetweenRequests()} wait between those
* two requests. Additionnally, this should help monitoring the last proxy
* change or the count of failed requests / HTTP status stats.
*
*
* @author Louis-wht
* @since 1.0.0
*/
public interface RequestSynchronizer {
/**
* @return the milliseconds since last request has started.
*/
Long getLastRequest();
/**
* @return the number of requests since last proxy change happend.
*/
int getLastProxyChange();
/**
* Should increment in a synchronized way the inner {@code lastProxyChange}.
*/
void incrementLastProxyChange();
/**
* @param url the url to use for logging purpose when awaiting for the
* next request to perform.
*/
void checkAwaitBetweenRequest(String url);
/**
* @param httpStatus the httpStatus of the resulting HTTP response to log.
*
* Timeout exceptions should be logged with a
* {@link StatusRange#TIMEOUT_STATUS_CODE} HTTP
* status code.
*
*
* Unknown exceptions should be logged with a
* {@link StatusRange#UNKNOWN_EXCEPTION_STATUS_CODE}
* HTTP status code.
*
*
* Connect exceptions should be logged with a
* {@link StatusRange#CONNECT_EXCEPTION_STATUS_CODE}
* HTTP status code.
*
* @param newScrap wether it's a first time try of this current request or
* if it's a retry. It will be used for statistical purposes.
*/
void logHttpStatus(int httpStatus, boolean newScrap);
/**
* @see HttpMetrics
* @return the corresponding {@link HttpMetrics} of the current scrapping operation.
*/
HttpMetrics getHttpMetrics();
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy