use of com.peterphi.carbon.exception.CarbonConnectException in project stdlib by petergeneric.
the class CarbonClientImpl method createSocket.
private Socket createSocket() {
int attempt = 0;
Timeout sleep = reconnectSleep;
while (attempt++ < MAX_CONNECT_ATTEMPTS) try {
return new Socket(host, port);
} catch (Exception e) {
if (attempt < MAX_CONNECT_ATTEMPTS) {
// back off
sleep.sleep();
// Sleep longer next time
sleep = sleep.multiply(reconnectSleepMultiplier);
} else {
throw new CarbonConnectException("Could not connect to Carbon API in " + MAX_CONNECT_ATTEMPTS + " attempts", e);
}
}
throw new CarbonConnectException("Could not conect to Carbon API socket!");
}
Aggregations