use of com.thoughtworks.go.config.Agent in project gocd by gocd.
the class AgentMother method deniedAgent.
public static Agent deniedAgent() {
Agent agent = new Agent("uuid", "deniedAgent", "192.168.0.1", UUID.randomUUID().toString());
agent.disable();
return agent;
}
use of com.thoughtworks.go.config.Agent in project gocd by gocd.
the class JobController method addElasticAgentInfo.
private void addElasticAgentInfo(JobInstance jobInstance, Map data) {
if (!jobInstance.currentStatus().isActive()) {
return;
}
final JobAgentMetadata jobAgentMetadata = jobAgentMetadataDao.load(jobInstance.getId());
if (jobAgentMetadata == null) {
return;
}
ClusterProfile clusterProfile = jobAgentMetadata.clusterProfile();
if (clusterProfile == null) {
return;
}
final String pluginId = clusterProfile.getPluginId();
final ElasticAgentPluginInfo pluginInfo = elasticAgentMetadataStore.getPluginInfo(pluginId);
if (pluginInfo != null && pluginInfo.getCapabilities().supportsAgentStatusReport()) {
String clusterProfileId = jobAgentMetadata.clusterProfile().getId();
String elasticProfileId = jobAgentMetadata.elasticProfile().getId();
data.put("clusterProfileId", clusterProfileId);
data.put("elasticAgentProfileId", elasticProfileId);
data.put("elasticAgentPluginId", pluginId);
data.put("doesUserHaveViewAccessToStatusReportPage", securityService.doesUserHasPermissions(SessionUtils.currentUsername(), SupportedAction.VIEW, SupportedEntity.ELASTIC_AGENT_PROFILE, elasticProfileId, clusterProfileId));
final Agent agent = agentService.getAgentByUUID(jobInstance.getAgentUuid());
if (agent != null && agent.isElastic()) {
data.put("elasticAgentPluginId", agent.getElasticPluginId());
data.put("elasticAgentId", agent.getElasticAgentId());
return;
}
}
}
use of com.thoughtworks.go.config.Agent in project gocd by gocd.
the class AgentMutex method getAgentsByUUIDs.
public List<Agent> getAgentsByUUIDs(List<String> uuids) {
AgentMutex mutex = agentMutexes.acquire(uuids);
synchronized (mutex) {
List<Agent> agents = (List<Agent>) transactionTemplate.execute((TransactionCallback) transactionStatus -> {
Query query = sessionFactory.getCurrentSession().createQuery("FROM Agent where uuid in :uuids and deleted = false");
query.setCacheable(true);
query.setParameterList("uuids", uuids);
return query.list();
});
agentMutexes.release(uuids, mutex);
return agents;
}
}
use of com.thoughtworks.go.config.Agent in project gocd by gocd.
the class AgentMutex method fetchAgentFromDBByUUIDIncludingDeleted.
public Agent fetchAgentFromDBByUUIDIncludingDeleted(final String uuid) {
List<String> uuids = singletonList(uuid);
AgentMutex mutex = agentMutexes.acquire(uuids);
synchronized (mutex) {
Agent agent = (Agent) transactionTemplate.execute((TransactionCallback) transactionStatus -> {
Query query = sessionFactory.getCurrentSession().createQuery("FROM Agent where uuid = :uuid");
query.setCacheable(true);
query.setParameter("uuid", uuid);
return query.uniqueResult();
});
agentMutexes.release(uuids, mutex);
return agent;
}
}
use of com.thoughtworks.go.config.Agent in project gocd by gocd.
the class AgentMutex method getAgentByUUIDFromCacheOrDB.
public Agent getAgentByUUIDFromCacheOrDB(String uuid) {
String key = agentCacheKey(uuid);
Agent agent = (Agent) cache.get(key);
if (agent == null) {
List<String> uuids = singletonList(uuid);
AgentMutex mutex = agentMutexes.acquire(uuids);
synchronized (mutex) {
agent = (Agent) cache.get(key);
if (agent != null) {
return agent;
}
agent = fetchAgentFromDBByUUID(uuid);
cache.put(key, agent);
agentMutexes.release(uuids, mutex);
}
}
return agent;
}
Aggregations