Пример #1
0
  public JobIdentifier findOriginalJobIdentifier(StageIdentifier stageIdentifier, String jobName) {
    String key = cacheKeyForOriginalJobIdentifier(stageIdentifier, jobName);

    JobIdentifier jobIdentifier = (JobIdentifier) goCache.get(key);

    if (jobIdentifier == null) {
      synchronized (key) {
        jobIdentifier = (JobIdentifier) goCache.get(key);
        if (jobIdentifier == null) {
          Map params =
              arguments("pipelineName", stageIdentifier.getPipelineName())
                  .and("pipelineCounter", stageIdentifier.getPipelineCounter())
                  .and("pipelineLabel", stageIdentifier.getPipelineLabel())
                  .and("stageName", stageIdentifier.getStageName())
                  .and("stageCounter", Integer.parseInt(stageIdentifier.getStageCounter()))
                  .and("jobName", jobName)
                  .asMap();

          jobIdentifier =
              (JobIdentifier) getSqlMapClientTemplate().queryForObject("findJobId", params);

          goCache.put(key, jobIdentifier);
        }
      }
    }

    return cloner.deepClone(jobIdentifier);
  }
Пример #2
0
 public JobInstance buildByIdWithTransitions(long buildInstanceId) {
   String cacheKey = cacheKeyforJobInstanceWithTransitions(buildInstanceId);
   synchronized (cacheKey) {
     JobInstance instance = (JobInstance) goCache.get(cacheKey);
     if (instance == null) {
       instance = job(buildInstanceId, "buildByIdWithTransitions");
       goCache.put(cacheKey, instance);
     }
     return cloner.deepClone(instance);
   }
 }
Пример #3
0
  private List<Long> getActiveJobIds() {
    String idsCacheKey = cacheKeyForActiveJobIds();
    List<Long> activeJobIds = (List<Long>) goCache.get(idsCacheKey);

    synchronized (idsCacheKey) {
      if (activeJobIds == null) {
        activeJobIds = getSqlMapClientTemplate().queryForList("getActiveJobIds");
        goCache.put(idsCacheKey, activeJobIds);
      }
    }
    return activeJobIds;
  }
Пример #4
0
 private void cacheActiveJob(ActiveJob activeJob) {
   goCache.put(
       cacheKeyForActiveJob(activeJob.getId()),
       cloner.deepClone(
           activeJob)); // TODO: we should clone while serving the object out, and not while adding
                        // it to cache
 }
Пример #5
0
  @Before
  public void setup() throws Exception {
    configHelper = new GoConfigFileHelper();
    configHelper.usingCruiseConfigDao(goConfigDao);
    configHelper.onSetUp();
    testRepo = new SvnTestRepo("testSvnRepo");
    dbHelper.onSetUp();
    repository = new SvnCommand(null, testRepo.projectRepositoryUrl());
    mingleConfig = configHelper.addPipeline("mingle", STAGE_NAME, repository, "unit", "functional");

    goConfig = configHelper.addPipeline("go", STAGE_NAME, repository, "unit");
    StageConfig ftStageConfig = StageConfigMother.custom("ft", "twist");
    ftStageConfig
        .jobConfigByConfigName(new CaseInsensitiveString("twist"))
        .addVariable("JOB_LVL", "job value");
    ftStageConfig.setVariables(env("STAGE_LVL", "stage value"));
    configHelper.addStageToPipeline("go", ftStageConfig);
    configHelper.addEnvironmentVariableToPipeline("go", env("PIPELINE_LVL", "pipeline value"));
    configHelper.addEnvironments("uat");
    EnvironmentConfig uatEnv =
        configHelper.currentConfig().getEnvironments().named(new CaseInsensitiveString("uat"));
    uatEnv.addPipeline(new CaseInsensitiveString("go"));
    uatEnv.addEnvironmentVariable("ENV_LVL", "env value");

    evolveConfig = configHelper.addPipeline("evolve", STAGE_NAME, repository, "unit");
    goCache.clear();
  }
