@Override public void onApplicationStarted() { esClient = getClient(); if (Boolean.parseBoolean(Framework.getProperty(MIGRATION_FLAG_PROP))) { if (!isMigrationDone()) { log.info(String.format( "Property %s is true and migration is not done yet, processing audit migration from SQL to Elasticsearch index", MIGRATION_FLAG_PROP)); // Drop audit index first in case of a previous bad migration ElasticSearchAdmin esa = Framework.getService(ElasticSearchAdmin.class); esa.dropAndInitIndex(getESIndexName()); int batchSize = MIGRATION_DEFAULT_BACTH_SIZE; String batchSizeProp = Framework.getProperty(MIGRATION_BATCH_SIZE_PROP); if (batchSizeProp != null) { batchSize = Integer.parseInt(batchSizeProp); } migrate(batchSize); } else { log.warn(String.format( "Property %s is true but migration is already done, please set this property to false", MIGRATION_FLAG_PROP)); } } else { log.debug(String.format("Property %s is false, not processing any migration", MIGRATION_FLAG_PROP)); } cursorService = new CursorService<>(SearchHit::getSourceAsString); }