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);
}
});
}
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));
}
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, "{}"));
}
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 "));
}
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);
}
}
Aggregations