Skip to content
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
82a378a
Fix performance
lsiepel Dec 24, 2024
2080346
Improvements
lsiepel Jan 1, 2025
dcce737
Add logging
lsiepel May 30, 2025
0f6dfd1
Improve logging
lsiepel May 30, 2025
9618fb6
Update bundles/org.openhab.binding.network/src/main/java/org/openhab/…
lsiepel May 30, 2025
ae384b0
Improve thread handling
lsiepel Aug 28, 2025
ce74629
Improve shutdown
lsiepel Aug 28, 2025
72cd118
thread cleanup
lsiepel Aug 28, 2025
a07516d
Improve per thread allocation
lsiepel Aug 28, 2025
8cd2ceb
Stop on finishing all interfaces
lsiepel Aug 28, 2025
a62ef9e
Change Arping to make use of completeablefeature
lsiepel Aug 29, 2025
92a82bc
Seperate presence detection from lifecycle
lsiepel Aug 29, 2025
ce17620
Improve logging and filtering
lsiepel Aug 29, 2025
1397df2
Create seperate ScheduledExecutorService
lsiepel Aug 30, 2025
ee80608
Fix review comment
lsiepel Aug 30, 2025
4d2164a
Improve network address checks
lsiepel Aug 30, 2025
2a6be86
Improve interrupthandling
lsiepel Aug 30, 2025
7e3efa0
Revert threadlocal
lsiepel Aug 31, 2025
5e1313f
Refactor Presencedetection
lsiepel Aug 31, 2025
71508fb
Make LatencyParser accept Windows' <1ms syntax for minimal latency
Aug 30, 2025
b203761
Remove misleading reference to non-existing NetworkHandlerBuilder
Aug 30, 2025
e080bae
Handle thread-safety of NetworkDiscoveryService.executorService
Aug 30, 2025
165df30
Fix network interface exclusion
Sep 2, 2025
8d099e0
Make PresenceDetectionValue thread-safe
Sep 2, 2025
571f1a2
Partial refactoring of PresenceDetection
Sep 2, 2025
42a03da
Partial refactoring of NetworkDiscoveryService
Sep 2, 2025
370b133
Make NetworkHandler thread-safe
Sep 3, 2025
cab9542
Make SpeedTestHandler thread-safe
Sep 4, 2025
04786e2
Make sure that process output is consumed
Sep 5, 2025
14a0d39
Implement tool-specific latency parsing
Sep 5, 2025
5fcd5a9
Fix NetworkDiscoveryService configuration and make the thread pool si…
Sep 5, 2025
75c1e07
i18n
lsiepel Sep 6, 2025
e36ff67
Review comments
lsiepel Sep 6, 2025
b4a70da
Fix test
lsiepel Sep 6, 2025
8664e05
Remove restart from doc
lsiepel Sep 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,17 @@
@NonNullByDefault
public class NetworkBindingConfiguration {

public final static int DEFAULT_DISCOVERY_THREADS = 100;
public final static String DEFAULT_ARPING_TOOL_PATH = "arping";
public final static ArpPingUtilEnum DEFAULT_ARPING_METHOD = ArpPingUtilEnum.DISABLED;
public boolean allowSystemPings = true;
public boolean allowDHCPlisten = true;
public BigDecimal cacheDeviceStateTimeInMS = BigDecimal.valueOf(2000);
public String arpPingToolPath = "arping";
public ArpPingUtilEnum arpPingUtilMethod = ArpPingUtilEnum.DISABLED;
public String arpPingToolPath = DEFAULT_ARPING_TOOL_PATH;
public ArpPingUtilEnum arpPingUtilMethod = DEFAULT_ARPING_METHOD;
// For backwards compatibility reasons, the default is to use the ping method execution time as latency value
public boolean preferResponseTimeAsLatency = false;
public int numberOfDiscoveryThreads = DEFAULT_DISCOVERY_THREADS;

private List<NetworkBindingConfigurationListener> listeners = new ArrayList<>();

Expand All @@ -45,6 +49,7 @@ public void update(NetworkBindingConfiguration newConfiguration) {
this.cacheDeviceStateTimeInMS = newConfiguration.cacheDeviceStateTimeInMS;
this.arpPingToolPath = newConfiguration.arpPingToolPath;
this.preferResponseTimeAsLatency = newConfiguration.preferResponseTimeAsLatency;
this.numberOfDiscoveryThreads = newConfiguration.numberOfDiscoveryThreads;

NetworkUtils networkUtils = new NetworkUtils();
this.arpPingUtilMethod = networkUtils.determineNativeArpPingMethod(arpPingToolPath);
Expand All @@ -65,6 +70,6 @@ public String toString() {
return "NetworkBindingConfiguration{" + "allowSystemPings=" + allowSystemPings + ", allowDHCPlisten="
+ allowDHCPlisten + ", cacheDeviceStateTimeInMS=" + cacheDeviceStateTimeInMS + ", arpPingToolPath='"
+ arpPingToolPath + '\'' + ", arpPingUtilMethod=" + arpPingUtilMethod + ", preferResponseTimeAsLatency="
+ preferResponseTimeAsLatency + '}';
+ preferResponseTimeAsLatency + ", numberOfDiscoveryThreads=" + numberOfDiscoveryThreads + '}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
public class NetworkBindingConstants {

public static final String BINDING_ID = "network";
public static final String BINDING_CONFIGURATION_PID = "binding.network";

// List of all Thing Type UIDs
public static final ThingTypeUID BACKWARDS_COMPATIBLE_DEVICE = new ThingTypeUID(BINDING_ID, "device");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@
*/
package org.openhab.binding.network.internal;

import static org.openhab.binding.network.internal.NetworkBindingConstants.*;

import java.util.Map;
import java.util.concurrent.ScheduledExecutorService;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.network.internal.handler.NetworkHandler;
import org.openhab.binding.network.internal.handler.SpeedTestHandler;
import org.openhab.core.common.ThreadPoolManager;
import org.openhab.core.config.core.Configuration;
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingTypeUID;
Expand All @@ -39,15 +43,17 @@
* @author David Graeff - Initial contribution
*/
@NonNullByDefault
@Component(service = ThingHandlerFactory.class, configurationPid = "binding.network")
@Component(service = ThingHandlerFactory.class, configurationPid = BINDING_CONFIGURATION_PID)
public class NetworkHandlerFactory extends BaseThingHandlerFactory {
final NetworkBindingConfiguration configuration = new NetworkBindingConfiguration();

private static final String NETWORK_HANDLER_THREADPOOL_NAME = "networkBinding";
private final Logger logger = LoggerFactory.getLogger(NetworkHandlerFactory.class);
private final ScheduledExecutorService executor = ThreadPoolManager
.getScheduledPool(NETWORK_HANDLER_THREADPOOL_NAME);

@Override
public boolean supportsThingType(ThingTypeUID thingTypeUID) {
return NetworkBindingConstants.SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID);
return SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID);
}

// The activate component call is used to access the bindings configuration
Expand Down Expand Up @@ -76,12 +82,11 @@ protected void modified(Map<String, Object> config) {
protected @Nullable ThingHandler createHandler(Thing thing) {
ThingTypeUID thingTypeUID = thing.getThingTypeUID();

if (thingTypeUID.equals(NetworkBindingConstants.PING_DEVICE)
|| thingTypeUID.equals(NetworkBindingConstants.BACKWARDS_COMPATIBLE_DEVICE)) {
return new NetworkHandler(thing, false, configuration);
} else if (thingTypeUID.equals(NetworkBindingConstants.SERVICE_DEVICE)) {
return new NetworkHandler(thing, true, configuration);
} else if (thingTypeUID.equals(NetworkBindingConstants.SPEEDTEST_DEVICE)) {
if (thingTypeUID.equals(PING_DEVICE) || thingTypeUID.equals(BACKWARDS_COMPATIBLE_DEVICE)) {
return new NetworkHandler(thing, executor, false, configuration);
} else if (thingTypeUID.equals(SERVICE_DEVICE)) {
return new NetworkHandler(thing, executor, true, configuration);
} else if (thingTypeUID.equals(SPEEDTEST_DEVICE)) {
return new SpeedTestHandler(thing);
}
return null;
Expand Down
Loading