Examples of IElementAttributes


Examples of org.apache.jcs.engine.behavior.IElementAttributes

        disk.doRemoveAll();

        int cnt = 25;
        for ( int i = 0; i < cnt; i++ )
        {
            IElementAttributes eAttr = new ElementAttributes();
            eAttr.setIsSpool( true );
            ICacheElement element = new CacheElement( cattr.getCacheName(), "key:" + i, "data:" + i );
            element.setElementAttributes( eAttr );
            disk.doUpdate( element );
        }

        long preAddRemoveSize = disk.getDataFileSize();

        IElementAttributes eAttr = new ElementAttributes();
        eAttr.setIsSpool( true );
        ICacheElement elementSetup = new CacheElement( cattr.getCacheName(), "key:" + "A", "data:" + "A" );
        elementSetup.setElementAttributes( eAttr );
        disk.doUpdate( elementSetup );

        ICacheElement elementRet = disk.doGet( "key:" + "A" );
View Full Code Here

Examples of org.apache.jcs.engine.behavior.IElementAttributes

                log.debug( "Keys size: " + size );
            }

            Serializable key;
            ICacheElement cacheElement;
            IElementAttributes attributes;

            int spoolCount = 0;

            for ( int i = 0; i < size; i++ )
            {
                key = (Serializable) keys[i];
                cacheElement = cache.getQuiet( key );

                if ( cacheElement == null )
                {
                    continue;
                }

                attributes = cacheElement.getElementAttributes();

                boolean remove = false;

                long now = System.currentTimeMillis();

                // Useful, but overkill even for DEBUG since it is written for
                // every element in memory
                //
                // if ( log.isDebugEnabled() )
                // {
                // log.debug( "IsEternal: " + attributes.getIsEternal() );
                // log.debug( "MaxLifeSeconds: "
                // + attributes.getMaxLifeSeconds() );
                // log.debug( "CreateTime:" + attributes.getCreateTime() );
                // }

                // If the element is not eternal, check if it should be
                // removed and remove it if so.

                if ( !cacheElement.getElementAttributes().getIsEternal() )
                {
                    remove = checkForRemoval( cacheElement, now );

                    if ( remove )
                    {
                        cache.remove( cacheElement.getKey() );
                    }
                }

                // If the item is not removed, check is it has been idle
                // long enough to be spooled.

                if ( !remove && ( maxMemoryIdleTime != -1 ) )
                {
                    if ( !spoolLimit || ( spoolCount < this.maxSpoolPerRun ) )
                    {

                        final long lastAccessTime = attributes.getLastAccessTime();

                        if ( lastAccessTime + maxMemoryIdleTime < now )
                        {
                            if ( log.isDebugEnabled() )
                            {
View Full Code Here

Examples of org.apache.jcs.engine.behavior.IElementAttributes

     * @throws IOException
     */
    private boolean checkForRemoval( ICacheElement cacheElement, long now )
        throws IOException
    {
        IElementAttributes attributes = cacheElement.getElementAttributes();

        final long maxLifeSeconds = attributes.getMaxLifeSeconds();
        final long createTime = attributes.getCreateTime();

        // Check if maxLifeSeconds has been exceeded
        if ( maxLifeSeconds != -1 && now - createTime > maxLifeSeconds * 1000 )
        {
            if ( log.isInfoEnabled() )
            {
                log.info( "Exceeded maxLifeSeconds: " + cacheElement.getKey() );
            }

            handleElementEvents( cacheElement, IElementEventConstants.ELEMENT_EVENT_EXCEEDED_MAXLIFE_BACKGROUND );

            return true;
        }

        final long idleTime = attributes.getIdleTime();
        final long lastAccessTime = attributes.getLastAccessTime();

        // Check maxIdleTime has been exceeded
        if ( idleTime != -1 && now - lastAccessTime > idleTime * 1000 )
        {
            if ( log.isInfoEnabled() )
View Full Code Here

Examples of org.apache.jcs.engine.behavior.IElementAttributes

     *             If an error occurs
     */
    private void handleElementEvents( ICacheElement cacheElement, int eventType )
        throws IOException
    {
        IElementAttributes attributes = cacheElement.getElementAttributes();

        ArrayList eventHandlers = attributes.getElementEventHandlers();

        if ( eventHandlers != null )
        {
            if ( log.isDebugEnabled() )
            {
View Full Code Here

Examples of org.apache.jcs.engine.behavior.IElementAttributes

     *
     * @param props
     */
    protected void setDefaultElementAttributes( Properties props )
    {
        IElementAttributes iea = parseElementAttributes( props, "", CompositeCacheConfigurator.DEFAULT_REGION );
        compositeCacheManager.setDefaultElementAttributes( iea );

        log.info( "setting defaultElementAttributes to " + iea );
    }
View Full Code Here

Examples of org.apache.stratum.jcs.engine.behavior.IElementAttributes

    }

    /** Set the default ElementAttributes for new caches. */
    protected void setDefaultElementAttributes( Properties props )
    {
        IElementAttributes iea =
            parseElementAttributes( props, "", this.DEFAULT_REGION );
        ccMgr.setDefaultElementAttributes( iea );

        log.info( "setting defaultElementAttributes to " + iea );
    }
View Full Code Here

Examples of org.apache.stratum.jcs.engine.behavior.IElementAttributes

        if ( cca == null )
        {
            cca = parseCompositeCacheAttributes( props, regName, regionPrefix );
        }

        IElementAttributes ea = parseElementAttributes( props, regName, regionPrefix );


        ICache cache = null;
        if ( regionPrefix.equals( SYSTEM_REGION_PREFIX ) )
        {
View Full Code Here

Examples of org.apache.stratum.jcs.engine.behavior.IElementAttributes

    protected IElementAttributes
        parseElementAttributes( Properties props,
                                       String regName,
                                       String regionPrefix )
    {
        IElementAttributes eAttr;

        String attrName = regionPrefix + regName + this.ELEMENT_ATTRIBUTE_PREFIX;

        // auxFactory was not previously initialized.
        //String prefix = regionPrefix + regName + ATTRIBUTE_PREFIX;
        eAttr = ( IElementAttributes ) OptionConverter.instantiateByKey( props, attrName,
            org.apache.stratum.jcs.engine.behavior.IElementAttributes.class,
            null );
        if ( eAttr == null )
        {
            log.warn( "Could not instantiate eAttr named '" + attrName +
                "', using defaults." );

            IElementAttributes eAttr2 = ccMgr.getDefaultElementAttributes();
            eAttr = eAttr2.copy();
        }

        log.debug( "Parsing options for '" + attrName + "'" );

        PropertySetter.setProperties( eAttr, props, attrName + "." );
View Full Code Here

Examples of org.apache.stratum.jcs.engine.behavior.IElementAttributes

     * @return The Element Attributes for the group
     */
    public IElementAttributes getGroupAttributes( Object name )
        throws CacheException
    {
        IElementAttributes attr = null;
        try
        {
            attr = cacheControl.getElementAttributes( ( Serializable ) name );
        }
        catch ( Exception ioe )
View Full Code Here

Examples of org.apache.stratum.jcs.engine.behavior.IElementAttributes

     * @exception CacheException
     */
    public IElementAttributes getElementAttributes( Object name )
        throws CacheException
    {
        IElementAttributes attr = null;

        try
        {
            attr = cacheControl.getElementAttributes( ( Serializable ) name );
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.