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 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(); } }