Search in sources :

Example 1 with PayaraInstanceImpl

use of fish.payara.appserver.micro.services.PayaraInstanceImpl 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)

Example 2 with PayaraInstanceImpl

use of fish.payara.appserver.micro.services.PayaraInstanceImpl in project Payara by payara.

the class AsAdminCallable method call.

@Override
public ClusterCommandResult call() throws Exception {
    ServiceLocator locator = Globals.getDefaultBaseServiceLocator();
    PayaraInstanceImpl instance = locator.getService(PayaraInstanceImpl.class, "payara-instance");
    return instance.executeLocalAsAdmin(command, args);
}
Also used : ServiceLocator(org.glassfish.hk2.api.ServiceLocator) PayaraInstanceImpl(fish.payara.appserver.micro.services.PayaraInstanceImpl)

Aggregations

PayaraInstanceImpl (fish.payara.appserver.micro.services.PayaraInstanceImpl)2 InstanceDescriptor (fish.payara.micro.data.InstanceDescriptor)1 PayaraCluster (fish.payara.nucleus.cluster.PayaraCluster)1 ClusterMessage (fish.payara.nucleus.eventbus.ClusterMessage)1 ServiceLocator (org.glassfish.hk2.api.ServiceLocator)1