All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.deephaven.engine.table.impl.util.AsyncClientErrorNotifier Maven / Gradle / Ivy

There is a newer version: 0.37.1
Show newest version
/**
 * Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending
 */
package io.deephaven.engine.table.impl.util;

import io.deephaven.engine.table.impl.UpdateErrorReporter;
import io.deephaven.util.datastructures.WeakIdentityHashSet;

import java.io.IOException;

/**
 * When we get an error from a table in the listener tree, we want to send an appropriate command to the clients
 * indicating that something has gone wrong with the table.
 */
public class AsyncClientErrorNotifier {

    private static volatile UpdateErrorReporter reporter = null;
    private static final WeakIdentityHashSet knownErrors = new WeakIdentityHashSet.Synchronized<>();

    public static UpdateErrorReporter setReporter(UpdateErrorReporter reporter) {
        final UpdateErrorReporter old = AsyncClientErrorNotifier.reporter;
        AsyncClientErrorNotifier.reporter = reporter;
        return old;
    }

    public static void reportError(Throwable t) throws IOException {
        final UpdateErrorReporter localReporter = reporter;
        if (localReporter != null && knownErrors.add(t)) {
            localReporter.reportUpdateError(t);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy