-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #435: Add the possibility to use the same connector with differ…
…ent connector variables * Added the possibility to define additional connectors, which are connectors with variables where the user can customize variables values. * It is possible to define many instances of the same connector, and this by customizing values for each instance. * Updated unit tests to make sure everything is working. * Tested the changes on MetricsHub. * Updated the MetricsHub documentation to explain how to define and customize connector variables. * Updated MetricsHub maven plugin to generate additionalConnectors configuration.
- Loading branch information
1 parent
2affb96
commit 1b686c0
Showing
15 changed files
with
569 additions
and
358 deletions.
There are no files selected for viewing
76 changes: 76 additions & 0 deletions
76
...b-agent/src/main/java/org/sentrysoftware/metricshub/agent/config/AdditionalConnector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package org.sentrysoftware.metricshub.agent.config; | ||
|
||
/*- | ||
* ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲ | ||
* MetricsHub Engine | ||
* ჻჻჻჻჻჻ | ||
* Copyright 2023 - 2024 Sentry Software | ||
* ჻჻჻჻჻჻ | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* ╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱ | ||
*/ | ||
|
||
import static com.fasterxml.jackson.annotation.Nulls.SKIP; | ||
|
||
import com.fasterxml.jackson.annotation.JsonSetter; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Builder.Default; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
/** | ||
* Configures additional connectors with variables, the connector ID to use, and a force flag. | ||
*/ | ||
@Data | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Builder | ||
public class AdditionalConnector { | ||
|
||
/** | ||
* The connector Id of the additional connector instance. | ||
*/ | ||
private String uses; | ||
|
||
/** | ||
* A map representing the variables for the additional connector. | ||
* The keys are the names of the variables, and the values are the values assigned to those variables. | ||
*/ | ||
@Default | ||
@JsonSetter(nulls = SKIP) | ||
private Map<String, String> variables = new HashMap<>(); | ||
|
||
/** | ||
* A flag indicating whether this connector is forced. | ||
*/ | ||
@Default | ||
@JsonSetter(nulls = SKIP) | ||
private boolean force = true; | ||
|
||
/** | ||
* Setter that removes variables with null values. | ||
* | ||
* @param variables Map of variables to set. | ||
*/ | ||
@JsonSetter | ||
public void setVariables(Map<String, String> variables) { | ||
this.variables = variables; | ||
if (variables != null) { | ||
variables.entrySet().removeIf(entry -> entry.getValue() == null); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...rg/sentrysoftware/metricshub/agent/deserialization/AdditionalConnectorsParsingResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package org.sentrysoftware.metricshub.agent.deserialization; | ||
|
||
/*- | ||
* ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲ | ||
* MetricsHub Engine | ||
* ჻჻჻჻჻჻ | ||
* Copyright 2023 - 2024 Sentry Software | ||
* ჻჻჻჻჻჻ | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* ╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱ | ||
*/ | ||
|
||
import java.util.HashSet; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.TreeMap; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import org.sentrysoftware.metricshub.engine.connector.model.Connector; | ||
|
||
/** | ||
* Represents the result of parsing additional connectors, containing a map of connectors | ||
* and a set of forced connector IDs. | ||
*/ | ||
@Builder | ||
@Data | ||
@NoArgsConstructor | ||
public class AdditionalConnectorsParsingResult { | ||
|
||
/** | ||
* The map containing the parsed additional custom connectors. | ||
*/ | ||
final Map<String, Connector> customConnectorsMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); | ||
|
||
/** | ||
* A set of connector IDs to add into the host connectors set. | ||
*/ | ||
final Set<String> hostConnectors = new HashSet<>(); | ||
} |
88 changes: 0 additions & 88 deletions
88
...a/org/sentrysoftware/metricshub/agent/deserialization/ConnectorVariablesDeserializer.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.