Changeset 4341


Ignore:
Timestamp:
Jun 17, 2008, 2:06:53 PM (15 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #1056: Disk usage does not seem to report disk usage properly for experiments

Location:
trunk/src/core/net/sf/basedb/core
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/net/sf/basedb/core/Experiment.java

    r4257 r4341  
    169169
    170170  private long addedBytes = 0;
     171  private long updatedBytes = 0;
    171172 
    172173  /**
     
    244245    {
    245246      getData().setBytes(addedBytes);
    246       addedBytes = 0;
    247247    }
    248     else if (action == Transactional.Action.UPDATE && addedBytes != 0)
     248    else if (action == Transactional.Action.UPDATE && addedBytes != updatedBytes)
    249249    {
    250250      /*
     
    261261        WHERE xpm.id = :experiment
    262262      */
    263       query.setLong("addedBytes", addedBytes);
     263      query.setLong("addedBytes", addedBytes - updatedBytes);
    264264      query.setInteger("experiment", getId());
    265265      query.executeUpdate();
    266       addedBytes = 0;
     266      updatedBytes = addedBytes;
    267267    }
    268268  }
  • trunk/src/core/net/sf/basedb/core/Install.java

    r4334 r4341  
    107107    method.
    108108  */
    109   public static final int NEW_SCHEMA_VERSION = Integer.valueOf(59).intValue();
     109  public static final int NEW_SCHEMA_VERSION = Integer.valueOf(60).intValue();
    110110 
    111111  public static synchronized void createTables(boolean update, final ProgressReporter progress)
  • trunk/src/core/net/sf/basedb/core/Update.java

    r4335 r4341  
    682682    </td>
    683683  </tr>
     684  <tr>
     685    <td>60</td>
     686    <td>
     687      Not a schema change as such. We need to update incorrect quota values
     688      for experiments. See http://base.thep.lu.se/ticket/1056
     689    </td>
     690  </tr>
    684691 
    685692  </table>
     
    957964        if (progress != null) progress.display((int)(58*progress_factor), "--Updating schema version: " + schemaVersion + " -> 59...");
    958965        schemaVersion = setSchemaVersionInTransaction(session, 59);
     966      }
     967     
     968      if (schemaVersion < 60)
     969      {
     970        if (progress != null) progress.display((int)(59*progress_factor), "--Updating schema version: " + schemaVersion + " -> 60...");
     971        schemaVersion = updateToSchemaVersion60(session);
    959972      }
    960973     
     
    23232336      if (tx != null) HibernateUtil.rollback(tx);
    23242337      log.error("updateToSchemaVersion57: FAILED", ex);
     2338      throw ex;
     2339    }
     2340    return schemaVersion;
     2341  }
     2342 
     2343  /**
     2344    Update incorrect quota values for experiments.
     2345   
     2346    @return The new schema version (=60)
     2347  */
     2348  private static int updateToSchemaVersion60(org.hibernate.Session session)
     2349    throws BaseException
     2350  {
     2351    final int schemaVersion = 60;
     2352    org.hibernate.Transaction tx = null;
     2353    try
     2354    {
     2355      tx = HibernateUtil.newTransaction(session);
     2356     
     2357      org.hibernate.Query query = HibernateUtil.createQuery(session,
     2358        "SELECT exp FROM ExperimentData exp");
     2359      List<ExperimentData> experiments =
     2360        HibernateUtil.loadList(ExperimentData.class, query, null);
     2361      for (ExperimentData exp : experiments)
     2362      {
     2363        exp.getDiskUsage().setBytes(exp.getBytes());
     2364      }
     2365
     2366      // Update the schema version number
     2367      setSchemaVersion(session, schemaVersion);
     2368 
     2369      // Commit the changes
     2370      HibernateUtil.commit(tx);
     2371      log.info("updateToSchemaVersion60: OK");
     2372    }
     2373    catch (BaseException ex)
     2374    {
     2375      if (tx != null) HibernateUtil.rollback(tx);
     2376      log.error("updateToSchemaVersion60: FAILED", ex);
    23252377      throw ex;
    23262378    }
Note: See TracChangeset for help on using the changeset viewer.