mirror of https://github.com/apache/nifi.git
NIFI-12633 Avoid resetting state in GetSolr on restart
This closes #8267 Signed-off-by: David Handermann <exceptionfactory@apache.org>
This commit is contained in:
parent
a95f327b31
commit
043e2dd3ff
|
@ -41,6 +41,7 @@ import org.apache.nifi.annotation.behavior.Stateful;
|
|||
import org.apache.nifi.annotation.configuration.DefaultSchedule;
|
||||
import org.apache.nifi.annotation.documentation.CapabilityDescription;
|
||||
import org.apache.nifi.annotation.documentation.Tags;
|
||||
import org.apache.nifi.annotation.lifecycle.OnConfigurationRestored;
|
||||
import org.apache.nifi.annotation.lifecycle.OnScheduled;
|
||||
import org.apache.nifi.components.AllowableValue;
|
||||
import org.apache.nifi.components.PropertyDescriptor;
|
||||
|
@ -154,6 +155,7 @@ public class GetSolr extends SolrProcessor {
|
|||
|
||||
private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US);
|
||||
|
||||
private final AtomicBoolean configurationRestored = new AtomicBoolean(false);
|
||||
private final AtomicBoolean clearState = new AtomicBoolean(false);
|
||||
private final AtomicBoolean dateFieldNotInSpecifiedFieldsList = new AtomicBoolean(false);
|
||||
private volatile String id_field = null;
|
||||
|
@ -211,10 +213,15 @@ public class GetSolr extends SolrProcessor {
|
|||
|
||||
@Override
|
||||
public void onPropertyModified(PropertyDescriptor descriptor, String oldValue, String newValue) {
|
||||
if (propertyNamesForActivatingClearState.contains(descriptor.getName()))
|
||||
if (configurationRestored.get() && propertyNamesForActivatingClearState.contains(descriptor.getName()))
|
||||
clearState.set(true);
|
||||
}
|
||||
|
||||
@OnConfigurationRestored
|
||||
public void onConfigurationRestored() {
|
||||
configurationRestored.set(true);
|
||||
}
|
||||
|
||||
@OnScheduled
|
||||
public void clearState(final ProcessContext context) throws IOException {
|
||||
if (clearState.getAndSet(false))
|
||||
|
|
Loading…
Reference in New Issue