Search in sources :

Example 1 with PayaraCluster

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);
}
Also used : InstanceDescriptor(fish.payara.micro.data.InstanceDescriptor) PayaraInstanceImpl(fish.payara.appserver.micro.services.PayaraInstanceImpl) ClusterMessage(fish.payara.nucleus.eventbus.ClusterMessage) PayaraCluster(fish.payara.nucleus.cluster.PayaraCluster)

Aggregations

PayaraInstanceImpl (fish.payara.appserver.micro.services.PayaraInstanceImpl)1 InstanceDescriptor (fish.payara.micro.data.InstanceDescriptor)1 PayaraCluster (fish.payara.nucleus.cluster.PayaraCluster)1 ClusterMessage (fish.payara.nucleus.eventbus.ClusterMessage)1