コード例 #1
0
  /**
   * Update properties
   *
   * @param svcId node service id
   * @throws Exception
   */
  private void updateProperties(String svcId) throws Exception {
    if (targetPropInfo.TARGET_PROPERTY.equals(targetPropInfo.OLD_TARGET_PROPERTY)) {
      coordinator.removeTargetInfo(targetPropInfo, true);
    }
    PropertyInfoExt diffProperties =
        new PropertyInfoExt(targetPropInfo.getDiffProperties(localTargetPropInfo));
    PropertyInfoExt override_properties =
        new PropertyInfoExt(localRepository.getOverrideProperties().getAllProperties());
    log.info("Step3a: Updating User Changed properties file: {}", override_properties);
    PropertyInfoExt updatedUserChangedProps = combineProps(override_properties, diffProperties);
    if (diffProperties.hasRebootProperty()) {
      if (!getPropertyLock(svcId)) {
        retrySleep();
      } else if (!isQuorumMaintained()) {
        try {
          coordinator.releasePersistentLock(svcId, propertyLockId);
        } catch (Exception e) {
          log.error("Failed to release the property lock:", e);
        }
        retrySleep();
      } else {
        log.info("Step3a: Reboot property found.");
        localRepository.setOverrideProperties(updatedUserChangedProps);
        log.info("Step3a: Updating properties: {}", updatedUserChangedProps);
        reboot();
      }
    } else if (diffProperties.hasReconfigProperty()
        || !diffProperties.getNotifierTags().isEmpty()) {
      log.info("Step3a: Reconfig property found or notifiers specified.");

      // CTRL-9860: don't update the local config version until everything is done.
      String targetVersion = targetPropInfo.getProperty(PropertyInfoExt.CONFIG_VERSION);
      updatedUserChangedProps.addProperty(PropertyInfoExt.CONFIG_VERSION, localConfigVersion);
      localRepository.setOverrideProperties(updatedUserChangedProps);
      log.info(
          "Step3a: Updating properties without updating the config version: {}",
          updatedUserChangedProps);
      if (diffProperties.hasReconfigAttributeWithoutNotifiers()) {
        // this is the old-school "complete" reconfig that takes no notifiers as arguments.
        // moving forward this will diminish
        // i.e., all reconfigRequired properties will have notifier specified.
        localRepository.reconfig();
      } else if (diffProperties.hasReconfigProperty()) {
        reconfigProperties(diffProperties);
      }

      // the notifier list can be empty, in which case nothing will be done.
      notifyPropertyChanges(diffProperties);

      // update the local config version to target version now
      log.info("Step3a: Updating the config version to {}", targetVersion);
      updatedUserChangedProps.addProperty(PropertyInfoExt.CONFIG_VERSION, targetVersion);
      localRepository.setOverrideProperties(updatedUserChangedProps);

    } else {
      log.info("Step3a: No reboot property found.");
      localRepository.setOverrideProperties(updatedUserChangedProps);
      log.info("Step3a: Updating properties: {}", updatedUserChangedProps);
    }
  }
コード例 #2
0
 private void notifyPropertyChanges(PropertyInfoExt diffProperties) {
   List<String> notifierTags = diffProperties.getNotifierTags();
   for (String notifierTag : notifierTags) {
     log.info("Step3a: Calling notifier {}", notifierTag);
     try {
       Notifier notifier = Notifier.getInstance(notifierTag);
       if (notifier != null) notifier.doNotify();
     } catch (Exception e) {
       log.error("Step3a: Fail to invoke notifier {}", notifierTag, e);
     }
   }
 }
コード例 #3
0
  private void reconfigProperties(PropertyInfoExt diffProperties) {
    // only get the notifiers that requires reconfig as well
    List<String> notifierTagList = diffProperties.getNotifierTags(true);
    String notifierTags = StringUtils.join(notifierTagList, " ");
    log.info("Step3a: Reconfiguring properties related to {}", notifierTags);

    try {
      localRepository.reconfigProperties(notifierTags);
    } catch (Exception e) {
      log.error("Step3a: Fail to reconfig properties related to {}", notifierTags, e);
    }
  }