Пример #6
0
 private ActiveJob getActiveJob(Long activeJobId) {
   String activeJobKey = cacheKeyForActiveJob(activeJobId);
   ActiveJob activeJob = (ActiveJob) goCache.get(activeJobKey);
   if (activeJob == null) {
     synchronized (activeJobKey) {
       activeJob = (ActiveJob) goCache.get(activeJobKey);
       if (activeJob == null) {
         activeJob = _getActiveJob(activeJobId);
         if (activeJob
             != null) { // could have changed to not active and consquently no match found
           cacheActiveJob(activeJob);
         }
       }
     }
   }
   return activeJob; // TODO: clone it, caller may mutate
 }
 @Before
 public void setup() throws Exception {
   configHelper = new GoConfigFileHelper(goConfigDao);
   dbHelper.onSetUp();
   goCache.clear();
   configHelper.onSetUp();
   svnRepo = new SvnTestRepoWithExternal();
   cleanupTempFolders();
 }
Пример #8
0
  public List<JobPlan> orderedScheduledBuilds() {
    List<Long> jobIds = (List<Long>) getSqlMapClientTemplate().queryForList("scheduledPlanIds");

    List<JobPlan> plans = new ArrayList<JobPlan>();
    for (Long jobId : jobIds) {
      String cacheKey = cacheKeyForJobPlan(jobId);
      synchronized (cacheKey) {
        JobPlan jobPlan = (JobPlan) goCache.get(cacheKey);
        if (jobPlan == null) {
          jobPlan = _loadJobPlan(jobId);
        }
        if (jobPlan != null) {
          jobPlan = cloner.deepClone(jobPlan);
          goCache.put(cacheKey, jobPlan);
          plans.add(jobPlan);
        }
      }
    }
    return plans;
  }
 @After
 public void teardown() throws Exception {
   goCache.clear();
   agentService.clearAll();
   fixture.onTearDown();
   dbHelper.onTearDown();
   configHelper.onTearDown();
   FileUtil.deleteFolder(goConfigService.artifactsDir());
   agentAssignment.clear();
   agentRemoteHandler.connectedAgents().clear();
 }
  @Before
  public void setUp() throws Exception {
    configHelper = new GoConfigFileHelper().usingCruiseConfigDao(goConfigDao);
    configHelper.onSetUp();

    dbHelper.onSetUp();
    fixture = new PipelineWithTwoStages(materialRepository, transactionTemplate);
    fixture.usingConfigHelper(configHelper).usingDbHelper(dbHelper).onSetUp();

    repository = new SvnCommand(null, testRepo.projectRepositoryUrl());
    evolveConfig = configHelper.addPipeline("evolve", STAGE_NAME, repository, "unit");
    configHelper.addPipeline("anotherPipeline", STAGE_NAME, repository, "anotherTest");
    configHelper.addPipeline("thirdPipeline", STAGE_NAME, repository, "yetAnotherTest");
    goConfigService.forceNotifyListeners();
    goCache.clear();
    u = new ScheduleTestUtil(transactionTemplate, materialRepository, dbHelper, configHelper);

    agent = new AgentStub();
  }
  @Before
  public void setup() throws Exception {
    CONFIG_HELPER = new GoConfigFileHelper();
    dbHelper.onSetUp();
    CONFIG_HELPER.usingCruiseConfigDao(goConfigDao).initializeConfigFile();
    CONFIG_HELPER.onSetUp();

    repository = new SvnCommand(null, testRepo.projectRepositoryUrl());
    goConfigService.forceNotifyListeners();
    agentAssignment.clear();
    goCache.clear();

    CONFIG_HELPER.addPipeline(
        "blahPipeline",
        "blahStage",
        MaterialConfigsMother.hgMaterialConfig(
            "file:///home/cruise/projects/cruisen/manual-testing/ant_hg/dummy"),
        "job1",
        "job2");
    CONFIG_HELPER.makeJobRunOnAllAgents("blahPipeline", "blahStage", "job2");
  }
Пример #12
0
 public void onTearDown() throws Exception {
   databaseTester.onTearDown();
   goCache.clear();
 }
Пример #13
0
 private void removeCachedJobPlan(JobInstance jobInstance) {
   goCache.remove(cacheKeyForJobPlan(jobInstance.getId()));
 }
Пример #14
0
 private void removeCachedJobInstance(JobInstance jobInstance) {
   String cacheKeyOfJob = cacheKeyforJobInstanceWithTransitions(jobInstance.getId());
   synchronized (cacheKeyOfJob) {
     goCache.remove(cacheKeyOfJob);
   }
 }
Пример #15
0
 private void stopServingForTransaction() {
   goCache.stopServingForTransaction();
 }
 @After
 public void tearDown() {
   goCache.clear();
 }