
com.thematchbox.river.batch.AbstractBatchIndexAction Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of AbstractRiver Show documentation
Show all versions of AbstractRiver Show documentation
This project contains an abstract implementation of an ElasticSearch River and is used as a basis for custom river implementations.
package com.thematchbox.river.batch;
/* Copyright 2015 theMatchBox
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import com.thematchbox.river.actions.AbstractIndexAction;
import com.thematchbox.river.actions.ActionType;
import com.thematchbox.river.actions.IndexFeedback;
import com.thematchbox.river.actions.IndexJob;
import com.thematchbox.river.data.ContentDelegator;
import com.thematchbox.river.data.PersistentObject;
import com.thematchbox.river.indexers.MatchBoxIndexerManager;
import org.elasticsearch.client.Client;
import java.util.List;
public abstract class AbstractBatchIndexAction, T extends PersistentObject> extends AbstractIndexAction, BatchSessionDelegatorFactory> {
private ItemContainer itemContainer;
private MatchBoxIndexerManager indexerManager;
protected AbstractBatchIndexAction(int batchSize, Class clazz, ContentDelegator contentDelegator, ItemContainer itemContainer, MatchBoxIndexerManager indexerManager) {
super(batchSize, clazz, contentDelegator, new BatchSessionDelegatorFactory<>(itemContainer));
this.itemContainer = itemContainer;
this.indexerManager = indexerManager;
}
@Override
protected abstract boolean deleteFirst();
@Override
public void execute(Client client, IndexJob indexJob, IndexFeedback feedback) {
super.execute(client, indexJob, feedback);
List newActions = getNewActions(itemContainer);
for (BatchIndexKey newAction : newActions) {
indexerManager.addRequest(new IndexJob(getActionType(), newAction));
}
}
protected abstract List getNewActions(ItemContainer itemContainer);
protected abstract ActionType getActionType();
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy