Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem shutting CWMetricsFactory down cleanly. #81

Closed
rankinc opened this issue Jun 27, 2016 · 1 comment
Closed

Problem shutting CWMetricsFactory down cleanly. #81

rankinc opened this issue Jun 27, 2016 · 1 comment

Comments

@rankinc
Copy link
Contributor

rankinc commented Jun 27, 2016

I'm trying to use KCL 1.6.3, but I cannot stop the cw-metrics-publisher thread cleanly. Or more specifically, I can't tell when the cw-metrics-publisher thread has finished shutting down, so that I can then shutdown the AWSCloudWatch instance.

I am launching my Worker object in its own thread:

Future<?> task = executor.submit(worker);

This means that I can shutdown the worker by executing:

executor.shutdown();
worker.shutdown();

if (!executor.awaitTermination(... timeout ...)) {
    executor.shutdownNow();
}

However, this only guarantees that CWMetricsFactory.shutdown() has been invoked. It does not wait for CWPublisherRunnable<>.isShutdown() to become true. Nor do I have access to the CWMetricsFactory.publicationThread field so that I can poll its isAlive() method. (Not without hacking my way in using reflection, anyway).

I think the CWPublisherRunnable<> should finish executing before the Worker exits, and so I've tweaked CWMetricsFactory.shutdown() locally as follows:

    public void shutdown() {
        runnable.shutdown();
        try {
            publicationThread.join();
        } catch (InterruptedException e) {
            throw new AbortedException(e.getMessage(), e);
        }
    }

See pull request #81.

@rankinc rankinc changed the title How to tell when CWMetricsFactory has finished shutting down? Problem shutting CWMetricsFactory down cleanly. Jun 29, 2016
@pfifer
Copy link
Contributor

pfifer commented Aug 5, 2016

PR #82 was released as part v1.6.5.

@pfifer pfifer closed this as completed Aug 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants