use of com.sequenceiq.cloudbreak.structuredevent.event.StructuredEventContainer in project cloudbreak by hortonworks.
the class EventV4Controller method download.
@Override
@CheckPermissionByAccount(action = AuthorizationResourceAction.POWERUSER_ONLY)
public Response download(String name, @AccountId String accountId) {
StructuredEventContainer events = legacyStructuredEventService.getStructuredEventsForStack(name, workspaceService.getForCurrentUser().getId());
StreamingOutput streamingOutput = output -> {
try (ZipOutputStream zipOutputStream = new ZipOutputStream(output)) {
zipOutputStream.putNextEntry(new ZipEntry("struct-events.json"));
zipOutputStream.write(JsonUtil.writeValueAsString(events).getBytes());
zipOutputStream.closeEntry();
}
};
return Response.ok(streamingOutput).header("content-disposition", "attachment; filename = struct-events.zip").build();
}
use of com.sequenceiq.cloudbreak.structuredevent.event.StructuredEventContainer in project cloudbreak by hortonworks.
the class DistroxStopStartScaleDurationAssertions method doAssertion.
@Override
public DistroXTestDto doAssertion(TestContext testContext, DistroXTestDto testDto, CloudbreakClient client) throws Exception {
String startMessage = scalingUp ? "Scaling up (via instance start) for host group" : "Scaling down (via instance stop) for host group";
String stopMessage = scalingUp ? "Scaled up (via instance start) host group" : "Scaled down (via instance stop) host group";
StructuredEventContainer structuredEventContainer = client.getDefaultClient().eventV4Endpoint().structured(testDto.getName(), testContext.getActingUserCrn().getAccountId());
List<StructuredNotificationEvent> structuredNotificationEvents = structuredEventContainer.getNotification();
long startTime = getTimestampForEvent(structuredNotificationEvents, startMessage);
long endTime = getTimestampForEvent(structuredNotificationEvents, stopMessage);
long actualDuration = endTime - startTime;
LOGGER.info(String.format("[%s] event duration '%s' minutes.", startMessage, TimeUnit.MILLISECONDS.toMinutes(actualDuration)));
String message = String.format("Distrox last scale have been took (%d) more than the expected %d minutes!", TimeUnit.MILLISECONDS.toMinutes(actualDuration), expectedDuration);
if (actualDuration > TimeUnit.MINUTES.toMillis(expectedDuration)) {
LOGGER.error(message);
throw new TestFailException(message);
}
return testDto;
}
Aggregations