org.apache.catalina.tribes.tipis.ReplicatedMap Java Examples

The following examples show how to use org.apache.catalina.tribes.tipis.ReplicatedMap. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ReplicatedContext.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
/**
 * Start this component and implement the requirements
 * of {@link org.apache.catalina.util.LifecycleBase#startInternal()}.
 *
 * @exception LifecycleException if this component detects a fatal error
 *  that prevents this component from being used
 */
@Override
protected synchronized void startInternal() throws LifecycleException {

    try {
        CatalinaCluster catclust = (CatalinaCluster)this.getCluster();
        if (this.context == null) this.context = new ReplApplContext(this);
        if ( catclust != null ) {
            ReplicatedMap<String,Object> map =
                    new ReplicatedMap<String,Object>(this,
                            catclust.getChannel(),DEFAULT_REPL_TIMEOUT,
                            getName(),getClassLoaders());
            map.setChannelSendOptions(mapSendOptions);
            ((ReplApplContext)this.context).setAttributeMap(map);
            if (getAltDDName() != null) context.setAttribute(Globals.ALT_DD_ATTR, getAltDDName());
        }
        super.startInternal();
    }  catch ( Exception x ) {
        log.error("Unable to start ReplicatedContext",x);
        throw new LifecycleException("Failed to start ReplicatedContext",x);
    }
}
 
Example #2
Source File: ReplicatedContext.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
/**
 * Start this component and implement the requirements
 * of {@link org.apache.catalina.util.LifecycleBase#startInternal()}.
 *
 * @exception LifecycleException if this component detects a fatal error
 *  that prevents this component from being used
 */
@Override
protected synchronized void startInternal() throws LifecycleException {
    super.startInternal();
    try {
        CatalinaCluster catclust = (CatalinaCluster)this.getCluster();
        if ( catclust != null ) {
            ReplicatedMap<String,Object> map = new ReplicatedMap<>(
                    this, catclust.getChannel(),DEFAULT_REPL_TIMEOUT,
                    getName(),getClassLoaders());
            map.setChannelSendOptions(mapSendOptions);
            ((ReplApplContext)this.context).setAttributeMap(map);
        }
    }  catch ( Exception x ) {
        log.error(sm.getString("replicatedContext.startUnable", getName()),x);
        throw new LifecycleException(sm.getString("replicatedContext.startFailed", getName()),x);
    }
}
 
Example #3
Source File: ReplicatedContext.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
/**
 * Start this component and implement the requirements
 * of {@link org.apache.catalina.util.LifecycleBase#startInternal()}.
 *
 * @exception LifecycleException if this component detects a fatal error
 *  that prevents this component from being used
 */
@Override
protected synchronized void startInternal() throws LifecycleException {

    try {
        CatalinaCluster catclust = (CatalinaCluster)this.getCluster();
        if (this.context == null) this.context = new ReplApplContext(this);
        if ( catclust != null ) {
            ReplicatedMap<String,Object> map =
                    new ReplicatedMap<String,Object>(this,
                            catclust.getChannel(),DEFAULT_REPL_TIMEOUT,
                            getName(),getClassLoaders());
            map.setChannelSendOptions(mapSendOptions);
            ((ReplApplContext)this.context).setAttributeMap(map);
            if (getAltDDName() != null) context.setAttribute(Globals.ALT_DD_ATTR, getAltDDName());
        }
        super.startInternal();
    }  catch ( Exception x ) {
        log.error("Unable to start ReplicatedContext",x);
        throw new LifecycleException("Failed to start ReplicatedContext",x);
    }
}
 
Example #4
Source File: ClusterSingleSignOn.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
/**
 * Stop this component and implement the requirements
 * of {@link org.apache.catalina.util.LifecycleBase#stopInternal()}.
 *
 * @exception LifecycleException if this component detects a fatal error
 *  that prevents this component from being used
 */
@Override
protected synchronized void stopInternal() throws LifecycleException {

    super.stopInternal();

    if (getCluster() != null) {
        ((ReplicatedMap<?,?>) cache).breakdown();
    }
}
 
