Search in sources :

Example 1 with BackingStoreException

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

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

the class HASingleSignOn method lookup.

@Override
protected SingleSignOnEntry lookup(final String ssoId, final long ssoVersion) {
    SingleSignOnEntry ssoEntry = super.lookup(ssoId, ssoVersion);
    if (ssoEntry != null && ssoVersion > ssoEntry.getVersion()) {
        // clean the old cache
        this.cache.remove(ssoId);
        ssoEntry = null;
    }
    if (ssoEntry == null) {
        // load from ha store
        try {
            final HASingleSignOnEntryMetadata mdata = this.ssoEntryMetadataBackingStore.load(ssoId, null);
            if (mdata != null) {
                ssoEntry = new HASingleSignOnEntry(getContainer(), mdata, ioUtils);
                this.cache.put(ssoId, ssoEntry);
            }
        } catch (BackingStoreException ex) {
            throw new IllegalStateException(ex);
        }
    }
    return ssoEntry;
}
Also used : SingleSignOnEntry(org.apache.catalina.authenticator.SingleSignOnEntry) BackingStoreException(org.glassfish.ha.store.api.BackingStoreException)

Example 3 with BackingStoreException

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

the class HASingleSignOn method deregister.

@Override
protected void deregister(final String ssoId) {
    // S1AS8 6155481 START
    if (logger.isLoggable(Level.FINE)) {
        logger.fine("Deregistering sso id '" + ssoId + "'");
    }
    // S1AS8 6155481 END
    // Look up and remove the corresponding SingleSignOnEntry
    final SingleSignOnEntry sso = this.cache.remove(ssoId);
    if (sso == null) {
        return;
    }
    // Expire any associated sessions
    sso.expireSessions();
    try {
        this.ssoEntryMetadataBackingStore.remove(ssoId);
    } catch (BackingStoreException ex) {
        throw new IllegalStateException(ex);
    }
// NOTE:  Clients may still possess the old single sign on cookie,
// but it will be removed on the next request since it is no longer
// in the cache
}
Also used : SingleSignOnEntry(org.apache.catalina.authenticator.SingleSignOnEntry) BackingStoreException(org.glassfish.ha.store.api.BackingStoreException)

Example 4 with BackingStoreException

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

the class ReplicationStore method doValveSave.

/**
 * Save the specified Session into this Store.  Any previously saved
 * information for the associated session identifier is replaced.
 *
 * @param session Session to be saved
 *
 * @exception IOException if an input/output error occurs
 */
public void doValveSave(Session session) throws IOException {
    if (_logger.isLoggable(Level.FINE)) {
        if (session instanceof HASession) {
            _logger.fine("ReplicationStore>>doValveSave:id =" + ((HASession) session).getIdInternal());
        }
        _logger.fine("ReplicationStore>>doValveSave:valid =" + session.getIsValid());
    }
    // begin 6470831 do not save if session is not valid
    if (!session.getIsValid()) {
        return;
    }
    if (!(session instanceof BaseHASession)) {
        return;
    }
    // end 6470831
    String userName = "";
    if (session.getPrincipal() != null) {
        userName = session.getPrincipal().getName();
        ((BaseHASession) session).setUserName(userName);
    }
    byte[] sessionState = this.getByteArray(session, isReplicationCompressionEnabled());
    if (_logger.isLoggable(Level.FINEST)) {
        _logger.finest("ReplicationStore->Byte array to save");
        StringBuilder sb = new StringBuilder("Session data{");
        for (byte b : sessionState) {
            sb.append(b + "_");
        }
        sb.append("}");
        _logger.finest(sb.toString());
    }
    SimpleMetadata simpleMetadata = // version
    SimpleMetadataFactory.createSimpleMetadata(// version
    session.getVersion(), // lastaccesstime
    session.getLastAccessedTime(), // maxinactiveinterval
    session.getMaxInactiveInterval() * 1000L, // state
    sessionState);
    if (_logger.isLoggable(Level.FINEST)) {
        _logger.finest("In doValveSave metadata is " + simpleMetadata);
    }
    try {
        BackingStore<String, SimpleMetadata> replicator = getSimpleMetadataBackingStore();
        if (_logger.isLoggable(Level.FINE)) {
            _logger.fine("ReplicationStore>>doValveSave replicator: " + replicator);
            _logger.fine("ReplicationStore>>doValveSave version:" + session.getVersion());
        }
        HASession haSess = (HASession) session;
        // id
        replicator.save(// id
        session.getIdInternal(), simpleMetadata, haSess.isPersistent());
        if (_logger.isLoggable(Level.FINE)) {
            _logger.fine("Save succeeded.");
        }
    } catch (BackingStoreException ex) {
        throw new IOException("Error during save: " + ex.getMessage(), ex);
    }
}
Also used : BackingStoreException(org.glassfish.ha.store.api.BackingStoreException) SimpleMetadata(org.glassfish.ha.store.util.SimpleMetadata)

Example 5 with BackingStoreException

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

Aggregations

BackingStoreException (org.glassfish.ha.store.api.BackingStoreException)15 SimpleMetadata (org.glassfish.ha.store.util.SimpleMetadata)5 BackingStoreConfiguration (org.glassfish.ha.store.api.BackingStoreConfiguration)4 EJBObject (javax.ejb.EJBObject)3 BackingStoreFactory (org.glassfish.ha.store.api.BackingStoreFactory)3 HazelcastCore (fish.payara.nucleus.hazelcast.HazelcastCore)2 Serializable (java.io.Serializable)2 SingleSignOnEntry (org.apache.catalina.authenticator.SingleSignOnEntry)2 ComponentContext (com.sun.ejb.ComponentContext)1 EjbInvocation (com.sun.ejb.EjbInvocation)1 CNonceCacheImpl (com.sun.enterprise.security.auth.digest.impl.CNonceCacheImpl)1 File (java.io.File)1 IOException (java.io.IOException)1 NotSerializableException (java.io.NotSerializableException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 RemoteException (java.rmi.RemoteException)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 ConcurrentAccessException (javax.ejb.ConcurrentAccessException)1 ConcurrentAccessTimeoutException (javax.ejb.ConcurrentAccessTimeoutException)1