Search in sources :

Example 1 with BackingStoreFactory

use of org.glassfish.ha.store.api.BackingStoreFactory in project Payara by payara.

the class ExpiredSessionsRemovalTask method buildStoreManager.

private void buildStoreManager() throws BackingStoreException {
    String persistenceStoreType = "file";
    if (ejbAvailability != null) {
        persistenceStoreType = HAEnabled ? ejbAvailability.getSfsbHaPersistenceType() : ejbAvailability.getSfsbPersistenceType();
        if ("ha".equals(persistenceStoreType)) {
            persistenceStoreType = "replicated";
        } else if ("memory".equals(persistenceStoreType)) {
            persistenceStoreType = "file";
        }
    }
    BackingStoreConfiguration<Serializable, SimpleMetadata> conf = new BackingStoreConfiguration<Serializable, SimpleMetadata>();
    String storeName = ejbDescriptor.getName() + "-" + ejbDescriptor.getUniqueId() + "-BackingStore";
    _logger.log(Level.FINE, SFSB_BUILDER_STORE_NAME, storeName);
    String subDirName = "";
    /*        if (ejbDescriptor.getApplication().isVirtual()) {
            String archURI = ejbDescriptor.getEjbBundleDescriptor().
                    getModuleDescriptor().getArchiveUri();
            subDirName += FileUtils.makeFriendlyFilename(archURI);
            subDirName += "_" + FileUtils.makeFriendlyFilename(ejbDescriptor.getName());
        } else {
            subDirName += FileUtils.makeFriendlyFilename(ejbDescriptor.getApplication().getRegistrationName());
            subDirName += "_" + FileUtils.makeFriendlyFilename(ejbDescriptor.getEjbBundleDescriptor().getName());
            subDirName += "_" + FileUtils.makeFriendlyFilename(ejbDescriptor.getName());
        }*/
    subDirName += ejbDescriptor.getName() + "-" + ejbDescriptor.getUniqueId();
    conf.setShortUniqueName("" + ejbDescriptor.getUniqueId()).setStoreName(storeName).setStoreType(persistenceStoreType).setBaseDirectory(new File(ejbContainerConfig.getSessionStore(), subDirName)).setKeyClazz(Serializable.class).setValueClazz(SimpleMetadata.class).setClassLoader(StatefulContainerFactory.class.getClassLoader());
    Map<String, Object> vendorMap = conf.getVendorSpecificSettings();
    vendorMap.put("local.caching", true);
    vendorMap.put("start.gms", false);
    vendorMap.put("async.replication", asyncReplication);
    vendorMap.put("broadcast.remove.expired", false);
    vendorMap.put("value.class.is.thread.safe", true);
    vendorMap.put("key.transformer", keyGen);
    if (hazelcast != null) {
        if (hazelcast.isEnabled()) {
            conf.setClusterName(hazelcast.getMemberGroup());
            conf.setInstanceName(hazelcast.getMemberName());
        }
    }
    BackingStoreFactory factory = null;
    try {
        factory = services.getService(BackingStoreFactory.class, persistenceStoreType);
    } catch (Exception ex) {
        _logger.log(Level.WARNING, SFSB_BUILDER_INSTANTIATE_BACKING_STORE_EXCEPTION, new Object[] { persistenceStoreType, ex });
    }
    try {
        if (factory == null) {
            factory = services.getService(BackingStoreFactory.class, "noop");
        }
        this.backingStore = factory.createBackingStore(conf);
    } catch (Exception ex) {
        _logger.log(Level.WARNING, SFSB_BUILDER_INSTANTIATE_BACKING_STORE_EXCEPTION, new Object[] { persistenceStoreType, ex });
        throw new BackingStoreException("Could not instantiate backing store for type [" + persistenceStoreType + "]", ex);
    }
    _logger.log(Level.INFO, SFSB_BUILDER_INSTANTIATED_BACKING_STORE, new Object[] { backingStore, HAEnabled, conf });
}
Also used : BackingStoreFactory(org.glassfish.ha.store.api.BackingStoreFactory) Serializable(java.io.Serializable) BackingStoreException(org.glassfish.ha.store.api.BackingStoreException) SimpleMetadata(org.glassfish.ha.store.util.SimpleMetadata) File(java.io.File) BackingStoreException(org.glassfish.ha.store.api.BackingStoreException) BackingStoreConfiguration(org.glassfish.ha.store.api.BackingStoreConfiguration)

Example 2 with BackingStoreFactory

use of org.glassfish.ha.store.api.BackingStoreFactory 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 3 with BackingStoreFactory

use of org.glassfish.ha.store.api.BackingStoreFactory in project Payara by payara.

the class HACNonceCacheImpl method postConstruct.

public void postConstruct() {
    localStore = new CNonceCacheImpl();
    try {
        final BackingStoreConfiguration<String, NonceInfo> bsConfig = new BackingStoreConfiguration<String, NonceInfo>();
        bsConfig.setClusterName(props.get(CNonceCacheFactory.CLUSTER_NAME_PROP)).setInstanceName(props.get(CNonceCacheFactory.INSTANCE_NAME_PROP)).setStoreName(storeName).setKeyClazz(String.class).setValueClazz(NonceInfo.class);
        BackingStoreFactory bsFactory = services.getService(BackingStoreFactory.class, BS_TYPE_REPLICATED);
        backingStore = bsFactory.createBackingStore(bsConfig);
    } catch (BackingStoreException ex) {
        logger.log(Level.WARNING, null, ex);
    }
}
Also used : BackingStoreFactory(org.glassfish.ha.store.api.BackingStoreFactory) NonceInfo(org.glassfish.security.common.NonceInfo) BackingStoreException(org.glassfish.ha.store.api.BackingStoreException) CNonceCacheImpl(com.sun.web.security.CNonceCacheImpl) BackingStoreConfiguration(org.glassfish.ha.store.api.BackingStoreConfiguration)

Example 4 with BackingStoreFactory

use of org.glassfish.ha.store.api.BackingStoreFactory 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)

Aggregations

BackingStoreConfiguration (org.glassfish.ha.store.api.BackingStoreConfiguration)4 BackingStoreException (org.glassfish.ha.store.api.BackingStoreException)4 BackingStoreFactory (org.glassfish.ha.store.api.BackingStoreFactory)4 HazelcastCore (fish.payara.nucleus.hazelcast.HazelcastCore)2 CNonceCacheImpl (com.sun.web.security.CNonceCacheImpl)1 File (java.io.File)1 Serializable (java.io.Serializable)1 GlassFishHAReplicaPredictor (org.glassfish.ha.common.GlassFishHAReplicaPredictor)1 NoopHAReplicaPredictor (org.glassfish.ha.common.NoopHAReplicaPredictor)1 SimpleMetadata (org.glassfish.ha.store.util.SimpleMetadata)1 NonceInfo (org.glassfish.security.common.NonceInfo)1