<commit_before>package com.spectralogic.dsbrowser.gui.util;

import com.spectralogic.dsbrowser.gui.components.ds3panel.Ds3Common;
import com.spectralogic.dsbrowser.gui.services.Workers;
import com.spectralogic.dsbrowser.gui.services.sessionStore.Session;
import javafx.application.Platform;
import javafx.scene.control.Alert;
import javafx.scene.image.Image;
import javafx.stage.Stage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class BackgroundTask implements Runnable{

    private final static Logger LOG = LoggerFactory.getLogger(BackgroundTask.class);
    private final Ds3Common ds3Common;
    private final Workers workers;
    private boolean isAlertDisplayed = false;
    private final static Alert ALERT = new Alert(Alert.AlertType.INFORMATION);

    public BackgroundTask(final Ds3Common ds3Common, final Workers workers) {
        this.ds3Common = ds3Common;
        this.workers = workers;
        final Stage stage = (Stage) ALERT.getDialogPane().getScene().getWindow();
        stage.getIcons().add(new Image(ImageURLs.DEEPSTORAGEBROWSER));
    }

    @Override
    public void run() {
        ALERT.setHeaderText(null);
        ALERT.setTitle("Network connection error");
        while (true) {
            try {
                if (ds3Common.getCurrentSession().stream().findFirst().isPresent()) {
                    final Session session = ds3Common.getCurrentSession().stream().findFirst().get();
                    if (CheckNetwork.isReachable(session.getClient())) {
                        if (isAlertDisplayed) {
                            LOG.info("network is up");
                            Platform.runLater(() -> ParseJobInterruptionMap.refreshCompleteTreeTableView(ds3Common, workers));
                            isAlertDisplayed = false;
                        } else {
                            LOG.info("network is working");
                        }

                    } else {
                        LOG.error("network is not reachable");
                        if (!isAlertDisplayed) {
                            Platform.runLater(() -> {
                                final String msg = "Host " + session.getClient().getConnectionDetails().getEndpoint() + " is unreachable. Please check your connection";
                                dumpTheStack(msg);
                                ALERT.setContentText(msg);
                                ALERT.showAndWait();
                            });

                            isAlertDisplayed = true;
                        }
                    }
                } else {
                    LOG.error("No Connection..");
                }
                Thread.sleep(3000);
            } catch (final Throwable e) {
                LOG.error("Encountered an error when attempting to verify that the bp is reachable", e);
            }
        }
    }

    public static void dumpTheStack(final String msg) {
        final StackTraceElement[] elements = Thread.currentThread().getStackTrace();
        for (int i = 1; i < elements.length; i++) {
            final StackTraceElement s = elements[i];
            LOG.info(msg + "====> \tat " + s.getClassName() + "." + s.getMethodName() + "(" + s.getFileName() + ":" + s.getLineNumber() + ")");
        }
    }
}
<commit_msg>Updating the polling delay for the network check from 3 seconds to 5 minutes.  Also removed the logging statement that the network is good.  We only really care when the network is bad<commit_after>package com.spectralogic.dsbrowser.gui.util;

import com.spectralogic.dsbrowser.gui.components.ds3panel.Ds3Common;
import com.spectralogic.dsbrowser.gui.services.Workers;
import com.spectralogic.dsbrowser.gui.services.sessionStore.Session;
import javafx.application.Platform;
import javafx.scene.control.Alert;
import javafx.scene.image.Image;
import javafx.stage.Stage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class BackgroundTask implements Runnable{

    private final static Logger LOG = LoggerFactory.getLogger(BackgroundTask.class);
    private final static Alert ALERT = new Alert(Alert.AlertType.INFORMATION);
    private final static long FIVE_MINUTE_DELAY_IN_MILLIS = 1000 * 60 * 5;

    private final Ds3Common ds3Common;
    private final Workers workers;

    private boolean isAlertDisplayed = false;

    public BackgroundTask(final Ds3Common ds3Common, final Workers workers) {
        this.ds3Common = ds3Common;
        this.workers = workers;
        final Stage stage = (Stage) ALERT.getDialogPane().getScene().getWindow();
        stage.getIcons().add(new Image(ImageURLs.DEEPSTORAGEBROWSER));
    }

    @Override
    public void run() {
        ALERT.setHeaderText(null);
        ALERT.setTitle("Network connection error");
        while (true) {
            try {
                if (ds3Common.getCurrentSession().stream().findFirst().isPresent()) {
                    final Session session = ds3Common.getCurrentSession().stream().findFirst().get();
                    if (CheckNetwork.isReachable(session.getClient())) {
                        if (isAlertDisplayed) {
                            LOG.info("network is up");
                            Platform.runLater(() -> ParseJobInterruptionMap.refreshCompleteTreeTableView(ds3Common, workers));
                            isAlertDisplayed = false;
                        }

                    } else {
                        LOG.error("network is not reachable");
                        if (!isAlertDisplayed) {
                            Platform.runLater(() -> {
                                final String msg = "Host " + session.getClient().getConnectionDetails().getEndpoint() + " is unreachable. Please check your connection";
                                dumpTheStack(msg);
                                ALERT.setContentText(msg);
                                ALERT.showAndWait();
                            });

                            isAlertDisplayed = true;
                        }
                    }
                } else {
                    LOG.error("No Connection..");
                }
                Thread.sleep(FIVE_MINUTE_DELAY_IN_MILLIS);
            } catch (final Throwable e) {
                LOG.error("Encountered an error when attempting to verify that the bp is reachable", e);
            }
        }
    }

    public static void dumpTheStack(final String msg) {
        final StackTraceElement[] elements = Thread.currentThread().getStackTrace();
        for (int i = 1; i < elements.length; i++) {
            final StackTraceElement s = elements[i];
            LOG.info(msg + "====> \tat " + s.getClassName() + "." + s.getMethodName() + "(" + s.getFileName() + ":" + s.getLineNumber() + ")");
        }
    }
}

{'fraction_non_alphanumeric': 0.10167992926613616, 'fraction_numerical': 0.006041850869437077, 'mean_word_length': 1.8844028899277518, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5014852', 'n_tokens_mistral': 1784, 'n_tokens_neox': 1695, 'n_words': 382}