Subversion Repositories DevTools

Rev

Rev 866 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 866 Rev 868
Line 1... Line 1...
1
package com.erggroup.buildtool.daemon;
1
package com.erggroup.buildtool.daemon;
2
 
2
 
3
import com.erggroup.buildtool.daemon.BuildThread;
3
import com.erggroup.buildtool.daemon.BuildThread;
4
import com.erggroup.buildtool.ripple.MutableInt;
4
import com.erggroup.buildtool.ripple.MutableInt;
5
import com.erggroup.buildtool.ripple.MutableString;
5
import com.erggroup.buildtool.ripple.MutableString;
-
 
6
import com.erggroup.buildtool.ripple.Package;
6
import com.erggroup.buildtool.ripple.ReleaseManager;
7
import com.erggroup.buildtool.ripple.ReleaseManager;
-
 
8
import com.erggroup.buildtool.ripple.RippleEngine;
7
 
9
 
-
 
10
import java.io.File;
8
import java.sql.SQLException;
11
import java.sql.SQLException;
9
import org.apache.log4j.Logger;
12
import org.apache.log4j.Logger;
10
 
13
 
11
/**Slave Thread sub component
14
/**Slave Thread sub component
12
 */
15
 */
Line 35... Line 38...
35
  {
38
  {
36
    Integer id = new Integer(mRtagId);
39
    Integer id = new Integer(mRtagId);
37
    setName(id.toString());
40
    setName(id.toString());
38
    mLogger.debug("run");
41
    mLogger.debug("run");
39
    boolean exit = false;
42
    boolean exit = false;
-
 
43
    RippleEngine rippleEngine = new RippleEngine(mReleaseManager, mRtagId, true);
40
    MutableString buildFileContent = new MutableString();
44
    MutableString buildFileContent = new MutableString();
41
 
45
 
42
    while(!exit)
46
    while(!exit)
43
    {
47
    {
44
      try
48
      try
45
      {
49
      {
-
 
50
        rippleEngine.collectMetaData();
-
 
51
        
46
        if ( Thread.currentThread().isInterrupted() )
52
        if ( Thread.currentThread().isInterrupted() )
47
        {
53
        {
48
          mLogger.warn("run is interrupted");
54
          mLogger.warn("run is interrupted");
49
          // unit test technique
55
          // unit test technique
50
          throw new ExitException();
56
          throw new ExitException();
Line 57... Line 63...
57
        
63
        
58
        // allowed to proceed
64
        // allowed to proceed
59
        if ( mGbebuildfilter.compareTo("unit test consume build files") != 0)
65
        if ( mGbebuildfilter.compareTo("unit test consume build files") != 0)
60
        {
66
        {
61
          mLogger.warn("run checking allowedToProceed");
67
          mLogger.warn("run checking allowedToProceed");
62
          allowedToProceed();
68
          allowedToProceed(false);
63
          mLogger.info("run allowedToProceed returned");
69
          mLogger.info("run allowedToProceed returned");
64
        }
70
        }
65
        
71
        
66
        // consume build files
72
        // consume build files
67
        mLogger.warn("run consume build files");
73
        mLogger.warn("run consume build files");
Line 105... Line 111...
105
 
111
 
106
        mReleaseManager.queryRunLevel(mRconId, buildFileContent);
112
        mReleaseManager.queryRunLevel(mRconId, buildFileContent);
107
        
113
        
108
        if ( buildFileContent.value.compareTo("") == 0)
114
        if ( buildFileContent.value.compareTo("") == 0)
109
        {
115
        {
-
 
116
          mLogger.fatal("run empty buildFileContent");
110
          throw new Exception();
117
          throw new Exception("run empty buildFileContent");
111
        }
118
        }
112
        
119
        
113
        mLogger.info("run consumed build files");
120
        mLogger.info("run consumed build files");
114
 
121
 
115
        if ( mGbebuildfilter.compareTo("unit test consume build files") == 0 )
122
        if ( mGbebuildfilter.compareTo("unit test consume build files") == 0 )
Line 129... Line 136...
129
        if ( buildFileContent.value.compareTo(mDummyBuildFileContent) != 0 )
136
        if ( buildFileContent.value.compareTo(mDummyBuildFileContent) != 0 )
130
        {
137
        {
131
          // deliver change to product baseline
138
          // deliver change to product baseline
132
          mLogger.warn("run deliverChange");
139
          mLogger.warn("run deliverChange");
133
          setViewUp(buildFileContent.value, false);
140
          setViewUp(buildFileContent.value, false);
-
 
141
          
-
 
142
          if ( mGbeGatherMetricsOnly != null )
-
 
143
          {
-
 
144
            // special for metrics
-
 
145
            // deliverChange on a benign target to get mReportingPackageName and mReportingPackageVersion set up
-
 
146
            // nb in the metrics gathering world the <rtagid>build.xml is provided by the master thread
-
 
147
            deliverChange(null, "fullstart", false);
-
 
148
            
-
 
149
            String archive = Package.mGbeDpkg;
-
 
150
            
-
 
151
            if (archive != null)
-
 
152
            {
-
 
153
              String fs = System.getProperty( "file.separator" );
-
 
154
              String destination = archive + fs + mReportingPackageName + fs + mReportingPackageVersion;
-
 
155
              
-
 
156
              // do this for all unix based platforms
-
 
157
              new File( destination ).mkdirs();
-
 
158
              new File( destination, "built.sparc" ).createNewFile();
-
 
159
              new File( destination, "built.solaris10_sparc32" ).createNewFile();
-
 
160
              new File( destination, "built.solaris10_x86" ).createNewFile();
-
 
161
              new File( destination, "built.linux_i386" ).createNewFile();
-
 
162
            }
-
 
163
            
-
 
164
          }
-
 
165
          else
-
 
166
          {
134
          deliverChange(null, null, false);
167
            deliverChange(null, null, false);
135
          deliverChange(null, "AbtTearDown", false);
168
            deliverChange(null, "AbtTearDown", false);
-
 
169
          }
136
          
170
          
137
          if ( mReportingBuildFailureLogFile != null )
171
          if ( mReportingBuildFailureLogFile != null )
138
          {
172
          {
139
            // tweak the build failure log file in the database
173
            // tweak the build failure log file in the database
140
            Integer rtagId = mRtagId;
174
            Integer rtagId = mRtagId;
Line 163... Line 197...
163
        mLogger.warn("run InterruptedException");
197
        mLogger.warn("run InterruptedException");
164
      }
198
      }
165
      catch( Exception e )
199
      catch( Exception e )
166
      {
200
      {
167
        mLogger.error("run indefinitePause");
201
        mLogger.error("run indefinitePause");
168
        try
-
 
169
        {
-
 
170
          mReleaseManager.indefinitePause();
202
        String cause = e.getMessage();
171
        }
203
        
172
        catch( Exception f )
204
        if ( cause != null )
173
        {
205
        {
-
 
206
          try
-
 
207
          {
-
 
208
            // notify first
-
 
209
            // many reasons for indefinite pause, including database related, so do database last
-
 
210
            indefinitePause(rippleEngine, cause);
-
 
211
            mReleaseManager.indefinitePause();
-
 
212
          }
-
 
213
          catch( Exception f )
-
 
214
          {
174
          mLogger.error("run indefinitePause failed");
215
            mLogger.error("run indefinitePause failed");
-
 
216
          }
175
        }
217
        }
176
      }
218
      }
177
    }
219
    }
178
  }
220
  }
179
 
221