Search in sources :

Example 21 with Event

use of com.marcnuri.yakc.model.io.k8s.api.events.v1.Event in project skywalking by apache.

the class EventHookCallback method doAlarm.

@Override
public void doAlarm(List<AlarmMessage> alarmMessage) {
    EventAnalyzerService analyzerService = manager.find(EventAnalyzerModule.NAME).provider().getService(EventAnalyzerService.class);
    alarmMessage.forEach(a -> {
        for (Event event : constructCurrentEvent(a)) {
            analyzerService.analyze(event);
        }
    });
}
Also used : EventAnalyzerService(org.apache.skywalking.oap.server.analyzer.event.EventAnalyzerService) Event(org.apache.skywalking.apm.network.event.v3.Event)

Example 22 with Event

use of com.marcnuri.yakc.model.io.k8s.api.events.v1.Event in project prison-api by ministryofjustice.

the class NomisApiV1ResourceTest method getEvents.

@Test
public void getEvents() {
    final var events = List.of(new Event("EVENT", 3L, "noms", "prison", LocalDateTime.now(), "entry"));
    when(service.getEvents(anyString(), any(), anyString(), any(), anyLong())).thenReturn(events);
    final var transfer = nomisApiV1Resource.getOffenderEvents("client", null, "nomis", null, 50L);
    assertThat(transfer).isEqualTo(new Events(events));
}
Also used : Events(uk.gov.justice.hmpps.prison.api.model.v1.Events) Event(uk.gov.justice.hmpps.prison.api.model.v1.Event) Test(org.junit.jupiter.api.Test)

Example 23 with Event

use of com.marcnuri.yakc.model.io.k8s.api.events.v1.Event in project prison-api by ministryofjustice.

the class NomisApiV1ServiceTest method getEventsCopesWithAllNull.

@Test
public void getEventsCopesWithAllNull() {
    final var date = LocalDateTime.parse("2020-01-02T03:02:01");
    when(eventsV1Repository.getEvents(anyString(), isNull(), anyLong(), isNull(), anyString(), any(), anyLong())).thenReturn(List.of(new EventSP(5L, date, "MDI", "A1234", "ETYPE", null, null, null)));
    final var events = service.getEvents("prison", new OffenderIdentifier("12345"), "type", LocalDateTime.now(), 5L);
    assertThat(events).containsExactly(new Event("ETYPE", 5L, "A1234", "MDI", date, "{}"));
}
Also used : OffenderIdentifier(uk.gov.justice.hmpps.prison.api.model.v1.OffenderIdentifier) Event(uk.gov.justice.hmpps.prison.api.model.v1.Event) EventSP(uk.gov.justice.hmpps.prison.repository.v1.model.EventSP) Test(org.junit.jupiter.api.Test)

Example 24 with Event

use of com.marcnuri.yakc.model.io.k8s.api.events.v1.Event in project prison-api by ministryofjustice.

the class NomisApiV1ServiceTest method getEventsCopesWithSomeNull.

@Test
public void getEventsCopesWithSomeNull() {
    final var date = LocalDateTime.parse("2020-01-02T03:02:01");
    when(eventsV1Repository.getEvents(anyString(), isNull(), anyLong(), isNull(), anyString(), any(), anyLong())).thenReturn(List.of(new EventSP(5L, date, "MDI", "A1234", "ETYPE", null, " a value ", null)));
    final var events = service.getEvents("prison", new OffenderIdentifier("12345"), "type", LocalDateTime.now(), 5L);
    assertThat(events).containsExactly(new Event("ETYPE", 5L, "A1234", "MDI", date, " a value "));
}
Also used : OffenderIdentifier(uk.gov.justice.hmpps.prison.api.model.v1.OffenderIdentifier) Event(uk.gov.justice.hmpps.prison.api.model.v1.Event) EventSP(uk.gov.justice.hmpps.prison.repository.v1.model.EventSP) Test(org.junit.jupiter.api.Test)

Example 25 with Event

use of com.marcnuri.yakc.model.io.k8s.api.events.v1.Event in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class EventCollector method storeNamespaceEvents.

/**
 * Store events in provided namespace
 *
 * @param client
 * @param logFolderName Name of a folder used to store logs
 * @param namespace
 * @throws IOException In case event log cannot be stored on filesystem for any reason
 */
public static void storeNamespaceEvents(OpenShiftClient client, String logFolderName, String namespace) throws IOException {
    Path logParentDirectory = LogConfig.getLogParentDirectory(logFolderName);
    Files.createDirectories(logParentDirectory);
    List<Event> events = client.events().v1().events().inNamespace(namespace).list().getItems();
    List<Map<EventEntry, String>> eventContent = new ArrayList<>();
    Map<EventEntry, String> eventHeader = new HashMap<>();
    eventHeader.put(EventEntry.LAST_SEEN, EventEntry.LAST_SEEN.toString());
    eventHeader.put(EventEntry.FIRST_SEEN, EventEntry.FIRST_SEEN.toString());
    eventHeader.put(EventEntry.COUNT, EventEntry.COUNT.toString());
    eventHeader.put(EventEntry.NAME, EventEntry.NAME.toString());
    eventHeader.put(EventEntry.KIND, EventEntry.KIND.toString());
    eventHeader.put(EventEntry.SUBOBJECT, EventEntry.SUBOBJECT.toString());
    eventHeader.put(EventEntry.TYPE, EventEntry.TYPE.toString());
    eventHeader.put(EventEntry.REASON, EventEntry.REASON.toString());
    eventHeader.put(EventEntry.ACTION, EventEntry.ACTION.toString());
    eventHeader.put(EventEntry.MESSAGE, EventEntry.MESSAGE.toString());
    eventContent.add(eventHeader);
    for (Event event : events) {
        Map<EventEntry, String> eventEntry = new HashMap<>();
        eventEntry.put(EventEntry.LAST_SEEN, getLastSeen(event));
        eventEntry.put(EventEntry.FIRST_SEEN, getFirstSeen(event));
        eventEntry.put(EventEntry.COUNT, event.getSeries() != null ? event.getSeries().getCount().toString() : "1");
        eventEntry.put(EventEntry.NAME, event.getRegarding().getName());
        eventEntry.put(EventEntry.KIND, event.getRegarding().getKind());
        eventEntry.put(EventEntry.SUBOBJECT, event.getRegarding().getFieldPath());
        eventEntry.put(EventEntry.TYPE, event.getType());
        eventEntry.put(EventEntry.REASON, event.getReason());
        eventEntry.put(EventEntry.ACTION, event.getAction());
        eventEntry.put(EventEntry.MESSAGE, event.getNote());
        eventContent.add(eventEntry);
    }
    for (Map<EventEntry, String> eventEntry : eventContent) {
        Files.write(logParentDirectory.resolve(Paths.get("events.log")), getEventLogLine(eventEntry).getBytes(), StandardOpenOption.CREATE, StandardOpenOption.APPEND, StandardOpenOption.WRITE);
    }
}
Also used : Path(java.nio.file.Path) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Event(io.fabric8.kubernetes.api.model.events.v1.Event) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

Test (org.junit.Test)18 Event (io.requery.test.model3.Event)9 UUID (java.util.UUID)9 Event (org.apache.skywalking.apm.network.event.v3.Event)9 Test (org.junit.jupiter.api.Test)9 Event (org.eclipse.bpmn2.Event)5 Event (com.google.cloud.video.livestream.v1.Event)4 LivestreamServiceClient (com.google.cloud.video.livestream.v1.LivestreamServiceClient)4 Place (io.requery.test.model3.Place)4 Tag (io.requery.test.model3.Tag)4 AlarmMessage (org.apache.skywalking.oap.server.core.alarm.AlarmMessage)4 ListNamespacedEvent (com.marcnuri.yakc.api.events.v1.EventsV1Api.ListNamespacedEvent)3 Event (com.marcnuri.yakc.model.io.k8s.api.events.v1.Event)3 Event (io.fabric8.kubernetes.api.model.events.v1.Event)3 Event (io.requery.test.model2.Event)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 Event (uk.gov.justice.hmpps.prison.api.model.v1.Event)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 JsonArray (com.google.gson.JsonArray)2