Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
Openfire
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Openfire
Commits
02870ab9
Commit
02870ab9
authored
Mar 01, 2018
by
GregDThomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
HZ-11: Fire the left cluster event before we leave the cluster
parent
8e3434cb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
16 deletions
+49
-16
ClusterManager.java
...ava/org/jivesoftware/openfire/cluster/ClusterManager.java
+6
-0
ClusteredCacheFactory.java
...are/openfire/plugin/util/cache/ClusteredCacheFactory.java
+43
-16
No files found.
src/java/org/jivesoftware/openfire/cluster/ClusterManager.java
View file @
02870ab9
...
...
@@ -16,6 +16,7 @@
package
org
.
jivesoftware
.
openfire
.
cluster
;
import
java.nio.charset.StandardCharsets
;
import
java.util.Collection
;
import
java.util.Map
;
import
java.util.Queue
;
...
...
@@ -177,6 +178,7 @@ public class ClusterManager {
*/
public
static
void
fireJoinedCluster
(
boolean
asynchronous
)
{
try
{
Log
.
info
(
"Firing joined cluster event for this node"
);
Event
event
=
new
Event
(
EventType
.
joined_cluster
,
null
);
events
.
put
(
event
);
if
(!
asynchronous
)
{
...
...
@@ -201,6 +203,7 @@ public class ClusterManager {
*/
public
static
void
fireJoinedCluster
(
byte
[]
nodeID
,
boolean
asynchronous
)
{
try
{
Log
.
info
(
"Firing joined cluster event for another node:"
+
new
String
(
nodeID
,
StandardCharsets
.
UTF_8
));
Event
event
=
new
Event
(
EventType
.
joined_cluster
,
nodeID
);
events
.
put
(
event
);
if
(!
asynchronous
)
{
...
...
@@ -228,6 +231,7 @@ public class ClusterManager {
*/
public
static
void
fireLeftCluster
()
{
try
{
Log
.
info
(
"Firing left cluster event for this node"
);
Event
event
=
new
Event
(
EventType
.
left_cluster
,
null
);
events
.
put
(
event
);
}
catch
(
InterruptedException
e
)
{
...
...
@@ -245,6 +249,7 @@ public class ClusterManager {
*/
public
static
void
fireLeftCluster
(
byte
[]
nodeID
)
{
try
{
Log
.
info
(
"Firing left cluster event for another node:"
+
new
String
(
nodeID
,
StandardCharsets
.
UTF_8
));
Event
event
=
new
Event
(
EventType
.
left_cluster
,
nodeID
);
events
.
put
(
event
);
}
catch
(
InterruptedException
e
)
{
...
...
@@ -269,6 +274,7 @@ public class ClusterManager {
*/
public
static
void
fireMarkedAsSeniorClusterMember
()
{
try
{
Log
.
info
(
"Firing marked as senior event"
);
events
.
put
(
new
Event
(
EventType
.
marked_senior_cluster_member
,
null
));
}
catch
(
InterruptedException
e
)
{
// Should never happen
...
...
src/plugins/hazelcast/src/java/org/jivesoftware/openfire/plugin/util/cache/ClusteredCacheFactory.java
View file @
02870ab9
...
...
@@ -26,6 +26,8 @@ import com.hazelcast.core.HazelcastInstance;
import
com.hazelcast.core.Member
;
import
org.jivesoftware.openfire.JMXManager
;
import
org.jivesoftware.openfire.XMPPServer
;
import
org.jivesoftware.openfire.cluster.ClusterEventListener
;
import
org.jivesoftware.openfire.cluster.ClusterManager
;
import
org.jivesoftware.openfire.cluster.ClusterNodeInfo
;
import
org.jivesoftware.openfire.cluster.NodeID
;
import
org.jivesoftware.openfire.plugin.session.RemoteSessionLocator
;
...
...
@@ -57,6 +59,7 @@ import java.util.Map;
import
java.util.Set
;
import
java.util.concurrent.Callable
;
import
java.util.concurrent.Future
;
import
java.util.concurrent.Semaphore
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeoutException
;
import
java.util.concurrent.locks.Condition
;
...
...
@@ -177,25 +180,49 @@ public class ClusteredCacheFactory implements CacheFactoryStrategy {
cacheStats
=
null
;
// Update the running state of the cluster
state
=
State
.
stopped
;
// Fire the leftClusterEvent before we leave the cluster - we need to access the clustered data before the
// cluster is shutdown so it can be copied in to the non-clustered, DefaultCache
final
Semaphore
leftClusterSemaphore
=
new
Semaphore
(
0
);
final
ClusterEventListener
clusterEventListener
=
new
ClusterEventListener
()
{
@Override
public
void
joinedCluster
()
{
}
@Override
public
void
joinedCluster
(
byte
[]
bytes
)
{
}
@Override
public
void
leftCluster
()
{
leftClusterSemaphore
.
release
();
}
@Override
public
void
leftCluster
(
byte
[]
bytes
)
{
}
@Override
public
void
markedAsSeniorClusterMember
()
{
}
};
try
{
ClusterManager
.
addListener
(
clusterEventListener
);
ClusterManager
.
fireLeftCluster
();
leftClusterSemaphore
.
tryAcquire
(
30
,
TimeUnit
.
SECONDS
);
}
catch
(
final
Exception
e
)
{
logger
.
error
(
"Unexpected exception waiting for clustering to shut down"
,
e
);
}
finally
{
ClusterManager
.
removeListener
(
clusterEventListener
);
}
// Stop the cluster
hazelcast
.
getLifecycleService
().
removeLifecycleListener
(
lifecycleListener
);
cluster
.
removeMembershipListener
(
membershipListener
);
Hazelcast
.
shutdownAll
();
cluster
=
null
;
if
(
clusterListener
!=
null
)
{
// Wait until the server has updated its internal state
while
(!
clusterListener
.
isDone
()
&&
!
Thread
.
currentThread
().
isInterrupted
())
{
try
{
Thread
.
sleep
(
100
);
}
catch
(
final
InterruptedException
ignored
)
{
Thread
.
currentThread
().
interrupt
();
}
}
hazelcast
.
getLifecycleService
().
removeLifecycleListener
(
lifecycleListener
);
cluster
.
removeMembershipListener
(
membershipListener
);
lifecycleListener
=
null
;
membershipListener
=
null
;
clusterListener
=
null
;
}
// Reset the node ID
lifecycleListener
=
null
;
membershipListener
=
null
;
clusterListener
=
null
;
XMPPServer
.
getInstance
().
setNodeID
(
null
);
// Reset packet router to use to deliver packets to remote cluster nodes
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment