Search in sources :

Example 1 with NodeRosterProcessHosts

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

the class HostsDao method listProcesses.

public List<ProcessEntry> listProcesses(UUID hostId, int limit, int offset) {
    NodeRosterProcessHosts h = NODE_ROSTER_PROCESS_HOSTS.as("h");
    Field<String> projectNameField = select(PROJECTS.PROJECT_NAME).from(PROJECTS).where(PROJECTS.PROJECT_ID.eq(h.PROJECT_ID)).asField();
    SelectJoinStep<Record6<UUID, OffsetDateTime, UUID, String, UUID, String>> q = dsl().select(h.INSTANCE_ID, h.INSTANCE_CREATED_AT, h.INITIATOR_ID, h.INITIATOR, h.PROJECT_ID, projectNameField).from(h);
    return q.where(h.HOST_ID.eq(hostId)).orderBy(h.INSTANCE_CREATED_AT.desc()).limit(limit).offset(offset).fetch(HostsDao::toProcessEntry);
}
Also used : NodeRosterProcessHosts(com.walmartlabs.concord.server.plugins.noderoster.jooq.tables.NodeRosterProcessHosts)

Example 2 with NodeRosterProcessHosts

use of com.walmartlabs.concord.server.plugins.noderoster.jooq.tables.NodeRosterProcessHosts 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

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