Skip to content

Commit

Permalink
Merge branch 'main' of github.com:cryostatio/cryostat
Browse files Browse the repository at this point in the history
  • Loading branch information
aali309 committed Mar 19, 2024
2 parents 959101c + 614f9d9 commit bdf0cb5
Show file tree
Hide file tree
Showing 271 changed files with 807 additions and 1,712 deletions.
12 changes: 6 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,19 @@
<org.apache.maven.plugins.info.reports.version>3.5.0</org.apache.maven.plugins.info.reports.version>
<org.apache.maven.plugins.clean.version>3.3.2</org.apache.maven.plugins.clean.version>
<org.apache.maven.plugins.resources.version>3.3.1</org.apache.maven.plugins.resources.version>
<org.apache.maven.plugins.assembly.version>3.6.0</org.apache.maven.plugins.assembly.version>
<org.apache.maven.plugins.assembly.version>3.7.0</org.apache.maven.plugins.assembly.version>
<com.github.eirslett.frontend.plugin.version>1.15.0</com.github.eirslett.frontend.plugin.version>
<org.codehaus.mojo.exec.plugin.version>3.1.1</org.codehaus.mojo.exec.plugin.version>
<org.codehaus.mojo.exec.plugin.version>3.2.0</org.codehaus.mojo.exec.plugin.version>
<org.codehaus.mojo.build.helper.plugin.version>3.5.0</org.codehaus.mojo.build.helper.plugin.version>
<com.mycila.license.maven.plugin.version>4.3</com.mycila.license.maven.plugin.version>
<org.owasp.dependency.check.version>9.0.9</org.owasp.dependency.check.version>
<com.google.cloud.tools.jib.maven.plugin.version>3.4.0</com.google.cloud.tools.jib.maven.plugin.version>
<org.owasp.dependency.check.version>9.0.10</org.owasp.dependency.check.version>
<com.google.cloud.tools.jib.maven.plugin.version>3.4.1</com.google.cloud.tools.jib.maven.plugin.version>

<!-- Use a separate property for dependency alignment purposes. -->
<com.google.dagger.version>2.47</com.google.dagger.version>
<com.google.dagger.compiler.version>${com.google.dagger.version}</com.google.dagger.compiler.version>

<io.cryostat.core.version>2.28.0</io.cryostat.core.version>
<io.cryostat.core.version>2.30.0</io.cryostat.core.version>

<org.openjdk.nashorn.core.version>15.4</org.openjdk.nashorn.core.version>
<org.apache.commons.lang3.version>3.13.0</org.apache.commons.lang3.version>
Expand All @@ -104,7 +104,7 @@
<org.hibernate.hibernate.version>5.6.14.Final</org.hibernate.hibernate.version>
<com.vladmihalcea.hibernate.types.version>2.21.1</com.vladmihalcea.hibernate.types.version>
<com.h2database.h2.version>2.1.214</com.h2database.h2.version>
<org.postgresql.postgresql.version>42.6.0</org.postgresql.postgresql.version>
<org.postgresql.postgresql.version>42.7.2</org.postgresql.postgresql.version>

<com.github.spotbugs.version>4.8.0</com.github.spotbugs.version>
<com.github.spotbugs.plugin.version>4.7.3.6</com.github.spotbugs.plugin.version>
Expand Down
2 changes: 1 addition & 1 deletion src/container/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM registry.access.redhat.com/ubi8/openjdk-17-runtime:1.18-2.1705573231
FROM registry.access.redhat.com/ubi8/openjdk-17-runtime:1.19-1

USER root

Expand Down
11 changes: 4 additions & 7 deletions src/main/java/io/cryostat/ApplicationVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,14 @@
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;

import io.cryostat.core.log.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ApplicationVersion {

private static final String RESOURCE_LOCATION = "/io/cryostat/version";
private volatile String version;
private final Logger logger;

ApplicationVersion(Logger logger) {
this.logger = logger;
}
private final Logger logger = LoggerFactory.getLogger(getClass());

public synchronized String getVersionString() {
if (version == null) {
Expand All @@ -49,7 +46,7 @@ public synchronized String getVersionString() {
RESOURCE_LOCATION)))
.trim();
} catch (Exception e) {
logger.error(e);
logger.error("Version retrieval exception", e);
version = "unknown";
}
}
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/io/cryostat/Cryostat.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

