@Override public Void call() throws Exception { final BackupResult backupResult = _result.get(); if (_pingSessionIfBackupWasSkipped) { if (backupResult.getStatus() == BackupResultStatus.SKIPPED) { pingSession(_session, _backupSessionService); } } /* * For non-sticky sessions we store a backup of the session in a secondary memcached node (under a special key * that's resolved by the SuffixBasedNodeLocator), but only when we have more than 1 memcached node configured... */ if (_storeSecondaryBackup) { try { if (_log.isDebugEnabled()) { _log.debug( "Storing backup in secondary memcached for non-sticky session " + _session.getId()); } if (backupResult.getStatus() == BackupResultStatus.SKIPPED) { pingSessionBackup(_session); } else { saveSessionBackupFromResult(backupResult); } saveValidityBackup(); } catch (final RuntimeException e) { _log.info("Could not store secondary backup of session " + _session.getIdInternal(), e); } } return null; }
public void saveSessionBackupFromResult(final BackupResult backupResult) { final byte[] data = backupResult.getData(); if (data != null) { final String key = _sessionIdFormat.createBackupKey(_session.getId()); _memcached.set( key, toMemcachedExpiration(_session.getMemcachedExpirationTimeToSet()), data); } else { _log.warn( "No data set for backupResultStatus " + backupResult.getStatus() + " for sessionId " + _session.getIdInternal() + ", skipping backup" + " of non-sticky session in secondary memcached."); } }