Example #5
Source File: ReplicatedContext.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * Stop this component and implement the requirements
 * of {@link org.apache.catalina.util.LifecycleBase#stopInternal()}.
 *
 * @exception LifecycleException if this component detects a fatal error
 *  that prevents this component from being used
 */
@Override
protected synchronized void stopInternal() throws LifecycleException {

    Map<String, Object> map = ((ReplApplContext) this.context)
            .getAttributeMap();

    super.stopInternal();

    if ( map!=null && map instanceof ReplicatedMap) {
        ((ReplicatedMap<?, ?>) map).breakdown();
    }

}
 
Example #6
Source File: ClusterSingleSignOn.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * Stop this component and implement the requirements
 * of {@link org.apache.catalina.util.LifecycleBase#stopInternal()}.
 *
 * @exception LifecycleException if this component detects a fatal error
 *  that prevents this component from being used
 */
@Override
protected synchronized void stopInternal() throws LifecycleException {

    super.stopInternal();

    if (getCluster() != null) {
        ((ReplicatedMap<?,?>) cache).breakdown();
    }
}
 
Example #7
Source File: ClusterSingleSignOn.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * Start this component and implement the requirements
 * of {@link org.apache.catalina.util.LifecycleBase#startInternal()}.
 *
 * @exception LifecycleException if this component detects a fatal error
 *  that prevents this component from being used
 */
@Override
protected synchronized void startInternal() throws LifecycleException {
    
    // Load the cluster component, if any
    try {
        if(cluster == null) {
            Container host = getContainer();
            if(host instanceof Host) {
                if(host.getCluster() instanceof CatalinaCluster) {
                    setCluster((CatalinaCluster) host.getCluster());
                }
            }
        }
        if (cluster == null) {
            throw new LifecycleException(
                    "There is no Cluster for ClusterSingleSignOn");
        }

        ClassLoader[] cls = new ClassLoader[] { this.getClass().getClassLoader() };

        ReplicatedMap<String,SingleSignOnEntry> cache =
                new ReplicatedMap<String,SingleSignOnEntry>(
                this, cluster.getChannel(), rpcTimeout, cluster.getClusterName() + "-SSO-cache",
                cls, terminateOnStartFailure);
        cache.setChannelSendOptions(mapSendOptions);
        this.cache = cache;
    } catch (Throwable t) {
        ExceptionUtils.handleThrowable(t);
        throw new LifecycleException(
                "ClusterSingleSignOn exception during clusterLoad " + t);
    }

    super.startInternal();
}
 
Example #8
Source File: ClusterSingleSignOn.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean update(String ssoId, Principal principal, String authType,
        String username, String password) {
    boolean result = super.update(ssoId, principal, authType, username, password);
    if (result) {
        ((ReplicatedMap<String,SingleSignOnEntry>) cache).replicate(ssoId, true);
    }
    return result;
}
 
Example #9
Source File: ClusterSingleSignOn.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean associate(String ssoId, Session session) {
    boolean result = super.associate(ssoId, session);
    if (result) {
        ((ReplicatedMap<String,SingleSignOnEntry>) cache).replicate(ssoId, true);
    }
    return result;
}
 
Example #10
Source File: ReplicatedContext.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
/**
 * Stop this component and implement the requirements
 * of {@link org.apache.catalina.util.LifecycleBase#stopInternal()}.
 *
 * @exception LifecycleException if this component detects a fatal error
 *  that prevents this component from being used
 */
@Override
protected synchronized void stopInternal() throws LifecycleException {

    Map<String, Object> map = ((ReplApplContext) this.context)
            .getAttributeMap();

    super.stopInternal();

    if ( map!=null && map instanceof ReplicatedMap) {
        ((ReplicatedMap<?, ?>) map).breakdown();
    }

}
 
Example #11
Source File: ClusterSingleSignOn.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@Override
protected boolean associate(String ssoId, Session session) {
    boolean result = super.associate(ssoId, session);
    if (result) {
        ((ReplicatedMap<String,SingleSignOnEntry>) cache).replicate(ssoId, true);
    }
    return result;
}
 
Example #12
Source File: ClusterSingleSignOn.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
/**
 * Start this component and implement the requirements
 * of {@link org.apache.catalina.util.LifecycleBase#startInternal()}.
 *
 * @exception LifecycleException if this component detects a fatal error
 *  that prevents this component from being used
 */
@Override
protected synchronized void startInternal() throws LifecycleException {
    
    // Load the cluster component, if any
    try {
        if(cluster == null) {
            Container host = getContainer();
            if(host instanceof Host) {
                if(host.getCluster() instanceof CatalinaCluster) {
                    setCluster((CatalinaCluster) host.getCluster());
                }
            }
        }
        if (cluster == null) {
            throw new LifecycleException(
                    "There is no Cluster for ClusterSingleSignOn");
        }

        ClassLoader[] cls = new ClassLoader[] { this.getClass().getClassLoader() };

        ReplicatedMap<String,SingleSignOnEntry> cache =
                new ReplicatedMap<String,SingleSignOnEntry>(
                this, cluster.getChannel(), rpcTimeout, cluster.getClusterName() + "-SSO-cache",
                cls, terminateOnStartFailure);
        cache.setChannelSendOptions(mapSendOptions);
        this.cache = cache;
    } catch (Throwable t) {
        ExceptionUtils.handleThrowable(t);
        throw new LifecycleException(
                "ClusterSingleSignOn exception during clusterLoad " + t);
    }

    super.startInternal();
}
 
Example #13
Source File: ClusterSingleSignOn.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean update(String ssoId, Principal principal, String authType,
        String username, String password) {
    boolean result = super.update(ssoId, principal, authType, username, password);
    if (result) {
        ((ReplicatedMap<String,SingleSignOnEntry>) cache).replicate(ssoId, true);
    }
    return result;
}
 
Example #14
Source File: ClusterSingleSignOn.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean associate(String ssoId, Session session) {
    boolean result = super.associate(ssoId, session);
    if (result) {
        ((ReplicatedMap<String,SingleSignOnEntry>) cache).replicate(ssoId, true);
    }
    return result;
}
 
Example #15
Source File: ReplicatedContext.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 * Stop this component and implement the requirements
 * of {@link org.apache.catalina.util.LifecycleBase#stopInternal()}.
 *
 * @exception LifecycleException if this component detects a fatal error
 *  that prevents this component from being used
 */
@Override
protected synchronized void stopInternal() throws LifecycleException {

    Map<String, Object> map = ((ReplApplContext) this.context)
            .getAttributeMap();

    super.stopInternal();

    if (map instanceof ReplicatedMap) {
        ((ReplicatedMap<?, ?>) map).breakdown();
    }

}
 
Example #16
Source File: ClusterSingleSignOn.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 * Stop this component and implement the requirements
 * of {@link org.apache.catalina.util.LifecycleBase#stopInternal()}.
 *
 * @exception LifecycleException if this component detects a fatal error
 *  that prevents this component from being used
 */
@Override
protected synchronized void stopInternal() throws LifecycleException {

    super.stopInternal();

    if (getCluster() != null) {
        ((ReplicatedMap<?,?>) cache).breakdown();
    }
}
 
Example #17
Source File: ClusterSingleSignOn.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 * Start this component and implement the requirements
 * of {@link org.apache.catalina.util.LifecycleBase#startInternal()}.
 *
 * @exception LifecycleException if this component detects a fatal error
 *  that prevents this component from being used
 */
@Override
protected synchronized void startInternal() throws LifecycleException {

    // Load the cluster component, if any
    try {
        if(cluster == null) {
            Container host = getContainer();
            if(host instanceof Host) {
                if(host.getCluster() instanceof CatalinaCluster) {
                    setCluster((CatalinaCluster) host.getCluster());
                }
            }
        }
        if (cluster == null) {
            throw new LifecycleException(sm.getString("clusterSingleSignOn.nocluster"));
        }

        ClassLoader[] cls = new ClassLoader[] { this.getClass().getClassLoader() };

        ReplicatedMap<String,SingleSignOnEntry> cache = new ReplicatedMap<>(
                this, cluster.getChannel(), rpcTimeout, cluster.getClusterName() + "-SSO-cache",
                cls, terminateOnStartFailure);
        cache.setChannelSendOptions(mapSendOptions);
        cache.setAccessTimeout(accessTimeout);
        this.cache = cache;
    } catch (Throwable t) {
        ExceptionUtils.handleThrowable(t);
        throw new LifecycleException(sm.getString("clusterSingleSignOn.clusterLoad.fail"), t);
    }

    super.startInternal();
}
 
Example #18
Source File: ClusterSingleSignOn.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
@Override
protected boolean update(String ssoId, Principal principal, String authType,
        String username, String password) {
    boolean result = super.update(ssoId, principal, authType, username, password);
    if (result) {
        ((ReplicatedMap<String,SingleSignOnEntry>) cache).replicate(ssoId, true);
    }
    return result;
}