Skip to content

Commit

Permalink
Merge conflicts for 2.8.2 release
Browse files Browse the repository at this point in the history
  • Loading branch information
Deer-WarLord committed May 27, 2024
2 parents 86395ed + b489276 commit c19abd4
Show file tree
Hide file tree
Showing 18 changed files with 261 additions and 50 deletions.
2 changes: 1 addition & 1 deletion Dockerfile_test_image.in
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ update-alternatives --install /usr/bin/python python /usr/bin/python2 2
mkdir -p /opt/zenoss
EOT

ADD dist/target/zep-dist-2.8.1.tar.gz /opt/zenoss
ADD dist/target/zep-dist-2.8.2.tar.gz /opt/zenoss

ENV TERM=xterm ZENHOME=/opt/zenoss PATH="/opt/zenoss/bin:${PATH}"

Expand Down
23 changes: 17 additions & 6 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<parent>
<groupId>org.zenoss.zep</groupId>
<artifactId>zep-parent</artifactId>
<version>2.8.1</version>
<version>2.8.2</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down Expand Up @@ -304,6 +304,11 @@
<artifactId>jetty-deploy</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-jmx</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
Expand All @@ -322,11 +327,6 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
<version>${spring-data-redis.version}</version>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
Expand Down Expand Up @@ -406,7 +406,13 @@
<jettyXml>${project.basedir}/../dist/src/assembly/etc/zeneventserver/jetty/jetty-deploy.xml</jettyXml>
<jettyXml>${project.basedir}/../dist/src/assembly/etc/zeneventserver/jetty/jetty-http.xml</jettyXml>
<jettyXml>${project.basedir}/../dist/src/assembly/etc/zeneventserver/jetty/jetty-webapp.xml</jettyXml>
<jettyXml>${project.basedir}/../dist/src/assembly/etc/zeneventserver/jetty/jetty-jmx.xml</jettyXml>
<jettyXml>${project.basedir}/../dist/src/assembly/etc/zeneventserver/jetty/jetty-jmx-remote.xml</jettyXml>
</jettyXmls>
<modules>
<module>${project.basedir}/../dist/src/assembly/modules/jmx.mod</module>
<module>${project.basedir}/../dist/src/assembly/modules/jmx-remote.mod</module>
</modules>
<supportedPackagings>
<supportedPackaging>jar</supportedPackaging>
</supportedPackagings>
Expand Down Expand Up @@ -446,6 +452,11 @@
<artifactId>jetty-util-ajax</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-jmx</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.toolchain</groupId>
<artifactId>jetty-jakarta-servlet-api</artifactId>
Expand Down
33 changes: 22 additions & 11 deletions core/src/main/java/org/zenoss/zep/MetricsRegistryConfig.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.zenoss.zep;

