Search in sources :

Example 1 with ServiceUnavailableException

use of org.jumpmind.symmetric.transport.ServiceUnavailableException in project symmetric-ds by JumpMind.

the class RegistrationService method attemptToRegisterWithServer.

public synchronized boolean attemptToRegisterWithServer(int maxNumberOfAttempts) {
    List<INodeRegistrationListener> registrationListeners = extensionService.getExtensionPointList(INodeRegistrationListener.class);
    boolean registered = isRegisteredWithServer();
    if (!registered) {
        try {
            for (INodeRegistrationListener l : registrationListeners) {
                l.registrationStarting();
            }
            log.info("This node is unregistered.  It will attempt to register using the registration.url");
            String channelId = null;
            registered = dataLoaderService.loadDataFromPull(null, channelId).getStatus() == Status.DATA_PROCESSED;
        } catch (ConnectException e) {
            log.warn("The request to register failed because the client failed to connect to the server.  The connection error message was: {}", e.getMessage());
            for (INodeRegistrationListener l : registrationListeners) {
                l.registrationFailed("The request to register failed because the client failed to connect to the server.  The connection error message was: " + e.getMessage());
            }
        } catch (UnknownHostException e) {
            log.warn("The request to register failed because the host was unknown.  The unknown host exception was: {}", e.getMessage());
            for (INodeRegistrationListener l : registrationListeners) {
                l.registrationFailed("The request to register failed because the host was unknown.  The unknown host exception was: " + e.getMessage());
            }
        } catch (ConnectionRejectedException e) {
            log.warn("The request to register was rejected by the server.  Either the server node is not started, the server is not configured properly or the registration url is incorrect");
            for (INodeRegistrationListener l : registrationListeners) {
                l.registrationFailed("The request to register was rejected by the server.  Either the server node is not started, the server is not configured properly or the registration url is incorrect");
            }
        } catch (RegistrationNotOpenException e) {
            log.warn("Unable to register with server because registration is not open.");
            for (INodeRegistrationListener l : registrationListeners) {
                l.registrationFailed("Unable to register with server because registration is not open.");
            }
        } catch (ServiceUnavailableException e) {
            log.warn("Unable to register with server because the service is not available.  It may be starting up.");
            for (INodeRegistrationListener l : registrationListeners) {
                l.registrationFailed("Unable to register with server because the service is not available.  It may be starting up.");
            }
        } catch (Exception e) {
            log.error("Unexpected error during registration: " + (StringUtils.isNotBlank(e.getMessage()) ? e.getMessage() : e.getClass().getName()), e);
            for (INodeRegistrationListener l : registrationListeners) {
                l.registrationFailed("Unexpected error during registration: " + (StringUtils.isNotBlank(e.getMessage()) ? e.getMessage() : e.getClass().getName()));
            }
        }
        registered = checkRegistrationSuccessful(registered, maxNumberOfAttempts);
    }
    return registered;
}
Also used : RegistrationNotOpenException(org.jumpmind.symmetric.service.RegistrationNotOpenException) UnknownHostException(java.net.UnknownHostException) INodeRegistrationListener(org.jumpmind.symmetric.ext.INodeRegistrationListener) ServiceUnavailableException(org.jumpmind.symmetric.transport.ServiceUnavailableException) ConnectionRejectedException(org.jumpmind.symmetric.transport.ConnectionRejectedException) ConnectionRejectedException(org.jumpmind.symmetric.transport.ConnectionRejectedException) ConnectException(java.net.ConnectException) IOException(java.io.IOException) RegistrationNotOpenException(org.jumpmind.symmetric.service.RegistrationNotOpenException) UnknownHostException(java.net.UnknownHostException) RegistrationRedirectException(org.jumpmind.symmetric.service.RegistrationRedirectException) ServiceUnavailableException(org.jumpmind.symmetric.transport.ServiceUnavailableException) RegistrationFailedException(org.jumpmind.symmetric.service.RegistrationFailedException) ConnectException(java.net.ConnectException)

Aggregations

IOException (java.io.IOException)1 ConnectException (java.net.ConnectException)1 UnknownHostException (java.net.UnknownHostException)1 INodeRegistrationListener (org.jumpmind.symmetric.ext.INodeRegistrationListener)1 RegistrationFailedException (org.jumpmind.symmetric.service.RegistrationFailedException)1 RegistrationNotOpenException (org.jumpmind.symmetric.service.RegistrationNotOpenException)1 RegistrationRedirectException (org.jumpmind.symmetric.service.RegistrationRedirectException)1 ConnectionRejectedException (org.jumpmind.symmetric.transport.ConnectionRejectedException)1 ServiceUnavailableException (org.jumpmind.symmetric.transport.ServiceUnavailableException)1