-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
261 additions
and
50 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
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
87 changes: 87 additions & 0 deletions
87
core/src/main/java/org/zenoss/zep/rest/IncManResource.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,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(); | ||
} | ||
|
||
} |
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
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
20 changes: 20 additions & 0 deletions
20
dist/src/assembly/etc/zeneventserver/jetty/jetty-jmx-remote.xml
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,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> |
Oops, something went wrong.