1 package org.apache.continuum.distributed.transport.master;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.continuum.builder.distributed.DistributedBuildService;
23 import org.apache.continuum.distributed.commons.utils.ContinuumDistributedUtil;
24 import org.slf4j.Logger;
25 import org.slf4j.LoggerFactory;
26
27 import java.util.Map;
28
29
30
31
32 public class MasterBuildAgentTransportServer
33 implements MasterBuildAgentTransportService
34 {
35 private static final Logger log = LoggerFactory.getLogger( MasterBuildAgentTransportServer.class );
36
37 private final DistributedBuildService distributedBuildService;
38
39 public MasterBuildAgentTransportServer( DistributedBuildService distributedBuildService )
40 {
41 this.distributedBuildService = distributedBuildService;
42 }
43
44 public Boolean returnBuildResult( Map<String, Object> buildResult, String buildAgentUrl )
45 throws Exception
46 {
47 distributedBuildService.updateBuildResult( buildResult );
48 log.info( "Project {} build finished in build agent {}. Returned build result.",
49 ContinuumDistributedUtil.getProjectNameAndId( buildResult ), buildAgentUrl );
50 return Boolean.TRUE;
51 }
52
53 public Boolean ping()
54 throws Exception
55 {
56 log.debug( "Ping master ok" );
57
58 return Boolean.TRUE;
59 }
60
61 public Boolean prepareBuildFinished( Map<String, Object> prepareBuildResult, String buildAgentUrl )
62 throws Exception
63 {
64 distributedBuildService.prepareBuildFinished( prepareBuildResult );
65 log.info( "Prepare build finished for project {} in build agent {}",
66 ContinuumDistributedUtil.getProjectNameAndId( prepareBuildResult ), buildAgentUrl );
67 return Boolean.TRUE;
68 }
69
70 public Boolean startProjectBuild( Integer projectId, String buildAgentUrl )
71 throws Exception
72 {
73 distributedBuildService.startProjectBuild( projectId );
74 log.info( "Start building project (projectId={}) in build agent {}.", projectId, buildAgentUrl );
75 return Boolean.TRUE;
76 }
77
78 public Boolean startPrepareBuild( Map<String, Object> prepareBuildResult, String buildAgentUrl )
79 throws Exception
80 {
81 distributedBuildService.startPrepareBuild( prepareBuildResult );
82 log.info( "Start preparing build of project {} in build agent {}", ContinuumDistributedUtil.getProjectNameAndId(
83 prepareBuildResult ), buildAgentUrl );
84 return Boolean.TRUE;
85 }
86
87 public Map<String, String> getEnvironments( Integer buildDefinitionId, String installationType )
88 throws Exception
89 {
90 Map<String, String> envs = distributedBuildService.getEnvironments( buildDefinitionId, installationType );
91 log.debug( "Retrieving environments buildDefinitionId={}, installationType={}",
92 new Object[]{buildDefinitionId, installationType} );
93 return envs;
94 }
95
96 public Boolean updateProject( Map<String, Object> project )
97 throws Exception
98 {
99 distributedBuildService.updateProject( project );
100 log.debug( "Start updating project {}", ContinuumDistributedUtil.getProjectNameAndId( project ) );
101 return Boolean.TRUE;
102 }
103
104 public Boolean shouldBuild( Map<String, Object> context, String buildAgentUrl )
105 throws Exception
106 {
107 log.debug( "Checking if project {} should build in build agent {}",
108 ContinuumDistributedUtil.getProjectNameAndId( context ), buildAgentUrl );
109 return distributedBuildService.shouldBuild( context );
110 }
111 }