Package com.sun.messaging.jmq.util

Examples of com.sun.messaging.jmq.util.PHashMap


    // when instantiated, old data are upgraded
    PropertiesFile(FileStore p, File topDir, File oldTop)
  throws BrokerException {

  File oldFile = new File(oldTop, BASENAME);
  PHashMap olddata = null;

  backingFile = new File(topDir, BASENAME);
  try {
      // load old data
      // safe=false; reset=false
      olddata = new PHashMap(oldFile, false, false);
  } catch (IOException e) {
      logger.log(logger.ERROR, br.X_UPGRADE_PROPERTIES_FAILED,
      oldFile, backingFile, e);
      throw new BrokerException(
      br.getString(br.X_UPGRADE_PROPERTIES_FAILED,
        oldFile, backingFile), e);
  }

  try {
      olddata.load();
  } catch (IOException e) {
      logger.log(logger.ERROR, br.X_UPGRADE_PROPERTIES_FAILED, oldFile,
      backingFile, e);
      throw new BrokerException(
      br.getString(br.X_UPGRADE_PROPERTIES_FAILED,
        oldFile, backingFile), e);
  } catch (ClassNotFoundException e) {
      logger.log(logger.ERROR, br.X_UPGRADE_PROPERTIES_FAILED, oldFile,
      backingFile, e);
      throw new BrokerException(
      br.getString(br.X_UPGRADE_PROPERTIES_FAILED,
        oldFile, backingFile), e);
  } catch (PHashMapLoadException le) {
 
      while (le != null) {
    logger.log(Logger.WARNING,
      br.X_FAILED_TO_LOAD_A_PROPERTY_FROM_OLDSTORE, le);

    // save info in LoadException
    LoadException e = new LoadException(le.getMessage(),
              le.getCause());
    e.setKey(le.getKey());
    e.setValue(le.getValue());
    e.setKeyCause(le.getKeyCause());
    e.setValueCause(le.getValueCause());
    e.setNextException(loadException);
    loadException = e;

    // get the chained exception
    le = le.getNextException();
      }
  }

  VRFileWarning w = olddata.getWarning();
  if (w != null) {
      logger.log(logger.WARNING,
    "possible loss of persisted properties in old store", w);
  }

  try {
      // pass in safe=false; let caller decide when to sync
      // safe=false; reset=false
      propMap = new PHashMap(backingFile, oldFile.length(), false, false);
  } catch (IOException e) {
      logger.log(logger.ERROR, br.X_UPGRADE_DESTINATIONS_FAILED,
      oldFile, backingFile, e);
      throw new BrokerException(
      br.getString(br.X_UPGRADE_DESTINATIONS_FAILED,
        oldFile, backingFile), e);
  }

  try {
      propMap.load();
  } catch (IOException e) {
      // should not happen so throw exception
      logger.log(logger.ERROR, br.X_UPGRADE_PROPERTIES_FAILED, oldFile,
      backingFile, e);
      throw new BrokerException(
      br.getString(br.X_UPGRADE_PROPERTIES_FAILED,
        oldFile, backingFile), e);
  } catch (ClassNotFoundException e) {
      // should not happen so throw exception
      logger.log(logger.ERROR, br.X_UPGRADE_PROPERTIES_FAILED, oldFile,
      backingFile, e);
      throw new BrokerException(
      br.getString(br.X_UPGRADE_PROPERTIES_FAILED,
        oldFile, backingFile), e);
  } catch (PHashMapLoadException e) {
      // should not happen so throw exception
      logger.log(logger.ERROR, br.X_UPGRADE_PROPERTIES_FAILED,
      oldFile, backingFile, e);
      throw new BrokerException(
      br.getString(br.X_UPGRADE_PROPERTIES_FAILED,
        oldFile, backingFile), e);
  }

  w = propMap.getWarning();
  if (w != null) {
      logger.log(logger.WARNING,
      "possible loss of persisted properties", w);
  }

  // just copy old data to new store
  Iterator itr = olddata.entrySet().iterator();
  while (itr.hasNext()) {
      Map.Entry entry = (Map.Entry)itr.next();
      Object key = entry.getKey();
      Object value = entry.getValue();
      propMap.put(key, value);
  }
  olddata.close();

  // if upgradeNoBackup, remove oldfile
  if (p.upgradeNoBackup()) {
      if (!oldFile.delete()) {
    logger.log(logger.ERROR, br.I_DELETE_FILE_FAILED, oldFile);
View Full Code Here

TOP

Related Classes of com.sun.messaging.jmq.util.PHashMap

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.