diff --git a/src/main/java/io/github/rtib/cmc/Context.java b/src/main/java/io/github/rtib/cmc/Context.java index 2f7c40b..0d4b7a4 100644 --- a/src/main/java/io/github/rtib/cmc/Context.java +++ b/src/main/java/io/github/rtib/cmc/Context.java @@ -313,12 +313,12 @@ public void onUp(Node node) { @Override public void onDown(Node node) { - // ToDo: add handler here + shutdown(); } @Override public void onRemove(Node node) { - // ToDo: add handler here + shutdown(); } @Override diff --git a/src/main/java/io/github/rtib/cmc/CqlMetricsCollectorDaemon.java b/src/main/java/io/github/rtib/cmc/CqlMetricsCollectorDaemon.java index 40142a0..2ed9342 100644 --- a/src/main/java/io/github/rtib/cmc/CqlMetricsCollectorDaemon.java +++ b/src/main/java/io/github/rtib/cmc/CqlMetricsCollectorDaemon.java @@ -8,7 +8,7 @@ * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, +distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. @@ -83,4 +83,11 @@ private void deactivate() { if (httpServer != null) httpServer.stop(); } + + /** + * Shutdown the service when the connected Cassandra node leaves the ring. + */ + public void shutdownService() { + deactivate(); + } }