use of com.sequenceiq.mock.clouderamanager.CmProfile in project cloudbreak by hortonworks.
the class ConfigureController method configure.
@GetMapping("/{mockUuid}/profile/{profile}/{times}")
public void configure(@PathVariable("mockUuid") String mockUuid, @PathVariable("profile") String profile, @PathVariable("times") int times) {
if (!clouderaManagerStoreService.exists(mockUuid)) {
clouderaManagerStoreService.start(mockUuid);
}
List<CmProfile> activeProfiles = clouderaManagerStoreService.read(mockUuid).getActiveProfiles();
Optional<CmProfile> cmProfileOpt = activeProfiles.stream().filter(p -> p.getProfile().equals(profile)).findFirst();
if (cmProfileOpt.isPresent()) {
CmProfile cmProfile = cmProfileOpt.get();
if (times == 0) {
activeProfiles.remove(cmProfile);
} else {
cmProfile.setTimes(times);
}
} else {
activeProfiles.add(new CmProfile(profile, times));
}
}
use of com.sequenceiq.mock.clouderamanager.CmProfile in project cloudbreak by hortonworks.
the class ResponseModifierService method handleProfiles.
public void handleProfiles(String mockUuid, String path) {
if (mockUuid != null && profileSupported(mockUuid, path) && clouderaManagerStoreService.exists(mockUuid)) {
ClouderaManagerDto dto = clouderaManagerStoreService.read(mockUuid);
Optional<CmProfile> http500 = dto.getActiveProfiles().stream().filter(p -> p.getProfile().equals("HTTP_500")).findFirst();
if (http500.isPresent()) {
int called = profileCalled.computeIfAbsent(path, key -> 0);
profileCalled.put(path, called + 1);
if (called < http500.get().getTimes()) {
throw new HttpServerErrorException(HttpStatus.INTERNAL_SERVER_ERROR, "HTTP_500 profile set");
}
}
}
}
Aggregations