Search in sources :

Example 1 with UnwriteableSessionDataException

use of org.eclipse.jetty.server.session.UnwriteableSessionDataException in project jetty.project by eclipse.

the class GCloudSessionDataStore method doStore.

/** 
     * @see org.eclipse.jetty.server.session.AbstractSessionDataStore#doStore(java.lang.String, org.eclipse.jetty.server.session.SessionData, long)
     */
@Override
public void doStore(String id, SessionData data, long lastSaveTime) throws Exception {
    if (LOG.isDebugEnabled())
        LOG.debug("Writing session {} to DataStore", data.getId());
    Entity entity = entityFromSession(data, makeKey(id, _context));
    //attempt the update with exponential back-off
    int backoff = getBackoffMs();
    int attempts;
    for (attempts = 0; attempts < getMaxRetries(); attempts++) {
        try {
            _datastore.put(entity);
            return;
        } catch (DatastoreException e) {
            if (e.isRetryable()) {
                if (LOG.isDebugEnabled())
                    LOG.debug("Datastore put retry {} waiting {}ms", attempts, backoff);
                try {
                    Thread.currentThread().sleep(backoff);
                } catch (InterruptedException x) {
                }
                backoff *= 2;
            } else {
                throw e;
            }
        }
    }
    //retries have been exceeded
    throw new UnwriteableSessionDataException(id, _context, null);
}
Also used : Entity(com.google.cloud.datastore.Entity) ProjectionEntity(com.google.cloud.datastore.ProjectionEntity) DatastoreException(com.google.cloud.datastore.DatastoreException) UnwriteableSessionDataException(org.eclipse.jetty.server.session.UnwriteableSessionDataException)

Aggregations

DatastoreException (com.google.cloud.datastore.DatastoreException)1 Entity (com.google.cloud.datastore.Entity)1 ProjectionEntity (com.google.cloud.datastore.ProjectionEntity)1 UnwriteableSessionDataException (org.eclipse.jetty.server.session.UnwriteableSessionDataException)1