import io.cryostat.configuration.CredentialsManager;
import io.cryostat.core.CryostatCore;
import io.cryostat.core.log.Logger;
import io.cryostat.core.sys.Environment;
import io.cryostat.discovery.DiscoveryStorage;
import io.cryostat.messaging.MessagingServer;
Expand All @@ -39,12 +38,14 @@
import io.vertx.core.AbstractVerticle;
import io.vertx.core.Promise;
import io.vertx.core.Vertx;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

class Cryostat extends AbstractVerticle {

private final Environment environment = new Environment();
private final Client client;
private final Logger logger = Logger.INSTANCE;
private final Logger logger = LoggerFactory.getLogger(getClass());

private Cryostat(Client client) {
this.client = client;
Expand All @@ -58,7 +59,7 @@ public void start(Promise<Void> future) {
client.credentialsManager().migrate();
client.ruleRegistry().loadRules();
} catch (Exception e) {
logger.error(e);
logger.error("Startup exception", e);
future.fail(e);
return;
}
Expand Down Expand Up @@ -113,7 +114,7 @@ private void shutdown(Throwable cause) {
if (!(cause instanceof Exception)) {
cause = new RuntimeException(cause);
}
logger.error((Exception) cause);
logger.error("Shutdown exception", (Exception) cause);
}
logger.info("{} shutting down...", instanceName());
client.vertx().close().onComplete(n -> logger.info("Shutdown complete"));
Expand Down
39 changes: 16 additions & 23 deletions src/main/java/io/cryostat/MainModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package io.cryostat;

import java.lang.management.MemoryUsage;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Set;
Expand All @@ -31,7 +30,6 @@
import io.cryostat.configuration.ConfigurationModule;
import io.cryostat.configuration.Variables;
import io.cryostat.core.agent.ProbeTemplate;
import io.cryostat.core.log.Logger;
import io.cryostat.core.sys.Environment;
import io.cryostat.core.tui.ClientWriter;
import io.cryostat.discovery.DiscoveryModule;
Expand All @@ -47,7 +45,6 @@
import io.cryostat.templates.TemplatesModule;
import io.cryostat.util.GsonJmxServiceUrlAdapter;
import io.cryostat.util.HttpMimeTypeAdapter;
import io.cryostat.util.MemoryUsageTypeAdapter;
import io.cryostat.util.PathTypeAdapter;
import io.cryostat.util.PluggableJsonDeserializer;
import io.cryostat.util.PluggableTypeAdapter;
Expand All @@ -61,6 +58,8 @@
import dagger.Provides;
import io.vertx.core.Vertx;
import org.apache.commons.codec.binary.Base32;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Module(
includes = {
Expand All @@ -81,16 +80,12 @@ public abstract class MainModule {
public static final String CONF_DIR = "CONF_DIR";
public static final String UUID_FROM_STRING = "UUID_FROM_STRING";

@Provides
@Singleton
static ApplicationVersion provideApplicationVersion(Logger logger) {
return new ApplicationVersion(logger);
}
private static final Logger logger = LoggerFactory.getLogger(MainModule.class);

@Provides
@Singleton
static Logger provideLogger() {
return Logger.INSTANCE;
static ApplicationVersion provideApplicationVersion() {
return new ApplicationVersion();
}

@Provides
Expand All @@ -102,7 +97,8 @@ static Base32 provideBase32() {
@Singleton
// FIXME remove this outdated ClientWriter abstraction and simply replace with an injected
// Logger at all ClientWriter injection sites
static ClientWriter provideClientWriter(Logger logger) {
static ClientWriter provideClientWriter() {
Logger logger = LoggerFactory.getLogger(ClientWriter.class);
return new ClientWriter() {
@Override
public void print(String s) {
Expand All @@ -111,34 +107,31 @@ public void print(String s) {

@Override
public void println(Exception e) {
logger.warn(e);
logger.warn("Write exception", e);
}
};
}

// testing-only when extra adapters aren't needed
public static Gson provideGson(Logger logger) {
return provideGson(Set.of(), Set.of(), logger);
public static Gson provideGson() {
return provideGson(Set.of(), Set.of());
}

// public since this is useful to use directly in tests
@Provides
@Singleton
public static Gson provideGson(
Set<PluggableTypeAdapter<?>> extraAdapters,
Set<PluggableJsonDeserializer<?>> deserializers,
Logger logger) {
Set<PluggableJsonDeserializer<?>> deserializers) {
GsonBuilder builder =
new GsonBuilder()
.serializeNulls()
.disableHtmlEscaping()
.registerTypeAdapter(
JMXServiceURL.class, new GsonJmxServiceUrlAdapter(logger))
.registerTypeAdapter(JMXServiceURL.class, new GsonJmxServiceUrlAdapter())
.registerTypeAdapter(HttpMimeType.class, new HttpMimeTypeAdapter())
.registerTypeHierarchyAdapter(Path.class, new PathTypeAdapter())
.registerTypeAdapter(Rule.class, new RuleDeserializer())
.registerTypeAdapter(ProbeTemplate.class, new ProbeTemplateTypeAdapter())
.registerTypeAdapter(MemoryUsage.class, new MemoryUsageTypeAdapter());
.registerTypeAdapter(ProbeTemplate.class, new ProbeTemplateTypeAdapter());
for (PluggableTypeAdapter<?> pta : extraAdapters) {
builder = builder.registerTypeAdapter(pta.getAdaptedType(), pta);
}
Expand All @@ -151,7 +144,7 @@ JMXServiceURL.class, new GsonJmxServiceUrlAdapter(logger))
@Provides
@Singleton
@Named(RECORDINGS_PATH)
static Path provideSavedRecordingsPath(Logger logger, Environment env) {
static Path provideSavedRecordingsPath(Environment env) {
String archivePath = env.getEnv(Variables.ARCHIVE_PATH, "/flightrecordings");
logger.info("Local save path for flight recordings set as {}", archivePath);
return Paths.get(archivePath);
Expand Down Expand Up @@ -180,7 +173,7 @@ public static int provideVertxPoolSize(Environment env) {
@Provides
@Singleton
public static VerticleDeployer provideVerticleDeployer(
Vertx vertx, @Named(Variables.VERTX_POOL_SIZE) int poolSize, Logger logger) {
return new VerticleDeployer(vertx, poolSize, logger);
Vertx vertx, @Named(Variables.VERTX_POOL_SIZE) int poolSize) {
return new VerticleDeployer(vertx, poolSize);
}
}
9 changes: 4 additions & 5 deletions src/main/java/io/cryostat/VerticleDeployer.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,26 @@
*/
package io.cryostat;

import io.cryostat.core.log.Logger;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.vertx.core.DeploymentOptions;
import io.vertx.core.Future;
import io.vertx.core.Verticle;
import io.vertx.core.Vertx;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class VerticleDeployer {

private final Vertx vertx;
private final int poolSize;
private final Logger logger;
private final Logger logger = LoggerFactory.getLogger(getClass());

@SuppressFBWarnings(
value = "EI_EXPOSE_REP2",
justification = "vertx is externally mutable and that's fine")
public VerticleDeployer(Vertx vertx, int poolSize, Logger logger) {
public VerticleDeployer(Vertx vertx, int poolSize) {
this.vertx = vertx;
this.poolSize = poolSize;
this.logger = logger;
}

public Future deploy(Verticle verticle, boolean worker) {
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/io/cryostat/configuration/ConfigurationModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import javax.inject.Singleton;
import javax.persistence.EntityManager;

import io.cryostat.core.log.Logger;
import io.cryostat.core.sys.Environment;
import io.cryostat.core.sys.FileSystem;
import io.cryostat.discovery.DiscoveryStorage;
Expand All @@ -33,16 +32,19 @@
import dagger.Lazy;
import dagger.Module;
import dagger.Provides;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Module
public abstract class ConfigurationModule {
public static final String CONFIGURATION_PATH = "CONFIGURATION_PATH";
public static final String CREDENTIALS_SUBDIRECTORY = "credentials";
private static final Logger logger = LoggerFactory.getLogger(ConfigurationModule.class);

@Provides
@Singleton
@Named(CONFIGURATION_PATH)
static Path provideConfigurationPath(Logger logger, Environment env) {
static Path provideConfigurationPath(Environment env) {
String path = env.getEnv(Variables.CONFIG_PATH, "/opt/cryostat.d/conf.d");
logger.info(String.format("Local config path set as %s", path));
return Paths.get(path);
Expand All @@ -57,8 +59,7 @@ static CredentialsManager provideCredentialsManager(
DiscoveryStorage discovery,
StoredCredentialsDao dao,
FileSystem fs,
Gson gson,
Logger logger) {
Gson gson) {
Path credentialsDir = confDir.resolve(CREDENTIALS_SUBDIRECTORY);
return new CredentialsManager(
credentialsDir,
Expand All @@ -67,13 +68,12 @@ static CredentialsManager provideCredentialsManager(
discovery,
dao,
fs,
gson,
logger);
gson);
}

@Provides
@Singleton
static StoredCredentialsDao provideStoredCredentialsDao(EntityManager em, Logger logger) {
return new StoredCredentialsDao(em, logger);
static StoredCredentialsDao provideStoredCredentialsDao(EntityManager em) {
return new StoredCredentialsDao(em);
}
}
13 changes: 6 additions & 7 deletions src/main/java/io/cryostat/configuration/CredentialsManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

import javax.script.ScriptException;

import io.cryostat.core.log.Logger;
import io.cryostat.core.net.Credentials;
import io.cryostat.core.sys.FileSystem;
import io.cryostat.platform.PlatformClient;
Expand All @@ -49,6 +48,8 @@
import dagger.Lazy;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.client.utils.URIBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class CredentialsManager
extends AbstractEventEmitter<CredentialsManager.CredentialsEvent, String> {
Expand All @@ -60,7 +61,7 @@ public class CredentialsManager
private final StoredCredentialsDao dao;
private final FileSystem fs;
private final Gson gson;
private final Logger logger;
private final Logger logger = LoggerFactory.getLogger(getClass());

CredentialsManager(
Path credentialsDir,
Expand All @@ -69,16 +70,14 @@ public class CredentialsManager
PlatformClient platformClient,
StoredCredentialsDao dao,
FileSystem fs,
Gson gson,
Logger logger) {
Gson gson) {
this.credentialsDir = credentialsDir;
this.matchExpressionValidator = matchExpressionValidator;
this.matchExpressionEvaluator = matchExpressionEvaluator;
this.platformClient = platformClient;
this.dao = dao;
this.fs = fs;
this.gson = gson;
this.logger = logger;
}

// TODO remove after 2.2 release
Expand Down Expand Up @@ -126,7 +125,7 @@ public void migrate() throws Exception {
}
}
} catch (IOException | IllegalStateException e) {
logger.warn(e);
logger.warn("Migration exception", e);
continue;
}
}
Expand Down Expand Up @@ -231,7 +230,7 @@ public Set<ServiceRef> resolveMatchingTargets(String matchExpression) {
matchedTargets.add(target);
}
} catch (ScriptException e) {
logger.error(e);
logger.error("Script execution exception", e);
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@

import javax.persistence.EntityManager;

import io.cryostat.core.log.Logger;
import io.cryostat.storage.AbstractDao;

class StoredCredentialsDao extends AbstractDao<Integer, StoredCredentials> {
StoredCredentialsDao(EntityManager em, Logger logger) {
super(StoredCredentials.class, em, logger);
StoredCredentialsDao(EntityManager em) {
super(StoredCredentials.class, em);
}
}
Loading

0 comments on commit bdf0cb5

Please sign in to comment.