]> git.basschouten.com Git - openhab-addons.git/blob
ee7383b1583fa63ea12558ab0ad716a4c79e9aad
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2020 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
7  * This program and the accompanying materials are made available under the
8  * terms of the Eclipse Public License 2.0 which is available at
9  * http://www.eclipse.org/legal/epl-2.0
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.systeminfo.internal.handler;
14
15 import static org.openhab.binding.systeminfo.internal.SysteminfoBindingConstants.*;
16
17 import java.math.BigDecimal;
18 import java.util.HashSet;
19 import java.util.Iterator;
20 import java.util.List;
21 import java.util.Map;
22 import java.util.Set;
23 import java.util.concurrent.ScheduledFuture;
24 import java.util.concurrent.TimeUnit;
25
26 import org.eclipse.jdt.annotation.NonNullByDefault;
27 import org.eclipse.jdt.annotation.Nullable;
28 import org.openhab.binding.systeminfo.internal.model.DeviceNotFoundException;
29 import org.openhab.binding.systeminfo.internal.model.SysteminfoInterface;
30 import org.openhab.core.config.core.Configuration;
31 import org.openhab.core.thing.Channel;
32 import org.openhab.core.thing.ChannelUID;
33 import org.openhab.core.thing.Thing;
34 import org.openhab.core.thing.ThingStatus;
35 import org.openhab.core.thing.ThingStatusDetail;
36 import org.openhab.core.thing.binding.BaseThingHandler;
37 import org.openhab.core.types.Command;
38 import org.openhab.core.types.RefreshType;
39 import org.openhab.core.types.State;
40 import org.openhab.core.types.UnDefType;
41 import org.slf4j.Logger;
42 import org.slf4j.LoggerFactory;
43
44 /**
45  * The {@link SysteminfoHandler} is responsible for providing real time information about the system
46  * (CPU, Memory, Storage, Display and others).
47  *
48  * @author Svilen Valkanov - Initial contribution
49  * @author Lyubomir Papzov - Separate the creation of the systeminfo object and its initialization
50  * @author Wouter Born - Add null annotations
51  */
52 @NonNullByDefault
53 public class SysteminfoHandler extends BaseThingHandler {
54     /**
55      * Refresh interval for {@link #highPriorityChannels} in seconds.
56      */
57     private @NonNullByDefault({}) BigDecimal refreshIntervalHighPriority;
58
59     /**
60      * Refresh interval for {@link #mediumPriorityChannels} in seconds.
61      */
62     private @NonNullByDefault({}) BigDecimal refreshIntervalMediumPriority;
63
64     /**
65      * Channels with priority configuration parameter set to High. They usually need frequent update of the state like
66      * CPU load, or information about the free and used memory.
67      * They are updated periodically at {@link #refreshIntervalHighPriority}.
68      */
69     private final Set<ChannelUID> highPriorityChannels = new HashSet<>();
70
71     /**
72      * Channels with priority configuration parameter set to Medium. These channels usually need update of the
73      * state not so oft like battery capacity, storage used and etc.
74      * They are updated periodically at {@link #refreshIntervalMediumPriority}.
75      */
76     private final Set<ChannelUID> mediumPriorityChannels = new HashSet<>();
77
78     /**
79      * Channels with priority configuration parameter set to Low. They represent static information or information
80      * that is updated rare- e.g. CPU name, storage name and etc.
81      * They are updated only at {@link #initialize()}.
82      */
83     private final Set<ChannelUID> lowPriorityChannels = new HashSet<>();
84
85     /**
86      * Wait time for the creation of Item-Channel links in seconds. This delay is needed, because the Item-Channel
87      * links have to be created before the thing state is updated, otherwise item state will not be updated.
88      */
89     public static final int WAIT_TIME_CHANNEL_ITEM_LINK_INIT = 1;
90
91     private SysteminfoInterface systeminfo;
92
93     private @Nullable ScheduledFuture<?> highPriorityTasks;
94     private @Nullable ScheduledFuture<?> mediumPriorityTasks;
95
96     private Logger logger = LoggerFactory.getLogger(SysteminfoHandler.class);
97
98     public SysteminfoHandler(Thing thing, @Nullable SysteminfoInterface systeminfo) {
99         super(thing);
100         if (systeminfo != null) {
101             this.systeminfo = systeminfo;
102         } else {
103             throw new IllegalArgumentException("No systeminfo service was provided");
104         }
105     }
106
107     @Override
108     public void initialize() {
109         logger.debug("Start initializing!");
110
111         if (instantiateSysteminfoLibrary() && isConfigurationValid() && updateProperties()) {
112             groupChannelsByPriority();
113             scheduleUpdates();
114             logger.debug("Thing is successfully initialized!");
115             updateStatus(ThingStatus.ONLINE);
116         } else {
117             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.HANDLER_INITIALIZING_ERROR,
118                     "Thing cannot be initialized!");
119         }
120     }
121
122     private boolean instantiateSysteminfoLibrary() {
123         try {
124             systeminfo.initializeSysteminfo();
125             logger.debug("Systeminfo implementation is instantiated!");
126             return true;
127         } catch (Exception e) {
128             logger.warn("Cannot instantiate Systeminfo object!", e);
129             return false;
130         }
131     }
132
133     private boolean isConfigurationValid() {
134         logger.debug("Start reading Thing configuration.");
135         try {
136             refreshIntervalMediumPriority = (BigDecimal) this.thing.getConfiguration()
137                     .get(MEDIUM_PRIORITY_REFRESH_TIME);
138             refreshIntervalHighPriority = (BigDecimal) this.thing.getConfiguration().get(HIGH_PRIORITY_REFRESH_TIME);
139
140             if (refreshIntervalHighPriority.intValue() <= 0 || refreshIntervalMediumPriority.intValue() <= 0) {
141                 throw new IllegalArgumentException("Refresh time must be positive number!");
142             }
143             logger.debug("Refresh time for medium priority channels set to {} s", refreshIntervalMediumPriority);
144             logger.debug("Refresh time for high priority channels set to {} s", refreshIntervalHighPriority);
145             return true;
146         } catch (IllegalArgumentException e) {
147             logger.warn("Refresh time value is invalid! Please change the thing configuration!");
148             return false;
149         } catch (ClassCastException e) {
150             logger.debug("Channel configuration cannot be read!");
151             return false;
152         }
153     }
154
155     private boolean updateProperties() {
156         Map<String, String> properties = editProperties();
157         try {
158             properties.put(PROPERTY_CPU_LOGICAL_CORES, systeminfo.getCpuLogicalCores().toString());
159             properties.put(PROPERTY_CPU_PHYSICAL_CORES, systeminfo.getCpuPhysicalCores().toString());
160             properties.put(PROPERTY_OS_FAMILY, systeminfo.getOsFamily().toString());
161             properties.put(PROPERTY_OS_MANUFACTURER, systeminfo.getOsManufacturer().toString());
162             properties.put(PROPERTY_OS_VERSION, systeminfo.getOsVersion().toString());
163             updateProperties(properties);
164             logger.debug("Properties updated!");
165             return true;
166         } catch (Exception e) {
167             logger.debug("Cannot get system properties! Please try to restart the binding.", e);
168             return false;
169         }
170     }
171
172     private void groupChannelsByPriority() {
173         logger.trace("Grouping channels by priority.");
174         List<Channel> channels = this.thing.getChannels();
175
176         for (Channel channel : channels) {
177             Configuration properties = channel.getConfiguration();
178             String priority = (String) properties.get(PRIOIRITY_PARAM);
179             if (priority == null) {
180                 logger.debug("Channel with UID {} will not be updated. The channel has no priority set !",
181                         channel.getUID());
182                 break;
183             }
184             switch (priority) {
185                 case "High":
186                     highPriorityChannels.add(channel.getUID());
187                     break;
188                 case "Medium":
189                     mediumPriorityChannels.add(channel.getUID());
190                     break;
191                 case "Low":
192                     lowPriorityChannels.add(channel.getUID());
193                     break;
194                 default:
195                     logger.debug("Invalid priority configuration parameter. Channel will not be updated!");
196             }
197         }
198     }
199
200     private void changeChannelPriority(ChannelUID channelUID, String priority) {
201         switch (priority) {
202             case "High":
203                 mediumPriorityChannels.remove(channelUID);
204                 lowPriorityChannels.remove(channelUID);
205                 highPriorityChannels.add(channelUID);
206                 break;
207             case "Medium":
208                 lowPriorityChannels.remove(channelUID);
209                 highPriorityChannels.remove(channelUID);
210                 mediumPriorityChannels.add(channelUID);
211                 break;
212             case "Low":
213                 highPriorityChannels.remove(channelUID);
214                 mediumPriorityChannels.remove(channelUID);
215                 lowPriorityChannels.add(channelUID);
216                 break;
217             default:
218                 logger.debug("Invalid priority configuration parameter. Channel will not be updated!");
219         }
220     }
221
222     private void scheduleUpdates() {
223         logger.debug("Schedule high priority tasks at fixed rate {} s.", refreshIntervalHighPriority);
224         highPriorityTasks = scheduler.scheduleWithFixedDelay(() -> {
225             publishData(highPriorityChannels);
226         }, WAIT_TIME_CHANNEL_ITEM_LINK_INIT, refreshIntervalHighPriority.intValue(), TimeUnit.SECONDS);
227
228         logger.debug("Schedule medium priority tasks at fixed rate {} s.", refreshIntervalMediumPriority);
229         mediumPriorityTasks = scheduler.scheduleWithFixedDelay(() -> {
230             publishData(mediumPriorityChannels);
231         }, WAIT_TIME_CHANNEL_ITEM_LINK_INIT, refreshIntervalMediumPriority.intValue(), TimeUnit.SECONDS);
232
233         logger.debug("Schedule one time update for low priority tasks.");
234         scheduler.schedule(() -> {
235             publishData(lowPriorityChannels);
236         }, WAIT_TIME_CHANNEL_ITEM_LINK_INIT, TimeUnit.SECONDS);
237     }
238
239     private void publishData(Set<ChannelUID> channels) {
240         Iterator<ChannelUID> iter = channels.iterator();
241         while (iter.hasNext()) {
242             ChannelUID channeUID = iter.next();
243             if (isLinked(channeUID.getId())) {
244                 publishDataForChannel(channeUID);
245             }
246         }
247     }
248
249     private void publishDataForChannel(ChannelUID channelUID) {
250         State state = getInfoForChannel(channelUID);
251         String channelID = channelUID.getId();
252         updateState(channelID, state);
253     }
254
255     public Set<ChannelUID> getHighPriorityChannels() {
256         return highPriorityChannels;
257     }
258
259     public Set<ChannelUID> getMediumPriorityChannels() {
260         return mediumPriorityChannels;
261     }
262
263     public Set<ChannelUID> getLowPriorityChannels() {
264         return lowPriorityChannels;
265     }
266
267     /**
268      * This method gets the information for specific channel through the {@link SysteminfoInterface}. It uses the
269      * channel ID to call the correct method from the {@link SysteminfoInterface} with deviceIndex parameter (in case of
270      * multiple devices, for reference see {@link #getDeviceIndex(String)}})
271      *
272      * @param channelUID the UID of the channel
273      * @return State object or null, if there is no information for the device with this index
274      */
275     private State getInfoForChannel(ChannelUID channelUID) {
276         State state = null;
277
278         String channelID = channelUID.getId();
279         String channelIDWithoutGroup = channelUID.getIdWithoutGroup();
280         String channelGroupID = channelUID.getGroupId();
281
282         int deviceIndex = getDeviceIndex(channelUID);
283
284         // The channelGroup may contain deviceIndex. It must be deleted from the channelID, because otherwise the
285         // switch will not find the correct method below.
286         // All digits are deleted from the ID
287         if (channelGroupID != null) {
288             channelID = channelGroupID.replaceAll("\\d+", "") + "#" + channelIDWithoutGroup;
289         }
290
291         try {
292             switch (channelID) {
293                 case CHANNEL_DISPLAY_INFORMATION:
294                     state = systeminfo.getDisplayInformation(deviceIndex);
295                     break;
296                 case CHANNEL_BATTERY_NAME:
297                     state = systeminfo.getBatteryName(deviceIndex);
298                     break;
299                 case CHANNEL_BATTERY_REMAINING_CAPACITY:
300                     state = systeminfo.getBatteryRemainingCapacity(deviceIndex);
301                     break;
302                 case CHANNEL_BATTERY_REMAINING_TIME:
303                     state = systeminfo.getBatteryRemainingTime(deviceIndex);
304                     break;
305                 case CHANNEL_SENSORS_CPU_TEMPERATURE:
306                     state = systeminfo.getSensorsCpuTemperature();
307                     break;
308                 case CHANNEL_SENOSRS_CPU_VOLTAGE:
309                     state = systeminfo.getSensorsCpuVoltage();
310                     break;
311                 case CHANNEL_SENSORS_FAN_SPEED:
312                     state = systeminfo.getSensorsFanSpeed(deviceIndex);
313                     break;
314                 case CHANNEL_CPU_LOAD_1:
315                     state = systeminfo.getCpuLoad1();
316                     break;
317                 case CHANNEL_CPU_LOAD_5:
318                     state = systeminfo.getCpuLoad5();
319                     break;
320                 case CHANNEL_CPU_LOAD_15:
321                     state = systeminfo.getCpuLoad15();
322                     break;
323                 case CHANNEL_CPU_UPTIME:
324                     state = systeminfo.getCpuUptime();
325                     break;
326                 case CHANNEL_CPU_THREADS:
327                     state = systeminfo.getCpuThreads();
328                     break;
329                 case CHANNEL_CPU_DESCRIPTION:
330                     state = systeminfo.getCpuDescription();
331                     break;
332                 case CHANNEL_CPU_NAME:
333                     state = systeminfo.getCpuName();
334                     break;
335                 case CHANNEL_MEMORY_AVAILABLE:
336                     state = systeminfo.getMemoryAvailable();
337                     break;
338                 case CHANNEL_MEMORY_USED:
339                     state = systeminfo.getMemoryUsed();
340                     break;
341                 case CHANNEL_MEMORY_TOTAL:
342                     state = systeminfo.getMemoryTotal();
343                     break;
344                 case CHANNEL_MEMORY_AVAILABLE_PERCENT:
345                     state = systeminfo.getMemoryAvailablePercent();
346                     break;
347                 case CHANNEL_MEMORY_USED_PERCENT:
348                     state = systeminfo.getMemoryUsedPercent();
349                     break;
350                 case CHANNEL_SWAP_AVAILABLE:
351                     state = systeminfo.getSwapAvailable();
352                     break;
353                 case CHANNEL_SWAP_USED:
354                     state = systeminfo.getSwapUsed();
355                     break;
356                 case CHANNEL_SWAP_TOTAL:
357                     state = systeminfo.getSwapTotal();
358                     break;
359                 case CHANNEL_SWAP_AVAILABLE_PERCENT:
360                     state = systeminfo.getSwapAvailablePercent();
361                     break;
362                 case CHANNEL_SWAP_USED_PERCENT:
363                     state = systeminfo.getSwapUsedPercent();
364                     break;
365                 case CHANNEL_DRIVE_MODEL:
366                     state = systeminfo.getDriveModel(deviceIndex);
367                     break;
368                 case CHANNEL_DRIVE_SERIAL:
369                     state = systeminfo.getDriveSerialNumber(deviceIndex);
370                     break;
371                 case CHANNEL_DRIVE_NAME:
372                     state = systeminfo.getDriveName(deviceIndex);
373                     break;
374                 case CHANNEL_STORAGE_NAME:
375                     state = systeminfo.getStorageName(deviceIndex);
376                     break;
377                 case CHANNEL_STORAGE_DESCRIPTION:
378                     state = systeminfo.getStorageDescription(deviceIndex);
379                     break;
380                 case CHANNEL_STORAGE_AVAILABLE:
381                     state = systeminfo.getStorageAvailable(deviceIndex);
382                     break;
383                 case CHANNEL_STORAGE_USED:
384                     state = systeminfo.getStorageUsed(deviceIndex);
385                     break;
386                 case CHANNEL_STORAGE_TOTAL:
387                     state = systeminfo.getStorageTotal(deviceIndex);
388                     break;
389                 case CHANNEL_STORAGE_TYPE:
390                     state = systeminfo.getStorageType(deviceIndex);
391                     break;
392                 case CHANNEL_STORAGE_AVAILABLE_PERCENT:
393                     state = systeminfo.getStorageAvailablePercent(deviceIndex);
394                     break;
395                 case CHANNEL_STORAGE_USED_PERCENT:
396                     state = systeminfo.getStorageUsedPercent(deviceIndex);
397                     break;
398                 case CHANNEL_NETWORK_IP:
399                     state = systeminfo.getNetworkIp(deviceIndex);
400                     break;
401                 case CHANNEL_NETWORK_ADAPTER_NAME:
402                     state = systeminfo.getNetworkDisplayName(deviceIndex);
403                     break;
404                 case CHANNEL_NETWORK_NAME:
405                     state = systeminfo.getNetworkName(deviceIndex);
406                     break;
407                 case CHANNEL_NETWORK_MAC:
408                     state = systeminfo.getNetworkMac(deviceIndex);
409                     break;
410                 case CHANNEL_NETWORK_DATA_SENT:
411                     state = systeminfo.getNetworkDataSent(deviceIndex);
412                     break;
413                 case CHANNEL_NETWORK_DATA_RECEIVED:
414                     state = systeminfo.getNetworkDataReceived(deviceIndex);
415                     break;
416                 case CHANNEL_NETWORK_PACKETS_RECEIVED:
417                     state = systeminfo.getNetworkPacketsReceived(deviceIndex);
418                     break;
419                 case CHANNEL_NETWORK_PACKETS_SENT:
420                     state = systeminfo.getNetworkPacketsSent(deviceIndex);
421                     break;
422                 case CHANNEL_PROCESS_LOAD:
423                     state = systeminfo.getProcessCpuUsage(deviceIndex);
424                     break;
425                 case CHANNEL_PROCESS_MEMORY:
426                     state = systeminfo.getProcessMemoryUsage(deviceIndex);
427                     break;
428                 case CHANNEL_PROCESS_NAME:
429                     state = systeminfo.getProcessName(deviceIndex);
430                     break;
431                 case CHANNEL_PROCESS_PATH:
432                     state = systeminfo.getProcessPath(deviceIndex);
433                     break;
434                 case CHANNEL_PROCESS_THREADS:
435                     state = systeminfo.getProcessThreads(deviceIndex);
436                     break;
437                 default:
438                     logger.debug("Channel with unknown ID: {} !", channelID);
439             }
440         } catch (DeviceNotFoundException e) {
441             logger.warn("No information for channel {} with device index {} :", channelID, deviceIndex);
442         } catch (Exception e) {
443             logger.debug("Unexpected error occurred while getting system information!", e);
444             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
445                     "Cannot get system info as result of unexpected error. Please try to restart the binding (remove and re-add the thing)!");
446         }
447         return state != null ? state : UnDefType.UNDEF;
448     }
449
450     /**
451      * The device index is an optional part of the channelID - the last characters of the groupID. It is used to
452      * identify unique device, when more than one devices are available (e.g. local disks with names C:\, D:\, E"\ - the
453      * first will have deviceIndex=0, the second deviceIndex=1 ant etc).
454      * When no device index is specified, default value of 0 (first device in the list) is returned.
455      *
456      * @param channelID the ID of the channel
457      * @return natural number (number >=0)
458      */
459     private int getDeviceIndex(ChannelUID channelUID) {
460         String channelGroupID = channelUID.getGroupId();
461         if (channelGroupID == null) {
462             return 0;
463         }
464
465         if (channelGroupID.contains(CHANNEL_GROUP_PROCESS)) {
466             // Only in this case the deviceIndex is part of the channel configuration - PID (Process Identifier)
467             int pid = getPID(channelUID);
468             logger.debug("Channel with UID {} tracks process with PID: {}", channelUID, pid);
469             return pid;
470         }
471
472         char lastChar = channelGroupID.charAt(channelGroupID.length() - 1);
473         if (Character.isDigit(lastChar)) {
474             // All non-digits are deleted from the ID
475             String deviceIndexPart = channelGroupID.replaceAll("\\D+", "");
476             return Integer.parseInt(deviceIndexPart);
477         }
478
479         return 0;
480     }
481
482     /**
483      * This method gets the process identifier (PID) for specific process
484      *
485      * @param channelUID channel unique identifier
486      * @return natural number
487      */
488     private int getPID(ChannelUID channelUID) {
489         int pid = 0;
490         try {
491             Channel channel = this.thing.getChannel(channelUID.getId());
492             if (channel != null) {
493                 Configuration channelProperties = channel.getConfiguration();
494                 BigDecimal pidValue = (BigDecimal) channelProperties.get(PID_PARAM);
495                 if (pidValue == null || pidValue.intValue() < 0) {
496                     throw new IllegalArgumentException("Invalid value for Process Identifier.");
497                 } else {
498                     pid = pidValue.intValue();
499                 }
500             } else {
501                 logger.debug("Channel does not exist ! Fall back to default value.");
502             }
503         } catch (ClassCastException e) {
504             logger.debug("Channel configuration cannot be read ! Fall back to default value.", e);
505         } catch (IllegalArgumentException e) {
506             logger.debug("PID (Process Identifier) must be positive number. Fall back to default value. ", e);
507         }
508         return pid;
509     }
510
511     @Override
512     public void handleCommand(ChannelUID channelUID, Command command) {
513         if (thing.getStatus().equals(ThingStatus.ONLINE)) {
514             if (command instanceof RefreshType) {
515                 logger.debug("Refresh command received for channel {}!", channelUID);
516                 publishDataForChannel(channelUID);
517             } else {
518                 logger.debug("Unsupported command {}! Supported commands: REFRESH", command);
519             }
520         } else {
521             logger.debug("Cannot handle command. Thing is not ONLINE.");
522         }
523     }
524
525     private boolean isConfigurationKeyChanged(Configuration currentConfig, Configuration newConfig, String key) {
526         Object currentValue = currentConfig.get(key);
527         Object newValue = newConfig.get(key);
528
529         if (currentValue == null) {
530             return (newValue != null);
531         }
532
533         return !currentValue.equals(newValue);
534     }
535
536     @Override
537     public void thingUpdated(Thing thing) {
538         logger.trace("About to update thing.");
539         boolean isChannelConfigChanged = false;
540         List<Channel> channels = thing.getChannels();
541
542         for (Channel channel : channels) {
543             ChannelUID channelUID = channel.getUID();
544             Configuration newChannelConfig = channel.getConfiguration();
545             Channel oldChannel = this.thing.getChannel(channelUID.getId());
546
547             if (oldChannel == null) {
548                 logger.warn("Channel with UID {} cannot be updated, as it cannot be found !", channelUID);
549                 continue;
550             }
551             Configuration currentChannelConfig = oldChannel.getConfiguration();
552
553             if (isConfigurationKeyChanged(currentChannelConfig, newChannelConfig, PRIOIRITY_PARAM)) {
554                 isChannelConfigChanged = true;
555
556                 handleChannelConfigurationChange(oldChannel, newChannelConfig, PRIOIRITY_PARAM);
557
558                 String newPriority = (String) newChannelConfig.get(PRIOIRITY_PARAM);
559                 changeChannelPriority(channelUID, newPriority);
560             }
561
562             if (isConfigurationKeyChanged(currentChannelConfig, newChannelConfig, PID_PARAM)) {
563                 isChannelConfigChanged = true;
564                 handleChannelConfigurationChange(oldChannel, newChannelConfig, PID_PARAM);
565             }
566         }
567
568         if (!(isInitialized() && isChannelConfigChanged)) {
569             super.thingUpdated(thing);
570         }
571     }
572
573     private void handleChannelConfigurationChange(Channel channel, Configuration newConfig, String parameter) {
574         Configuration configuration = channel.getConfiguration();
575         Object oldValue = configuration.get(parameter);
576
577         configuration.put(parameter, newConfig.get(parameter));
578
579         Object newValue = newConfig.get(parameter);
580         logger.debug("Channel with UID {} has changed its {} from {} to {}", channel.getUID(), parameter, oldValue,
581                 newValue);
582         publishDataForChannel(channel.getUID());
583     }
584
585     private void stopScheduledUpdates() {
586         ScheduledFuture<?> localHighPriorityTasks = highPriorityTasks;
587         if (localHighPriorityTasks != null) {
588             logger.debug("High prioriy tasks will not be run anymore !");
589             localHighPriorityTasks.cancel(true);
590         }
591
592         ScheduledFuture<?> localMediumPriorityTasks = mediumPriorityTasks;
593         if (localMediumPriorityTasks != null) {
594             logger.debug("Medium prioriy tasks will not be run anymore !");
595             localMediumPriorityTasks.cancel(true);
596         }
597     }
598
599     @Override
600     public void dispose() {
601         stopScheduledUpdates();
602     }
603 }