Skip to content

Commit

Permalink
PAYARA-1696 stop previous thread when notifier is configured (payara#…
Browse files Browse the repository at this point in the history
…1640)

Only a single thread will now exist for each notifer.
  • Loading branch information
Cousjava committed Jun 5, 2017
1 parent 5e0d173 commit 3f83272
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 30 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2016 Payara Foundation and/or its affiliates. All rights reserved.
* Copyright (c) 2016-2017 Payara Foundation and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
Expand Down Expand Up @@ -101,8 +101,4 @@ public void bootstrap() {
}
}

@Override
public void shutdown() {
super.reset();
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2016 Payara Foundation and/or its affiliates. All rights reserved.
* Copyright (c) 2016-2017 Payara Foundation and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
Expand Down Expand Up @@ -81,8 +81,4 @@ public void bootstrap() {
scheduleExecutor(new HipchatNotificationRunnable(queue, executionOptions));
}

@Override
public void shutdown() {
super.reset();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (c) 2016 Payara Foundation and/or its affiliates. All rights reserved.
* Copyright (c) 2016-2017 Payara Foundation and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
Expand Down Expand Up @@ -123,11 +123,6 @@ public void bootstrap() {
}
}

@Override
public void shutdown() {
super.reset();
}

@Override
@Subscribe
public void handleNotification(JmsNotificationEvent event) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2016 Payara Foundation and/or its affiliates. All rights reserved.
* Copyright (c) 2016-2017 Payara Foundation and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
Expand Down Expand Up @@ -82,8 +82,4 @@ public void bootstrap() {
scheduleExecutor(new SlackNotificationRunnable(queue, executionOptions));
}

@Override
public void shutdown() {
super.reset();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public void bootstrap() {

@Override
public void shutdown() {
super.reset();
super.shutdown();
if (snmp != null) {
try {
snmp.close();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2016 Payara Foundation and/or its affiliates. All rights reserved.
* Copyright (c) 2016-2017 Payara Foundation and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
Expand Down Expand Up @@ -116,7 +116,7 @@ public void bootstrap() {

@Override
public void shutdown() {
super.reset();
super.shutdown();
if (connection != null) {
connection.disconnect();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ public NotifierConfigurationExecutionOptions getNotifierConfigurationExecutionOp
return null;
}

/**
* Unregisters a service and cleans up any information stored in it
* This function does NOT restart the service.
* @param service
*/
protected void reset(BaseNotifierService service) {
eventBus.unregister(service);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (c) 2016 Payara Foundation and/or its affiliates. All rights reserved.
* Copyright (c) 2016-2017 Payara Foundation and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
Expand Down Expand Up @@ -85,12 +85,27 @@ protected ScheduledFuture scheduleExecutor(NotificationRunnable notificationRunn
TimeUnit.MILLISECONDS);
}

/**
* Unregisters the service and cleans up any information stored in it
* This function does NOT restart the service.
*/
protected void reset() {
super.reset(this);
queue.resetQueue();
if (scheduledFuture != null) {
scheduledFuture.cancel(true);
}
initializeExecutor();
//initializeExecutor();
}

/**
* Shuts down the service
*/
@Override
public void shutdown(){
if (executor != null){
executor.shutdown();
}
reset();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,4 @@ public void bootstrap() {
executionOptions = (EventbusNotifierConfigurationExecutionOptions) getNotifierConfigurationExecutionOptions();
}

@Override
public void shutdown() {
super.reset();
}
}

0 comments on commit 3f83272

Please sign in to comment.