001/*
002 * (C) Copyright 2014 Nuxeo SA (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl-2.1.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     Nuxeo
016 */
017
018package org.nuxeo.elasticsearch.work;
019
020import org.nuxeo.ecm.core.work.AbstractWork;
021
022import static org.nuxeo.elasticsearch.ElasticSearchConstants.INDEXING_QUEUE_ID;
023
024/**
025 * Abstract class for sharing the worker state
026 */
027public abstract class BaseIndexingWorker extends AbstractWork {
028
029    private static final long serialVersionUID = 1L;
030
031    @Override
032    public String getCategory() {
033        return INDEXING_QUEUE_ID;
034    }
035
036    @Override
037    public int getRetryCount() {
038        // even read-only threads may encounter concurrent update exceptions
039        // when trying to read a previously deleted complex property
040        // due to read committed semantics, cf NXP-17384
041        return 1;
042    }
043
044    @Override
045    public void work() {
046        doWork();
047    }
048
049    protected abstract void doWork();
050
051}