import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.MetricSet;
import com.codahale.metrics.jvm.GarbageCollectorMetricSet;
import com.codahale.metrics.jvm.MemoryUsageGaugeSet;
import com.codahale.metrics.jvm.ThreadStatesGaugeSet;
Expand All @@ -15,39 +16,49 @@
public class MetricsRegistryConfig {

private static final Logger logger = LoggerFactory.getLogger(MetricsRegistryConfig.class);

private void skipOrRegister(MetricRegistry registry, String metricSetName, MetricSet metricSet) {
if (registry.getNames().stream().noneMatch(n->n.startsWith(metricSetName))) {
registry.register(metricSetName, metricSet);
logger.info("Register {} metrics set in zep registry", metricSetName);
} else {
logger.warn("Metrics set {} already exist in zep registry", metricSetName);
}
}
@Bean
public GarbageCollectorMetricSet garbageCollectorMetricSet(@Autowired MetricRegistry registry) {
GarbageCollectorMetricSet metricSet = new GarbageCollectorMetricSet();
String metricName = "jvm.gc";
registry.register(metricName, metricSet);
logger.info("Register {} metric in zep registry", metricName);
String metricSetName = "jvm.gc";
skipOrRegister(registry, metricSetName, metricSet);
return metricSet;
}

@Bean
public MemoryUsageGaugeSet memoryUsageGaugeSet(@Autowired MetricRegistry registry) {
MemoryUsageGaugeSet metricSet = new MemoryUsageGaugeSet();
String metricName = "jvm.memory";
registry.register(metricName, metricSet);
logger.info("Register {} metric in zep registry", metricName);
String metricSetName = "jvm.memory";
skipOrRegister(registry, metricSetName, metricSet);
return metricSet;
}

@Bean
public ThreadStatesGaugeSet threadStatesGaugeSet(@Autowired MetricRegistry registry) {
ThreadStatesGaugeSet metricSet = new ThreadStatesGaugeSet();
String metricName = "jvm.thread-states";
registry.register(metricName, metricSet);
logger.info("Register {} metric in zep registry", metricName);
String metricSetName = "jvm.thread-states";
skipOrRegister(registry, metricSetName, metricSet);
return metricSet;
}

@Bean
public FileDescriptorRatioGauge fileDescriptorRatioGauge(@Autowired MetricRegistry registry) {
FileDescriptorRatioGauge metric = new FileDescriptorRatioGauge();
String metricName = "jvm.fd.usage";
registry.register(metricName, metric);
logger.info("Register {} metric in zep registry", metricName);
if (!registry.getNames().contains(metricName)) {
registry.register(metricName, metric);
logger.info("Register {} metric in zep registry", metricName);
} else {
logger.warn("Metric {} already exist in zep registry", metricName);
}
return metric;
}
}
24 changes: 10 additions & 14 deletions core/src/main/java/org/zenoss/zep/dao/impl/FlapTrackerDaoImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.RedisConnectionFailureException;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.zenoss.zep.ZepException;
import org.zenoss.zep.dao.FlapTrackerDao;
import org.zenoss.zep.impl.FlapTracker;
import org.zenoss.zep.utils.JedisPoolUtil;
import redis.clients.jedis.params.SetParams;

import java.util.concurrent.TimeUnit;

Expand All @@ -27,20 +27,15 @@ public class FlapTrackerDaoImpl implements FlapTrackerDao{
private final String REDIS_FLAP_KEY = "zenoss_event_flapping";

@Autowired
private StringRedisTemplate template = null;
private JedisPoolUtil pool = null;


private String createKey(String clearFingerPrintHash) {
return REDIS_FLAP_KEY + clearFingerPrintHash;
}
@Override
public FlapTracker getFlapTrackerByClearFingerprintHash(String clearFingerPrintHash) throws ZepException {
String result;
try {
result = template.opsForValue().get(createKey(clearFingerPrintHash));
} catch (RedisConnectionFailureException e) {
throw new ZepException(e);
}
String result = pool.useJedis(jedis -> jedis.get(createKey(clearFingerPrintHash)));
if (result != null) {
// return existing flap tracker
logger.debug("String gotten back from redis " + result);
Expand All @@ -54,10 +49,11 @@ public FlapTracker getFlapTrackerByClearFingerprintHash(String clearFingerPrintH
@Override
public void persistTracker(String clearFingerprintHash, FlapTracker tracker, long timeToKeep) throws ZepException {
logger.debug("Setting string key {} value {}", createKey(clearFingerprintHash), tracker.convertToString());
try {
template.opsForValue().set(createKey(clearFingerprintHash), tracker.convertToString(), timeToKeep, TimeUnit.SECONDS);
}catch (RedisConnectionFailureException e) {
throw new ZepException(e);
}
SetParams params = new SetParams();
params.ex(timeToKeep);
pool.useJedis(jedis -> {
jedis.set(createKey(clearFingerprintHash), tracker.convertToString(), params);
return null;
});
}
}
4 changes: 3 additions & 1 deletion core/src/main/java/org/zenoss/zep/impl/TriggerPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,9 @@ private void scheduleSpool() {
Instant nextExecution = null;
try {
long nextFlushTime = signalSpoolDao.getNextFlushTime();
if (nextFlushTime > 0) {
if (nextFlushTime == Long.MAX_VALUE) {
nextExecution = Instant.now().plusSeconds(31536000); // 10 years
} else if (nextFlushTime > 0) {
nextExecution = Instant.ofEpochMilli(nextFlushTime);
logger.debug("Next flush time: {}", nextExecution);
}
Expand Down
87 changes: 87 additions & 0 deletions core/src/main/java/org/zenoss/zep/rest/IncManResource.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package org.zenoss.zep.rest;

import jakarta.ws.rs.*;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import org.jboss.resteasy.annotations.GZIP;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.zenoss.protobufs.ProtobufConstants;
import org.zenoss.protobufs.zep.Zep.EventDetail;
import org.zenoss.protobufs.zep.Zep.EventDetailSet;
import org.zenoss.protobufs.zep.Zep.EventTriggerSubscription;
import org.zenoss.zep.ZepException;
import org.zenoss.zep.dao.EventSignalSpool;
import org.zenoss.zep.dao.EventSignalSpoolDao;
import org.zenoss.zep.dao.EventTriggerSubscriptionDao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Path("1.0/incman")
public class IncManResource {
private static final Logger logger = LoggerFactory.getLogger(IncManResource.class);

public class TriggerSubscriptionNotFound extends ZepException {}

private EventTriggerSubscriptionDao eventTriggerSubscriptionDao;
private EventSignalSpoolDao eventSignalSpoolDao;

public void setEventTriggerSubscriptionDao(EventTriggerSubscriptionDao eventTriggerSubscriptionDao) {
this.eventTriggerSubscriptionDao = eventTriggerSubscriptionDao;
}

public void setEventSignalSpoolDao(EventSignalSpoolDao eventSignalSpoolDao) {
this.eventSignalSpoolDao = eventSignalSpoolDao;
}

private String getTriggerSubscriptionUuid(String triggerUuid, String notificationUuid) throws ZepException {
List<EventTriggerSubscription> triggerSubscriptions =
this.eventTriggerSubscriptionDao.findAll();

logger.debug("Searching for " + triggerUuid + "/" + notificationUuid);
for (EventTriggerSubscription triggerSubscription :
triggerSubscriptions) {
logger.debug("\tComparing to " + triggerSubscription.getTriggerUuid() + "/" + triggerSubscription.getSubscriberUuid());

if ((triggerSubscription.getTriggerUuid().equals(triggerUuid)) &&
(triggerSubscription.getSubscriberUuid().equals(notificationUuid))) {
logger.debug("Found!");
return triggerSubscription.getUuid();
}
}
logger.debug("Not found!");
throw new TriggerSubscriptionNotFound();
}

@POST
@Path("trigger_spool")
@Produces({ MediaType.APPLICATION_JSON, ProtobufConstants.CONTENT_TYPE_PROTOBUF })
@GZIP
public Response insertTriggerSpool(EventDetailSet update) throws ZepException {
EventSignalSpool spool;
Map<String, String> updatesByKey = new HashMap<String, String>();

for (EventDetail detail : update.getDetailsList()) {
updatesByKey.put(detail.getName(), detail.getValue(0));
}

String triggerSubscriptionUuid = this.getTriggerSubscriptionUuid(
updatesByKey.get("trigger_uuid"), updatesByKey.get("notification_uuid"));

spool = new EventSignalSpool();
spool.setSubscriptionUuid(triggerSubscriptionUuid);
spool.setEventSummaryUuid(updatesByKey.get("event_summary_uuid"));
spool.setSentSignal(true);
spool.setCreated(System.currentTimeMillis());
spool.setFlushTime(Long.MAX_VALUE);

this.eventSignalSpoolDao.create(spool);

return Response.noContent().build();
}

}
11 changes: 0 additions & 11 deletions core/src/main/resources/zep-config-daos.xml
Original file line number Diff line number Diff line change
Expand Up @@ -407,13 +407,6 @@
<property name="testWhileIdle" value="${zep.jedis.pool.testidle:true}"/>
</bean>

<bean id="jedisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
<property name="hostName" value="${zep.redis.host}"/>
<property name="port" value="${zep.redis.port}"/>
<property name="usePool" value="true"/>
<property name="poolConfig" ref="jedisPoolConfig"/>
</bean>

<bean id="jedisPool" class="redis.clients.jedis.JedisPool">
<constructor-arg index="0" ref="jedisPoolConfig"/>
<constructor-arg index="1" type="java.lang.String" value="${zep.redis.host:127.0.0.1}"/>
Expand All @@ -426,10 +419,6 @@
<constructor-arg index="2" value="10000"/>
</bean>

<bean id="redisTemplate" class="org.springframework.data.redis.core.StringRedisTemplate">
<property name="connectionFactory" ref="jedisConnectionFactory"/>
</bean>

<bean id="workQueueBuilder" class="org.zenoss.zep.index.impl.RedisWorkQueueBuilder">
<constructor-arg index="0" ref="jedisPoolUtil"/>
</bean>
Expand Down
5 changes: 4 additions & 1 deletion core/src/main/resources/zep-config-rest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
</bean>
<bean id="diagnosticsResource" class="org.zenoss.zep.rest.DiagnosticsResource">
</bean>

<bean id="incManResource" class="org.zenoss.zep.rest.IncManResource">
<property name="eventTriggerSubscriptionDao" ref="eventTriggerSubscriptionDao" />
<property name="eventSignalSpoolDao" ref="eventSignalSpoolDao" />
</bean>

</beans>
9 changes: 8 additions & 1 deletion dist/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<parent>
<groupId>org.zenoss.zep</groupId>
<artifactId>zep-parent</artifactId>
<version>2.8.1</version>
<version>2.8.2</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down Expand Up @@ -64,6 +64,13 @@
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-jmx</artifactId>
<version>${jetty.version}</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
Expand Down
7 changes: 7 additions & 0 deletions dist/src/assembly/bin/zeneventserver-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ JETTYSTART_JAR=`ls -1 ${JETTY_HOME}/lib/jetty-start*.jar`
JETTY_ARGS="--module=centralized-webapp-logging,http,ext"
PS="ps"

[ -n "$JETTY_MODULES" ] && {
JETTY_ARGS="$JETTY_ARGS,$JETTY_MODULES";
echo "Additional modules added for jetty startup: $JETTY_ARGS";
}

# Add --add-opens args to open modules to pre-module code.
OPEN_PACKAGES="java.base/java.lang java.base/java.nio java.base/java.io"
for pkg in ${OPEN_PACKAGES}; do
Expand Down Expand Up @@ -307,6 +312,8 @@ Usage: $0 {start|stop|restart|status|run|run_quiet|threads} [options]
threads - display thread status to stdout
for running jetty with additional modules export JETTY_MODULES variable, eg JETTY_MODULES="jmx,jmx-remote"
HELP
exit 1
esac
Expand Down
20 changes: 20 additions & 0 deletions dist/src/assembly/etc/zeneventserver/jetty/jetty-jmx-remote.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://www.eclipse.org/jetty/configure_10_0.dtd">

<Configure id="Server" class="org.eclipse.jetty.server.Server">
<Call name="addBean">
<Arg>
<New id="JMXConnectorServer" class="org.eclipse.jetty.jmx.ConnectorServer">
<Arg>
<New class="javax.management.remote.JMXServiceURL">
<Arg type="java.lang.String">rmi</Arg>
<Arg type="java.lang.String"><Property name="jetty.jmxremote.rmiserverhost" default="localhost"/></Arg>
<Arg type="java.lang.Integer"><Property name="jetty.jmxremote.rmiserverport" default="1099"/></Arg>
<Arg type="java.lang.String">/jndi/rmi://<Property name="jetty.jmxremote.rmiregistryhost" default="localhost"/>:<Property name="jetty.jmxremote.rmiregistryport" default="1099"/>/jmxrmi</Arg>
</New>
</Arg>
<Arg>org.eclipse.jetty.jmx:name=jmxconnectorserver</Arg>
</New>
</Arg>
</Call>
</Configure>
Loading

0 comments on commit c19abd4

Please sign in to comment.