|
14 | 14 | import org.apache.commons.lang3.StringUtils; |
15 | 15 | import org.phoebus.channelfinder.entity.Channel; |
16 | 16 | import org.phoebus.channelfinder.entity.Property; |
17 | | -import org.phoebus.channelfinder.service.external.ArchiverClient; |
| 17 | +import org.phoebus.channelfinder.service.external.ArchiverService; |
18 | 18 | import org.phoebus.channelfinder.service.model.archiver.ChannelProcessorInfo; |
19 | 19 | import org.phoebus.channelfinder.service.model.archiver.aa.ArchiveAction; |
20 | 20 | import org.phoebus.channelfinder.service.model.archiver.aa.ArchivePVOptions; |
21 | 21 | import org.phoebus.channelfinder.service.model.archiver.aa.ArchiverInfo; |
22 | 22 | import org.springframework.beans.factory.annotation.Autowired; |
23 | 23 | import org.springframework.beans.factory.annotation.Value; |
| 24 | +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
24 | 25 | import org.springframework.context.annotation.Configuration; |
25 | 26 |
|
26 | 27 | /** |
|
31 | 32 | * <p>e.g. archive=monitor@1.0 |
32 | 33 | */ |
33 | 34 | @Configuration |
| 35 | +@ConditionalOnProperty(name = "aa.enabled", havingValue = "true") |
34 | 36 | public class AAChannelProcessor implements ChannelProcessor { |
35 | 37 |
|
36 | 38 | private static final Logger logger = Logger.getLogger(AAChannelProcessor.class.getName()); |
@@ -60,7 +62,7 @@ public class AAChannelProcessor implements ChannelProcessor { |
60 | 62 | @Value("${aa.auto_pause:}") |
61 | 63 | private List<String> autoPauseOptions; |
62 | 64 |
|
63 | | - @Autowired private final ArchiverClient archiverClient = new ArchiverClient(); |
| 65 | + @Autowired private ArchiverService archiverService; |
64 | 66 |
|
65 | 67 | @Override |
66 | 68 | public boolean enabled() { |
@@ -180,7 +182,7 @@ public long process(List<Channel> channels) throws JsonProcessingException { |
180 | 182 | Collectors.toMap(ArchivePVOptions::getPv, archivePVOptions -> archivePVOptions)); |
181 | 183 | Map<ArchiveAction, List<ArchivePVOptions>> archiveActionArchivePVMap = |
182 | 184 | getArchiveActions(archivePVSList, archiverInfo); |
183 | | - count += archiverClient.configureAA(archiveActionArchivePVMap, archiverInfo.url()); |
| 185 | + count += archiverService.configureAA(archiveActionArchivePVMap, archiverInfo.url()); |
184 | 186 | } |
185 | 187 | long finalCount = count; |
186 | 188 | logger.log(Level.INFO, () -> String.format("Configured %s channels.", finalCount)); |
@@ -240,7 +242,7 @@ private Map<ArchiveAction, List<ArchivePVOptions>> getArchiveActions( |
240 | 242 | return result; |
241 | 243 | } |
242 | 244 | List<Map<String, String>> statuses = |
243 | | - archiverClient.getStatuses(archivePVS, archiverInfo.url(), archiverInfo.alias()); |
| 245 | + archiverService.getStatuses(archivePVS, archiverInfo.url(), archiverInfo.alias()); |
244 | 246 | logger.log(Level.FINER, "Statuses {0}", statuses); |
245 | 247 | statuses.forEach( |
246 | 248 | archivePVStatusJsonMap -> { |
@@ -290,9 +292,8 @@ private Map<String, ArchiverInfo> getArchiversInfo(Map<String, String> aaURLs) { |
290 | 292 | // Empty archiver tagged |
291 | 293 | continue; |
292 | 294 | } |
293 | | - String version = archiverClient.getVersion(aa.getValue()); |
294 | | - List<String> policies = archiverClient.getAAPolicies(aa.getValue()); |
295 | | - result.put(aa.getKey(), new ArchiverInfo(aa.getKey(), aa.getValue(), version, policies)); |
| 295 | + List<String> policies = archiverService.getAAPolicies(aa.getValue()); |
| 296 | + result.put(aa.getKey(), new ArchiverInfo(aa.getKey(), aa.getValue(), policies)); |
296 | 297 | } |
297 | 298 | return result; |
298 | 299 | } |
|
0 commit comments