Project

General

Profile

« Previous | Next » 

Revision 2426

Fixed bug in command-line mode which caused array index out of bounds exception.

Changed default maxHarvests value to 0. Added logic to ignore maxHarvests value when it is set to 0 or a negative number. This allows Harvester to run indefinitely without shutting down after reaching a maximum number of harvests. The previous default value of 30 would cause Harvester to terminate after 30 harvests.

View differences:

src/edu/ucsb/nceas/metacat/harvesterClient/Harvester.java
108 108
    long delta;                           // endTime - startTime
109 109
    long endTime;                         // time that a harvest completes
110 110
    Harvester harvester;                  // object for a single harvest run
111
    Integer maxHarvestsDefault = new Integer(30);    // Default max harvests
111
    Integer maxHarvestsDefault = new Integer(0);     // Default max harvests
112 112
    int maxHarvests = maxHarvestsDefault.intValue(); // Max number of harvests
113 113
    Integer mh;                              // used in determining max harvests
114 114
    int nHarvests = 0;                      // counts the number of harvest runs
......
119 119
    long startTime;                          // time that a harvest run starts
120 120
    boolean test = false;                    // Passed to loadOption()
121 121
    
122
    if (args[0] != null) {
122
    if (args.length > 0) {
123 123
      schemaLocation = args[0];
124 124
    }
125 125

  
......
182 182
    }
183 183

  
184 184
    // Repeat a new harvest once every period number of hours, until we reach
185
    // the maximum number of harvests. Subtract delta from the time period so 
185
    // the maximum number of harvests, or indefinitely if maxHarvests <= 0.
186
    // Subtract delta from the time period so 
186 187
    // that each harvest will start at a fixed interval.
187 188
    //
188
    while (nHarvests < maxHarvests) {
189
    while ((nHarvests < maxHarvests) || (maxHarvests <= 0)) {
189 190
      nHarvests++;
190 191
      startTime = System.currentTimeMillis();
191 192
      harvester = new Harvester();                // New object for this harvest
......
196 197
      endTime = System.currentTimeMillis();
197 198
      delta = endTime - startTime;
198 199

  
199
      if (nHarvests < maxHarvests) {
200
      if ((nHarvests < maxHarvests) || (maxHarvests <= 0)) {
200 201
        try {
201 202
          System.out.println("Next harvest will begin in " + 
202 203
                             period + " hours.");
......
941 942
    
942 943
    timestamp = now.toString();
943 944
    System.out.println(Harvester.marker);
944
    System.out.println(timestamp + ": Starting Next Harvest (" +
945
                       nHarvests + "/" + maxHarvests + ")");
945
    System.out.print(timestamp + ": Starting Next Harvest");
946
    if (maxHarvests > 0) {
947
      System.out.print(" (" + nHarvests + "/" + maxHarvests + ")");
948
    }
949
    System.out.print("\n");
946 950
    ctm = Boolean.valueOf(options.getOption("connectToMetacat"));
947 951
    connectToMetacat = ctm.booleanValue();
948 952
    harvesterAdministrator = options.getOption("harvesterAdministrator");

Also available in: Unified diff