@Test public void assertChildEventWhenStateIsAddAndIsConfigPath() { cloudJobConfigurationListener.event(Type.NODE_CREATED, null, new ChildData("/config/job/test_job", null, CloudJsonConstants.getJobJson().getBytes())); verify(producerManager).schedule(ArgumentMatchers.any()); }
@Override public void event(final Type type, final ChildData oldData, final ChildData data) { String path = Type.NODE_DELETED == type ? oldData.getPath() : data.getPath(); if (Type.NODE_CREATED == type && isJobConfigNode(path)) { CloudJobConfigurationPOJO cloudJobConfig = getCloudJobConfiguration(data); if (null != cloudJobConfig) { producerManager.schedule(cloudJobConfig); } } else if (Type.NODE_CHANGED == type && isJobConfigNode(path)) { CloudJobConfigurationPOJO cloudJobConfig = getCloudJobConfiguration(data); if (null == cloudJobConfig) { return; } if (CloudJobExecutionType.DAEMON == cloudJobConfig.getJobExecutionType()) { readyService.remove(Collections.singletonList(cloudJobConfig.getJobName())); } if (!cloudJobConfig.isMisfire()) { readyService.setMisfireDisabled(cloudJobConfig.getJobName()); } producerManager.reschedule(cloudJobConfig.getJobName()); } else if (Type.NODE_DELETED == type && isJobConfigNode(path)) { String jobName = path.substring(CloudJobConfigurationNode.ROOT.length() + 1); producerManager.unschedule(jobName); } }
CloudJobConfigurationListener implements CuratorCacheListener { @Override public void event(final Type type, final ChildData oldData, final ChildData data) { String path = Type.NODE_DELETED == type ? oldData.getPath() : data.getPath(); if (Type.NODE_CREATED == type && isJobConfigNode(path)) { CloudJobConfigurationPOJO cloudJobConfig = getCloudJobConfiguration(data); if (null != cloudJobConfig) { producerManager.schedule(cloudJobConfig); } } else if (Type.NODE_CHANGED == type && isJobConfigNode(path)) { CloudJobConfigurationPOJO cloudJobConfig = getCloudJobConfiguration(data); if (null == cloudJobConfig) { return; } if (CloudJobExecutionType.DAEMON == cloudJobConfig.getJobExecutionType()) { readyService.remove(Collections.singletonList(cloudJobConfig.getJobName())); } if (!cloudJobConfig.isMisfire()) { readyService.setMisfireDisabled(cloudJobConfig.getJobName()); } producerManager.reschedule(cloudJobConfig.getJobName()); } else if (Type.NODE_DELETED == type && isJobConfigNode(path)) { String jobName = path.substring(CloudJobConfigurationNode.ROOT.length() + 1); producerManager.unschedule(jobName); } } }
CloudJobConfigurationListener implements CuratorCacheListener { @Override public void event(final Type type, final ChildData oldData, final ChildData data) { String path = Type.NODE_DELETED == type ? oldData.getPath() : data.getPath(); if (Type.NODE_CREATED == type && isJobConfigNode(path)) { CloudJobConfigurationPOJO cloudJobConfig = getCloudJobConfiguration(data); if (null != cloudJobConfig) { producerManager.schedule(cloudJobConfig); } } else if (Type.NODE_CHANGED == type && isJobConfigNode(path)) { CloudJobConfigurationPOJO cloudJobConfig = getCloudJobConfiguration(data); if (null == cloudJobConfig) { return; } if (CloudJobExecutionType.DAEMON == cloudJobConfig.getJobExecutionType()) { readyService.remove(Collections.singletonList(cloudJobConfig.getJobName())); } if (!cloudJobConfig.isMisfire()) { readyService.setMisfireDisabled(cloudJobConfig.getJobName()); } producerManager.reschedule(cloudJobConfig.getJobName()); } else if (Type.NODE_DELETED == type && isJobConfigNode(path)) { String jobName = path.substring(CloudJobConfigurationNode.ROOT.length() + 1); producerManager.unschedule(jobName); } } CloudJobConfigurationListener(final CoordinatorRegistryCenter regCenter, final ProducerManager producerManager); }
CloudJobConfigurationListener implements CuratorCacheListener { @Override public void event(final Type type, final ChildData oldData, final ChildData data) { String path = Type.NODE_DELETED == type ? oldData.getPath() : data.getPath(); if (Type.NODE_CREATED == type && isJobConfigNode(path)) { CloudJobConfigurationPOJO cloudJobConfig = getCloudJobConfiguration(data); if (null != cloudJobConfig) { producerManager.schedule(cloudJobConfig); } } else if (Type.NODE_CHANGED == type && isJobConfigNode(path)) { CloudJobConfigurationPOJO cloudJobConfig = getCloudJobConfiguration(data); if (null == cloudJobConfig) { return; } if (CloudJobExecutionType.DAEMON == cloudJobConfig.getJobExecutionType()) { readyService.remove(Collections.singletonList(cloudJobConfig.getJobName())); } if (!cloudJobConfig.isMisfire()) { readyService.setMisfireDisabled(cloudJobConfig.getJobName()); } producerManager.reschedule(cloudJobConfig.getJobName()); } else if (Type.NODE_DELETED == type && isJobConfigNode(path)) { String jobName = path.substring(CloudJobConfigurationNode.ROOT.length() + 1); producerManager.unschedule(jobName); } } CloudJobConfigurationListener(final CoordinatorRegistryCenter regCenter, final ProducerManager producerManager); @Override void event(final Type type, final ChildData oldData, final ChildData data); void start(); void stop(); }
CloudJobConfigurationListener implements CuratorCacheListener { @Override public void event(final Type type, final ChildData oldData, final ChildData data) { String path = Type.NODE_DELETED == type ? oldData.getPath() : data.getPath(); if (Type.NODE_CREATED == type && isJobConfigNode(path)) { CloudJobConfigurationPOJO cloudJobConfig = getCloudJobConfiguration(data); if (null != cloudJobConfig) { producerManager.schedule(cloudJobConfig); } } else if (Type.NODE_CHANGED == type && isJobConfigNode(path)) { CloudJobConfigurationPOJO cloudJobConfig = getCloudJobConfiguration(data); if (null == cloudJobConfig) { return; } if (CloudJobExecutionType.DAEMON == cloudJobConfig.getJobExecutionType()) { readyService.remove(Collections.singletonList(cloudJobConfig.getJobName())); } if (!cloudJobConfig.isMisfire()) { readyService.setMisfireDisabled(cloudJobConfig.getJobName()); } producerManager.reschedule(cloudJobConfig.getJobName()); } else if (Type.NODE_DELETED == type && isJobConfigNode(path)) { String jobName = path.substring(CloudJobConfigurationNode.ROOT.length() + 1); producerManager.unschedule(jobName); } } CloudJobConfigurationListener(final CoordinatorRegistryCenter regCenter, final ProducerManager producerManager); @Override void event(final Type type, final ChildData oldData, final ChildData data); void start(); void stop();  }