@Test public void assertConnectionLostListenerWhenConnectionStateIsReconnected() { JobRegistry.getInstance().registerRegistryCenter("test_job", regCenter); JobRegistry.getInstance().registerJob("test_job", jobScheduleController); when(shardingService.getLocalShardingItems()).thenReturn(Arrays.asList(0, 1)); when(serverService.isEnableServer("127.0.0.1")).thenReturn(true); regCenterConnectionStateListener.stateChanged(null, ConnectionState.RECONNECTED); verify(serverService).persistOnline(true); verify(executionService).clearRunningInfo(Arrays.asList(0, 1)); verify(jobScheduleController).resumeJob(); JobRegistry.getInstance().shutdown("test_job"); }
@Override public void stateChanged(final CuratorFramework client, final ConnectionState newState) { if (JobRegistry.getInstance().isShutdown(jobName)) { return; } JobScheduleController jobScheduleController = JobRegistry.getInstance().getJobScheduleController(jobName); if (ConnectionState.SUSPENDED == newState || ConnectionState.LOST == newState) { jobScheduleController.pauseJob(); } else if (ConnectionState.RECONNECTED == newState) { serverService.persistOnline(serverService.isEnableServer(JobRegistry.getInstance().getJobInstance(jobName).getIp())); instanceService.persistOnline(); executionService.clearRunningInfo(shardingService.getLocalShardingItems()); jobScheduleController.resumeJob(); } }
RegistryCenterConnectionStateListener implements ConnectionStateListener { @Override public void stateChanged(final CuratorFramework client, final ConnectionState newState) { if (JobRegistry.getInstance().isShutdown(jobName)) { return; } JobScheduleController jobScheduleController = JobRegistry.getInstance().getJobScheduleController(jobName); if (ConnectionState.SUSPENDED == newState || ConnectionState.LOST == newState) { jobScheduleController.pauseJob(); } else if (ConnectionState.RECONNECTED == newState) { serverService.persistOnline(serverService.isEnableServer(JobRegistry.getInstance().getJobInstance(jobName).getIp())); instanceService.persistOnline(); executionService.clearRunningInfo(shardingService.getLocalShardingItems()); jobScheduleController.resumeJob(); } } }
RegistryCenterConnectionStateListener implements ConnectionStateListener { @Override public void stateChanged(final CuratorFramework client, final ConnectionState newState) { if (JobRegistry.getInstance().isShutdown(jobName)) { return; } JobScheduleController jobScheduleController = JobRegistry.getInstance().getJobScheduleController(jobName); if (ConnectionState.SUSPENDED == newState || ConnectionState.LOST == newState) { jobScheduleController.pauseJob(); } else if (ConnectionState.RECONNECTED == newState) { serverService.persistOnline(serverService.isEnableServer(JobRegistry.getInstance().getJobInstance(jobName).getIp())); instanceService.persistOnline(); executionService.clearRunningInfo(shardingService.getLocalShardingItems()); jobScheduleController.resumeJob(); } } RegistryCenterConnectionStateListener(final CoordinatorRegistryCenter regCenter, final String jobName); }
RegistryCenterConnectionStateListener implements ConnectionStateListener { @Override public void stateChanged(final CuratorFramework client, final ConnectionState newState) { if (JobRegistry.getInstance().isShutdown(jobName)) { return; } JobScheduleController jobScheduleController = JobRegistry.getInstance().getJobScheduleController(jobName); if (ConnectionState.SUSPENDED == newState || ConnectionState.LOST == newState) { jobScheduleController.pauseJob(); } else if (ConnectionState.RECONNECTED == newState) { serverService.persistOnline(serverService.isEnableServer(JobRegistry.getInstance().getJobInstance(jobName).getIp())); instanceService.persistOnline(); executionService.clearRunningInfo(shardingService.getLocalShardingItems()); jobScheduleController.resumeJob(); } } RegistryCenterConnectionStateListener(final CoordinatorRegistryCenter regCenter, final String jobName); @Override void stateChanged(final CuratorFramework client, final ConnectionState newState); }
RegistryCenterConnectionStateListener implements ConnectionStateListener { @Override public void stateChanged(final CuratorFramework client, final ConnectionState newState) { if (JobRegistry.getInstance().isShutdown(jobName)) { return; } JobScheduleController jobScheduleController = JobRegistry.getInstance().getJobScheduleController(jobName); if (ConnectionState.SUSPENDED == newState || ConnectionState.LOST == newState) { jobScheduleController.pauseJob(); } else if (ConnectionState.RECONNECTED == newState) { serverService.persistOnline(serverService.isEnableServer(JobRegistry.getInstance().getJobInstance(jobName).getIp())); instanceService.persistOnline(); executionService.clearRunningInfo(shardingService.getLocalShardingItems()); jobScheduleController.resumeJob(); } } RegistryCenterConnectionStateListener(final CoordinatorRegistryCenter regCenter, final String jobName); @Override void stateChanged(final CuratorFramework client, final ConnectionState newState);  }