Skip to content

Commit

Permalink
minor change to show just one ElasticSearch commit msg for all workers
Browse files Browse the repository at this point in the history
  • Loading branch information
lfcnassif committed Jan 26, 2022
1 parent e3d1e4f commit 3859c57
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ public class ElasticSearchIndexTask extends AbstractTask {

public static final String PREVIEW_IN_DATASOURCE = "previewInDataSource";
public static final String KEY_VAL_SEPARATOR = ":";

private static boolean isEnabled = false;

private ElasticSearchTaskConfig elasticConfig;

Expand All @@ -103,7 +105,7 @@ public class ElasticSearchIndexTask extends AbstractTask {

@Override
public boolean isEnabled() {
return elasticConfig.isEnabled();
return isEnabled;
}

public List<Configurable<?>> getConfigurables() {
Expand All @@ -116,7 +118,7 @@ public void init(ConfigurationManager configurationManager) throws Exception {
taskInstances.add(this);
elasticConfig = configurationManager.findObject(ElasticSearchTaskConfig.class);

if (!elasticConfig.isEnabled()) {
if (!(isEnabled = elasticConfig.isEnabled())) {
return;
}

Expand Down Expand Up @@ -279,9 +281,10 @@ private void createFieldMappings(String indexName) throws IOException {
}

public static void commit() throws IOException, InterruptedException {
if (!isEnabled)
return;
WorkerProvider.getInstance().firePropertyChange("mensagem", "", "Commiting to ElasticSearch...");
for (ElasticSearchIndexTask instance : taskInstances) {
WorkerProvider.getInstance().firePropertyChange("mensagem", "", //$NON-NLS-1$ //$NON-NLS-2$
"Commiting Worker-" + instance.worker.id + " ElasticSearchTask..."); //$NON-NLS-1$
LOGGER.info("Commiting Worker-" + instance.worker.id + " ElasticSearchTask..."); //$NON-NLS-1$ //$NON-NLS-2$
instance.onCommit.set(true);
instance.sendBulkRequest();
Expand Down

0 comments on commit 3859c57

Please sign in to comment.