public void syncSettingsInDbAndConfigFile(){
  boolean configurationChanged=false;
  Configuration loadedConf=mapper.load(Configuration.class,EC2MetadataUtils.getInstanceId());
  if (cronExpressionIsValid(retentionCronExpression) && !retentionCronExpression.equals(loadedConf.getRetentionCronExpression())) {
    LOG.debug("Applying new cron expression {} for Retention policy.",retentionCronExpression);
    loadedConf.setRetentionCronExpression(retentionCronExpression);
    configurationChanged=true;
  }
  if (correctPropertyProvided(pollingRate,WORKER_POLLING_RATE) && Integer.parseInt(pollingRate) != loadedConf.getWorkerDispatcherPollingRate()) {
    LOG.debug("Applying new polling rate to pick up new task {} ms.",pollingRate);
    loadedConf.setWorkerDispatcherPollingRate(Integer.parseInt(pollingRate));
    configurationChanged=true;
  }
  if (correctPropertyProvided(waitTimeBeforeNewSync,WAIT_TIME_BEFORE_NEXT_CHECK_IN_SECONDS) && Integer.parseInt(waitTimeBeforeNewSync) != loadedConf.getWaitTimeBeforeNewSyncWithAWS()) {
    LOG.debug("Applying new wait time before new sync of Snapshot/Volume with AWS data {} seconds.",waitTimeBeforeNewSync);
    loadedConf.setWaitTimeBeforeNewSyncWithAWS(Integer.parseInt(waitTimeBeforeNewSync));
    configurationChanged=true;
  }
  if (correctPropertyProvided(maxWaitTimeToDetachVolume,MAX_WAIT_TIME_VOLUME_TO_DETACH_IN_SECONDS) && Integer.parseInt(maxWaitTimeToDetachVolume) != loadedConf.getMaxWaitTimeToDetachVolume()) {
    LOG.debug("Applying new max wait time for volume to be detach {} seconds.",maxWaitTimeToDetachVolume);
    loadedConf.setMaxWaitTimeToDetachVolume(Integer.parseInt(maxWaitTimeToDetachVolume));
    configurationChanged=true;
  }
  if (configurationChanged) {
    LOG.debug("Storing updated settings from config file to DB.");
    mapper.save(loadedConf);
  }
  removeProperties();
  storePropertiesEditableFromConfigFile(loadedConf.getRetentionCronExpression(),loadedConf.getWorkerDispatcherPollingRate(),loadedConf.getWaitTimeBeforeNewSyncWithAWS(),loadedConf.getMaxWaitTimeToDetachVolume());
}

public void syncSettingsInDbAndConfigFile ( ) { boolean configurationChanged = false ; Configuration loadedConf = mapper . load ( Configuration . class , EC2MetadataUtils . getInstanceId ( ) ) ; if ( cronExpressionIsValid ( retentionCronExpression ) && ! retentionCronExpression . equals ( loadedConf . getRetentionCronExpression ( ) ) ) { LOG . debug ( "Applying new cron expression {} for Retention policy." , retentionCronExpression ) ; loadedConf . setRetentionCronExpression ( retentionCronExpression ) ; configurationChanged = true ; } if ( correctPropertyProvided ( pollingRate , WORKER_POLLING_RATE ) && Integer . parseInt ( pollingRate ) != loadedConf . getWorkerDispatcherPollingRate ( ) ) { LOG . debug ( "Applying new polling rate to pick up new task {} ms." , pollingRate ) ; loadedConf . setWorkerDispatcherPollingRate ( Integer . parseInt ( pollingRate ) ) ; configurationChanged = true ; } if ( correctPropertyProvided ( waitTimeBeforeNewSync , WAIT_TIME_BEFORE_NEXT_CHECK_IN_SECONDS ) && Integer . parseInt ( waitTimeBeforeNewSync ) != loadedConf . getWaitTimeBeforeNewSyncWithAWS ( ) ) { LOG . debug ( "Applying new wait time before new sync of Snapshot/Volume with AWS data {} seconds." , waitTimeBeforeNewSync ) ; loadedConf . setWaitTimeBeforeNewSyncWithAWS ( Integer . parseInt ( waitTimeBeforeNewSync ) ) ; configurationChanged = true ; } if ( correctPropertyProvided ( maxWaitTimeToDetachVolume , MAX_WAIT_TIME_VOLUME_TO_DETACH_IN_SECONDS ) && Integer . parseInt ( maxWaitTimeToDetachVolume ) != loadedConf . getMaxWaitTimeToDetachVolume ( ) ) { LOG . debug ( "Applying new max wait time for volume to be detach {} seconds." , maxWaitTimeToDetachVolume ) ; loadedConf . setMaxWaitTimeToDetachVolume ( Integer . parseInt ( maxWaitTimeToDetachVolume ) ) ; configurationChanged = true ; } if ( configurationChanged ) { LOG . debug ( "Storing updated settings from config file to DB." ) ; mapper . save ( loadedConf ) ; } removeProperties ( ) ; storePropertiesEditableFromConfigFile ( loadedConf . getRetentionCronExpression ( ) , loadedConf . getWorkerDispatcherPollingRate ( ) , loadedConf . getWaitTimeBeforeNewSyncWithAWS ( ) , loadedConf . getMaxWaitTimeToDetachVolume ( ) ) ; }
store properties changed in config file to db
