Search in sources :

Example 1 with HazelcastCore

use of fish.payara.nucleus.hazelcast.HazelcastCore in project Payara by payara.

the class HASSOFactory method getSsoEntryMetadataBackingStore.

protected static synchronized BackingStore<String, HASingleSignOnEntryMetadata> getSsoEntryMetadataBackingStore(String persistenceType, String storeName, ServiceLocator services) {
    if (ssoEntryMetadataBackingStore == null) {
        BackingStoreFactory factory = services.getService(BackingStoreFactory.class, persistenceType);
        BackingStoreConfiguration<String, HASingleSignOnEntryMetadata> conf = new BackingStoreConfiguration<String, HASingleSignOnEntryMetadata>();
        String clusterName = "";
        String instanceName = "";
        HazelcastCore hazelcast = services.getService(HazelcastCore.class);
        if (hazelcast.isEnabled()) {
            clusterName = hazelcast.getMemberGroup();
            instanceName = hazelcast.getMemberName();
        }
        conf.setStoreName(storeName).setClusterName(clusterName).setInstanceName(instanceName).setStoreType(persistenceType).setKeyClazz(String.class).setValueClazz(HASingleSignOnEntryMetadata.class);
        try {
            ssoEntryMetadataBackingStore = factory.createBackingStore(conf);
        } catch (BackingStoreException e) {
            e.printStackTrace();
        }
    }
    return ssoEntryMetadataBackingStore;
}
Also used : BackingStoreFactory(org.glassfish.ha.store.api.BackingStoreFactory) HazelcastCore(fish.payara.nucleus.hazelcast.HazelcastCore) BackingStoreException(org.glassfish.ha.store.api.BackingStoreException) BackingStoreConfiguration(org.glassfish.ha.store.api.BackingStoreConfiguration)

Example 2 with HazelcastCore

use of fish.payara.nucleus.hazelcast.HazelcastCore in project Payara by payara.

the class ReplicationWebEventPersistentManager method createBackingStore.

@Override
public void createBackingStore(String persistenceType, String storeName, Class<T> metadataClass, Map<String, Object> vendorMap) {
    if (_logger.isLoggable(Level.FINE)) {
        _logger.fine("Create backing store invoked with persistence type " + persistenceType + " and store name " + storeName);
    }
    BackingStoreFactory factory = services.getService(BackingStoreFactory.class, persistenceType);
    BackingStoreConfiguration<String, T> conf = new BackingStoreConfiguration<String, T>();
    HazelcastCore hazelcast = services.getService(HazelcastCore.class);
    if (hazelcast.isEnabled()) {
        clusterName = hazelcast.getMemberGroup();
        instanceName = hazelcast.getMemberName();
    }
    conf.setStoreName(storeName).setClusterName(clusterName).setInstanceName(instanceName).setStoreType(persistenceType).setKeyClazz(String.class).setValueClazz(metadataClass).setClassLoader(this.getClass().getClassLoader());
    if (vendorMap != null) {
        conf.getVendorSpecificSettings().putAll(vendorMap);
    }
    try {
        if (_logger.isLoggable(Level.FINE)) {
            _logger.fine("About to create backing store " + conf);
        }
        this.backingStore = factory.createBackingStore(conf);
    } catch (BackingStoreException e) {
        _logger.log(Level.WARNING, LogFacade.COULD_NOT_CREATE_BACKING_STORE, e);
    }
    Object obj = conf.getVendorSpecificSettings().get("key.mapper");
    if (obj != null && obj instanceof GlassFishHAReplicaPredictor) {
        predictor = (GlassFishHAReplicaPredictor) obj;
        if (_logger.isLoggable(Level.FINE)) {
            _logger.fine("ReplicatedManager.keymapper is " + predictor);
        }
    } else {
        predictor = new NoopHAReplicaPredictor();
    }
}
Also used : BackingStoreFactory(org.glassfish.ha.store.api.BackingStoreFactory) HazelcastCore(fish.payara.nucleus.hazelcast.HazelcastCore) BackingStoreException(org.glassfish.ha.store.api.BackingStoreException) GlassFishHAReplicaPredictor(org.glassfish.ha.common.GlassFishHAReplicaPredictor) NoopHAReplicaPredictor(org.glassfish.ha.common.NoopHAReplicaPredictor) BackingStoreConfiguration(org.glassfish.ha.store.api.BackingStoreConfiguration)

Example 3 with HazelcastCore

use of fish.payara.nucleus.hazelcast.HazelcastCore in project Payara by payara.

the class ReplicationWebEventPersistentManager method getReplicaFromPredictor.

public String getReplicaFromPredictor(String sessionId, String oldJreplicaValue) {
    if (isDisableJreplica()) {
        return null;
    }
    String gmsClusterName = "";
    HazelcastCore hazelcast = services.getService(HazelcastCore.class);
    if (hazelcast.isEnabled()) {
        gmsClusterName = hazelcast.getMemberGroup();
    }
    HACookieInfo cookieInfo = predictor.makeCookie(gmsClusterName, sessionId, oldJreplicaValue);
    HACookieManager.setCurrrent(cookieInfo);
    return cookieInfo.getNewReplicaCookie();
}
Also used : HACookieInfo(org.glassfish.ha.common.HACookieInfo) HazelcastCore(fish.payara.nucleus.hazelcast.HazelcastCore)

Aggregations

HazelcastCore (fish.payara.nucleus.hazelcast.HazelcastCore)3 BackingStoreConfiguration (org.glassfish.ha.store.api.BackingStoreConfiguration)2 BackingStoreException (org.glassfish.ha.store.api.BackingStoreException)2 BackingStoreFactory (org.glassfish.ha.store.api.BackingStoreFactory)2 GlassFishHAReplicaPredictor (org.glassfish.ha.common.GlassFishHAReplicaPredictor)1 HACookieInfo (org.glassfish.ha.common.HACookieInfo)1 NoopHAReplicaPredictor (org.glassfish.ha.common.NoopHAReplicaPredictor)1