public void stop() { try { if (selfCheckStart.compareAndSet(true, false)) { if (scheduledFuture != null) { scheduledFuture.cancel(true); scheduledFuture = null; failStore.close(); RETRY_EXECUTOR_SERVICE.shutdown(); RETRY_EXECUTOR_SERVICE = null; } LOGGER.info("Stop {} RetryScheduler success, identity=[{}]", name, appContext.getConfig().getIdentity()); } stopMasterCheck(); } catch (Throwable t) { LOGGER.error("Stop {} RetryScheduler failed, identity=[{}]", name, appContext.getConfig().getIdentity(), t); } }
public void destroy() { try { stop(); failStore.destroy(); } catch (FailStoreException e) { LOGGER.error("destroy {} RetryScheduler failed, identity=[{}]", name, appContext.getConfig().getIdentity(), e); } }
public void inSchedule(String key, T value) { try { lock.tryLock(); failStore.put(key, value); LOGGER.info("{} RetryScheduler, local files save success, identity=[{}], {}", name, appContext.getConfig().getIdentity(), JSON.toJSONString(value)); } catch (FailStoreException e) { LOGGER.error("{} RetryScheduler in schedule error, identity=[{}]", name, e, appContext.getConfig().getIdentity()); } finally { if (lock.isHeldByCurrentThread()) { lock.unlock(); } } }
public RetryScheduler(String name, final AppContext appContext, String storePath) { this.name = name; this.appContext = appContext; FailStoreFactory failStoreFactory = ServiceLoader.load(FailStoreFactory.class, appContext.getConfig()); failStore = failStoreFactory.getFailStore(appContext.getConfig(), storePath); try { failStore.open(); } catch (FailStoreException e) { throw new RuntimeException(e); } EventSubscriber subscriber = new EventSubscriber(RetryScheduler.class.getSimpleName() .concat(appContext.getConfig().getIdentity()), new Observer() { @Override public void onObserved(EventInfo eventInfo) { Node masterNode = (Node) eventInfo.getParam("master"); if (masterNode != null && masterNode.getIdentity().equals(appContext.getConfig().getIdentity())) { startMasterCheck(); } else { stopMasterCheck(); } } }); appContext.getEventCenter().subscribe(subscriber, EcTopic.MASTER_CHANGED); if (appContext.getMasterElector().isCurrentMaster()) { startMasterCheck(); } }
public RetryScheduler(String name, final AppContext appContext, String storePath) { this.name = name; this.appContext = appContext; FailStoreFactory failStoreFactory = ServiceLoader.load(FailStoreFactory.class, appContext.getConfig()); failStore = failStoreFactory.getFailStore(appContext.getConfig(), storePath); try { failStore.open(); } catch (FailStoreException e) { throw new RuntimeException(e); } EventSubscriber subscriber = new EventSubscriber(RetryScheduler.class.getSimpleName() .concat(appContext.getConfig().getIdentity()), new Observer() { @Override public void onObserved(EventInfo eventInfo) { Node masterNode = (Node) eventInfo.getParam("master"); if (masterNode != null && masterNode.getIdentity().equals(appContext.getConfig().getIdentity())) { startMasterCheck(); } else { stopMasterCheck(); } } }); appContext.getEventCenter().subscribe(subscriber, EcTopic.MASTER_CHANGED); if (appContext.getMasterElector().isCurrentMaster()) { startMasterCheck(); } }
public void destroy() { try { stop(); failStore.destroy(); } catch (FailStoreException e) { LOGGER.error("destroy {} RetryScheduler failed, identity=[{}]", name, appContext.getConfig().getIdentity(), e); } }
public void inSchedule(String key, T value) { try { lock.tryLock(); failStore.put(key, value); LOGGER.info("{} RetryScheduler, local files save success, identity=[{}], {}", name, appContext.getConfig().getIdentity(), JSON.toJSONString(value)); } catch (FailStoreException e) { LOGGER.error("{} RetryScheduler in schedule error, identity=[{}]", name, e, appContext.getConfig().getIdentity()); } finally { if (lock.isHeldByCurrentThread()) { lock.unlock(); } } }
public void stop() { try { if (selfCheckStart.compareAndSet(true, false)) { if (scheduledFuture != null) { scheduledFuture.cancel(true); scheduledFuture = null; failStore.close(); RETRY_EXECUTOR_SERVICE.shutdown(); RETRY_EXECUTOR_SERVICE = null; } LOGGER.info("Stop {} RetryScheduler success, identity=[{}]", name, appContext.getConfig().getIdentity()); } stopMasterCheck(); } catch (Throwable t) { LOGGER.error("Stop {} RetryScheduler failed, identity=[{}]", name, appContext.getConfig().getIdentity(), t); } }
public RetryScheduler(String name, final AppContext appContext, String storePath) { this.name = name; this.appContext = appContext; FailStoreFactory failStoreFactory = ServiceLoader.load(FailStoreFactory.class, appContext.getConfig()); failStore = failStoreFactory.getFailStore(appContext.getConfig(), storePath); try { failStore.open(); } catch (FailStoreException e) { throw new RuntimeException(e); } EventSubscriber subscriber = new EventSubscriber(RetryScheduler.class.getSimpleName() .concat(appContext.getConfig().getIdentity()), new Observer() { @Override public void onObserved(EventInfo eventInfo) { Node masterNode = (Node) eventInfo.getParam("master"); if (masterNode != null && masterNode.getIdentity().equals(appContext.getConfig().getIdentity())) { startMasterCheck(); } else { stopMasterCheck(); } } }); appContext.getEventCenter().subscribe(subscriber, EcTopic.MASTER_CHANGED); if (appContext.getMasterElector().isCurrentMaster()) { startMasterCheck(); } }
public void destroy() { try { stop(); failStore.destroy(); } catch (FailStoreException e) { LOGGER.error("destroy {} RetryScheduler failed, identity=[{}]", name, appContext.getConfig().getIdentity(), e); } }
public void inSchedule(String key, T value) { try { lock.tryLock(); failStore.put(key, value); LOGGER.info("{} RetryScheduler, local files save success, identity=[{}], {}", name, appContext.getConfig().getIdentity(), JSON.toJSONString(value)); } catch (FailStoreException e) { LOGGER.error("{} RetryScheduler in schedule error, identity=[{}]", name, e, appContext.getConfig().getIdentity()); } finally { if (lock.isHeldByCurrentThread()) { lock.unlock(); } } }
public void stop() { try { if (selfCheckStart.compareAndSet(true, false)) { if (scheduledFuture != null) { scheduledFuture.cancel(true); scheduledFuture = null; failStore.close(); RETRY_EXECUTOR_SERVICE.shutdown(); RETRY_EXECUTOR_SERVICE = null; } LOGGER.info("Stop {} RetryScheduler success, identity=[{}]", name, appContext.getConfig().getIdentity()); } stopMasterCheck(); } catch (Throwable t) { LOGGER.error("Stop {} RetryScheduler failed, identity=[{}]", name, appContext.getConfig().getIdentity(), t); } }