This is an automated email from the ASF dual-hosted git repository.

glcj pushed a commit to branch feature/merlot
in repository https://gitbox.apache.org/repos/asf/plc4x-extras.git


The following commit(s) were added to refs/heads/feature/merlot by this push:
     new 32b4217  Support for multiple device connections in Merlot (#719)
32b4217 is described below

commit 32b421727337129987fda30fd22f52f728412163
Author: Lerb123 <[email protected]>
AuthorDate: Tue Jun 23 11:57:59 2026 -0400

    Support for multiple device connections in Merlot (#719)
    
    * feat: Implement Loki appender for Karaf event bus
    
    * fix: Implement Loki appender for Karaf event bus, added comments.
    
    * feat: Functional test for Loki Appender using WireMock
    
    * feat: CI Pipeline for MerlotLokiAppender
    
    * Correction to the Maven configuration to prevent tests from being 
skipped; add .mvn
    
    * Correction to Maven configuration: local cache is disabled
    
    * feat:Kafka collector for topics on the Phoebus alarm server
    
    * feat:Local data persistence for PVHtc
    
    * feat:Creation of an event log service
    
    * beta: test servlets
    
    * feat:Improved handling of multipart/form-data requests
    
    * openjpa
    
    * test simple
    
    * test simple
    
    * beta:  Log entry in the pax data source
    
    * beta:  Log entry persistent and files
    
    * beta: logrecorder functional bundle (up)
    
    * Service for creating and retrieving logs (reports) using ops4j data 
sources for Phoebus
    
    * test simple
    
    * Implement and document Loki appender for Karaf event bus (#649)
    
    * feat: Implement Loki appender for Karaf event bus
    
    * fix: Implement Loki appender for Karaf event bus, added comments.
    
    * feat: Functional test for Loki Appender using WireMock
    
    * feat: CI Pipeline for MerlotLokiAppender
    
    * Correction to the Maven configuration to prevent tests from being 
skipped; add .mvn
    
    * Correction to Maven configuration: local cache is disabled
    
    * feat:Kafka collector for topics on the Phoebus alarm server
    
    * Local Buffer PVHtc-Archiver (#682)
    
    * feat: Implement Loki appender for Karaf event bus
    
    * fix: Implement Loki appender for Karaf event bus, added comments.
    
    * feat: Functional test for Loki Appender using WireMock
    
    * feat: CI Pipeline for MerlotLokiAppender
    
    * Correction to the Maven configuration to prevent tests from being 
skipped; add .mvn
    
    * Correction to Maven configuration: local cache is disabled
    
    * feat:Kafka collector for topics on the Phoebus alarm server
    
    * feat:Local data persistence for PVHtc
    
    * fix: rebase merlot and logrecorder
    
    * fix: merlot (htc) and logrecorder and kafka collector
    
    * test Case: Creating a Report and Inserting a Record into the Database
    
    * Create Log entry: test MerlotLogRecorderMultipart
    
    * fix:Multiple connections supported. Device loading from the database has 
been resolved
---
 .../data/tmp/olog_olog_2132687163876.png           |   1 +
 .../merlot/org.apache.plc4x.logrecorder/pom.xml    |   7 +-
 .../MerlotLogRecorderServletDefinition.java        |  49 +--
 .../resources/features/logRecorderServlet.feature  |   6 -
 .../img/olog_image15526173202119244381.png         | Bin 9116 -> 0 bytes
 .../plc4x/merlot/api/impl/PlcSecureBootImpl.java   | 385 +++++++++++----------
 .../org/apache/plc4x/merlot/db/api/DBRecord.java   |   2 +-
 .../impl/MerlotKafkaDecanterCollectorImpl.java     | 255 ++++----------
 8 files changed, 281 insertions(+), 424 deletions(-)

diff --git 
a/plc4j/tools/merlot/org.apache.plc4x.logrecorder/data/tmp/olog_olog_2132687163876.png
 
b/plc4j/tools/merlot/org.apache.plc4x.logrecorder/data/tmp/olog_olog_2132687163876.png
new file mode 100644
index 0000000..fc98ee4
--- /dev/null
+++ 
b/plc4j/tools/merlot/org.apache.plc4x.logrecorder/data/tmp/olog_olog_2132687163876.png
@@ -0,0 +1 @@
+olog_2132687163876
\ No newline at end of file
diff --git a/plc4j/tools/merlot/org.apache.plc4x.logrecorder/pom.xml 
b/plc4j/tools/merlot/org.apache.plc4x.logrecorder/pom.xml
index 0f2dec0..2bf1982 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.logrecorder/pom.xml
+++ b/plc4j/tools/merlot/org.apache.plc4x.logrecorder/pom.xml
@@ -37,6 +37,8 @@
         
<cucumber-junit-platform-engine.version>7.34.3</cucumber-junit-platform-engine.version>
 
         <mockito.version>5.23.0</mockito.version>
+        <mockito.inline.version>5.2.0</mockito.inline.version>
+
     </properties>
 
     <dependencies>
@@ -148,7 +150,8 @@
         <dependency>
             <groupId>org.junit.platform</groupId>
             <artifactId>junit-platform-suite-engine</artifactId>
-            <version>${junit-platform.version}</version> <scope>test</scope>
+            <version>${junit-platform.version}</version>
+            <scope>test</scope>
         </dependency>
 
         <dependency>
@@ -165,7 +168,7 @@
         <dependency>
             <groupId>org.mockito</groupId>
             <artifactId>mockito-inline</artifactId>
-            <version>5.2.0</version>
+            <version>${mockito.inline.version}</version>
             <scope>test</scope>
         </dependency>
     </dependencies>
diff --git 
a/plc4j/tools/merlot/org.apache.plc4x.logrecorder/src/test/java/stepdefinition/MerlotLogRecorderServletDefinition.java
 
b/plc4j/tools/merlot/org.apache.plc4x.logrecorder/src/test/java/stepdefinition/MerlotLogRecorderServletDefinition.java
index 7a2a4b2..fb70837 100644
--- 
a/plc4j/tools/merlot/org.apache.plc4x.logrecorder/src/test/java/stepdefinition/MerlotLogRecorderServletDefinition.java
+++ 
b/plc4j/tools/merlot/org.apache.plc4x.logrecorder/src/test/java/stepdefinition/MerlotLogRecorderServletDefinition.java
@@ -1,25 +1,18 @@
 package stepdefinition;
 
-import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import io.cucumber.java.en.Given;
 import io.cucumber.java.en.Then;
 import io.cucumber.java.en.When;
-import 
org.apache.plc4x.merlot.logrecorder.appender.MerlotLogRecorderJDBCAppender;
 import 
org.apache.plc4x.merlot.logrecorder.core.MerlotLogRecorderSecurityAction;
 import 
org.apache.plc4x.merlot.logrecorder.servlets.MerlotLogRecorderLogMultipart;
-import org.json.JSONArray;
 import org.json.JSONObject;
-import org.junit.Assert;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import javax.servlet.http.Part;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.nio.charset.StandardCharsets;
-import java.time.Instant;
 import java.util.*;
 import javax.servlet.ServletException;
 import javax.servlet.ServletOutputStream;
@@ -31,7 +24,6 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.mockito.ArgumentMatchers.any;
 import org.mockito.MockedStatic;
-import org.mockito.Mockito;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.mockStatic;
 import static org.mockito.Mockito.verify;
@@ -40,7 +32,6 @@ import static org.mockito.Mockito.when;
 //TODO: Hacer las implementacion de cada metodo
 public class MerlotLogRecorderServletDefinition {
 
-    private final static Logger LOGGER = 
LoggerFactory.getLogger(MerlotLogRecorderServletDefinition.class);
     private String username;
     private String password;
     private String level;
@@ -51,8 +42,6 @@ public class MerlotLogRecorderServletDefinition {
     private String title;
 
     private String serverResponse;
-    JSONObject payload = new JSONObject();
-    
     //
 
     //Scenario 1: Create a fault report (servlet logMultipart)
@@ -91,10 +80,10 @@ public class MerlotLogRecorderServletDefinition {
 
     @When("The user clicks the submit button")
     public void whenTheUserClicksTheSubmitButton() throws IOException, 
ServletException {
-        
+       
         //Mock that collects and prepares the message
         MerlotLogRecorderAction merlotAction = 
mock(MerlotLogRecorderAction.class);
-        
+
         //Mock of the servlet responsible for creating the log
         MerlotLogRecorderLogMultipart servlet = new 
MerlotLogRecorderLogMultipart(merlotAction);
 
@@ -102,7 +91,6 @@ public class MerlotLogRecorderServletDefinition {
         HttpServletRequest request = mock(HttpServletRequest.class);
         HttpServletResponse response = mock(HttpServletResponse.class);
 
-  
         //Log Builder
         ObjectMapper mapper = new ObjectMapper();
         com.fasterxml.jackson.databind.node.ObjectNode payloadNode = 
mapper.createObjectNode();
@@ -137,12 +125,11 @@ public class MerlotLogRecorderServletDefinition {
         attachmentsArray.add(attachmentObj);
         payloadNode.set("attachments", attachmentsArray);
 
-        
         //Request JSON
         final String jsonString = mapper.writeValueAsString(payloadNode);
 
-        System.out.println("\nLog created before sending: "+new 
ObjectMapper().readTree(jsonString).toPrettyString());
-        
+        System.out.println("\nLog created before sending: " + new 
ObjectMapper().readTree(jsonString).toPrettyString());
+
         //Multi-part
         Part jsonPart = mock(Part.class);
         when(jsonPart.getContentType()).thenReturn("application/json");
@@ -191,14 +178,11 @@ public class MerlotLogRecorderServletDefinition {
             servlet.doPut(request, response);
         }
 
-
-        
         String responseBodyStr = baos.toString(StandardCharsets.UTF_8);
         assertFalse("The body of the response should not be empty", 
responseBodyStr.isEmpty());
 
         JSONObject jsonResponse = new JSONObject(responseBodyStr);
 
-        
         assertEquals(payloadNode.get("owner").asText(), 
jsonResponse.getString("owner"));
         assertEquals(payloadNode.get("level").asText(), 
jsonResponse.getString("level"));
         assertEquals(payloadNode.get("title").asText(), 
jsonResponse.getString("title"));
@@ -208,35 +192,14 @@ public class MerlotLogRecorderServletDefinition {
         verify(response).setContentType("application/json");
         verify(response).setStatus(HttpServletResponse.SC_OK);
         verify(merlotAction).prepareAndSendMessage(any(JSONObject.class));
-        
+
         this.serverResponse = new 
ObjectMapper().readTree(responseBodyStr).toPrettyString();
-    }
 
-  
 
     @Then("Returns the JSON from the created report and an HTTP {int} 
response")
     public void returnsTheJSONFromTheCreatedReportAndAnHTTPResponse(Integer 
httpCode) {
-        System.out.println("Simplified log as a response: 
"+this.serverResponse+"\nHttp Code: "+httpCode+"\n");
+        System.out.println("Simplified log as a response: " + 
this.serverResponse + "\nHttp Code: " + httpCode + "\n");
     }
 
-    //Scenario 2: Retrieve reports from the database (search servlet)
-    @Given("The user navigates to the {string} option")
-    public void theUserNavigatesToTheOption(String logBook) {
-        System.out.println("Option: " + logBook);
-    }
 
-    @Given("No search parameters are specified")
-    public void noSearchParametersAreSpecified() {
-        System.out.println("No search parameters, defects in the last 12 
hours");
-    }
-
-    @When("The UI is being updated")
-    public void theUi_isBeingUpdated() {
-        System.out.println("UI updated");
-    }
-
-    @Then("The records stored over the last {int} hours are returned")
-    public void theRecordsStoredOverTheLastHoursAreReturned(Integer limitHour) 
{
-        System.out.println("Records: " + limitHour);
-    }
 }
diff --git 
a/plc4j/tools/merlot/org.apache.plc4x.logrecorder/src/test/resources/features/logRecorderServlet.feature
 
b/plc4j/tools/merlot/org.apache.plc4x.logrecorder/src/test/resources/features/logRecorderServlet.feature
index 5053bd6..3bc7782 100644
--- 
a/plc4j/tools/merlot/org.apache.plc4x.logrecorder/src/test/resources/features/logRecorderServlet.feature
+++ 
b/plc4j/tools/merlot/org.apache.plc4x.logrecorder/src/test/resources/features/logRecorderServlet.feature
@@ -14,9 +14,3 @@ Feature: Create a fault report
     Then Returns the JSON from the created report and an HTTP 200 response
 
 
-  Scenario: Retrieve reports from the database
-    Given The user navigates to the "Log Books" option
-    And No search parameters are specified
-    When The UI is being updated
-    Then The records stored over the last 12 hours are returned
-
diff --git 
a/plc4j/tools/merlot/org.apache.plc4x.logrecorder/src/test/resources/img/olog_image15526173202119244381.png
 
b/plc4j/tools/merlot/org.apache.plc4x.logrecorder/src/test/resources/img/olog_image15526173202119244381.png
deleted file mode 100644
index 007f85c..0000000
Binary files 
a/plc4j/tools/merlot/org.apache.plc4x.logrecorder/src/test/resources/img/olog_image15526173202119244381.png
 and /dev/null differ
diff --git 
a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcSecureBootImpl.java
 
b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcSecureBootImpl.java
index 66f1d0d..631ef58 100644
--- 
a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcSecureBootImpl.java
+++ 
b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcSecureBootImpl.java
@@ -18,10 +18,13 @@
  */
 package org.apache.plc4x.merlot.api.impl;
 
+import com.sun.source.tree.ContinueTree;
 import java.sql.Connection;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Map;
 import java.util.Optional;
 import java.util.Properties;
@@ -45,54 +48,54 @@ import org.osgi.service.event.EventAdmin;
 import org.osgi.service.jdbc.DataSourceFactory;
 import org.slf4j.LoggerFactory;
 
-
 public class PlcSecureBootImpl implements PlcSecureBoot, Job {
+
     private static final org.slf4j.Logger LOGGER = 
LoggerFactory.getLogger(PlcSecureBootImpl.class);
     private static final String DB_URL = "jdbc:sqlite:data/boot.db";
-            
-    private static final String SQL_CREATE_TABLE_DEVICES = 
-            "CREATE TABLE IF NOT EXISTS Devices("
+
+    private static final String SQL_CREATE_TABLE_DEVICES
+            = "CREATE TABLE IF NOT EXISTS Devices("
             + "DeviceUuId TEXT NOT NULL PRIMARY KEY,"
-            + "DriverName TEXT,"            
+            + "DriverName TEXT,"
             + "DeviceKey TEXT,"
             + "DeviceUrl TEXT,"
             + "DeviceName TEXT,"
             + "DeviceDescription TEXT,"
-            + "DeviceEnable TEXT,"            
+            + "DeviceEnable TEXT,"
             + "Md5 TEXT)";
-    
-    private static final String SQL_CREATE_TABLE_GROUPS = 
-            "CREATE TABLE IF NOT EXISTS Groups("
+
+    private static final String SQL_CREATE_TABLE_GROUPS
+            = "CREATE TABLE IF NOT EXISTS Groups("
             + "GroupUuid TEXT NOT NULL PRIMARY KEY,"
-            + "DeviceUuid TEXT,"            
+            + "DeviceUuid TEXT,"
             + "GroupName TEXT,"
             + "GroupDescription TEXT,"
             + "GroupScantime TEXT,"
-            + "GroupEnable TEXT,"            
-            + "Md5 TEXT)";  
+            + "GroupEnable TEXT,"
+            + "Md5 TEXT)";
 
-    private static final String SQL_CREATE_TABLE_ITEMS = 
-            "CREATE TABLE IF NOT EXISTS Items("
+    private static final String SQL_CREATE_TABLE_ITEMS
+            = "CREATE TABLE IF NOT EXISTS Items("
             + "ItemUuid TEXT NOT NULL PRIMARY KEY,"
             + "DeviceUuid TEXT,"
             + "GroupUuid TEXT,"
             + "ItemName TEXT,"
             + "ItemDescription TEXT,"
             + "ItemTag TEXT,"
-            + "ItemEnable TEXT,"             
-            + "Md5 TEXT)";  
-    
-    private static final String SQL_SELECT_DEVICES = 
-            "SELECT * FROM Devices";
-    
-    private static final String SQL_SELECT_GROUPS = 
-            "SELECT * FROM Groups WHERE DeviceUuid = '?'";  
-    
-    private static final String SQL_SELECT_ITEMS = 
-            "SELECT * FROM Items WHERE GroupUuid = '?'";     
-    
-    private static final String SQL_INSERT_DEVICE = 
-            "INSERT INTO Devices(DeviceUuId, DriverName, DeviceKey, DeviceUrl, 
DeviceName, DeviceDescription, DeviceEnable, Md5)"
+            + "ItemEnable TEXT,"
+            + "Md5 TEXT)";
+
+    private static final String SQL_SELECT_DEVICES
+            = "SELECT * FROM Devices";
+
+    private static final String SQL_SELECT_GROUPS
+            = "SELECT * FROM Groups WHERE DeviceUuid = '?'";
+
+    private static final String SQL_SELECT_ITEMS
+            = "SELECT * FROM Items WHERE GroupUuid = '?'";
+
+    private static final String SQL_INSERT_DEVICE
+            = "INSERT INTO Devices(DeviceUuId, DriverName, DeviceKey, 
DeviceUrl, DeviceName, DeviceDescription, DeviceEnable, Md5)"
             + "VALUES(?, ?, ?, ?, ?, ?, ?, ?) "
             + "ON CONFLICT(DeviceUuId) "
             + "DO "
@@ -102,12 +105,11 @@ public class PlcSecureBootImpl implements PlcSecureBoot, 
Job {
             + "DeviceUrl =   excluded.DeviceUrl, "
             + "DeviceName =  excluded.DeviceName, "
             + "DeviceDescription= excluded.DeviceDescription, "
-            + "DeviceEnable= excluded.DeviceEnable, "            
+            + "DeviceEnable= excluded.DeviceEnable, "
             + "Md5 =        excluded.Md5;";
-              
-    
-    private static final String SQL_INSERT_GROUP = 
-            "INSERT INTO Groups(GroupUuid, DeviceUuid, GroupName, 
GroupDescription, GroupScantime, GroupEnable, Md5)"
+
+    private static final String SQL_INSERT_GROUP
+            = "INSERT INTO Groups(GroupUuid, DeviceUuid, GroupName, 
GroupDescription, GroupScantime, GroupEnable, Md5)"
             + "VALUES(?, ?, ?, ?, ?, ?, ?) "
             + "ON CONFLICT(GroupUuid) "
             + "DO "
@@ -117,11 +119,11 @@ public class PlcSecureBootImpl implements PlcSecureBoot, 
Job {
             + "GroupName =          excluded.GroupName, "
             + "GroupDescription =   excluded.GroupDescription, "
             + "GroupScantime    =   excluded.GroupScantime, "
-            + "GroupEnable    =     excluded.GroupEnable, "            
+            + "GroupEnable    =     excluded.GroupEnable, "
             + "Md5 =                excluded.Md5;";
-    
-    private static final String SQL_INSERT_ITEM = 
-            "INSERT INTO Items(ItemUuid, DeviceUuid, GroupUuid, ItemName, 
ItemDescription, ItemTag, ItemEnable, Md5)"
+
+    private static final String SQL_INSERT_ITEM
+            = "INSERT INTO Items(ItemUuid, DeviceUuid, GroupUuid, ItemName, 
ItemDescription, ItemTag, ItemEnable, Md5)"
             + "VALUES(?, ?, ?, ?, ?, ?, ?, ?) "
             + "ON CONFLICT(ItemUuid) "
             + "DO "
@@ -131,17 +133,17 @@ public class PlcSecureBootImpl implements PlcSecureBoot, 
Job {
             + "GroupUuid =          excluded.GroupUuid, "
             + "ItemName =           excluded.ItemName, "
             + "ItemDescription  =   excluded.ItemDescription, "
-            + "ItemTag  =           excluded.ItemTag, "  
+            + "ItemTag  =           excluded.ItemTag, "
             + "ItemEnable  =        excluded.ItemEnable, "
-            + "Md5 =                excluded.Md5;";   
-    
+            + "Md5 =                excluded.Md5;";
+
     private Map<String, PlcDriver> delayedBootPlcDivers = new 
ConcurrentHashMap<>();
-    
+
     private final BundleContext ctx;
     private final PlcGeneralFunction gf;
-    
+
     private int delayed = 0;
-    
+
     DataSourceFactory dsFactory = null;
     Connection dbConnection = null;
 
@@ -149,7 +151,7 @@ public class PlcSecureBootImpl implements PlcSecureBoot, 
Job {
         this.ctx = ctx;
         this.gf = gf;
     }
-        
+
     @Override
     public void init() {
         if (null != dsFactory) {
@@ -164,14 +166,14 @@ public class PlcSecureBootImpl implements PlcSecureBoot, 
Job {
                     LOGGER.info("Boot driver name is [{}].", 
databaseMetaData.getDriverName());
                     createTables();
                     //Catalog,Schema, Table pattern,types of tables
-                    try(ResultSet resultSet = databaseMetaData.getTables(null, 
null, null, new String[]{"TABLE"})){ 
-                      while(resultSet.next()) { 
-                        String tableName = resultSet.getString("TABLE_NAME"); 
-                        String remarks = resultSet.getString("REMARKS"); 
-                      }
-                    }                    
+                    try (ResultSet resultSet = 
databaseMetaData.getTables(null, null, null, new String[]{"TABLE"})) {
+                        while (resultSet.next()) {
+                            String tableName = 
resultSet.getString("TABLE_NAME");
+                            String remarks = resultSet.getString("REMARKS");
+                        }
+                    }
                     dbConnection.commit();
-                    dbConnection.close();                    
+                    dbConnection.close();
                 }
             } catch (SQLException ex) {
                 LOGGER.error(ex.getMessage());
@@ -187,71 +189,70 @@ public class PlcSecureBootImpl implements PlcSecureBoot, 
Job {
             } catch (SQLException ex) {
                 LOGGER.info(ex.getMessage());
             }
-        }    
+        }
     }
 
     @Override
     public void bindPlcDriver(PlcDriver plcDriver) {
-        LOGGER.info("Loading driver: {%s}.",plcDriver.getProtocolCode());
+        LOGGER.info("Loading driver: {%s}.", plcDriver.getProtocolCode());
         if (null != dbConnection) {
             restore(plcDriver.getProtocolCode());
         } else {
-            LOGGER.info("Delayed start of driver 
[{}].",plcDriver.getProtocolCode());
+            LOGGER.info("Delayed start of driver [{}].", 
plcDriver.getProtocolCode());
             delayedBootPlcDivers.put(plcDriver.getProtocolCode(), plcDriver);
         }
     }
 
     @Override
     public void unbindPlcDriver(PlcDriver plcDriver) {
-        
+
     }
-    
+
     @Override
     public void bindDataSourceFactory(DataSourceFactory dsFactory) {
         this.dsFactory = dsFactory;
         init();
-    }  
-    
+    }
+
     @Override
     public void execute(JobContext context) {
         boolean res = false;
-        if ((null != dbConnection) && (delayed > 3)) {  
+        if ((null != dbConnection) && (delayed > 3)) {
             if (!delayedBootPlcDivers.isEmpty()) {
                 if (null != dbConnection) {
                     Set<String> keys = delayedBootPlcDivers.keySet();
-                    for (String key:keys) {
-                        res = restore(key);   
-                        delayedBootPlcDivers.remove(key);                     
+                    for (String key : keys) {
+                        res = restore(key);
+                        delayedBootPlcDivers.remove(key);
                     }
                 }
-            }            
+            }
         } else {
-            System.out.println("> " +  System.currentTimeMillis());            
+            System.out.println("> " + System.currentTimeMillis());
             delayed++;
-        }       
+        }
     }
 
     @Override
     public void persist() {
         var plcDrivers = gf.getPlcDrivers();
-        plcDrivers.forEach( (k, d) -> store(k));
+        plcDrivers.forEach((k, d) -> store(k));
         ServiceReference ref = 
ctx.getServiceReference(EventAdmin.class.getName());
-        if (ref != null){
+        if (ref != null) {
             EventAdmin eventAdmin = (EventAdmin) ctx.getService(ref);
-            Event eventPersist = new Event(EVENT_STORE, (Map) null); 
-            eventAdmin.sendEvent(eventPersist);            
+            Event eventPersist = new Event(EVENT_STORE, (Map) null);
+            eventAdmin.sendEvent(eventPersist);
         }
     }
 
-    
     @Override
     public void store(String plcDriver) {
         var plcDevices = gf.getPlcDevices(plcDriver);
-        plcDevices.forEach((duid, dname) ->{
+        plcDevices.forEach((duid, dname) -> {
             try {
                 var plcDevice = gf.getPlcDevice(duid);
                 insertDevice(plcDriver, plcDevice);
-                
+
                 var plcGroups = gf.getPlcDeviceGroups(duid);
 
                 plcGroups.forEach((guid, gname) -> {
@@ -275,96 +276,69 @@ public class PlcSecureBootImpl implements PlcSecureBoot, 
Job {
             } catch (SQLException ex) {
                 LOGGER.error(ex.getMessage());
             }
-        
+
         });
     }
-    
+
     @Override
     public boolean restore(String plcDriver) {
+        List<PlcGroup> groups = new ArrayList<>();
+        List<PlcItem> items = new ArrayList<>();
+
         boolean res = false;
-        if (null != dbConnection) {        
+        if (null != dbConnection) {
             try {
 
                 var stmt = dbConnection.createStatement();
                 //PlcDevice
-                var rsDevices = stmt.executeQuery(SQL_SELECT_DEVICES);         
       
-                while (rsDevices.next()) {
-                    String isDeviceEnable = 
rsDevices.getString("DeviceEnable");
-                    Optional<PlcDevice> optPlcDevice = gf.createDevice(
-                                            rsDevices.getString("DeviceUuid"),
-                                            rsDevices.getString("DriverName"),
-                                            rsDevices.getString("DeviceKey"),
-                                            rsDevices.getString("DeviceUrl"),
-                                            rsDevices.getString("DeviceName"),
-                                            
rsDevices.getString("DeviceDescription"),
-                                            
rsDevices.getString("DeviceEnable"));
-                                                            
-                    if (optPlcDevice.isPresent()) {                            
                                                                   
-                        LOGGER.info("Created PlcDevice [{}].", 
optPlcDevice.get().getDeviceKey());
-                        Optional<PlcModel> optPlcModel = gf.createPlcModel(
-                                optPlcDevice.get().getDeviceKey(), 
-                                optPlcDevice.get().getDeviceName());
-                        if (!optPlcModel.isPresent()) {
-                            LOGGER.info("No model key '{}' for device '{}'.", 
optPlcDevice.get().getDeviceKey(), optPlcDevice.get().getDeviceName());
-                        }
-                        
-                        //PlcGroups
-                        String queryGroups = SQL_SELECT_GROUPS.replace("?", 
optPlcDevice.get().getUid().toString());
-
-                        var rsGroups = stmt.executeQuery(queryGroups);
-                        while (rsGroups.next()) {
-                            Optional<PlcGroup> optPlcGroup =  gf.createGroup(
-                                                
rsGroups.getString("GroupUuid"),
-                                                
rsGroups.getString("DeviceUuid"),
-                                                
rsGroups.getString("GroupName"), 
-                                                
rsGroups.getString("GroupDescription"),
-                                                
rsGroups.getString("GroupScanTime"),
-                                                
rsGroups.getString("GroupEnable"));
-                            
-                            if (optPlcGroup.isPresent()) {
-                                LOGGER.info("Created PlcGroup [{}].", 
optPlcGroup.get().getGroupName());
-//                                String isGroupEnable = 
rsGroups.getString("GroupEnable");
-//                                if (isGroupEnable.equals("true")) 
optPlcGroup.get().enable();
-                                    
-                                //PlcItems
-                                String queryItems = 
SQL_SELECT_ITEMS.replace("?", optPlcGroup.get().getGroupUid().toString());   
-
-                                var rsItems = stmt.executeQuery(queryItems);
-                                while (rsItems.next()) {
-                                    Optional<PlcItem> optPlcItem = 
gf.createItem(
-                                                    
rsItems.getString("ItemUuid"),
-                                                    
rsItems.getString("GroupUuid"),
-                                                    
rsItems.getString("DeviceUuid"),
-                                                    
rsItems.getString("ItemName"),
-                                                    
rsItems.getString("ItemDescription"),
-                                                    
rsItems.getString("ItemTag"),
-                                                    
rsItems.getString("ItemEnable"));
-                                    
-                                   if (optPlcItem.isPresent()) {
-                                        LOGGER.info("Created PlcItem [{}].", 
optPlcItem.get().getItemName());                               
-                                        if (optPlcModel.isPresent()){
-                                            
optPlcModel.get().createMemoryArea(optPlcItem.get());
-                                        }
-                                   }
-                                }
+                var rsDevices = stmt.executeQuery(SQL_SELECT_DEVICES);
+                try {
+                    while (rsDevices.next()) {
+
+                        String isDeviceEnable = 
rsDevices.getString("DeviceEnable");
+                        Optional<PlcDevice> optPlcDevice = gf.createDevice(
+                                rsDevices.getString("DeviceUuid"),
+                                rsDevices.getString("DriverName"),
+                                rsDevices.getString("DeviceKey"),
+                                rsDevices.getString("DeviceUrl"),
+                                rsDevices.getString("DeviceName"),
+                                rsDevices.getString("DeviceDescription"),
+                                rsDevices.getString("DeviceEnable"));
+
+                        if (optPlcDevice.isPresent()) {
+                            LOGGER.info("Created PlcDevice [{}].", 
optPlcDevice.get().getDeviceKey());
+
+                            //PlcGroups
+                            
groups.addAll(createGroup(optPlcDevice.get().getUid().toString()));
+
+                            //PlcItems
+                            for (PlcGroup group : groups) {
+                                
items.addAll(createItems(group.getGroupUid().toString()));
                             }
                         }
+
+                        if (isDeviceEnable.equals("true")) {
+                            optPlcDevice.get().enable();
+                        }
+
                     }
-                    
-                    if (isDeviceEnable.equals("true")) 
optPlcDevice.get().enable();  
-                                      
+                } catch (Exception e) {
+                    LOGGER.info("Error Load DB: {}", e.getMessage());
                 }
-                
+
+                rsDevices.close();
+                stmt.close();
+
                 ServiceReference ref = 
ctx.getServiceReference(EventAdmin.class.getName());
-                if (ref != null){                   
+                if (ref != null) {
                     EventAdmin eventAdmin = (EventAdmin) ctx.getService(ref);
-                    Event eventPersist = new Event(EVENT_RESTORE, (Map) null); 
-                    eventAdmin.sendEvent(eventPersist);  
+                    Event eventPersist = new Event(EVENT_RESTORE, (Map) null);
+                    eventAdmin.sendEvent(eventPersist);
                     LOGGER.info("Allow clients to restore their state.");
-                } 
+                }
 
                 res = true;
-                
+
             } catch (Exception ex) {
                 LOGGER.error(ex.getMessage());
             }
@@ -374,58 +348,113 @@ public class PlcSecureBootImpl implements PlcSecureBoot, 
Job {
 
         return res;
     }
-        
-    private void createTables() throws SQLException{
+
+    private void createTables() throws SQLException {
         Statement statement;
         statement = dbConnection.createStatement();
-        
+
         statement.execute(SQL_CREATE_TABLE_DEVICES);
-        statement.execute(SQL_CREATE_TABLE_GROUPS);        
-        statement.execute(SQL_CREATE_TABLE_ITEMS);                 
+        statement.execute(SQL_CREATE_TABLE_GROUPS);
+        statement.execute(SQL_CREATE_TABLE_ITEMS);
     }
-    
-    private void insertDevice(String driverName, PlcDevice plcDevice) throws 
SQLException{
+
+    private void insertDevice(String driverName, PlcDevice plcDevice) throws 
SQLException {
         if (null != dbConnection) {
             var query = dbConnection.prepareStatement(SQL_INSERT_DEVICE);
             query.setString(1, plcDevice.getUid().toString());
-            query.setString(2, driverName);             
-            query.setString(3, plcDevice.getDeviceKey());   
-            query.setString(4, plcDevice.getUrl()); 
-            query.setString(5, plcDevice.getDeviceName());  
-            query.setString(6, plcDevice.getDeviceDescription());  
-            query.setString(7, Boolean.toString(plcDevice.isEnable()));        
     
-            query.setString(8,"");
+            query.setString(2, driverName);
+            query.setString(3, plcDevice.getDeviceKey());
+            query.setString(4, plcDevice.getUrl());
+            query.setString(5, plcDevice.getDeviceName());
+            query.setString(6, plcDevice.getDeviceDescription());
+            query.setString(7, Boolean.toString(plcDevice.isEnable()));
+            query.setString(8, "");
             query.executeUpdate();
         }
     }
-    
-    private void insertGroup(PlcGroup plcGroup) throws SQLException{
+
+    private void insertGroup(PlcGroup plcGroup) throws SQLException {
         if (null != dbConnection) {
             var query = dbConnection.prepareStatement(SQL_INSERT_GROUP);
             query.setString(1, plcGroup.getGroupUid().toString());
-            query.setString(2, plcGroup.getGroupDeviceUid().toString());       
      
-            query.setString(3, plcGroup.getGroupName());   
-            query.setString(4, plcGroup.getGroupDescription()); 
-            query.setString(5, Long.toString(plcGroup.getPeriod()));  
-            query.setString(6, Boolean.toString(plcGroup.isEnable()));         
    
-            query.setString(7, "");    
+            query.setString(2, plcGroup.getGroupDeviceUid().toString());
+            query.setString(3, plcGroup.getGroupName());
+            query.setString(4, plcGroup.getGroupDescription());
+            query.setString(5, Long.toString(plcGroup.getPeriod()));
+            query.setString(6, Boolean.toString(plcGroup.isEnable()));
+            query.setString(7, "");
             query.executeUpdate();
         }
-    }  
-    
-    private void insertItem(String uuidDevice, String uuidGroup, PlcItem 
plcItem) throws SQLException{
+    }
+
+    private void insertItem(String uuidDevice, String uuidGroup, PlcItem 
plcItem) throws SQLException {
         if (null != dbConnection) {
             var query = dbConnection.prepareStatement(SQL_INSERT_ITEM);
             query.setString(1, plcItem.getItemUid().toString());
-            query.setString(2, uuidDevice);             
-            query.setString(3, uuidGroup);   
-            query.setString(4, plcItem.getItemName()); 
-            query.setString(5, plcItem.getItemDescription());  
-            query.setString(6, plcItem.getItemId()); 
-            query.setString(7, Boolean.toString(plcItem.isEnable()));          
    
-            query.setString(8, "");    
+            query.setString(2, uuidDevice);
+            query.setString(3, uuidGroup);
+            query.setString(4, plcItem.getItemName());
+            query.setString(5, plcItem.getItemDescription());
+            query.setString(6, plcItem.getItemId());
+            query.setString(7, Boolean.toString(plcItem.isEnable()));
+            query.setString(8, "");
             query.executeUpdate();
         }
-    }      
-    
+    }
+
+    private List<PlcGroup> createGroup(String plcDeviceUid) throws 
SQLException {
+        List<PlcGroup> groups = new ArrayList<>();
+        var stmt = dbConnection.createStatement();
+        String queryGroups = SQL_SELECT_GROUPS.replace("?", plcDeviceUid);
+
+        var rsGroups = stmt.executeQuery(queryGroups);
+
+        while (rsGroups.next()) {
+
+            Optional<PlcGroup> optPlcGroup = gf.createGroup(
+                    rsGroups.getString("GroupUuid"),
+                    rsGroups.getString("DeviceUuid"),
+                    rsGroups.getString("GroupName"),
+                    rsGroups.getString("GroupDescription"),
+                    rsGroups.getString("GroupScanTime"),
+                    rsGroups.getString("GroupEnable"));
+            if (optPlcGroup.isPresent()) {
+                groups.add(optPlcGroup.get());
+            }
+        }
+
+        LOGGER.info("Groups were created");
+        rsGroups.close();
+        stmt.close();
+        return groups;
+    }
+
+    private List<PlcItem> createItems(String plcGroupUid) throws SQLException {
+        List<PlcItem> items = new ArrayList<>();
+        var stmt = dbConnection.createStatement();
+        String queryGroups = SQL_SELECT_ITEMS.replace("?", plcGroupUid);
+
+        var rsItems = stmt.executeQuery(queryGroups);
+
+        while (rsItems.next()) {
+
+            Optional<PlcItem> optPlcItem = gf.createItem(
+                    rsItems.getString("ItemUuid"),
+                    rsItems.getString("GroupUuid"),
+                    rsItems.getString("DeviceUuid"),
+                    rsItems.getString("ItemName"),
+                    rsItems.getString("ItemDescription"),
+                    rsItems.getString("ItemTag"),
+                    rsItems.getString("ItemEnable"));
+            if (optPlcItem.isPresent()) {
+                items.add(optPlcItem.get());
+            }
+        }
+
+        LOGGER.info("Items were created");
+        rsItems.close();
+        stmt.close();
+        return items;
+    }
+
 }
diff --git 
a/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/api/DBRecord.java
 
b/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/api/DBRecord.java
index e9fa037..9695770 100644
--- 
a/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/api/DBRecord.java
+++ 
b/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/api/DBRecord.java
@@ -50,7 +50,7 @@ public class DBRecord extends PVRecord implements 
PlcItemListener {
     
     protected static final String MONITOR_VALUE_FIELD = "field(value)";
     protected static final String MONITOR_WRITE_FIELD = "field(write_value)"; 
-    protected static final String MONITOR_SCALAR_FIELDS = "field(write_enable, 
write_value)";      
+    protected static final String MONITOR_SCALAR_FIELDS = "field(write_enable, 
value)";
     
     private static final Pattern BYTE_OFFSET_PATTERN = 
              Pattern.compile("(?<byteOffset>\\d{1,5})");
diff --git 
a/plc4j/tools/merlot/org.apache.plc4x.merlot.kafka/src/main/java/org/apache/plc4x/merlot/kafka/impl/MerlotKafkaDecanterCollectorImpl.java
 
b/plc4j/tools/merlot/org.apache.plc4x.merlot.kafka/src/main/java/org/apache/plc4x/merlot/kafka/impl/MerlotKafkaDecanterCollectorImpl.java
index dc121b0..7a8a76c 100644
--- 
a/plc4j/tools/merlot/org.apache.plc4x.merlot.kafka/src/main/java/org/apache/plc4x/merlot/kafka/impl/MerlotKafkaDecanterCollectorImpl.java
+++ 
b/plc4j/tools/merlot/org.apache.plc4x.merlot.kafka/src/main/java/org/apache/plc4x/merlot/kafka/impl/MerlotKafkaDecanterCollectorImpl.java
@@ -18,8 +18,6 @@ package org.apache.plc4x.merlot.kafka.impl;
 
 import java.io.ByteArrayInputStream;
 import java.io.UnsupportedEncodingException;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
 import java.time.Duration;
 import java.util.Arrays;
 import java.util.Dictionary;
@@ -32,6 +30,7 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
+
 import org.apache.kafka.clients.consumer.ConsumerRecord;
 import org.apache.kafka.clients.consumer.ConsumerRecords;
 import org.apache.kafka.clients.consumer.KafkaConsumer;
@@ -45,12 +44,9 @@ import org.osgi.service.event.EventConstants;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class MerlotKafkaDecanterCollectorImpl
-        implements MerlotDecanterCollector, Runnable {
 
-    private static final Logger LOGGER = LoggerFactory.getLogger(
-            MerlotKafkaDecanterCollectorImpl.class
-    );
+public class MerlotKafkaDecanterCollectorImpl implements 
MerlotDecanterCollector, Runnable {
+    private static final Logger LOGGER = 
LoggerFactory.getLogger(MerlotKafkaDecanterCollectorImpl.class);
 
     private String topic;
     private String eventAdminTopic;
@@ -62,13 +58,10 @@ public class MerlotKafkaDecanterCollectorImpl
     private KafkaConsumer<String, String> consumer;
 
     private final EventAdmin dispatcher;
-    private Unmarshaller unmarshaller;
+    private  Unmarshaller unmarshaller;
     private ExecutorService executor;
 
-    public MerlotKafkaDecanterCollectorImpl(
-            EventAdmin dispatcher,
-            Unmarshaller unmarshaller
-    ) {
+    public MerlotKafkaDecanterCollectorImpl(EventAdmin dispatcher, 
Unmarshaller unmarshaller) {
         this.dispatcher = dispatcher;
         this.unmarshaller = unmarshaller;
     }
@@ -76,8 +69,8 @@ public class MerlotKafkaDecanterCollectorImpl
     @Override
     public void init() {
         consuming = true;
-        this.executor = Executors.newSingleThreadExecutor();
-        this.executor.execute(this);
+       this.executor = Executors.newSingleThreadExecutor();
+       this.executor.execute(this);
     }
 
     @Override
@@ -103,183 +96,77 @@ public class MerlotKafkaDecanterCollectorImpl
     public void activate(String pid, Dictionary<String, Object> properties) {
         this.properties = properties;
         topic = getValue(properties, "topic", "decanter");
-        eventAdminTopic = getValue(
-                properties,
-                EventConstants.EVENT_TOPIC,
-                "decanter/collect/kafka/decanter"
-        );
+        eventAdminTopic = getValue(properties, EventConstants.EVENT_TOPIC, 
"decanter/collect/kafka/decanter");
         messageType = getValue(properties, "message.type", "text");
 
         Properties config = new Properties();
 
-        String bootstrapServers = getValue(
-                properties,
-                "bootstrap.servers",
-                "localhost:9092"
-        );
+        String bootstrapServers = getValue(properties, "bootstrap.servers", 
"localhost:9092");
         config.put("bootstrap.servers", bootstrapServers);
 
         String groupId = getValue(properties, "group.id", "decanter");
         config.put("group.id", groupId);
 
-        String enableAutoCommit = getValue(
-                properties,
-                "enable.auto.commit",
-                "true"
-        );
+        String enableAutoCommit = getValue(properties, "enable.auto.commit", 
"true");
         config.put("enable.auto.commit", enableAutoCommit);
 
-        String autoCommitIntervalMs = getValue(
-                properties,
-                "auto.commit.interval.ms",
-                "1000"
-        );
+        String autoCommitIntervalMs = getValue(properties, 
"auto.commit.interval.ms", "1000");
         config.put("auto.commit.interval.ms", autoCommitIntervalMs);
 
-        String sessionTimeoutMs = getValue(
-                properties,
-                "session.timeout.ms",
-                "10000"
-        );
+        String sessionTimeoutMs = getValue(properties, "session.timeout.ms", 
"10000");
         config.put("session.timeout.ms", sessionTimeoutMs);
 
-        String keyDeserializer = getValue(
-                properties,
-                "key.deserializer",
-                "org.apache.kafka.common.serialization.StringDeserializer"
-        );
+        String keyDeserializer = getValue(properties, "key.deserializer", 
"org.apache.kafka.common.serialization.StringDeserializer");
         config.put("key.deserializer", keyDeserializer);
 
-        String valueDeserializer = getValue(
-                properties,
-                "value.deserializer",
-                "org.apache.kafka.common.serialization.StringDeserializer"
-        );
+        String valueDeserializer = getValue(properties, "value.deserializer", 
"org.apache.kafka.common.serialization.StringDeserializer");
         config.put("value.deserializer", valueDeserializer);
 
-        String securityProtocol = getValue(
-                properties,
-                "security.protocol",
-                null
-        );
-        if (securityProtocol != null) {
-            config.put(
-                    "security.protocol",
-                    securityProtocol
-            );
-        }
+        String securityProtocol = getValue(properties, "security.protocol", 
null);
+        if (securityProtocol != null)
+            config.put("security.protocol", securityProtocol);
 
-        String sslTruststoreLocation = getValue(
-                properties,
-                "ssl.truststore.location",
-                null
-        );
-        if (sslTruststoreLocation != null) {
-            config.put(
-                    "ssl.truststore.location",
-                    sslTruststoreLocation
-            );
-        }
+        String sslTruststoreLocation = getValue(properties, 
"ssl.truststore.location", null);
+        if (sslTruststoreLocation != null)
+            config.put("ssl.truststore.location", sslTruststoreLocation);
 
-        String sslTruststorePassword = getValue(
-                properties,
-                "ssl.truststore.password",
-                null
-        );
-        if (sslTruststorePassword != null) {
-            config.put(
-                    "ssl.truststore.password",
-                    sslTruststorePassword
-            );
-        }
+        String sslTruststorePassword = getValue(properties, 
"ssl.truststore.password", null);
+        if (sslTruststorePassword != null)
+            config.put("ssl.truststore.password", sslTruststorePassword);
 
-        String sslKeystoreLocation = getValue(
-                properties,
-                "ssl.keystore.location",
-                null
-        );
-        if (sslKeystoreLocation != null) {
-            config.put(
-                    "ssl.keystore.location",
-                    sslKeystoreLocation
-            );
-        }
+        String sslKeystoreLocation = getValue(properties, 
"ssl.keystore.location", null);
+        if (sslKeystoreLocation != null)
+            config.put("ssl.keystore.location", sslKeystoreLocation);
 
-        String sslKeystorePassword = getValue(
-                properties,
-                "ssl.keystore.password",
-                null
-        );
-        if (sslKeystorePassword != null) {
-            config.put(
-                    "ssl.keystore.password",
-                    sslKeystorePassword
-            );
-        }
+        String sslKeystorePassword = getValue(properties, 
"ssl.keystore.password", null);
+        if (sslKeystorePassword != null)
+            config.put("ssl.keystore.password", sslKeystorePassword);
 
         String sslKeyPassword = getValue(properties, "ssl.key.password", null);
-        if (sslKeyPassword != null) {
-            config.put(
-                    "ssl.key.password",
-                    sslKeyPassword
-            );
-        }
+        if (sslKeyPassword != null)
+            config.put("ssl.key.password", sslKeyPassword);
 
         String sslProvider = getValue(properties, "ssl.provider", null);
-        if (sslProvider != null) {
+        if (sslProvider != null)
             config.put("ssl.provider", sslProvider);
-        }
 
-        String sslCipherSuites = getValue(
-                properties,
-                "ssl.cipher.suites",
-                null
-        );
-        if (sslCipherSuites != null) {
-            config.put(
-                    "ssl.cipher.suites",
-                    sslCipherSuites
-            );
-        }
+        String sslCipherSuites = getValue(properties, "ssl.cipher.suites", 
null);
+        if (sslCipherSuites != null)
+            config.put("ssl.cipher.suites", sslCipherSuites);
 
-        String sslEnabledProtocols = getValue(
-                properties,
-                "ssl.enabled.protocols",
-                null
-        );
-        if (sslEnabledProtocols != null) {
-            config.put(
-                    "ssl.enabled.protocols",
-                    sslEnabledProtocols
-            );
-        }
+        String sslEnabledProtocols = getValue(properties, 
"ssl.enabled.protocols", null);
+        if (sslEnabledProtocols != null)
+            config.put("ssl.enabled.protocols", sslEnabledProtocols);
 
-        String sslTruststoreType = getValue(
-                properties,
-                "ssl.truststore.type",
-                null
-        );
-        if (sslTruststoreType != null) {
-            config.put(
-                    "ssl.truststore.type",
-                    sslTruststoreType
-            );
-        }
+        String sslTruststoreType = getValue(properties, "ssl.truststore.type", 
null);
+        if (sslTruststoreType != null)
+            config.put("ssl.truststore.type", sslTruststoreType);
 
-        String sslKeystoreType = getValue(
-                properties,
-                "ssl.keystore.type",
-                null
-        );
-        if (sslKeystoreType != null) {
-            config.put(
-                    "ssl.keystore.type",
-                    sslKeystoreType
-            );
-        }
+        String sslKeystoreType = getValue(properties, "ssl.keystore.type", 
null);
+        if (sslKeystoreType != null)
+            config.put("ssl.keystore.type", sslKeystoreType);
 
-        ClassLoader originClassLoader
-                = Thread.currentThread().getContextClassLoader();
+        ClassLoader originClassLoader = 
Thread.currentThread().getContextClassLoader();
         try {
             Thread.currentThread().setContextClassLoader(null);
             consumer = new KafkaConsumer<String, String>(config);
@@ -315,10 +202,8 @@ public class MerlotKafkaDecanterCollectorImpl
         }
     }
 
-    private void consume() throws UnknownHostException {
-        ConsumerRecords<String, String> records = consumer.poll(
-                Duration.ofSeconds(1)
-        );
+    private void consume() {
+        ConsumerRecords<String, String> records = 
consumer.poll(Duration.ofSeconds(1));
 
         if (records.isEmpty()) {
             return;
@@ -326,8 +211,6 @@ public class MerlotKafkaDecanterCollectorImpl
 
         Map<String, Object> data = new HashMap<>();
         data.put("loki.label.job", "MerlotAlarmCollector");
-        data.put("loki.label.level", "info");
-        data.put("loki.label.host", InetAddress.getLocalHost().getHostName());
 
         for (ConsumerRecord<String, String> record : records) {
             if (!consuming) {
@@ -341,37 +224,35 @@ public class MerlotKafkaDecanterCollectorImpl
             String value = record.value();
 
             //LOGGER.info("Key: {} Value: {}", key, value);
+
             String pathPV = getPathPV(key);
 
             //Loki paramaters
             data.put("loki.label.topicalarm", getTopicAlarm(key));
             data.put("alarm.pathpvname", pathPV);
-            data.put( 
"loki.label.pvname",pathPV.substring(pathPV.indexOf("//") + 2));
+            data.put("loki.label.pvname", 
pathPV.substring(pathPV.indexOf("//") + 2));
             data.put("loki.label.component", getComponent(key));
             data.put("loki.label.severity", getSeverity(value));
             data.put("alarm.value", getValueAlarm(value));
 
+
             //Send event bus karaf
             Event event = new Event(eventAdminTopic, data);
             dispatcher.postEvent(event);
         }
     }
 
+
     //Initial parameters
-    private String getValue(
-            Dictionary<String, Object> config,
-            String key,
-            String defaultValue
-    ) {
-        String value = (String) config.get(key);
-        return (value != null) ? value : defaultValue;
+    private String getValue(Dictionary<String, Object> config, String key, 
String defaultValue) {
+        String value = (String)config.get(key);
+        return (value != null) ? value :  defaultValue;
     }
 
+
     //Kafka message parameters
     public static String getTopicAlarm(String keyText) {
-        if (keyText == null) {
-            return null;
-        }
+        if (keyText == null) return null;
         String regex = ":/([^/]+)/";
         Matcher matcher = Pattern.compile(regex).matcher(keyText);
 
@@ -381,11 +262,8 @@ public class MerlotKafkaDecanterCollectorImpl
 
         return null;
     }
-
     public static String getPathPV(String keyText) {
-        if (keyText == null) {
-            return null;
-        }
+        if (keyText == null) return null;
 
         int indexEndProtocol = keyText.indexOf(":\\/\\/");
         if (indexEndProtocol == -1) {
@@ -396,18 +274,13 @@ public class MerlotKafkaDecanterCollectorImpl
             int indexLastSlash = keyText.lastIndexOf("/", indexEndProtocol);
 
             if (indexLastSlash != -1) {
-                return keyText
-                        .substring(indexLastSlash + 1)
-                        .replace("\\/\\/", "//");
+                return keyText.substring(indexLastSlash + 1).replace("\\/\\/", 
"//");
             }
         }
         return null;
     }
-
     public static String getComponent(String keyText) {
-        if (keyText == null) {
-            return null;
-        }
+        if (keyText == null) return null;
         String regex = "^[^:/]+:/[^/]+/(.+)/[a-zA-Z0-9]+:[\\\\/]{2}";
 
         Matcher matcher = Pattern.compile(regex).matcher(keyText);
@@ -418,11 +291,8 @@ public class MerlotKafkaDecanterCollectorImpl
 
         return null;
     }
-
     public static String getSeverity(String valueText) {
-        if (valueText == null) {
-            return null;
-        }
+        if (valueText == null) return null;
 
         String regex = "\"severity\"\\s*:\\s*\"([^\"]+)\"";
 
@@ -433,11 +303,8 @@ public class MerlotKafkaDecanterCollectorImpl
         }
         return null;
     }
-
     public static String getValueAlarm(String valueText) {
-        if (valueText == null) {
-            return null;
-        }
+        if (valueText == null) return null;
         String regex = "\"value\"\\s*:\\s*\"([^\"]+)\"";
 
         Matcher matcher = Pattern.compile(regex).matcher(valueText);

Reply via email to