Search in sources :

Example 1 with IOfflineClientListener

use of org.jumpmind.symmetric.io.IOfflineClientListener in project symmetric-ds by JumpMind.

the class AbstractOfflineDetectorService method fireOffline.

protected void fireOffline(Exception error, Node remoteNode, RemoteNodeStatus status) {
    String syncUrl = remoteNode.getSyncUrl() == null ? parameterService.getRegistrationUrl() : remoteNode.getSyncUrl();
    Throwable cause = ExceptionUtils.getRootCause(error);
    if (cause == null) {
        cause = error;
    }
    if (isOffline(error)) {
        log.warn("Could not communicate with {} at {} because: {}", new Object[] { remoteNode, syncUrl, cause.getMessage() });
        status.setStatus(Status.OFFLINE);
    } else if (isServiceUnavailable(error)) {
        log.info("{} at {} was unavailable", new Object[] { remoteNode, syncUrl });
        status.setStatus(Status.OFFLINE);
    } else if (isBusy(error)) {
        log.info("{} at {} was busy", new Object[] { remoteNode, syncUrl });
        status.setStatus(Status.BUSY);
    } else if (isNotAuthenticated(error)) {
        log.info("{} at {} was not authorized", new Object[] { remoteNode, syncUrl });
        status.setStatus(Status.NOT_AUTHORIZED);
    } else if (isSyncDisabled(error)) {
        log.info("Sync was not enabled for {} at {}", new Object[] { remoteNode, syncUrl });
        status.setStatus(Status.SYNC_DISABLED);
    } else if (isRegistrationRequired(error)) {
        log.info("Registration was not open at {}", new Object[] { remoteNode, syncUrl });
        status.setStatus(Status.REGISTRATION_REQUIRED);
    } else {
        log.warn(String.format("Could not communicate with node '%s' at %s because of unexpected error", remoteNode, syncUrl), error);
        status.setStatus(Status.UNKNOWN_ERROR);
    }
    List<IOfflineClientListener> offlineListeners = extensionService.getExtensionPointList(IOfflineClientListener.class);
    if (offlineListeners != null) {
        for (IOfflineClientListener listener : offlineListeners) {
            if (isOffline(error)) {
                listener.offline(remoteNode);
            } else if (isBusy(error)) {
                listener.busy(remoteNode);
            } else if (isNotAuthenticated(error)) {
                listener.notAuthenticated(remoteNode);
            } else if (isSyncDisabled(error)) {
                listener.syncDisabled(remoteNode);
            } else if (isRegistrationRequired(error)) {
                listener.registrationRequired(remoteNode);
            } else {
                listener.unknownError(remoteNode, error);
            }
        }
    }
}
Also used : IOfflineClientListener(org.jumpmind.symmetric.io.IOfflineClientListener)

Example 2 with IOfflineClientListener

use of org.jumpmind.symmetric.io.IOfflineClientListener in project symmetric-ds by JumpMind.

the class AbstractSymmetricEngine method init.

