use of io.kubernetes.client.openapi.models.CoreV1Event in project java by kubernetes-client.
the class EventAggregator method aggregate.
public synchronized MutablePair<CoreV1Event, String> aggregate(CoreV1Event event) {
OffsetDateTime now = OffsetDateTime.now();
MutablePair<String, String> aggregatedKeys = keyFunc.apply(event);
String aggregatedKey = aggregatedKeys.getLeft();
String localKey = aggregatedKeys.getRight();
AggregatedRecord record = this.spammingCache.get(aggregatedKey, k -> new AggregatedRecord());
record.lastTimestamp = now;
record.localKeys.add(localKey);
if (record.localKeys.size() < this.maxEvents) {
this.spammingCache.put(aggregatedKey, record);
return new MutablePair<>(event, EventUtils.getEventKey(event));
}
// remove any keys
record.localKeys.remove(record.localKeys.stream().findAny().get());
CoreV1Event aggregatedEvent = new CoreV1EventBuilder(event).withMetadata(new V1ObjectMetaBuilder().withName(EventUtils.generateName(event.getInvolvedObject().getName(), now)).withNamespace(event.getInvolvedObject().getNamespace()).build()).withCount(1).withFirstTimestamp(now).withLastTimestamp(now).withMessage(this.messageFunc.apply(event)).build();
this.spammingCache.put(aggregatedKey, record);
return new MutablePair<>(aggregatedEvent, aggregatedKey);
}
use of io.kubernetes.client.openapi.models.CoreV1Event in project java by kubernetes-client.
the class LegacyEventBroadcaster method recordToSink.
private void recordToSink(CoreV1Event event) throws InterruptedException {
Optional<MutablePair<CoreV1Event, V1Patch>> eventAndPatch = this.eventCorrelator.correlate(event);
if (!eventAndPatch.isPresent()) {
// skip
return;
}
CoreV1Event recordingEvent = eventAndPatch.get().getLeft();
V1Patch patch = eventAndPatch.get().getRight();
for (int retries = 0; retries < maxTriesPerEvent; retries++) {
if (recordEvent(recordingEvent, patch, event.getCount() > 1)) {
break;
}
Thread.sleep(sleepDuration.toMillis());
}
}
use of io.kubernetes.client.openapi.models.CoreV1Event in project java by kubernetes-client.
the class CoreV1Api method readNamespacedEventWithHttpInfo.
/**
* read the specified Event
*
* @param name name of the Event (required)
* @param namespace object name and auth scope, such as for teams and projects (required)
* @param pretty If 'true', then the output is pretty printed. (optional)
* @return ApiResponse<CoreV1Event>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the
* response body
* @http.response.details
* <table summary="Response Details" border="1">
* <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
* <tr><td> 200 </td><td> OK </td><td> - </td></tr>
* <tr><td> 401 </td><td> Unauthorized </td><td> - </td></tr>
* </table>
*/
public ApiResponse<CoreV1Event> readNamespacedEventWithHttpInfo(String name, String namespace, String pretty) throws ApiException {
okhttp3.Call localVarCall = readNamespacedEventValidateBeforeCall(name, namespace, pretty, null);
Type localVarReturnType = new TypeToken<CoreV1Event>() {
}.getType();
return localVarApiClient.execute(localVarCall, localVarReturnType);
}
Aggregations