use of org.glassfish.ha.store.api.BackingStoreConfiguration 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 });
}
use of org.glassfish.ha.store.api.BackingStoreConfiguration 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.BackingStoreConfiguration in project Payara by payara.
the class HACNonceCacheImpl method postConstruct.
public void postConstruct() {
localStore = new CNonceCacheImpl();
try {
final BackingStoreConfiguration<String, NonceInfo> bsConfig = new BackingStoreConfiguration<String, NonceInfo>();
bsConfig.setClusterName(props.get(CNonceCacheFactory.CLUSTER_NAME_PROP)).setInstanceName(props.get(CNonceCacheFactory.INSTANCE_NAME_PROP)).setStoreName(storeName).setKeyClazz(String.class).setValueClazz(NonceInfo.class);
BackingStoreFactory bsFactory = services.getService(BackingStoreFactory.class, BS_TYPE_REPLICATED);
backingStore = bsFactory.createBackingStore(bsConfig);
} catch (BackingStoreException ex) {
logger.log(Level.WARNING, null, ex);
}
}
use of org.glassfish.ha.store.api.BackingStoreConfiguration in project Payara by payara.
the class ReplicationWebEventPersistentManager method createBackingStore.
@Override
public void createBackingStore(String persistenceType, String storeName, Class<T> metadataClass, Map<String, Object> vendorMap) {
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("Create backing store invoked with persistence type " + persistenceType + " and store name " + storeName);
}
BackingStoreFactory factory = services.getService(BackingStoreFactory.class, persistenceType);
BackingStoreConfiguration<String, T> conf = new BackingStoreConfiguration<String, T>();
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(metadataClass).setClassLoader(this.getClass().getClassLoader());
if (vendorMap != null) {
conf.getVendorSpecificSettings().putAll(vendorMap);
}
try {
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("About to create backing store " + conf);
}
this.backingStore = factory.createBackingStore(conf);
} catch (BackingStoreException e) {
_logger.log(Level.WARNING, LogFacade.COULD_NOT_CREATE_BACKING_STORE, e);
}
Object obj = conf.getVendorSpecificSettings().get("key.mapper");
if (obj != null && obj instanceof GlassFishHAReplicaPredictor) {
predictor = (GlassFishHAReplicaPredictor) obj;
if (_logger.isLoggable(Level.FINE)) {
_logger.fine("ReplicatedManager.keymapper is " + predictor);
}
} else {
predictor = new NoopHAReplicaPredictor();
}
}
Aggregations