Examples of ISerializableSession


Examples of org.eclipse.jetty.nosql.kvs.session.ISerializableSession

    return raw;
  }

  @Override
  public ISerializableSession unpack(byte[] raw, ISerializationTranscoder tc) throws TranscoderException {
    ISerializableSession session = null;
    try {
      session = tc.decode(raw, KryoSession.class);
    } catch (Exception error) {
      throw(new TranscoderException(error));
    }
View Full Code Here

Examples of org.eclipse.jetty.nosql.kvs.session.ISerializableSession

    return raw;
  }

  @Override
  public ISerializableSession unpack(byte[] raw, ISerializationTranscoder tc) throws TranscoderException {
    ISerializableSession session = null;
    try {
      session = tc.decode(raw, XStreamSession.class);
    } catch (Exception error) {
      throw(new TranscoderException(error));
    }
View Full Code Here

Examples of org.eclipse.jetty.nosql.kvs.session.ISerializableSession

    return raw;
  }

  @Override
  public ISerializableSession unpack(byte[] raw, ISerializationTranscoder tc) {
    ISerializableSession session = null;
    try {
      session = tc.decode(raw, SerializableSession.class);
    } catch (Exception error) {
      throw(new TranscoderException(error));
    }
View Full Code Here

Examples of org.eclipse.jetty.nosql.kvs.session.ISerializableSession

                log.debug("save: skip saving invalidated session: id=" + session.getId());
                deleteKey(session.getId());
                return null;
            }

            ISerializableSession data;
            synchronized (session)
            {
                data = getSessionFactory().create(session);
            }
            data.setDomain(_cookieDomain);
            data.setPath(_cookiePath);
            long longVersion = 1; // default version for new sessions
            if (version != null)
            {
                longVersion = (Long) version + 1L;
            }
            data.setVersion(longVersion);

            try
            {
                if (!setKey(session.getId(), data))
                {
View Full Code Here

Examples of org.eclipse.jetty.nosql.kvs.session.ISerializableSession

    /*------------------------------------------------------------ */
    @Override
    protected Object refresh(final NoSqlSession session, Object version)
    {
        log.debug("refresh " + session);
        ISerializableSession data = null;
        try
        {
            data = getKey(session.getClusterId());
        }
        catch (TranscoderException error)
        {
            throw (new IllegalStateException("unable to deserialize session: id=" + session.getClusterId(), error));
        }
        // check if our in memory version is the same as what is on KVS
        if (version != null)
        {
            long saved = 0;
            if (data != null)
            {
                saved = data.getVersion();

                if (saved == (Long) version)
                {
                    log.debug("refresh not needed");
                    return version;
                }
                version = Long.valueOf(saved);
            }
        }

        // If it doesn't exist, invalidate
        if (data == null)
        {
            log.debug("refresh:marking invalid, no object");
            session.invalidate();
            return null;
        }

        // If it has been flagged invalid, invalidate
        boolean valid = data.isValid();
        if (!valid)
        {
            log.debug("refresh:marking invalid, valid flag " + valid);
            session.invalidate();
            return null;
        }

        // We need to update the attributes. We will model this as a passivate,
        // followed by bindings and then activation.
        session.willPassivate();
        try
        {
            for (Enumeration<String> e = data.getAttributeNames(); e.hasMoreElements();)
            {
                String name = e.nextElement();
                Object value = data.getAttribute(name);
                // only bind value if it didn't exist in session
                if (!session.getNames().contains(name))
                {
                    session.doPutOrRemove(name, value);
                    session.bindValue(name, value);
                }
                else
                {
                    session.doPutOrRemove(name, value);
                }
            }

            // cleanup, remove values from session, that don't exist in data anymore:
            for (String name : session.getNames())
            {
                if (!data.getAttributeMap().containsKey(name))
                {
                    session.doPutOrRemove(name, null);
                    session.unbindValue(name, session.getAttribute(name));
                }
            }
View Full Code Here

Examples of org.eclipse.jetty.nosql.kvs.session.ISerializableSession

    /*------------------------------------------------------------ */
    @Override
    protected NoSqlSession loadSession(final String clusterId)
    {
        log.debug("loadSession: loading: id=" + clusterId);
        ISerializableSession data = getKey(clusterId);
        log.debug("loadSession: loaded: id=" + clusterId + ", data=" + data);

        if (data == null)
        {
            return null;
        }

        boolean valid = data.isValid();
        if (!valid)
        {
            log.debug("loadSession: id=" + clusterId + ", data=" + data + " has been invalidated.");
            return null;
        }

        if (!clusterId.equals(data.getId()))
        {
            log.warn("loadSession: invalid id (expected:" + clusterId + ", got:" + data.getId() + ")");
            return null;
        }

        synchronized (_cookieDomain)
        {
            if (_cookieDomain != null && !data.getDomain().equals("*") && !_cookieDomain.equals(data.getDomain()))
            {
                log.warn("loadSession: invalid cookie domain (expected:" + _cookieDomain + ", got:" + data.getDomain()
                    + ")");
                return null;
            }
        }

        synchronized (_cookiePath)
        {
            if (_cookiePath != null && !data.getPath().equals("*") && !_cookiePath.equals(data.getPath()))
            {
                log.warn("loadSession: invalid cookie path (expected:" + _cookiePath + ", got:" + data.getPath() + ")");
                return null;
            }
        }

        try
        {
            long version = data.getVersion();
            long created = data.getCreationTime();
            long accessed = data.getAccessed();
            SmarterNoSqlSession session = new SmarterNoSqlSession(this, created, accessed, clusterId, version);

            // get the attributes for the context
            Enumeration<String> attrs = data.getAttributeNames();

            //      log.debug("attrs: " + Collections.list(attrs));
            if (attrs != null)
            {
                while (attrs.hasMoreElements())
                {
                    String name = attrs.nextElement();
                    Object value = data.getAttribute(name);

                    session.initializeAttribute(name, value);
                    session.bindValue(name, value);

                }
View Full Code Here

Examples of org.eclipse.jetty.nosql.kvs.session.ISerializableSession

    @Override
    protected void update(final NoSqlSession session, final String newClusterId, final String newNodeId)
        throws Exception
    {
        ISerializableSession data = getKey(session.getClusterId());
        if (data == null)
        {
            log.warn("Couldn't get session data for old key {}", session.getClusterId());
            return;
        }
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.