Search in sources :

Example 6 with BackingStoreException

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

the class HASingleSignOn method deregister.

@Override
protected void deregister(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
    SingleSignOnEntry sso = null;
    synchronized (cache) {
        sso = cache.remove(ssoId);
    }
    if (sso == null)
        return;
    // Expire any associated sessions
    sso.expireSessions();
    try {
        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 7 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 8 with BackingStoreException

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

the class AsynchronousTask method passivateBeansOnShutdown.

private void passivateBeansOnShutdown() {
    ClassLoader origLoader = Utility.setContextClassLoader(loader);
    try {
        _logger.log(Level.FINE, "Passivating SFSBs before container shutdown");
        if (!isPassivationCapable() && _logger.isLoggable(Level.INFO)) {
            _logger.log(Level.INFO, SFSB_NOT_RESTORED_AFTER_RESTART);
        }
        sessionBeanCache.shutdown();
        while (true) {
            ComponentContext ctx = null;
            synchronized (asyncTaskSemaphore) {
                int sz = passivationCandidates.size();
                if (sz > 0) {
                    ctx = (ComponentContext) passivationCandidates.remove(sz - 1);
                } else {
                    break;
                }
            }
            passivateEJB(ctx);
        }
        sessionBeanCache.destroy();
        cacheProbeListener.unregister();
        try {
            // backingStore will be null when passivation-capable is false
            if (backingStore != null) {
                backingStore.close();
            }
        } catch (BackingStoreException sfsbEx) {
            _logger.log(Level.WARNING, ERROR_DURING_BACKING_STORE_SHUTDOWN, new Object[] { ejbName, sfsbEx });
        }
    } catch (Throwable th) {
        _logger.log(Level.WARNING, ERROR_DURING_ON_SHUTDOWN, new Object[] { ejbName, th });
    } finally {
        Utility.setContextClassLoader(origLoader);
    }
}
Also used : ComponentContext(com.sun.ejb.ComponentContext) BackingStoreException(org.glassfish.ha.store.api.BackingStoreException) EJBObject(javax.ejb.EJBObject)

Example 9 with BackingStoreException

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

the class AsynchronousTask method activateEJB.

// called from StatefulSessionStore
public void activateEJB(Object sessionKey, StatefulEJBContext sfsbCtx, Object cookie) {
    SessionContextImpl context = (SessionContextImpl) sfsbCtx.getSessionContext();
    if (_logger.isLoggable(TRACE_LEVEL)) {
        logTraceInfo(context, "Attempting to activate");
    }
    EJBLocalRemoteObject ejbObject = (EJBLocalRemoteObject) cookie;
    Object ejb = context.getEJB();
    EjbInvocation ejbInv = createEjbInvocation(ejb, context);
    invocationManager.preInvoke(ejbInv);
    boolean needToDoPostInvokeTx = false;
    try {
        // we're sure that no concurrent thread can be using this bean
        // so no need to synchronize.
        // No need to call enlistComponentResources here because
        // ejbActivate executes in unspecified tx context (spec 6.6.1)
        // Set the timestamp here, else Recycler might remove this bean!
        context.touch();
        context.setContainer(this);
        context.setState(BeanState.READY);
        incrementMethodReadyStat();
        context.setInstanceKey(sessionKey);
        context.setExistsInStore(true);
        context.initializeStatefulWriteLock();
        if (ejbObject == null) {
            // This MUST be a remote invocation
            if (hasRemoteHomeView) {
                createEJBObjectImpl(context);
            } else {
                createRemoteBusinessObjectImpl(context);
            }
        } else if (ejbObject instanceof EJBObjectImpl) {
            EJBObjectImpl eo = (EJBObjectImpl) ejbObject;
            ejbObject.setContext(context);
            ejbObject.setKey(sessionKey);
            byte[] sessionOID = uuidGenerator.keyToByteArray(sessionKey);
            if (eo.isRemoteHomeView()) {
                // introduce context and EJBObject to each other
                context.setEJBObjectImpl(eo);
                EJBObject ejbStub = (EJBObject) remoteHomeRefFactory.createRemoteReference(sessionOID);
                eo.setStub(ejbStub);
                context.setEJBStub(ejbStub);
                if (hasRemoteBusinessView) {
                    createRemoteBusinessObjectImpl(context);
                }
            } else {
                context.setEJBRemoteBusinessObjectImpl(eo);
                for (RemoteBusinessIntfInfo next : remoteBusinessIntfInfo.values()) {
                    java.rmi.Remote stub = next.referenceFactory.createRemoteReference(sessionOID);
                    eo.setStub(next.generatedRemoteIntf.getName(), stub);
                }
                if (hasRemoteHomeView) {
                    createEJBObjectImpl(context);
                }
            }
            if (isLocal) {
                // create localObj too
                if (hasLocalHomeView) {
                    createEJBLocalObjectImpl(context);
                }
                if (hasLocalBusinessView) {
                    createEJBLocalBusinessObjectImpl(context);
                }
                if (hasOptionalLocalBusinessView) {
                    createOptionalEJBLocalBusinessObjectImpl(context);
                }
            }
        } else if (ejbObject instanceof EJBLocalObjectImpl) {
            EJBLocalObjectImpl elo = (EJBLocalObjectImpl) ejbObject;
            ejbObject.setContext(context);
            ejbObject.setKey(sessionKey);
            if (elo.isLocalHomeView()) {
                context.setEJBLocalObjectImpl(elo);
                if (hasLocalBusinessView) {
                    createEJBLocalBusinessObjectImpl(context);
                }
                if (hasOptionalLocalBusinessView) {
                    createOptionalEJBLocalBusinessObjectImpl(context);
                }
            } else if (elo.isOptionalLocalBusinessView()) {
                context.setOptionalEJBLocalBusinessObjectImpl(elo);
                if (hasLocalBusinessView) {
                    createEJBLocalBusinessObjectImpl(context);
                }
                if (hasLocalHomeView) {
                    createEJBLocalObjectImpl(context);
                }
            } else {
                context.setEJBLocalBusinessObjectImpl(elo);
                if (hasLocalHomeView) {
                    createEJBLocalObjectImpl(context);
                }
                if (hasOptionalLocalBusinessView) {
                    createOptionalEJBLocalBusinessObjectImpl(context);
                }
            }
            if (hasRemoteHomeView) {
                // create remote obj too
                createEJBObjectImpl(context);
            }
            if (hasRemoteBusinessView) {
                createRemoteBusinessObjectImpl(context);
            }
        }
        // Now populate the EEM maps in this context
        repopulateEEMMapsInContext(sessionKey, context);
        try {
            needToDoPostInvokeTx = callLifecycleCallbackInTxIfUsed(ejbInv, context, postActivateInvInfo, CallbackType.POST_ACTIVATE);
        } catch (Throwable th) {
            EJBException ejbEx = new EJBException("Error during activation" + sessionKey);
            ejbEx.initCause(th);
            throw ejbEx;
        }
        long now = System.currentTimeMillis();
        try {
            backingStore.updateTimestamp((Serializable) sessionKey, now);
            context.setLastPersistedAt(now);
        } catch (BackingStoreException sfsbEx) {
            _logger.log(Level.WARNING, COULDNT_UPDATE_TIMESTAMP_FOR_EXCEPTION, new Object[] { sessionKey, sfsbEx });
            _logger.log(Level.FINE, "Couldn't update timestamp for: " + sessionKey, sfsbEx);
        }
        if (_logger.isLoggable(TRACE_LEVEL)) {
            logTraceInfo(context, "Successfully activated");
        }
        _logger.log(Level.FINE, "Activated: " + sessionKey);
    } catch (Exception ex) {
        if (_logger.isLoggable(TRACE_LEVEL)) {
            logTraceInfo(context, "Failed to activate");
        }
        _logger.log(Level.SEVERE, SFSB_ACTIVATION_ERROR, new Object[] { sessionKey, ex });
        _logger.log(Level.SEVERE, "", ex);
        throw new EJBException("Unable to activate EJB for key: " + sessionKey, ex);
    } finally {
        invocationManager.postInvoke(ejbInv);
        completeLifecycleCallbackTxIfUsed(ejbInv, context, needToDoPostInvokeTx);
    }
}
Also used : BackingStoreException(org.glassfish.ha.store.api.BackingStoreException) IllegalLoopbackException(javax.ejb.IllegalLoopbackException) ConcurrentAccessException(javax.ejb.ConcurrentAccessException) RemoveException(javax.ejb.RemoveException) ConcurrentAccessTimeoutException(javax.ejb.ConcurrentAccessTimeoutException) InvocationTargetException(java.lang.reflect.InvocationTargetException) RemoteException(java.rmi.RemoteException) EJBException(javax.ejb.EJBException) BackingStoreException(org.glassfish.ha.store.api.BackingStoreException) IOException(java.io.IOException) NotSerializableException(java.io.NotSerializableException) SystemException(javax.transaction.SystemException) CreateException(javax.ejb.CreateException) NoSuchObjectLocalException(javax.ejb.NoSuchObjectLocalException) EjbInvocation(com.sun.ejb.EjbInvocation) EJBObject(javax.ejb.EJBObject) EJBObject(javax.ejb.EJBObject) EJBException(javax.ejb.EJBException)

Example 10 with BackingStoreException

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

the class AsynchronousTask method removeBeansOnUndeploy.

private void removeBeansOnUndeploy() {
    ClassLoader origLoader = Utility.setContextClassLoader(loader);
    long myContainerId = 0;
    try {
        myContainerId = getContainerId();
        _logger.log(Level.FINE, "Removing SFSBs during application undeploy");
        sessionBeanCache.setUndeployedState();
        Iterator iter = sessionBeanCache.values();
        while (iter.hasNext()) {
            SessionContextImpl ctx = (SessionContextImpl) iter.next();
            invokePreDestroyAndUndeploy(ctx);
        }
        while (true) {
            SessionContextImpl ctx = null;
            synchronized (asyncTaskSemaphore) {
                int sz = passivationCandidates.size();
                if (sz > 0) {
                    ctx = (SessionContextImpl) passivationCandidates.remove(sz - 1);
                    invokePreDestroyAndUndeploy(ctx);
                } else {
                    break;
                }
            }
        }
        sessionBeanCache.destroy();
        try {
            // backingStore will be null when passivation-capable is false
            if (backingStore != null) {
                backingStore.destroy();
            }
        } catch (BackingStoreException sfsbEx) {
            _logger.log(Level.WARNING, ERROR_DURING_BACKING_STORE_SHUTDOWN, new Object[] { ejbName, sfsbEx });
        }
    } finally {
        if (sfsbVersionManager != null) {
            sfsbVersionManager.removeAll(myContainerId);
        }
        if (origLoader != null) {
            Utility.setContextClassLoader(origLoader);
        }
    }
}
Also used : Iterator(java.util.Iterator) BackingStoreException(org.glassfish.ha.store.api.BackingStoreException) EJBObject(javax.ejb.EJBObject)

Aggregations

BackingStoreException (org.glassfish.ha.store.api.BackingStoreException)13 SimpleMetadata (org.glassfish.ha.store.util.SimpleMetadata)5 BackingStoreConfiguration (org.glassfish.ha.store.api.BackingStoreConfiguration)4 BackingStoreFactory (org.glassfish.ha.store.api.BackingStoreFactory)4 EJBObject (javax.ejb.EJBObject)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.web.security.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