protected void init() {
    if (propertiesFactory == null) {
        this.propertiesFactory = createTypedPropertiesFactory();
    }
    if (securityService == null) {
        this.securityService = SecurityServiceFactory.create(getSecurityServiceType(), propertiesFactory.reload());
    }
    TypedProperties properties = this.propertiesFactory.reload();
    MDC.put("engineName", properties.get(ParameterConstants.ENGINE_NAME));
    this.platform = createDatabasePlatform(properties);
    this.parameterService = new ParameterService(platform, propertiesFactory, properties.get(ParameterConstants.RUNTIME_CONFIG_TABLE_PREFIX, "sym"));
    boolean parameterTableExists = this.platform.readTableFromDatabase(null, null, TableConstants.getTableName(properties.get(ParameterConstants.RUNTIME_CONFIG_TABLE_PREFIX), TableConstants.SYM_PARAMETER)) != null;
    if (parameterTableExists) {
        this.parameterService.setDatabaseHasBeenInitialized(true);
        this.parameterService.rereadParameters();
    }
    this.platform.setMetadataIgnoreCase(this.parameterService.is(ParameterConstants.DB_METADATA_IGNORE_CASE));
    this.platform.setClearCacheModelTimeoutInMs(parameterService.getLong(ParameterConstants.CACHE_TIMEOUT_TABLES_IN_MS));
    this.symmetricDialect = createSymmetricDialect();
    this.extensionService = createExtensionService();
    this.extensionService.refresh();
    this.symmetricDialect.setExtensionService(extensionService);
    this.parameterService.setExtensionService(extensionService);
    this.bandwidthService = new BandwidthService(parameterService);
    this.sequenceService = new SequenceService(parameterService, symmetricDialect);
    this.stagingManager = createStagingManager();
    this.nodeService = new NodeService(parameterService, symmetricDialect, securityService, extensionService);
    this.configurationService = new ConfigurationService(parameterService, symmetricDialect, nodeService);
    this.clusterService = new ClusterService(parameterService, symmetricDialect);
    this.statisticService = new StatisticService(parameterService, symmetricDialect);
    this.statisticManager = new StatisticManager(parameterService, nodeService, configurationService, statisticService, clusterService);
    this.concurrentConnectionManager = new ConcurrentConnectionManager(parameterService, statisticManager);
    this.purgeService = new PurgeService(parameterService, symmetricDialect, clusterService, statisticManager);
    this.transformService = new TransformService(parameterService, symmetricDialect, configurationService, extensionService);
    this.loadFilterService = new LoadFilterService(parameterService, symmetricDialect, configurationService);
    this.groupletService = new GroupletService(this);
    this.triggerRouterService = new TriggerRouterService(this);
    this.outgoingBatchService = new OutgoingBatchService(parameterService, symmetricDialect, nodeService, configurationService, sequenceService, clusterService, extensionService);
    this.dataService = new DataService(this, extensionService);
    this.routerService = buildRouterService();
    this.nodeCommunicationService = buildNodeCommunicationService(clusterService, nodeService, parameterService, symmetricDialect);
    this.incomingBatchService = new IncomingBatchService(parameterService, symmetricDialect, clusterService);
    this.dataExtractorService = new DataExtractorService(this);
    this.transportManager = new TransportManagerFactory(this).create();
    this.dataLoaderService = buildDataLoaderService();
    this.registrationService = new RegistrationService(this);
    this.acknowledgeService = new AcknowledgeService(this);
    this.pushService = buildPushService();
    this.pullService = new PullService(parameterService, symmetricDialect, nodeService, dataLoaderService, registrationService, clusterService, nodeCommunicationService, configurationService, extensionService);
    this.fileSyncService = new FileSyncService(this);
    this.jobManager = createJobManager();
    extensionService.addExtensionPoint(new DefaultOfflineServerListener(statisticManager, nodeService, outgoingBatchService));
    IOfflineClientListener defaultlistener = new DefaultOfflineClientListener(parameterService, nodeService);
    extensionService.addExtensionPoint(defaultlistener);
    extensionService.addExtensionPoint(defaultlistener);
    if (registerEngine) {
        registerHandleToEngine();
    }
}
Also used : TransportManagerFactory(org.jumpmind.symmetric.transport.TransportManagerFactory) IStatisticService(org.jumpmind.symmetric.service.IStatisticService) StatisticService(org.jumpmind.symmetric.service.impl.StatisticService) ITransformService(org.jumpmind.symmetric.service.ITransformService) TransformService(org.jumpmind.symmetric.service.impl.TransformService) TriggerRouterService(org.jumpmind.symmetric.service.impl.TriggerRouterService) ITriggerRouterService(org.jumpmind.symmetric.service.ITriggerRouterService) GroupletService(org.jumpmind.symmetric.service.impl.GroupletService) IGroupletService(org.jumpmind.symmetric.service.IGroupletService) IConfigurationService(org.jumpmind.symmetric.service.IConfigurationService) ConfigurationService(org.jumpmind.symmetric.service.impl.ConfigurationService) AcknowledgeService(org.jumpmind.symmetric.service.impl.AcknowledgeService) IAcknowledgeService(org.jumpmind.symmetric.service.IAcknowledgeService) LoadFilterService(org.jumpmind.symmetric.service.impl.LoadFilterService) ILoadFilterService(org.jumpmind.symmetric.service.ILoadFilterService) IOfflineClientListener(org.jumpmind.symmetric.io.IOfflineClientListener) IParameterService(org.jumpmind.symmetric.service.IParameterService) ParameterService(org.jumpmind.symmetric.service.impl.ParameterService) IBandwidthService(org.jumpmind.symmetric.service.IBandwidthService) BandwidthService(org.jumpmind.symmetric.service.impl.BandwidthService) INodeService(org.jumpmind.symmetric.service.INodeService) NodeService(org.jumpmind.symmetric.service.impl.NodeService) IDataExtractorService(org.jumpmind.symmetric.service.IDataExtractorService) DataExtractorService(org.jumpmind.symmetric.service.impl.DataExtractorService) SequenceService(org.jumpmind.symmetric.service.impl.SequenceService) ISequenceService(org.jumpmind.symmetric.service.ISequenceService) OutgoingBatchService(org.jumpmind.symmetric.service.impl.OutgoingBatchService) IOutgoingBatchService(org.jumpmind.symmetric.service.IOutgoingBatchService) DefaultOfflineServerListener(org.jumpmind.symmetric.job.DefaultOfflineServerListener) TypedProperties(org.jumpmind.properties.TypedProperties) IRegistrationService(org.jumpmind.symmetric.service.IRegistrationService) RegistrationService(org.jumpmind.symmetric.service.impl.RegistrationService) DataService(org.jumpmind.symmetric.service.impl.DataService) IDataService(org.jumpmind.symmetric.service.IDataService) ConcurrentConnectionManager(org.jumpmind.symmetric.transport.ConcurrentConnectionManager) IConcurrentConnectionManager(org.jumpmind.symmetric.transport.IConcurrentConnectionManager) PullService(org.jumpmind.symmetric.service.impl.PullService) IPullService(org.jumpmind.symmetric.service.IPullService) IClusterService(org.jumpmind.symmetric.service.IClusterService) ClusterService(org.jumpmind.symmetric.service.impl.ClusterService) PurgeService(org.jumpmind.symmetric.service.impl.PurgeService) IPurgeService(org.jumpmind.symmetric.service.IPurgeService) IncomingBatchService(org.jumpmind.symmetric.service.impl.IncomingBatchService) IIncomingBatchService(org.jumpmind.symmetric.service.IIncomingBatchService) FileSyncService(org.jumpmind.symmetric.service.impl.FileSyncService) IFileSyncService(org.jumpmind.symmetric.service.IFileSyncService) IStatisticManager(org.jumpmind.symmetric.statistic.IStatisticManager) StatisticManager(org.jumpmind.symmetric.statistic.StatisticManager) DefaultOfflineClientListener(org.jumpmind.symmetric.io.DefaultOfflineClientListener)

