You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2021/01/18 15:38:56 UTC
[karaf-decanter] branch master updated: [KARAF-6987] Add host
property on socket collector allowing to define the binding address/host
This is an automated email from the ASF dual-hosted git repository.
jbonofre pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/karaf-decanter.git
The following commit(s) were added to refs/heads/master by this push:
new fa5badf [KARAF-6987] Add host property on socket collector allowing to define the binding address/host
new edce3a7 Merge pull request #223 from jbonofre/KARAF-6987
fa5badf is described below
commit fa5badfbd220f01705340f5e027ad8c739d484d4
Author: jbonofre <jb...@apache.org>
AuthorDate: Sun Jan 17 08:05:22 2021 +0100
[KARAF-6987] Add host property on socket collector allowing to define the binding address/host
---
.../main/cfg/org.apache.karaf.decanter.collector.socket.cfg | 3 +++
.../karaf/decanter/collector/socket/SocketCollector.java | 10 ++++------
manual/src/main/asciidoc/user-guide/collectors.adoc | 4 ++++
3 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/collector/socket/src/main/cfg/org.apache.karaf.decanter.collector.socket.cfg b/collector/socket/src/main/cfg/org.apache.karaf.decanter.collector.socket.cfg
index fdc3f12..81b5597 100644
--- a/collector/socket/src/main/cfg/org.apache.karaf.decanter.collector.socket.cfg
+++ b/collector/socket/src/main/cfg/org.apache.karaf.decanter.collector.socket.cfg
@@ -22,6 +22,9 @@
# Port number on which to listen
#port=34343
+# Binding address on which to listen
+#host=0.0.0.0
+
# Number of worker threads to deal with
#workers=10
diff --git a/collector/socket/src/main/java/org/apache/karaf/decanter/collector/socket/SocketCollector.java b/collector/socket/src/main/java/org/apache/karaf/decanter/collector/socket/SocketCollector.java
index 163d49e..996dfa5 100644
--- a/collector/socket/src/main/java/org/apache/karaf/decanter/collector/socket/SocketCollector.java
+++ b/collector/socket/src/main/java/org/apache/karaf/decanter/collector/socket/SocketCollector.java
@@ -17,10 +17,7 @@
package org.apache.karaf.decanter.collector.socket;
import java.io.*;
-import java.net.DatagramPacket;
-import java.net.DatagramSocket;
-import java.net.ServerSocket;
-import java.net.Socket;
+import java.net.*;
import java.util.Dictionary;
import java.util.HashMap;
import java.util.Map;
@@ -79,6 +76,7 @@ public class SocketCollector implements Closeable, Runnable {
public void activate(Dictionary<String, Object> properties) throws IOException {
this.properties = properties;
int port = Integer.parseInt(getProperty(this.properties, "port", "34343"));
+ String host = getProperty(this.properties, "host", "0.0.0.0");
int workers = Integer.parseInt(getProperty(this.properties, "workers", "10"));
this.protocol = Protocol.valueOf(getProperty(this.properties, "protocol", "tcp").toUpperCase());
@@ -91,10 +89,10 @@ public class SocketCollector implements Closeable, Runnable {
switch (protocol) {
case TCP:
- this.serverSocket = new ServerSocket(port);
+ this.serverSocket = new ServerSocket(port, 50, InetAddress.getByName(host));
break;
case UDP:
- this.datagramSocket = new DatagramSocket(port);
+ this.datagramSocket = new DatagramSocket(port, InetAddress.getByName(host));
break;
}
diff --git a/manual/src/main/asciidoc/user-guide/collectors.adoc b/manual/src/main/asciidoc/user-guide/collectors.adoc
index 02a60f0..10d9831 100644
--- a/manual/src/main/asciidoc/user-guide/collectors.adoc
+++ b/manual/src/main/asciidoc/user-guide/collectors.adoc
@@ -669,6 +669,9 @@ This feature installs a default `etc/org.apache.karaf.decanter.collector.socket.
# Port number on which to listen
#port=34343
+# Binding address on which to listen
+#host=0.0.0.0
+
# Number of worker threads to deal with
#workers=10
@@ -681,6 +684,7 @@ unmarshaller.target=(dataFormat=json)
----
* the `port` property contains the port number where the network socket collector is listening
+* the `host` property contains the host name/interface address where the network socket collector is listening
* the `workers` property contains the number of worker threads the socket collector is using for the connection
* the `protocol` property contains the protocol used by the collector for transferring data with the client
* the `unmarshaller.target` property contains the unmarshaller used by the collector to transform the data