use of org.glassfish.ha.store.api.BackingStoreException in project Payara by payara.
the class HASSOFactory method getSsoEntryMetadataBackingStore.
protected static synchronized BackingStore<String, HASingleSignOnEntryMetadata> getSsoEntryMetadataBackingStore(String persistenceType, String storeName, ServiceLocator services) {
if (ssoEntryMetadataBackingStore == null) {
BackingStoreFactory factory = services.getService(BackingStoreFactory.class, persistenceType);
BackingStoreConfiguration<String, HASingleSignOnEntryMetadata> conf = new BackingStoreConfiguration<String, HASingleSignOnEntryMetadata>();
String clusterName = "";
String instanceName = "";
HazelcastCore hazelcast = services.getService(HazelcastCore.class);
if (hazelcast.isEnabled()) {
clusterName = hazelcast.getMemberGroup();
instanceName = hazelcast.getMemberName();
}
conf.setStoreName(storeName).setClusterName(clusterName).setInstanceName(instanceName).setStoreType(persistenceType).setKeyClazz(String.class).setValueClazz(HASingleSignOnEntryMetadata.class);
try {
ssoEntryMetadataBackingStore = factory.createBackingStore(conf);
} catch (BackingStoreException e) {
e.printStackTrace();
}
}
return ssoEntryMetadataBackingStore;
}
use of org.glassfish.ha.store.api.BackingStoreException in project Payara by payara.
the class HASingleSignOn method lookup.
@Override
protected SingleSignOnEntry lookup(final String ssoId, final long ssoVersion) {
SingleSignOnEntry ssoEntry = super.lookup(ssoId, ssoVersion);
if (ssoEntry != null && ssoVersion > ssoEntry.getVersion()) {
// clean the old cache
this.cache.remove(ssoId);
ssoEntry = null;
}
if (ssoEntry == null) {
// load from ha store
try {
final HASingleSignOnEntryMetadata mdata = this.ssoEntryMetadataBackingStore.load(ssoId, null);
if (mdata != null) {
ssoEntry = new HASingleSignOnEntry(getContainer(), mdata, ioUtils);
this.cache.put(ssoId, ssoEntry);
}
} catch (BackingStoreException ex) {
throw new IllegalStateException(ex);
}
}
return ssoEntry;
}
use of org.glassfish.ha.store.api.BackingStoreException in project Payara by payara.
the class HASingleSignOn method deregister.
@Override
protected void deregister(final String ssoId) {
// S1AS8 6155481 START
if (logger.isLoggable(Level.FINE)) {
logger.fine("Deregistering sso id '" + ssoId + "'");
}
// S1AS8 6155481 END
// Look up and remove the corresponding SingleSignOnEntry
final SingleSignOnEntry sso = this.cache.remove(ssoId);
if (sso == null) {
return;
}
// Expire any associated sessions
sso.expireSessions();
try {
this.ssoEntryMetadataBackingStore.remove(ssoId);
} catch (BackingStoreException ex) {
throw new IllegalStateException(ex);
}
// NOTE: Clients may still possess the old single sign on cookie,
// but it will be removed on the next request since it is no longer
// in the cache
}
use of org.glassfish.ha.store.api.BackingStoreException in project Payara by payara.
the class ReplicationStore method doValveSave.
/**
* Save the specified Session into this Store. Any previously saved
* information for the associated session identifier is replaced.
*
* @param session Session to be saved
*
* @exception IOException if an input/output error occurs
*/
public void doValveSave(Session session) throws IOException {
if (_logger.isLoggable(Level.FINE)) {
if (session instanceof HASession) {
_logger.fine("ReplicationStore>>doValveSave:id =" + ((HASession) session).getIdInternal());
}
_logger.fine("ReplicationStore>>doValveSave:valid =" + session.getIsValid());
}
// begin 6470831 do not save if session is not valid
if (!session.getIsValid()) {
return;
}
if (!(session instanceof BaseHASession)) {
return;
}
// end 6470831
String userName = "";
if (session.getPrincipal() != null) {
userName = session.getPrincipal().getName();
((BaseHASession) session).setUserName(userName);
}
byte[] sessionState = this.getByteArray(session, isReplicationCompressionEnabled());
if (_logger.isLoggable(Level.FINEST)) {
_logger.finest("ReplicationStore->Byte array to save");
StringBuilder sb = new StringBuilder("Session data{");
for (byte b : sessionState) {
sb.append(b + "_");
}
sb.append("}");
_logger.finest(sb.toString());
}
SimpleMetadata simpleMetadata = // version
SimpleMetadataFactory.createSimpleMetadata(// version
session.getVersion(), // lastaccesstime
session.getLastAccessedTime(), // maxinactiveinterval
session.getMaxInactiveInterval() * 1000L, // state
sessionState);
if (_logger.isLoggable(Level.FINEST)) {
_logger.finest("In doValveSave metadata is " + simpleMetadata);
}
try {
BackingStore<String, SimpleMetadata> replicator = getSimpleMetadataBackingStore();
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("ReplicationStore>>doValveSave replicator: " + replicator);
_logger.fine("ReplicationStore>>doValveSave version:" + session.getVersion());
}
HASession haSess = (HASession) session;
// id
replicator.save(// id
session.getIdInternal(), simpleMetadata, haSess.isPersistent());
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("Save succeeded.");
}
} catch (BackingStoreException ex) {
throw new IOException("Error during save: " + ex.getMessage(), ex);
}
}
use of org.glassfish.ha.store.api.BackingStoreException in project Payara by payara.
the class ExpiredSessionsRemovalTask method buildStoreManager.
private void buildStoreManager() throws BackingStoreException {
String persistenceStoreType = "file";
if (ejbAvailability != null) {
persistenceStoreType = HAEnabled ? ejbAvailability.getSfsbHaPersistenceType() : ejbAvailability.getSfsbPersistenceType();
if ("ha".equals(persistenceStoreType)) {
persistenceStoreType = "replicated";
} else if ("memory".equals(persistenceStoreType)) {
persistenceStoreType = "file";
}
}
BackingStoreConfiguration<Serializable, SimpleMetadata> conf = new BackingStoreConfiguration<Serializable, SimpleMetadata>();
String storeName = ejbDescriptor.getName() + "-" + ejbDescriptor.getUniqueId() + "-BackingStore";
_logger.log(Level.FINE, SFSB_BUILDER_STORE_NAME, storeName);
String subDirName = "";
/* if (ejbDescriptor.getApplication().isVirtual()) {
String archURI = ejbDescriptor.getEjbBundleDescriptor().
getModuleDescriptor().getArchiveUri();
subDirName += FileUtils.makeFriendlyFilename(archURI);
subDirName += "_" + FileUtils.makeFriendlyFilename(ejbDescriptor.getName());
} else {
subDirName += FileUtils.makeFriendlyFilename(ejbDescriptor.getApplication().getRegistrationName());
subDirName += "_" + FileUtils.makeFriendlyFilename(ejbDescriptor.getEjbBundleDescriptor().getName());
subDirName += "_" + FileUtils.makeFriendlyFilename(ejbDescriptor.getName());
}*/
subDirName += ejbDescriptor.getName() + "-" + ejbDescriptor.getUniqueId();
conf.setShortUniqueName("" + ejbDescriptor.getUniqueId()).setStoreName(storeName).setStoreType(persistenceStoreType).setBaseDirectory(new File(ejbContainerConfig.getSessionStore(), subDirName)).setKeyClazz(Serializable.class).setValueClazz(SimpleMetadata.class).setClassLoader(StatefulContainerFactory.class.getClassLoader());
Map<String, Object> vendorMap = conf.getVendorSpecificSettings();
vendorMap.put("local.caching", true);
vendorMap.put("start.gms", false);
vendorMap.put("async.replication", asyncReplication);
vendorMap.put("broadcast.remove.expired", false);
vendorMap.put("value.class.is.thread.safe", true);
vendorMap.put("key.transformer", keyGen);
if (hazelcast != null) {
if (hazelcast.isEnabled()) {
conf.setClusterName(hazelcast.getMemberGroup());
conf.setInstanceName(hazelcast.getMemberName());
}
}
BackingStoreFactory factory = null;
try {
factory = services.getService(BackingStoreFactory.class, persistenceStoreType);
} catch (Exception ex) {
_logger.log(Level.WARNING, SFSB_BUILDER_INSTANTIATE_BACKING_STORE_EXCEPTION, new Object[] { persistenceStoreType, ex });
}
try {
if (factory == null) {
factory = services.getService(BackingStoreFactory.class, "noop");
}
this.backingStore = factory.createBackingStore(conf);
} catch (Exception ex) {
_logger.log(Level.WARNING, SFSB_BUILDER_INSTANTIATE_BACKING_STORE_EXCEPTION, new Object[] { persistenceStoreType, ex });
throw new BackingStoreException("Could not instantiate backing store for type [" + persistenceStoreType + "]", ex);
}
_logger.log(Level.INFO, SFSB_BUILDER_INSTANTIATED_BACKING_STORE, new Object[] { backingStore, HAEnabled, conf });
}
Aggregations