// check and initialize versioned configuration
  private Configuration checkVersionedConfiguration() {
    String serviceVersion = _serviceInfo.getVersion();
    String dbSchemaVersion = _dbClient.getSchemaVersion();
    if (!serviceVersion.equals(dbSchemaVersion)) {
      _log.warn(
          "The db service version {} doesn't equals Db schema version {}, "
              + "set db service version to Db schema version",
          serviceVersion,
          dbSchemaVersion);
      _serviceInfo.setVersion(dbSchemaVersion);
    }

    String kind =
        _coordinator.getVersionedDbConfigPath(_serviceInfo.getName(), _serviceInfo.getVersion());
    Configuration config =
        _coordinator.queryConfiguration(_coordinator.getSiteId(), kind, _serviceInfo.getId());
    if (config == null) {
      // check if it is upgraded from previous version to yoda - configuration may be stored in
      // znode /config
      config = _coordinator.queryConfiguration(kind, _serviceInfo.getId());
      if (config != null) {
        _log.info("Upgrade from pre-2.5 release, move versioned dbconfig to new location");
        _coordinator.persistServiceConfiguration(_coordinator.getSiteId(), config);
        return config;
      }

      ConfigurationImpl cfg = new ConfigurationImpl();
      cfg.setId(_serviceInfo.getId());
      cfg.setKind(kind);
      // persist configuration
      _coordinator.persistServiceConfiguration(_coordinator.getSiteId(), cfg);
      config = cfg;
    }
    return config;
  }
 private void removeStaleVersionedDbConfiguration() {
   String configKind =
       _coordinator.getVersionedDbConfigPath(_serviceInfo.getName(), _serviceInfo.getVersion());
   List<Configuration> configs =
       _coordinator.queryAllConfiguration(_coordinator.getSiteId(), configKind);
   for (Configuration config : configs) {
     if (isStaleConfiguration(config)) {
       _coordinator.removeServiceConfiguration(_coordinator.getSiteId(), config);
       _log.info("Remove stale version db config, id: {}", config.getId());
     }
   }
 }
 /**
  * Checks and sets INIT_DONE state this means we are done with the actual cf changes on the
  * cassandra side for the target version
  */
 private void setDbConfigInitDone() {
   String configKind =
       _coordinator.getVersionedDbConfigPath(_serviceInfo.getName(), _serviceInfo.getVersion());
   Configuration config =
       _coordinator.queryConfiguration(_coordinator.getSiteId(), configKind, _serviceInfo.getId());
   if (config != null) {
     if (config.getConfig(DbConfigConstants.INIT_DONE) == null) {
       config.setConfig(DbConfigConstants.INIT_DONE, Boolean.TRUE.toString());
       _coordinator.persistServiceConfiguration(_coordinator.getSiteId(), config);
     }
   } else {
     // we are expecting this to exist, because its initialized from checkVersionedConfiguration
     throw new IllegalStateException("unexpected error, db versioned configuration is null");
   }
 }