Search in sources :

Example 1 with NodeRosterHostArtifacts

use of com.walmartlabs.concord.server.plugins.noderoster.jooq.tables.NodeRosterHostArtifacts in project concord by walmartlabs.

the class ArtifactsDao method getArtifacts.

public List<ArtifactEntry> getArtifacts(UUID hostId, int limit, int offset, String filter) {
    return txResult(tx -> {
        NodeRosterHostArtifacts a = NODE_ROSTER_HOST_ARTIFACTS.as("a");
        SelectJoinStep<Record2<String, UUID>> q = tx.select(a.ARTIFACT_URL, a.INSTANCE_ID).from(a);
        if (filter != null) {
            q.where(a.ARTIFACT_URL.likeRegex(filter));
        }
        return q.where(a.HOST_ID.eq(hostId)).orderBy(a.INSTANCE_CREATED_AT.desc()).limit(limit).offset(offset).fetch(r -> ArtifactEntry.of(r.get(a.ARTIFACT_URL), r.get(a.INSTANCE_ID)));
    });
}
Also used : NodeRosterHostArtifacts(com.walmartlabs.concord.server.plugins.noderoster.jooq.tables.NodeRosterHostArtifacts) Record2(org.jooq.Record2)

Example 2 with NodeRosterHostArtifacts

use of com.walmartlabs.concord.server.plugins.noderoster.jooq.tables.NodeRosterHostArtifacts in project concord by walmartlabs.

the class HostsDao method list.

public List<HostEntry> list(HostFilter filter, Set<HostsDataInclude> includes, int limit, int offset) {
    NodeRosterHosts nrh = NODE_ROSTER_HOSTS.as("nrh");
    NodeRosterProcessHosts nrph = NODE_ROSTER_PROCESS_HOSTS.as("nrph");
    NodeRosterHostArtifacts nrha = NODE_ROSTER_HOST_ARTIFACTS.as("nrha");
    SelectQuery<Record> query = dsl().selectQuery();
    query.addSelect(nrh.HOST_ID, nrh.NORMALIZED_HOSTNAME, nrh.CREATED_AT);
    query.addFrom(nrh);
    if (filter.host() != null) {
        query.addConditions(nrh.NORMALIZED_HOSTNAME.containsIgnoreCase(filter.host()));
    }
    ProcessKey key = null;
    if (filter.processInstanceId() != null) {
        key = processKeyCache.get(filter.processInstanceId());
        if (key == null) {
            return Collections.emptyList();
        }
        query.addFrom(nrph);
        query.addConditions(nrh.HOST_ID.eq(nrph.HOST_ID).and(nrph.INSTANCE_ID.eq(key.getInstanceId()).and(nrph.INSTANCE_CREATED_AT.eq(key.getCreatedAt()))));
    }
    if ((includes != null && includes.contains(HostsDataInclude.ARTIFACTS)) || filter.artifact() != null) {
        query.addSelect(nrha.ARTIFACT_URL);
        query.addFrom(nrha);
        query.addConditions(nrh.HOST_ID.eq(nrha.HOST_ID));
    }
    if (filter.artifact() != null) {
        query.addConditions(nrha.ARTIFACT_URL.likeRegex(filter.artifact()));
        if (key != null) {
            query.addConditions(nrha.INSTANCE_ID.eq(key.getInstanceId()).and(nrha.INSTANCE_CREATED_AT.eq(key.getCreatedAt())));
        }
    }
    query.addOrderBy(nrh.CREATED_AT.desc());
    query.addLimit(limit);
    query.addOffset(offset);
    return query.fetch(HostsDao::toHostEntry);
}
Also used : Record(org.jooq.Record) NodeRosterHostArtifacts(com.walmartlabs.concord.server.plugins.noderoster.jooq.tables.NodeRosterHostArtifacts) ProcessKey(com.walmartlabs.concord.server.sdk.ProcessKey) NodeRosterProcessHosts(com.walmartlabs.concord.server.plugins.noderoster.jooq.tables.NodeRosterProcessHosts) NodeRosterHosts(com.walmartlabs.concord.server.plugins.noderoster.jooq.tables.NodeRosterHosts)

Aggregations

NodeRosterHostArtifacts (com.walmartlabs.concord.server.plugins.noderoster.jooq.tables.NodeRosterHostArtifacts)2 NodeRosterHosts (com.walmartlabs.concord.server.plugins.noderoster.jooq.tables.NodeRosterHosts)1 NodeRosterProcessHosts (com.walmartlabs.concord.server.plugins.noderoster.jooq.tables.NodeRosterProcessHosts)1 ProcessKey (com.walmartlabs.concord.server.sdk.ProcessKey)1 Record (org.jooq.Record)1 Record2 (org.jooq.Record2)1