@Override public void start() { Preconditions.checkState(bulkRequest == null, ALREADY_STARTED_MESSAGE); if (large) { largeInitialSettings = Maps.newHashMap(); Map<String, Object> bulkSettings = Maps.newHashMap(); GetSettingsResponse settingsResp = client.nativeClient().admin().indices().prepareGetSettings(indexName).get(); // deactivate replicas int initialReplicas = Integer.parseInt( settingsResp.getSetting(indexName, IndexMetaData.SETTING_NUMBER_OF_REPLICAS)); if (initialReplicas > 0) { largeInitialSettings.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, initialReplicas); bulkSettings.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0); } // deactivate periodical refresh String refreshInterval = settingsResp.getSetting(indexName, REFRESH_INTERVAL_SETTING); largeInitialSettings.put(REFRESH_INTERVAL_SETTING, refreshInterval); bulkSettings.put(REFRESH_INTERVAL_SETTING, "-1"); updateSettings(bulkSettings); } bulkRequest = client.prepareBulk().setRefresh(false); counter.set(0L); progress.start(); }
private void executeBulk() { final BulkRequestBuilder req = this.bulkRequest; this.bulkRequest = client.prepareBulk().setRefresh(false); semaphore.acquireUninterruptibly(); req.execute(new BulkResponseActionListener(req)); }