use of org.finos.waltz.schema.tables.records.ServerUsageRecord in project waltz by khartec.
the class ServerGenerator method create.
@Override
public Map<String, Integer> create(ApplicationContext ctx) {
ServerInformationDao serverDao = ctx.getBean(ServerInformationDao.class);
DSLContext dsl = ctx.getBean(DSLContext.class);
commonHostNames.clear();
List<ServerInformation> servers = ListUtilities.newArrayList();
IntStream.range(0, 10_000).forEach(i -> {
String hostName = mkHostName(i);
boolean isCommonHost = commonHostNames.contains(hostName);
servers.add(ImmutableServerInformation.builder().hostname(hostName).location(isCommonHost ? SampleData.locations[0] : randomPick(SampleData.locations)).operatingSystem(isCommonHost ? SampleData.operatingSystems[0] : randomPick(SampleData.operatingSystems)).operatingSystemVersion(isCommonHost ? SampleData.operatingSystemVersions[0] : randomPick(SampleData.operatingSystemVersions)).country("UK").hardwareEndOfLifeDate(rnd.nextInt(10) > 5 ? Date.valueOf(LocalDate.now().plusMonths(rnd.nextInt(12 * 6) - (12 * 3))) : null).operatingSystemEndOfLifeDate(rnd.nextInt(10) > 5 ? Date.valueOf(LocalDate.now().plusMonths(rnd.nextInt(12 * 6) - (12 * 3))) : null).virtual(isCommonHost || rnd.nextInt(10) > 7).provenance(SAMPLE_DATA_PROVENANCE).lifecycleStatus(randomPick(LifecycleStatus.values())).externalId(mkExernalId(i)).build());
});
serverDao.bulkSave(servers);
// create server usages
List<Long> appIds = getAppIds(dsl);
List<Long> serverIds = getServerIds(dsl);
HashSet<Tuple2<Long, Long>> serverAppMappings = new HashSet<>();
IntStream.range(0, 20_000).forEach(i -> {
serverAppMappings.add(Tuple.tuple(randomPick(serverIds), randomPick(appIds)));
});
List<ServerUsageRecord> serverUsages = serverAppMappings.stream().map(t -> mkServerUsageRecord(t.v1, t.v2)).collect(Collectors.toList());
dsl.batchInsert(serverUsages).execute();
return null;
}
use of org.finos.waltz.schema.tables.records.ServerUsageRecord in project waltz by khartec.
the class ServerGenerator method mkServerUsageRecord.
private static ServerUsageRecord mkServerUsageRecord(long serverId, long appId) {
ServerUsageRecord r = new ServerUsageRecord();
r.setServerId(serverId);
r.setEntityKind(EntityKind.APPLICATION.name());
r.setEntityId(appId);
r.setEnvironment(randomPick(SampleData.environments));
r.setLastUpdatedBy("admin");
r.setProvenance(SAMPLE_DATA_PROVENANCE);
return r;
}
Aggregations