use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel in project gocd by gocd.
the class PipelineSqlMapDao method loadHistory.
public PipelineInstanceModel loadHistory(long id) {
String cacheKey = pipelineHistoryCacheKey(id);
PipelineInstanceModel result = (PipelineInstanceModel) goCache.get(cacheKey);
if (result == null) {
synchronized (cacheKey) {
result = (PipelineInstanceModel) goCache.get(cacheKey);
if (result == null) {
result = (PipelineInstanceModel) getSqlMapClientTemplate().queryForObject("getPipelineHistoryById", arguments("id", id).asMap());
if (result == null) {
return null;
}
goCache.put(cacheKey, result);
}
}
}
return cloner.deepClone(result);
}
use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel in project gocd by gocd.
the class PipelineSqlMapDao method pipelineGraphByNameAndCounter.
public PipelineDependencyGraphOld pipelineGraphByNameAndCounter(String pipelineName, int pipelineCounter) {
PipelineInstanceModels instanceModels = null;
try {
instanceModels = PipelineInstanceModels.createPipelineInstanceModels((List<PipelineInstanceModel>) getSqlMapClientTemplate().queryForList("pipelineAndItsDepedenciesByNameAndCounter", arguments("pipelineName", pipelineName).and("pipelineCounter", pipelineCounter).and("stageLocator", pipelineName + "/" + pipelineCounter + "/%/%").asMap()));
} catch (Exception e) {
throw new RuntimeException(e);
}
if (instanceModels.isEmpty()) {
return null;
}
PipelineInstanceModel upstreamPipeline = instanceModels.find(pipelineName);
loadPipelineHistoryBuildCause(upstreamPipeline);
return new PipelineDependencyGraphOld(upstreamPipeline, dependentPipelines(upstreamPipeline, instanceModels));
}
use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel in project gocd by gocd.
the class PipelineSqlMapDao method findPipelineHistoryByNameAndCounter.
public PipelineInstanceModel findPipelineHistoryByNameAndCounter(String pipelineName, int pipelineCounter) {
PipelineInstanceModel instanceModel = loadPipelineInstanceModelByNameAndCounter(pipelineName, pipelineCounter);
loadPipelineHistoryBuildCause(instanceModel);
return instanceModel;
}
use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel in project gocd by gocd.
the class PipelineSqlMapDao method loadActivePipelineAndHistoryToCache.
private Thread[] loadActivePipelineAndHistoryToCache(final List<PipelineInstanceModel> pipelines) {
final Thread activePipelinesCacheLoader = new Thread() {
@Override
public void run() {
LOGGER.info("Loading Active Pipelines to cache...Started");
Map<String, TreeSet<Long>> result = groupPipelineInstanceIdsByPipelineName(pipelines);
goCache.put(activePipelinesCacheKey(), result);
LOGGER.info("Loading Active Pipelines to cache...Done");
}
};
final Thread historyCacheLoader = new Thread() {
@Override
public void run() {
LOGGER.info("Loading pipeline history to cache...Started");
for (PipelineInstanceModel pipeline : pipelines) {
goCache.put(pipelineHistoryCacheKey(pipeline.getId()), pipeline);
}
LOGGER.info("Loading pipeline history to cache...Done");
}
};
historyCacheLoader.start();
activePipelinesCacheLoader.start();
return new Thread[] { activePipelinesCacheLoader, historyCacheLoader };
}
use of com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModel in project gocd by gocd.
the class PipelineHistoryServiceIntegrationTest method shouldLoadPipelineInstanceWithMultipleRevisions.
@Test
public void shouldLoadPipelineInstanceWithMultipleRevisions() {
Pipeline pipeline = pipelineOne.createPipelineWithFirstStageScheduled(ModificationsMother.multipleModifications(pipelineOne.pipelineConfig()));
configHelper.setViewPermissionForGroup("group1", "foo");
PipelineInstanceModel pipelineInstance = pipelineHistoryService.load(pipeline.getId(), new Username(new CaseInsensitiveString("foo")), new HttpOperationResult());
assertThat(pipelineInstance, is(not(nullValue())));
assertThat(pipelineInstance.hasNewRevisions(), is(false));
}
Aggregations