-
Notifications
You must be signed in to change notification settings - Fork 612
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ISPN-14766 Implement Infinispan Insights module
- Loading branch information
Showing
18 changed files
with
712 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.infinispan</groupId> | ||
<artifactId>infinispan-server-parent</artifactId> | ||
<version>15.0.0-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>infinispan-server-insights</artifactId> | ||
<name>Infinispan Insights Server</name> | ||
<description>Infinispan Server - Red Hat Insights integration module</description> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.infinispan</groupId> | ||
<artifactId>infinispan-component-processor</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.infinispan</groupId> | ||
<artifactId>infinispan-server-core</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.projectreactor.tools</groupId> | ||
<artifactId>blockhound</artifactId> | ||
<optional>true</optional> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.kohsuke.metainf-services</groupId> | ||
<artifactId>metainf-services</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.redhat.insights</groupId> | ||
<artifactId>runtimes-java-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.redhat.insights</groupId> | ||
<artifactId>runtimes-java-core-runtime</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.infinispan</groupId> | ||
<artifactId>infinispan-server-core</artifactId> | ||
<type>test-jar</type> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.testng</groupId> | ||
<artifactId>testng</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.assertj</groupId> | ||
<artifactId>assertj-core</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<repositories> | ||
<repository> | ||
<id>jboss-eap-7.4-product-repository</id> | ||
<name>JBoss EAP Product Repository</name> | ||
<url>https://download.devel.redhat.com/brewroot/repos/jb-eap-7.4-maven-build/latest/maven/</url> | ||
<layout>default</layout> | ||
<releases> | ||
<enabled>true</enabled> | ||
<updatePolicy>never</updatePolicy> | ||
</releases> | ||
<snapshots> | ||
<enabled>false</enabled> | ||
<updatePolicy>never</updatePolicy> | ||
</snapshots> | ||
</repository> | ||
<repository> | ||
<id>jboss-public-repository-group</id> | ||
<name>JBoss Public Maven Repository Group</name> | ||
<url>https://repository.jboss.org/nexus/content/groups/public</url> | ||
<releases> | ||
<enabled>true</enabled> | ||
<updatePolicy>never</updatePolicy> | ||
</releases> | ||
<snapshots> | ||
<enabled>true</enabled> | ||
<updatePolicy>never</updatePolicy> | ||
</snapshots> | ||
</repository> | ||
</repositories> | ||
</project> |
13 changes: 13 additions & 0 deletions
13
...nsights/src/main/java/org/infinispan/server/insights/InfinispanInsightsConfiguration.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,13 @@ | ||
package org.infinispan.server.insights; | ||
|
||
import org.infinispan.commons.util.Version; | ||
|
||
import com.redhat.insights.config.EnvAndSysPropsInsightsConfiguration; | ||
|
||
public class InfinispanInsightsConfiguration extends EnvAndSysPropsInsightsConfiguration { | ||
|
||
@Override | ||
public String getIdentificationName() { | ||
return Version.getBrandName(); | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
server/insights/src/main/java/org/infinispan/server/insights/InsightsModule.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,70 @@ | ||
package org.infinispan.server.insights; | ||
|
||
import org.infinispan.commons.logging.LogFactory; | ||
import org.infinispan.factories.GlobalComponentRegistry; | ||
import org.infinispan.factories.annotations.InfinispanModule; | ||
import org.infinispan.lifecycle.ModuleLifecycle; | ||
import org.infinispan.manager.CacheManagerInfo; | ||
import org.infinispan.server.core.ServerManagement; | ||
import org.infinispan.server.insights.config.InsightsActivation; | ||
import org.infinispan.server.insights.logging.Log; | ||
import org.infinispan.util.concurrent.BlockingManager; | ||
|
||
@InfinispanModule(name = "insights", requiredModules = {"core", "server-runtime"}) | ||
public class InsightsModule implements ModuleLifecycle { | ||
|
||
public static final String REDHAT_INSIGHTS_ACTIVATION_PROPERTY_NAME = "infinispan.insights.activation"; | ||
|
||
public static final Log log = LogFactory.getLog(InsightsModule.class, Log.class); | ||
|
||
private InsightsService service; | ||
|
||
@Override | ||
public void cacheManagerStarted(GlobalComponentRegistry gcr) { | ||
InsightsActivation activation = activation(); | ||
if (InsightsActivation.DISABLED.equals(activation)) { | ||
log.insightsDisabled(); | ||
return; | ||
} | ||
|
||
ServerManagement server = gcr.getComponent(ServerManagement.class); | ||
if (server == null) { | ||
log.serverManagementLookupFailed(); | ||
return; | ||
} | ||
|
||
CacheManagerInfo cacheManagerInfo = gcr.getCacheManager().getCacheManagerInfo(); | ||
service = new InsightsService(server, cacheManagerInfo.getNodeName()); | ||
gcr.registerComponent(service, InsightsService.class); | ||
if (InsightsActivation.LOCAL.equals(activation)) { | ||
log.insightsLocallyEnabled(REDHAT_INSIGHTS_ACTIVATION_PROPERTY_NAME); | ||
return; | ||
} | ||
|
||
log.insightsEnabled(); | ||
BlockingManager blockingManager = gcr.getComponent(BlockingManager.class); | ||
service.start(blockingManager); | ||
} | ||
|
||
@Override | ||
public void cacheManagerStopping(GlobalComponentRegistry gcr) { | ||
service.stop(); | ||
} | ||
|
||
private static InsightsActivation activation() { | ||
String activation = System.getProperty(REDHAT_INSIGHTS_ACTIVATION_PROPERTY_NAME); | ||
|
||
if (activation == null || activation.equalsIgnoreCase(InsightsActivation.LOCAL.name())) { | ||
return InsightsActivation.LOCAL; | ||
} | ||
if (activation.equalsIgnoreCase(InsightsActivation.DISABLED.name())) { | ||
return InsightsActivation.DISABLED; | ||
} | ||
if (activation.equalsIgnoreCase(InsightsActivation.ENABLED.name())) { | ||
return InsightsActivation.ENABLED; | ||
} | ||
|
||
log.insightsActivationNotValidValue(REDHAT_INSIGHTS_ACTIVATION_PROPERTY_NAME, activation); | ||
return InsightsActivation.LOCAL; | ||
} | ||
} |
94 changes: 94 additions & 0 deletions
94
server/insights/src/main/java/org/infinispan/server/insights/InsightsService.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,94 @@ | ||
package org.infinispan.server.insights; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.concurrent.LinkedBlockingQueue; | ||
import java.util.function.Supplier; | ||
|
||
import javax.net.ssl.SSLContext; | ||
|
||
import org.infinispan.commons.logging.LogFactory; | ||
import org.infinispan.server.core.ServerManagement; | ||
import org.infinispan.server.insights.logging.InsightsLoggerDelegate; | ||
import org.infinispan.server.insights.logging.Log; | ||
import org.infinispan.server.insights.report.InfinispanSubreport; | ||
import org.infinispan.server.insights.report.InfinispanTopReport; | ||
import org.infinispan.server.insights.scheduler.InfinispanInsightsScheduler; | ||
import org.infinispan.util.concurrent.BlockingManager; | ||
|
||
import com.redhat.insights.InsightsReport; | ||
import com.redhat.insights.InsightsReportController; | ||
import com.redhat.insights.InsightsSubreport; | ||
import com.redhat.insights.config.InsightsConfiguration; | ||
import com.redhat.insights.core.httpclient.InsightsJdkHttpClient; | ||
import com.redhat.insights.http.InsightsFileWritingClient; | ||
import com.redhat.insights.http.InsightsMultiClient; | ||
import com.redhat.insights.jars.ClasspathJarInfoSubreport; | ||
import com.redhat.insights.logging.InsightsLogger; | ||
import com.redhat.insights.tls.PEMSupport; | ||
|
||
public class InsightsService { | ||
|
||
private static final Log log = LogFactory.getLog(InsightsService.class, Log.class); | ||
|
||
private final InsightsConfiguration config; | ||
private final InsightsLogger insightsLogger; | ||
private final InsightsReport insightsReport; | ||
private final InfinispanSubreport infinispanSubreport; | ||
private final ClasspathJarInfoSubreport jarsSubreport; | ||
|
||
private InsightsReportController insightsReportController; | ||
|
||
public InsightsService(ServerManagement server, String nodeName) { | ||
this.config = new InfinispanInsightsConfiguration(); | ||
this.insightsLogger = new InsightsLoggerDelegate(log); | ||
|
||
if (config.isOptingOut()) { | ||
throw log.insightsConfigurationError(); | ||
} | ||
|
||
Map<String, InsightsSubreport> subReports = new HashMap<>(2); | ||
infinispanSubreport = new InfinispanSubreport(server::overviewReport); | ||
jarsSubreport = new ClasspathJarInfoSubreport(insightsLogger); | ||
subReports.put("infinispan", infinispanSubreport); | ||
subReports.put("jars", jarsSubreport); | ||
insightsReport = new InfinispanTopReport(insightsLogger, config, nodeName, subReports); | ||
} | ||
|
||
public void start(BlockingManager blockingManager) { | ||
PEMSupport pemSupport = new PEMSupport(insightsLogger, config); | ||
Supplier<SSLContext> sslContextSupplier = () -> { | ||
try { | ||
return pemSupport.createTLSContext(); | ||
} catch (Throwable ex) { | ||
throw log.insightsCertificateError(ex); | ||
} | ||
}; | ||
|
||
InfinispanInsightsScheduler insightsScheduler = | ||
new InfinispanInsightsScheduler(insightsLogger, config, blockingManager); | ||
|
||
try { | ||
insightsReportController = InsightsReportController.of(insightsLogger, config, insightsReport, | ||
() -> new InsightsMultiClient(insightsLogger, | ||
new InsightsJdkHttpClient(insightsLogger, config, sslContextSupplier), | ||
new InsightsFileWritingClient(insightsLogger, config)), insightsScheduler, | ||
new LinkedBlockingQueue<>()); | ||
insightsReportController.generate(); | ||
} catch (Throwable ex) { | ||
throw log.insightsServiceSetupError(ex); | ||
} | ||
} | ||
|
||
public void stop() { | ||
if (insightsReportController != null) { | ||
insightsReportController.shutdown(); | ||
} | ||
} | ||
|
||
public InsightsReport report() { | ||
infinispanSubreport.generateReport(); | ||
jarsSubreport.generateReport(); | ||
return insightsReport; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
server/insights/src/main/java/org/infinispan/server/insights/config/InsightsActivation.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,21 @@ | ||
package org.infinispan.server.insights.config; | ||
|
||
public enum InsightsActivation { | ||
|
||
/** | ||
* Full disabled | ||
*/ | ||
DISABLED, | ||
|
||
/** | ||
* Locally enabled - the report is accessible locally - not published remotely | ||
* The default value | ||
*/ | ||
LOCAL, | ||
|
||
/** | ||
* Full enabled - publishing the report | ||
*/ | ||
ENABLED; | ||
|
||
} |
Oops, something went wrong.