Example 3 with IOfflineClientListener

use of org.jumpmind.symmetric.io.IOfflineClientListener in project symmetric-ds by JumpMind.

the class AbstractOfflineDetectorService method fireOnline.

protected void fireOnline(Node remoteNode, RemoteNodeStatus status) {
    transportErrorTimeByNode.remove(remoteNode.getNodeId());
    List<IOfflineClientListener> offlineListeners = extensionService.getExtensionPointList(IOfflineClientListener.class);
    if (offlineListeners != null) {
        for (IOfflineClientListener listener : offlineListeners) {
            listener.online(remoteNode);
        }
    }
}
Also used : IOfflineClientListener(org.jumpmind.symmetric.io.IOfflineClientListener)

Aggregations

IOfflineClientListener (org.jumpmind.symmetric.io.IOfflineClientListener)3 TypedProperties (org.jumpmind.properties.TypedProperties)1 DefaultOfflineClientListener (org.jumpmind.symmetric.io.DefaultOfflineClientListener)1 DefaultOfflineServerListener (org.jumpmind.symmetric.job.DefaultOfflineServerListener)1 IAcknowledgeService (org.jumpmind.symmetric.service.IAcknowledgeService)1 IBandwidthService (org.jumpmind.symmetric.service.IBandwidthService)1 IClusterService (org.jumpmind.symmetric.service.IClusterService)1 IConfigurationService (org.jumpmind.symmetric.service.IConfigurationService)1 IDataExtractorService (org.jumpmind.symmetric.service.IDataExtractorService)1 IDataService (org.jumpmind.symmetric.service.IDataService)1 IFileSyncService (org.jumpmind.symmetric.service.IFileSyncService)1 IGroupletService (org.jumpmind.symmetric.service.IGroupletService)1 IIncomingBatchService (org.jumpmind.symmetric.service.IIncomingBatchService)1 ILoadFilterService (org.jumpmind.symmetric.service.ILoadFilterService)1 INodeService (org.jumpmind.symmetric.service.INodeService)1 IOutgoingBatchService (org.jumpmind.symmetric.service.IOutgoingBatchService)1 IParameterService (org.jumpmind.symmetric.service.IParameterService)1 IPullService (org.jumpmind.symmetric.service.IPullService)1 IPurgeService (org.jumpmind.symmetric.service.IPurgeService)1 IRegistrationService (org.jumpmind.symmetric.service.IRegistrationService)1