-
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.
Merge pull request #153 from sentrysoftware/feature/issue-115-develop…
…-http-extension Issue #115: Develop HTTP Extension
- Loading branch information
Showing
62 changed files
with
2,717 additions
and
1,221 deletions.
There are no files selected for viewing
86 changes: 0 additions & 86 deletions
86
...rc/main/java/org/sentrysoftware/metricshub/agent/config/protocols/HttpProtocolConfig.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
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
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
74 changes: 74 additions & 0 deletions
74
...nt/src/test/java/org/sentrysoftware/metricshub/agent/extension/HttpTestConfiguration.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,74 @@ | ||
package org.sentrysoftware.metricshub.agent.extension; | ||
|
||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Builder.Default; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import org.sentrysoftware.metricshub.engine.common.exception.InvalidConfigurationException; | ||
import org.sentrysoftware.metricshub.engine.common.helpers.StringHelper; | ||
import org.sentrysoftware.metricshub.engine.configuration.IConfiguration; | ||
import org.sentrysoftware.metricshub.engine.deserialization.TimeDeserializer; | ||
|
||
/** | ||
* The HttpConfiguration class represents the configuration for HTTP connections in the MetricsHub engine. | ||
*/ | ||
@Data | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class HttpTestConfiguration implements IConfiguration { | ||
|
||
@Default | ||
private final Boolean https = true; | ||
|
||
@Default | ||
private final Integer port = 443; | ||
|
||
@Default | ||
@JsonDeserialize(using = TimeDeserializer.class) | ||
private final Long timeout = 120L; | ||
|
||
private String username; | ||
private char[] password; | ||
|
||
@Override | ||
public String toString() { | ||
return String.format( | ||
"%s/%d%s", | ||
Boolean.TRUE.equals(https) ? "HTTPS" : "HTTP", | ||
port, | ||
username != null ? " as " + username : "" | ||
); | ||
} | ||
|
||
@Override | ||
public void validateConfiguration(String resourceKey) throws InvalidConfigurationException { | ||
StringHelper.validateConfigurationAttribute( | ||
timeout, | ||
attr -> attr == null || attr < 0L, | ||
() -> | ||
String.format( | ||
"Resource %s - Timeout value is invalid for protocol %s." + | ||
" Timeout value returned: %s. This resource will not be monitored. Please verify the configured timeout value.", | ||
resourceKey, | ||
"HTTP", | ||
timeout | ||
) | ||
); | ||
|
||
StringHelper.validateConfigurationAttribute( | ||
port, | ||
attr -> attr == null || attr < 1 || attr > 65535, | ||
() -> | ||
String.format( | ||
"Resource %s - Invalid port configured for protocol %s. Port value returned: %s." + | ||
" This resource will not be monitored. Please verify the configured port value.", | ||
resourceKey, | ||
"HTTP", | ||
port | ||
) | ||
); | ||
} | ||
} |
Oops, something went wrong.