use of fish.payara.nucleus.cluster.PayaraCluster in project Payara by payara.
the class HazelcastTimerStore method _notifyMigratedFromInstance.
/**
* Sends an {@link EjbTimerEvent} across the DataGrid with the {@link InstanceDescriptor} of the instance from
* which the EJB timers were migrated from, to allow other instances to react to the migration.
* @param fromOwnerId The {@link InstanceDescriptor} of the instance from which the timers were migrated from
*/
private void _notifyMigratedFromInstance(String fromOwnerId) {
PayaraCluster cluster = Globals.getDefaultBaseServiceLocator().getService(PayaraCluster.class);
PayaraInstanceImpl instance = Globals.getDefaultBaseServiceLocator().getService(PayaraInstanceImpl.class);
if (cluster == null || instance == null) {
return;
}
// Get the InstanceDescriptor of the fromOwnerId instance
InstanceDescriptor fromOwnerInstanceDescriptor = null;
for (InstanceDescriptor instanceDescriptor : instance.getClusteredPayaras()) {
if (instanceDescriptor.getInstanceName().equals(fromOwnerId)) {
fromOwnerInstanceDescriptor = instanceDescriptor;
break;
}
}
if (fromOwnerInstanceDescriptor == null) {
return;
}
EjbTimerEvent ejbTimerEvent = new EjbTimerEvent(EjbTimerEvent.Event.MIGRATED, fromOwnerInstanceDescriptor);
ClusterMessage<EjbTimerEvent> message = new ClusterMessage<>(ejbTimerEvent);
cluster.getEventBus().publish(EjbTimerEvent.EJB_TIMER_EVENTS_TOPIC, message);
}
Aggregations