use of com.hazelcast.config.XmlConfigBuilder in project ddf by codice.
the class HazelcastNotificationStore method getHazelcastConfig.
private Config getHazelcastConfig(BundleContext context, String xmlConfigFilename) {
Config cfg = null;
Bundle bundle = context.getBundle();
URL xmlConfigFileUrl = null;
if (StringUtils.isNotBlank(xmlConfigFilename)) {
xmlConfigFileUrl = bundle.getResource(xmlConfigFilename);
}
XmlConfigBuilder xmlConfigBuilder = null;
if (xmlConfigFileUrl != null) {
try {
xmlConfigBuilder = new XmlConfigBuilder(xmlConfigFileUrl.openStream());
cfg = xmlConfigBuilder.build();
LOGGER.debug("Successfully built hazelcast config from XML config file {}", xmlConfigFilename);
} catch (FileNotFoundException e) {
LOGGER.info("FileNotFoundException trying to build hazelcast config from XML file " + xmlConfigFilename, e);
cfg = null;
} catch (IOException e) {
LOGGER.info("IOException trying to build hazelcast config from XML file " + xmlConfigFilename, e);
cfg = null;
}
}
if (cfg == null) {
LOGGER.info("Falling back to using generic Config for hazelcast");
cfg = new Config();
} else if (LOGGER.isDebugEnabled()) {
MapConfig mapConfig = cfg.getMapConfig("persistentNotifications");
if (mapConfig == null) {
LOGGER.debug("mapConfig is NULL for persistentNotifications - try persistent*");
mapConfig = cfg.getMapConfig("persistent*");
if (mapConfig == null) {
LOGGER.debug("mapConfig is NULL for persistent*");
}
} else {
MapStoreConfig mapStoreConfig = mapConfig.getMapStoreConfig();
if (mapStoreConfig != null) {
LOGGER.debug("mapStoreConfig factoryClassName = {}", mapStoreConfig.getFactoryClassName());
} else {
LOGGER.debug("mapStoreConfig is null");
}
}
}
return cfg;
}
use of com.hazelcast.config.XmlConfigBuilder in project ddf by codice.
the class ResourceCacheImpl method getHazelcastConfig.
private Config getHazelcastConfig(BundleContext context, String xmlConfigFilename) {
Config cfg = null;
Bundle bundle = context.getBundle();
URL xmlConfigFileUrl = null;
if (StringUtils.isNotBlank(xmlConfigFilename)) {
xmlConfigFileUrl = bundle.getResource(xmlConfigFilename);
}
XmlConfigBuilder xmlConfigBuilder = null;
if (xmlConfigFileUrl != null) {
try {
xmlConfigBuilder = new XmlConfigBuilder(xmlConfigFileUrl.openStream());
cfg = xmlConfigBuilder.build();
LOGGER.debug("Successfully built hazelcast config from XML config file {}", xmlConfigFilename);
} catch (FileNotFoundException e) {
LOGGER.info("FileNotFoundException trying to build hazelcast config from XML file " + xmlConfigFilename, e);
cfg = null;
} catch (IOException e) {
LOGGER.info("IOException trying to build hazelcast config from XML file " + xmlConfigFilename, e);
cfg = null;
}
}
if (cfg == null) {
LOGGER.info("Falling back to using generic Config for hazelcast");
cfg = new Config();
} else if (LOGGER.isDebugEnabled()) {
MapConfig mapConfig = cfg.getMapConfig("Product_Cache");
if (mapConfig == null) {
LOGGER.debug("mapConfig is NULL for persistentNotifications - try persistent*");
mapConfig = cfg.getMapConfig("persistent*");
if (mapConfig == null) {
LOGGER.debug("mapConfig is NULL for persistent*");
}
} else {
MapStoreConfig mapStoreConfig = mapConfig.getMapStoreConfig();
if (null != mapStoreConfig) {
LOGGER.debug("mapStoreConfig factoryClassName = {}", mapStoreConfig.getFactoryClassName());
}
}
}
return cfg;
}
use of com.hazelcast.config.XmlConfigBuilder in project cas by apereo.
the class HazelcastSessionConfiguration method hazelcastInstance.
/**
* Hazelcast instance that is used by the spring session
* repository to broadcast session events. The name
* of this bean must be left untouched.
*
* @return the hazelcast instance
*/
@Bean
@SneakyThrows
public HazelcastInstance hazelcastInstance() {
final Resource hzConfigResource = casProperties.getWebflow().getSession().getHzLocation();
final URL configUrl = hzConfigResource.getURL();
final Config config = new XmlConfigBuilder(hzConfigResource.getInputStream()).build();
config.setConfigurationUrl(configUrl);
config.setInstanceName(this.getClass().getSimpleName()).setProperty("hazelcast.logging.type", "slf4j").setProperty("hazelcast.max.no.heartbeat.seconds", "300");
return Hazelcast.newHazelcastInstance(config);
}
use of com.hazelcast.config.XmlConfigBuilder in project openmeetings by apache.
the class Application method init.
@Override
protected void init() {
setWicketApplicationName(super.getName());
getSecuritySettings().setAuthenticationStrategy(new OmAuthenticationStrategy(rememberMeKey, rememberMeSalt));
getApplicationSettings().setAccessDeniedPage(AccessDeniedPage.class);
getApplicationSettings().setInternalErrorPage(InternalErrorPage.class);
getExceptionSettings().setUnexpectedExceptionDisplay(ExceptionSettings.SHOW_INTERNAL_ERROR_PAGE);
getComponentInstantiationListeners().add(new SpringComponentInjector(this, ctx, true));
Config cfg = new XmlConfigBuilder().build();
cfg.setClassLoader(getClass().getClassLoader());
hazelcast = Hazelcast.getOrCreateHazelcastInstance(cfg);
serverId = hazelcast.getName();
hazelcast.getCluster().getMembers().forEach(m -> cm.serverAdded(m.getAttribute(NAME_ATTR_KEY), m.getAttribute(SERVER_URL_ATTR_KEY)));
hazelWsTopic = hazelcast.getTopic("default");
hazelWsTopic.addMessageListener(msg -> {
String mServerId = msg.getPublishingMember().getAttribute(NAME_ATTR_KEY);
if (mServerId.equals(serverId)) {
return;
}
IClusterWsMessage wsMsg = msg.getMessageObject();
if (WbWebSocketHelper.send(wsMsg)) {
return;
}
if (ChatWebSocketHelper.send(msg.getMessageObject())) {
return;
}
WebSocketHelper.send(msg.getMessageObject());
});
hazelcast.getCluster().addMembershipListener(new MembershipListener() {
@Override
public void memberRemoved(MembershipEvent evt) {
// server down, need to remove all online clients, process persistent addresses
String serverId = evt.getMember().getAttribute(NAME_ATTR_KEY);
cm.serverRemoved(serverId);
updateJpaAddresses();
}
@Override
public void memberAdded(MembershipEvent evt) {
// no-op
// server added, need to process persistent addresses
updateJpaAddresses();
// check for duplicate instance-names
Set<String> names = new HashSet<>();
for (Member m : evt.getMembers()) {
if (evt.getMember().getUuid().equals(m.getUuid())) {
continue;
}
String serverId = m.getAttribute(NAME_ATTR_KEY);
names.add(serverId);
}
String newServerId = evt.getMember().getAttribute(NAME_ATTR_KEY);
log.warn("Name added: {}", newServerId);
cm.serverAdded(newServerId, evt.getMember().getAttribute(SERVER_URL_ATTR_KEY));
if (names.contains(newServerId)) {
log.warn("Duplicate cluster instance with name {} found {}", newServerId, evt.getMember());
}
}
});
setPageManagerProvider(new DefaultPageManagerProvider(this) {
@Override
protected IPageStore newAsynchronousStore(IPageStore pageStore) {
return new SerializingPageStore(new HazelcastDataStore(getName(), hazelcast), getFrameworkSettings().getSerializer());
}
});
// Add custom resource loader at the beginning, so it will be checked first in the
// chain of Resource Loaders, if not found it will search in Wicket's internal
// Resource Loader for a the property key
getResourceSettings().getStringResourceLoaders().add(0, new LabelResourceLoader());
getRequestCycleListeners().add(new WebSocketAwareResourceIsolationRequestCycleListener() {
@Override
public void onBeginRequest(RequestCycle cycle) {
String wsUrl = getWsUrl(cycle.getRequest().getUrl());
if (wsUrl != null && !wsUrls.contains(wsUrl)) {
wsUrls.add(wsUrl);
cfgDao.updateCsp();
}
}
@Override
public void onEndRequest(RequestCycle cycle) {
Response resp = cycle.getResponse();
if (resp instanceof WebResponse) {
WebResponse wresp = (WebResponse) resp;
if (wresp.isHeaderSupported()) {
wresp.setHeader("X-XSS-Protection", "1; mode=block");
wresp.setHeader("Strict-Transport-Security", "max-age=31536000; includeSubDomains; preload");
wresp.setHeader("X-Content-Type-Options", "nosniff");
}
}
}
});
final WebSocketContainer sc = (WebSocketContainer) getServletContext().getAttribute(SERVER_CONTAINER_SERVLET_CONTEXT_ATTRIBUTE);
if (sc != null) {
// should be enough, should it be configurable?
sc.setDefaultMaxSessionIdleTimeout(60 * 1000L);
}
getHeaderResponseDecorators().add(FilteringHeaderResponse::new);
super.init();
final IBootstrapSettings settings = new BootstrapSettings();
Bootstrap.builder().withBootstrapSettings(settings).install(this);
WysiwygLibrarySettings.get().setBootstrapCssReference(null);
WysiwygLibrarySettings.get().setBootstrapDropDownJavaScriptReference(null);
// register some widgets
final DashboardContext dashboardContext = getDashboardContext();
dashboardContext.setDashboardPersister(new UserDashboardPersister());
WidgetRegistry widgetRegistry = dashboardContext.getWidgetRegistry();
widgetRegistry.registerWidget(new MyRoomsWidgetDescriptor());
widgetRegistry.registerWidget(new RecentRoomsWidgetDescriptor());
widgetRegistry.registerWidget(new WelcomeWidgetDescriptor());
widgetRegistry.registerWidget(new StartWidgetDescriptor());
widgetRegistry.registerWidget(new RssWidgetDescriptor());
widgetRegistry.registerWidget(new AdminWidgetDescriptor());
DashboardSettings dashboardSettings = DashboardSettings.get();
dashboardSettings.setIncludeJQueryUI(false);
getRootRequestMapperAsCompound().add(new NoVersionMapper(getHomePage()));
getRootRequestMapperAsCompound().add(new NoVersionMapper(NOTINIT_MAPPING, NotInitedPage.class));
getRootRequestMapperAsCompound().add(new NoVersionMapper("denied", AccessDeniedPage.class));
getRootRequestMapperAsCompound().add(new NoVersionMapper(HASH_MAPPING, HashPage.class));
getRootRequestMapperAsCompound().add(new NoVersionMapper(SIGNIN_MAPPING, getSignInPageClass()));
getRootRequestMapperAsCompound().add(new NoVersionMapper("oauth/${oauthid}", getSignInPageClass()));
getRootRequestMapperAsCompound().add(new NoVersionMapper("privacy", PrivacyPage.class));
mountPage("install", InstallWizardPage.class);
mountPage("activate", ActivatePage.class);
mountPage("reset", ResetPage.class);
mountPage("error", InternalErrorPage.class);
mountResource("/recordings/mp4/${id}", new Mp4RecordingResourceReference());
// should be in sync with VideoPlayer
mountResource("/recordings/png/${id}", new PngRecordingResourceReference());
mountResource("/room/file/${id}", new RoomResourceReference());
mountResource("/room/preview/${id}", new RoomPreviewResourceReference());
mountResource("/room/file/upload", new RoomFileUploadResourceReference());
mountResource("/admin/backup/upload", new BackupUploadResourceReference());
mountResource("/profile/${id}", new ProfileImageResourceReference());
mountResource("/group/${id}", new GroupLogoResourceReference());
mountResource("/group/customcss/${id}", new GroupCustomCssResourceReference());
mountResource("/ping", new PingResourceReference());
log.debug("Application::init");
try {
if (OmFileHelper.getOmHome() == null) {
OmFileHelper.setOmHome(new File(getServletContext().getRealPath("/")));
}
LabelDao.initLanguageMap();
log.debug("webAppPath : {}", OmFileHelper.getOmHome());
// Init all global config properties
cfgDao.reinit();
wbManager.init();
cm.init();
// Init properties
updateJpaAddresses();
setExtProcessTtl(cfgDao.getInt(CONFIG_EXT_PROCESS_TTL, getExtProcessTtl()));
Version.logOMStarted();
// we are starting so all processing recordings are now errors
recordingDao.resetProcessingStatus();
userManager.initHttpClient();
setInitComplete(true);
CompletableFuture.runAsync(() -> {
ThreadContext.setApplication(Application.this);
ApplicationHelper.ensureRequestCycle(Application.this);
sipManager.setUserPicture(u -> ProfileImageResourceReference.getUrl(RequestCycle.get(), u));
});
} catch (Exception err) {
log.error("[appStart]", err);
}
}
use of com.hazelcast.config.XmlConfigBuilder in project hazelcast-simulator by hazelcast.
the class Hazelcast3Driver method startDriverInstance.
@Override
public void startDriverInstance() throws Exception {
String workerType = get("WORKER_TYPE");
LOGGER.info(format("%s HazelcastInstance starting", workerType));
if ("javaclient".equals(workerType)) {
File configFile = new File(getUserDir(), "client-hazelcast.xml");
XmlClientConfigBuilder configBuilder = new XmlClientConfigBuilder(configFile);
ClientConfig clientConfig = configBuilder.build();
hazelcastInstance = HazelcastClient.newHazelcastClient(clientConfig);
} else {
File configFile = new File(getUserDir(), "hazelcast.xml");
XmlConfigBuilder configBuilder = new XmlConfigBuilder(configFile.getAbsolutePath());
Config config = configBuilder.build();
hazelcastInstance = Hazelcast.newHazelcastInstance(config);
}
LOGGER.info(format("%s HazelcastInstance started", workerType));
warmupPartitions(hazelcastInstance);
LOGGER.info("Warmed up partitions");
}
Aggregations