List of usage examples for java.util Properties isEmpty
@Override public boolean isEmpty()
From source file:org.sakaiproject.announcement.tool.AnnouncementAction.java
/** * Default is to use when Portal starts up *///from www . j a va 2s .com public String buildMainPanelContext(VelocityPortlet portlet, Context context, RunData rundata, SessionState sstate) { // retrieve the state from state object AnnouncementActionState state = (AnnouncementActionState) getState(portlet, rundata, AnnouncementActionState.class); // load the saved option data Placement placement = ToolManager.getCurrentPlacement(); if (placement != null) { Properties props = placement.getPlacementConfig(); if (props.isEmpty()) props = placement.getConfig(); AnnouncementActionState.DisplayOptions disOptions = state.getDisplayOptions(); if (disOptions != null) { disOptions.loadProperties(props); } context.put(VELOCITY_DISPLAY_OPTIONS, disOptions); } else { // Put our display options in the context so // that we can modify our list display accordingly context.put(VELOCITY_DISPLAY_OPTIONS, state.getDisplayOptions()); } String template = (String) getContext(rundata).get("template"); // group realted variables context.put("channelAccess", MessageHeader.MessageAccess.CHANNEL); context.put("groupAccess", MessageHeader.MessageAccess.GROUPED); // ********* for site column display ******** Site site = null; try { site = SiteService.getSite(ToolManager.getCurrentPlacement().getContext()); context.put("site", site); } catch (IdUnusedException e) { // No site available. M_log.debug(this + ".buildMainPanelContext ", e); } catch (NullPointerException e) { M_log.error(this + ".buildMainPanelContext ", e); } // get the current channel ID from state object or prolet initial parameter String channelId = state.getChannelId(); if (channelId == null) { // try the portlet parameter channelId = StringUtils.trimToNull(portlet.getPortletConfig().getInitParameter("channel")); if (channelId == null) { // form based on the request's site's "main" channel channelId = AnnouncementService.channelReference(ToolManager.getCurrentPlacement().getContext(), SiteService.MAIN_CONTAINER); } // let the state object have the current channel id state.setChannelId(channelId); state.setIsListVM(true); } // context.put("channel_id", ((channelId == null) ? "Now null" : channelId)); context.put("channel_id", ((channelId == null) ? rb.getString("java.nownull") : channelId)); // set if we have notification enabled context.put("notification", Boolean.valueOf(notificationEnabled(state))); // find the channel and channel information through the service AnnouncementChannel channel = null; boolean menu_new = true; boolean menu_delete = true; boolean menu_revise = true; boolean menu_reorder = true; // check the state status to decide which vm to render String statusName = state.getStatus(); if (statusName != null) { template = getTemplate(portlet, context, rundata, sstate, state, template); } try { if (AnnouncementService.allowGetChannel(channelId) && isOkayToDisplayMessageMenu(state)) { // get the channel name throught announcement service API channel = AnnouncementService.getAnnouncementChannel(channelId); if (DEFAULT_TEMPLATE.equals(template)) { // only query for messages for the list view if (channel.allowGetMessages() && !state.getCurrentSortedBy().equals(SORT_GROUPTITLE) && !state.getCurrentSortedBy().equals(SORT_GROUPDESCRIPTION)) { // this checks for any possibility of an add, channel or any site group menu_new = channel.allowAddMessage(); List messages = null; String view = (String) sstate.getAttribute(STATE_SELECTED_VIEW); if (view != null) { if (view.equals(VIEW_MODE_ALL)) { messages = getMessages(channel, null, true, state, portlet); } else if (view.equals(VIEW_MODE_BYGROUP)) { messages = getMessagesByGroups(site, channel, null, true, state, portlet); } else if (view.equals(VIEW_MODE_PUBLIC)) { messages = getMessagesPublic(site, channel, null, true, state, portlet); } } else { messages = getMessages(channel, null, true, state, portlet); } //readResourcesPage expects messages to be in session, so put the entire messages list in the session sstate.setAttribute("messages", messages); //readResourcesPage just orders the list correctly, so we can trim a correct list messages = readResourcesPage(sstate, 1, messages.size() + 1); //this will trim the list for us to put into the session messages = trimListToMaxNumberOfAnnouncements(messages, state.getDisplayOptions()); //now put it back into the session so we can prepare the page with a correctly sorted and trimmed message list sstate.setAttribute("messages", messages); messages = prepPage(sstate); sstate.setAttribute(STATE_MESSAGES, messages); menu_delete = false; for (int i = 0; i < messages.size(); i++) { AnnouncementWrapper message = (AnnouncementWrapper) messages.get(i); // If any message is allowed to be removed // Also check to see if the AnnouncementWrapper object thinks // that this message is editable from the default site. if (message.editable && channel.allowRemoveMessage(message)) { menu_delete = true; break; } } menu_revise = false; for (int i = 0; i < messages.size(); i++) { // if any message is allowed to be edited if (channel.allowEditMessage(((Message) messages.get(i)).getId())) { menu_revise = true; break; } } } else // if the messages in this channel are not allow to be accessed { menu_new = channel.allowAddMessage(); menu_revise = false; menu_delete = false; } // if-else } } else // if the channel is not allowed to access { menu_new = false; menu_revise = false; menu_delete = false; } } catch (PermissionException error) { M_log.error(this + ".buildMainPanelContext ", error); } catch (IdUnusedException error) { if (AnnouncementService.allowAddChannel(channelId)) { try { AnnouncementChannelEdit edit = AnnouncementService.addAnnouncementChannel(channelId); AnnouncementService.commitChannel(edit); channel = edit; } catch (IdUsedException err) { M_log.debug(this + ".buildMainPanelContext ", err); } catch (IdInvalidException err) { } catch (PermissionException err) { } if (channel != null) { menu_new = channel.allowAddMessage(); } menu_revise = false; menu_delete = false; } else { menu_new = false; menu_revise = false; menu_delete = false; } // if-else } // try-catch AnnouncementActionState.DisplayOptions displayOptions = state.getDisplayOptions(); if (statusName == "showMetadata" && channel != null) { String messageReference = state.getMessageReference(); AnnouncementMessage message; try { message = channel.getAnnouncementMessage(this.getMessageIDFromReference(messageReference)); menu_new = channel.allowAddMessage(); menu_delete = channel.allowRemoveMessage(message); menu_revise = channel.allowEditMessage(message.getId()); } catch (IdUnusedException e) { M_log.error(e); } catch (PermissionException e) { M_log.error(e); } } //Check for MOTD, if yes then is not ok to show permissions button boolean showMerge = !isMotd(channelId) && isOkToShowMergeButton(statusName); boolean showPermissions = !isMotd(channelId) && isOkToShowPermissionsButton(statusName); boolean showOptions = this.isOkToShowOptionsButton(statusName); buildMenu(portlet, context, rundata, state, menu_new, menu_delete, menu_revise, showMerge, showPermissions, showOptions, displayOptions); // added by zqian for toolbar context.put("allow_new", Boolean.valueOf(menu_new)); context.put("allow_delete", Boolean.valueOf(menu_delete)); context.put("allow_revise", Boolean.valueOf(menu_revise)); if (channel != null) { // ********* for sorting ********* if (channel.allowGetMessages() && isOkayToDisplayMessageMenu(state)) { String currentSortedBy = state.getCurrentSortedBy(); context.put("currentSortedBy", currentSortedBy); if (state.getCurrentSortAsc()) context.put("currentSortAsc", "true"); else context.put("currentSortAsc", "false"); if (currentSortedBy != null && !currentSortedBy.equals(SORT_GROUPTITLE) && !currentSortedBy.equals(SORT_GROUPDESCRIPTION)) { // sort in announcement list view buildSortedContext(portlet, context, rundata, sstate); } } // if allowGetMessages() } context.put("service", AnnouncementService.getInstance()); context.put("entityManager", EntityManager.getInstance()); context.put("timeservice", TimeService.getInstance()); // ********* for site column display ******** context.put("isOnWorkspaceTab", (isOnWorkspaceTab() ? "true" : "false")); context.put("channel", channel); final Tool tool = ToolManager.getCurrentTool(); final String toolId = tool.getId(); context.put("toolId", toolId); if (channel != null) { // show all the groups in this channal that user has get message in Collection groups = channel.getGroupsAllowGetMessage(); if (groups != null && groups.size() > 0) { //context.put("groups", groups); Collection sortedGroups = new Vector(); for (Iterator i = new SortedIterator(groups.iterator(), new AnnouncementComparator(SORT_GROUPTITLE, true)); i.hasNext();) { sortedGroups.add(i.next()); } context.put("groups", sortedGroups); } } if (sstate.getAttribute(STATE_SELECTED_VIEW) != null) { context.put("view", sstate.getAttribute(STATE_SELECTED_VIEW)); } // inform the observing courier that we just updated the page... // if there are pending requests to do so they can be cleared justDelivered(sstate); return template; }
From source file:org.apache.geode.internal.cache.GemFireCacheImpl.java
/** * Creates a new instance of GemFireCache and populates it according to the * <code>cache.xml</code>, if appropriate. * /*from w ww .j a v a 2s .c om*/ * @param typeRegistry: currently only unit tests set this parameter to a non-null value */ private GemFireCacheImpl(boolean isClient, PoolFactory pf, DistributedSystem system, CacheConfig cacheConfig, boolean asyncEventListeners, TypeRegistry typeRegistry) { this.isClient = isClient; this.clientpf = pf; this.cacheConfig = cacheConfig; // do early for bug 43213 this.pdxRegistry = typeRegistry; // Synchronized to prevent a new cache from being created // before an old one has finished closing synchronized (GemFireCacheImpl.class) { // start JTA transaction manager within this synchronized block // to prevent race with cache close. fixes bug 43987 JNDIInvoker.mapTransactions(system); this.system = (InternalDistributedSystem) system; this.dm = this.system.getDistributionManager(); if (!this.isClient && PoolManager.getAll().isEmpty()) { // We only support management on members of a distributed system // Should do this: if (!getSystem().isLoner()) { // but it causes quickstart.CqClientTest to hang this.listener = new ManagementListener(); this.system.addResourceListener(listener); if (this.system.isLoner()) { this.system.getInternalLogWriter() .info(LocalizedStrings.GemFireCacheImpl_RUNNING_IN_LOCAL_MODE); } } else { getLogger().info("Running in client mode"); this.listener = null; } // Don't let admin-only VMs create Cache's just yet. DM dm = this.system.getDistributionManager(); if (dm instanceof DistributionManager) { if (((DistributionManager) dm).getDMType() == DistributionManager.ADMIN_ONLY_DM_TYPE) { throw new IllegalStateException( LocalizedStrings.GemFireCache_CANNOT_CREATE_A_CACHE_IN_AN_ADMINONLY_VM .toLocalizedString()); } } this.rootRegions = new HashMap(); this.cqService = CqServiceProvider.create(this); this.rmqFactory = new ReliableMessageQueueFactoryImpl(); // Create the CacheStatistics this.cachePerfStats = new CachePerfStats(system); CachePerfStats.enableClockStats = this.system.getConfig().getEnableTimeStatistics(); this.txMgr = new TXManagerImpl(this.cachePerfStats, this); dm.addMembershipListener(this.txMgr); this.creationDate = new Date(); this.persistentMemberManager = new PersistentMemberManager(); if (asyncEventListeners) { final ThreadGroup group = LoggingThreadGroup.createThreadGroup("Message Event Threads", logger); ThreadFactory tf = new ThreadFactory() { public Thread newThread(final Runnable command) { final Runnable r = new Runnable() { public void run() { ConnectionTable.threadWantsSharedResources(); command.run(); } }; Thread thread = new Thread(group, r, "Message Event Thread"); thread.setDaemon(true); return thread; } }; ArrayBlockingQueue q = new ArrayBlockingQueue(EVENT_QUEUE_LIMIT); this.eventThreadPool = new PooledExecutorWithDMStats(q, EVENT_THREAD_LIMIT, this.cachePerfStats.getEventPoolHelper(), tf, 1000); } else { this.eventThreadPool = null; } // Initialize the advisor here, but wait to exchange profiles until cache is fully built this.resourceAdvisor = ResourceAdvisor.createResourceAdvisor(this); // Initialize the advisor here, but wait to exchange profiles until cache is fully built this.jmxAdvisor = JmxManagerAdvisor.createJmxManagerAdvisor(new JmxManagerAdvisee(this)); resourceManager = InternalResourceManager.createResourceManager(this); this.serialNumber = DistributionAdvisor.createSerialNumber(); getResourceManager().addResourceListener(ResourceType.HEAP_MEMORY, getHeapEvictor()); /* * Only bother creating an off-heap evictor if we have off-heap memory enabled. */ if (null != getOffHeapStore()) { getResourceManager().addResourceListener(ResourceType.OFFHEAP_MEMORY, getOffHeapEvictor()); } recordedEventSweeper = EventTracker.startTrackerServices(this); tombstoneService = TombstoneService.initialize(this); TypeRegistry.init(); basicSetPdxSerializer(this.cacheConfig.getPdxSerializer()); TypeRegistry.open(); if (!isClient()) { // Initialize the QRM thread freqeuncy to default (1 second )to prevent spill // over from previous Cache , as the interval is stored in a static // volatile field. HARegionQueue.setMessageSyncInterval(HARegionQueue.DEFAULT_MESSAGE_SYNC_INTERVAL); } FunctionService.registerFunction(new PRContainsValueFunction()); this.expirationScheduler = new ExpirationScheduler(this.system); // uncomment following line when debugging CacheExistsException if (DEBUG_CREATION_STACK) { this.creationStack = new Exception( LocalizedStrings.GemFireCache_CREATED_GEMFIRECACHE_0.toLocalizedString(toString())); } this.txEntryStateFactory = TXEntryState.getFactory(); if (xmlParameterizationEnabled) { /** If product properties file is available replace properties from there */ Properties userProps = this.system.getConfig().getUserDefinedProps(); if (userProps != null && !userProps.isEmpty()) { resolver = new CacheXmlPropertyResolver(false, PropertyResolver.NO_SYSTEM_PROPERTIES_OVERRIDE, userProps); } else { resolver = new CacheXmlPropertyResolver(false, PropertyResolver.NO_SYSTEM_PROPERTIES_OVERRIDE, null); } } SystemFailure.signalCacheCreate(); diskMonitor = new DiskStoreMonitor(); } // synchronized }
From source file:org.epics.archiverappliance.config.DefaultConfigService.java
@Override public void postStartup() throws ConfigException { if (this.startupState != STARTUP_SEQUENCE.READY_TO_JOIN_APPLIANCE) { configlogger.info("Webapp is not in correct state for postStartup " + this.getWarFile().toString() + ". It is in " + this.startupState.toString()); return;//from w w w. ja va 2s. c o m } this.startupState = STARTUP_SEQUENCE.POST_STARTUP_RUNNING; configlogger.info("Post startup for " + this.getWarFile().toString()); // Inherit logging from log4j configuration. try { PlatformLoggingMXBean logging = ManagementFactory.getPlatformMXBean(PlatformLoggingMXBean.class); if (logging != null) { java.util.logging.Logger.getLogger("com.hazelcast"); if (clusterLogger.isDebugEnabled()) { logging.setLoggerLevel("com.hazelcast", java.util.logging.Level.FINE.toString()); } else if (clusterLogger.isInfoEnabled()) { logging.setLoggerLevel("com.hazelcast", java.util.logging.Level.INFO.toString()); } else { logger.info( "Setting clustering logging based on log levels for cluster." + getClass().getName()); logging.setLoggerLevel("com.hazelcast", java.util.logging.Level.SEVERE.toString()); } } Logger hzMain = Logger.getLogger("com.hazelcast"); if (clusterLogger.isDebugEnabled()) { hzMain.setLevel(Level.DEBUG); } else if (clusterLogger.isInfoEnabled()) { hzMain.setLevel(Level.INFO); } else { logger.info("Setting clustering logging based on log levels for cluster." + getClass().getName()); hzMain.setLevel(Level.FATAL); } } catch (Exception ex) { logger.error("Exception setting logging JVM levels ", ex); } // Add this to the system props before doing anything with Hz System.getProperties().put("hazelcast.logging.type", "log4j"); HazelcastInstance hzinstance = null; // Set the thread count to control how may threads this library spawns. Properties hzThreadCounts = new Properties(); if (System.getenv().containsKey("ARCHAPPL_ALL_APPS_ON_ONE_JVM")) { logger.info("Reducing the generic clustering thread counts."); hzThreadCounts.put("hazelcast.clientengine.thread.count", "2"); hzThreadCounts.put("hazelcast.operation.generic.thread.count", "2"); hzThreadCounts.put("hazelcast.operation.thread.count", "2"); } if (this.warFile == WAR_FILE.MGMT) { // The management webapps are the head honchos in the cluster. We set them up differently configlogger.debug("Initializing the MGMT webapp's clustering"); // If we have a hazelcast.xml in the servlet classpath, the XmlConfigBuilder picks that up. // If not we use the default config found in hazelcast.jar // We then alter this config to suit our purposes. Config config = new XmlConfigBuilder().build(); try { if (this.getClass().getResource("hazelcast.xml") == null) { logger.info("We override the default cluster config by disabling multicast discovery etc."); // We do not use multicast as it is not supported on all networks. config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false); // We use TCPIP to discover the members in the cluster. // This is part of the config that comes from appliance.xml config.getNetworkConfig().getJoin().getTcpIpConfig().setEnabled(true); // Clear any tcpip config that comes from the default config // This gets rid of the localhost in the default that prevents clusters from forming.. // If we need localhost, we'll add it back later. config.getNetworkConfig().getJoin().getTcpIpConfig().clear(); // Enable interfaces; we seem to need this after 2.4 for clients to work correctly in a multi-homed environment. // We'll add the actual interface later below config.getNetworkConfig().getInterfaces().setEnabled(true); config.getNetworkConfig().getInterfaces().clear(); // We don't really use the authentication provided by the tool; however, we set it to some default config.getGroupConfig().setName("archappl"); config.getGroupConfig().setPassword("archappl"); // Backup count is 1 by default; we set it explicitly however... config.getMapConfig("default").setBackupCount(1); config.setProperty("hazelcast.logging.type", "log4j"); } else { logger.debug( "There is a hazelcast.xml in the classpath; skipping default configuration in the code."); } } catch (Exception ex) { throw new ConfigException("Exception configuring cluster", ex); } config.setInstanceName(myIdentity); if (!hzThreadCounts.isEmpty()) { logger.info("Reducing the generic clustering thread counts."); config.getProperties().putAll(hzThreadCounts); } try { String[] myAddrParts = myApplianceInfo.getClusterInetPort().split(":"); String myHostName = myAddrParts[0]; InetAddress myInetAddr = InetAddress.getByName(myHostName); if (!myHostName.equals("localhost") && myInetAddr.isLoopbackAddress()) { logger.info("Address for this appliance -- " + myInetAddr.toString() + " is a loopback address. Changing this to 127.0.0.1 to clustering happy"); myInetAddr = InetAddress.getByName("127.0.0.1"); } int myClusterPort = Integer.parseInt(myAddrParts[1]); logger.debug("We do not let the port auto increment for the MGMT webap"); config.getNetworkConfig().setPortAutoIncrement(false); config.getNetworkConfig().setPort(myClusterPort); config.getNetworkConfig().getInterfaces().addInterface(myInetAddr.getHostAddress()); configlogger.info("Setting my cluster port base to " + myClusterPort + " and using interface " + myInetAddr.getHostAddress()); for (ApplianceInfo applInfo : appliances.values()) { if (applInfo.getIdentity().equals(myIdentity) && this.warFile == WAR_FILE.MGMT) { logger.debug("Not adding myself to the discovery process when I am the mgmt webapp"); } else { String[] addressparts = applInfo.getClusterInetPort().split(":"); String inetaddrpart = addressparts[0]; try { InetAddress inetaddr = InetAddress.getByName(inetaddrpart); if (!inetaddrpart.equals("localhost") && inetaddr.isLoopbackAddress()) { logger.info("Address for appliance " + applInfo.getIdentity() + " - " + inetaddr.toString() + " is a loopback address. Changing this to 127.0.0.1 to clustering happy"); inetaddr = InetAddress.getByName("127.0.0.1"); } int clusterPort = Integer.parseInt(addressparts[1]); logger.info("Adding " + applInfo.getIdentity() + " from appliances.xml to the cluster discovery using cluster inetport " + inetaddr.toString() + ":" + clusterPort); config.getNetworkConfig().getJoin().getTcpIpConfig() .addMember(inetaddr.getHostAddress() + ":" + clusterPort); } catch (UnknownHostException ex) { configlogger.info("Cannnot resolve the IP address for appliance " + inetaddrpart + ". Skipping adding this appliance to the cliuster."); } } } hzinstance = Hazelcast.newHazelcastInstance(config); } catch (Exception ex) { throw new ConfigException("Exception adding member to cluster", ex); } } else { // All other webapps are "native" clients. try { configlogger.debug("Initializing a non-mgmt webapp's clustering"); ClientConfig clientConfig = new ClientConfig(); clientConfig.getGroupConfig().setName("archappl"); clientConfig.getGroupConfig().setPassword("archappl"); clientConfig.setExecutorPoolSize(4); // Non mgmt client can only connect to their MGMT webapp. String[] myAddrParts = myApplianceInfo.getClusterInetPort().split(":"); String myHostName = myAddrParts[0]; InetAddress myInetAddr = InetAddress.getByName(myHostName); if (!myHostName.equals("localhost") && myInetAddr.isLoopbackAddress()) { logger.info("Address for this appliance -- " + myInetAddr.toString() + " is a loopback address. Changing this to 127.0.0.1 to clustering happy"); myInetAddr = InetAddress.getByName("127.0.0.1"); } int myClusterPort = Integer.parseInt(myAddrParts[1]); configlogger.debug(this.warFile + " connecting as a native client to " + myInetAddr.getHostAddress() + ":" + myClusterPort); clientConfig.getNetworkConfig().addAddress(myInetAddr.getHostAddress() + ":" + myClusterPort); clientConfig.setProperty("hazelcast.logging.type", "log4j"); if (!hzThreadCounts.isEmpty()) { logger.info("Reducing the generic clustering thread counts."); clientConfig.getProperties().putAll(hzThreadCounts); } if (!clusterLogger.isDebugEnabled()) { // The client code logs some SEVERE exceptions on shutdown when deploying on the same Tomcat container. // These exceptions are confusing; ideally, we would not have to set the log levels like so. Logger.getLogger("com.hazelcast.client.spi.impl.ClusterListenerThread").setLevel(Level.OFF); Logger.getLogger("com.hazelcast.client.spi.ClientPartitionService").setLevel(Level.OFF); } hzinstance = HazelcastClient.newHazelcastClient(clientConfig); } catch (Exception ex) { throw new ConfigException("Exception adding client to cluster", ex); } } pv2appliancemapping = hzinstance.getMap("pv2appliancemapping"); namedFlags = hzinstance.getMap("namedflags"); typeInfos = hzinstance.getMap("typeinfo"); archivePVRequests = hzinstance.getMap("archivePVRequests"); channelArchiverDataServers = hzinstance.getMap("channelArchiverDataServers"); clusterInet2ApplianceIdentity = hzinstance.getMap("clusterInet2ApplianceIdentity"); aliasNamesToRealNames = hzinstance.getMap("aliasNamesToRealNames"); pv2ChannelArchiverDataServer = hzinstance.getMap("pv2ChannelArchiverDataServer"); pubSub = hzinstance.getTopic("pubSub"); final HazelcastInstance shutdownHzInstance = hzinstance; shutdownHooks.add(0, new Runnable() { @Override public void run() { logger.debug("Shutting down clustering instance in webapp " + warFile.toString()); shutdownHzInstance.shutdown(); } }); if (this.warFile == WAR_FILE.MGMT) { Cluster cluster = hzinstance.getCluster(); String localInetPort = getMemberKey(cluster.getLocalMember()); clusterInet2ApplianceIdentity.put(localInetPort, myIdentity); logger.debug("Adding myself " + myIdentity + " as having inetport " + localInetPort); hzinstance.getMap("clusterInet2ApplianceIdentity") .addEntryListener(new EntryAddedListener<Object, Object>() { @Override public void entryAdded(EntryEvent<Object, Object> event) { String appliden = (String) event.getValue(); appliancesInCluster.add(appliden); logger.info("Adding appliance " + appliden + " to the list of active appliances as inetport " + ((String) event.getKey())); } }, true); hzinstance.getMap("clusterInet2ApplianceIdentity") .addEntryListener(new EntryRemovedListener<Object, Object>() { @Override public void entryRemoved(EntryEvent<Object, Object> event) { String appliden = (String) event.getValue(); appliancesInCluster.remove(appliden); logger.info("Removing appliance " + appliden + " from the list of active appliancesas inetport " + ((String) event.getKey())); } }, true); logger.debug( "Establishing a cluster membership listener to detect when appliances drop off the cluster"); cluster.addMembershipListener(new MembershipListener() { public void memberAdded(MembershipEvent membersipEvent) { Member member = membersipEvent.getMember(); String inetPort = getMemberKey(member); if (clusterInet2ApplianceIdentity.containsKey(inetPort)) { String appliden = clusterInet2ApplianceIdentity.get(inetPort); appliancesInCluster.add(appliden); configlogger.info("Adding newly started appliance " + appliden + " to the list of active appliances for inetport " + inetPort); } else { logger.debug("Skipping adding appliance using inetport " + inetPort + " to the list of active instances as we do not have a mapping to its identity"); } } public void memberRemoved(MembershipEvent membersipEvent) { Member member = membersipEvent.getMember(); String inetPort = getMemberKey(member); if (clusterInet2ApplianceIdentity.containsKey(inetPort)) { String appliden = clusterInet2ApplianceIdentity.get(inetPort); appliancesInCluster.remove(appliden); configlogger.info("Removing appliance " + appliden + " from the list of active appliances"); } else { configlogger.debug("Received member removed event for " + inetPort); } } @Override public void memberAttributeChanged(MemberAttributeEvent membersipEvent) { Member member = membersipEvent.getMember(); String inetPort = getMemberKey(member); configlogger.debug("Received membership attribute changed event for " + inetPort); } }); logger.debug( "Adding the current members in the cluster after establishing the cluster membership listener"); for (Member member : cluster.getMembers()) { String mbrInetPort = getMemberKey(member); logger.debug("Found member " + mbrInetPort); if (clusterInet2ApplianceIdentity.containsKey(mbrInetPort)) { String appliden = clusterInet2ApplianceIdentity.get(mbrInetPort); appliancesInCluster.add(appliden); logger.info("Adding appliance " + appliden + " to the list of active appliances for inetport " + mbrInetPort); } else { logger.debug("Skipping adding appliance using inetport " + mbrInetPort + " to the list of active instances as we do not have a mapping to its identity"); } } logger.info("Established subscription(s) for appliance availability"); if (this.getInstallationProperties().containsKey(ARCHAPPL_NAMEDFLAGS_PROPERTIES_FILE_PROPERTY)) { String namedFlagsFileName = (String) this.getInstallationProperties() .get(ARCHAPPL_NAMEDFLAGS_PROPERTIES_FILE_PROPERTY); configlogger.info("Loading named flags from file " + namedFlagsFileName); File namedFlagsFile = new File(namedFlagsFileName); if (!namedFlagsFile.exists()) { configlogger.error( "File containing named flags " + namedFlagsFileName + " specified but not present"); } else { Properties namedFlagsFromFile = new Properties(); try (FileInputStream is = new FileInputStream(namedFlagsFile)) { namedFlagsFromFile.load(is); for (Object namedFlagFromFile : namedFlagsFromFile.keySet()) { try { String namedFlagFromFileStr = (String) namedFlagFromFile; Boolean namedFlagFromFileValue = Boolean .parseBoolean((String) namedFlagsFromFile.get(namedFlagFromFileStr)); logger.debug("Setting named flag " + namedFlagFromFileStr + " to " + namedFlagFromFileValue); this.namedFlags.put(namedFlagFromFileStr, namedFlagFromFileValue); } catch (Exception ex) { logger.error("Exception loading named flag from file" + namedFlagsFileName, ex); } } } catch (Exception ex) { configlogger.error("Exception loading named flags from " + namedFlagsFileName, ex); } } } } if (this.warFile == WAR_FILE.ENGINE) { // It can take a while for the engine to start up. // We probably want to do this in the background so that the appliance as a whole starts up quickly and we get retrieval up and running quickly. this.startupExecutor.schedule(new Runnable() { @Override public void run() { try { logger.debug("Starting up the engine's channels on startup."); archivePVSonStartup(); logger.debug("Done starting up the engine's channels in startup."); } catch (Throwable t) { configlogger.fatal("Exception starting up the engine channels on startup", t); } } }, 1, TimeUnit.SECONDS); } else if (this.warFile == WAR_FILE.ETL) { this.etlPVLookup.postStartup(); } else if (this.warFile == WAR_FILE.MGMT) { pvsForThisAppliance = new ConcurrentSkipListSet<String>(); pausedPVsForThisAppliance = new ConcurrentSkipListSet<String>(); initializePersistenceLayer(); loadTypeInfosFromPersistence(); loadAliasesFromPersistence(); loadArchiveRequestsFromPersistence(); loadExternalServersFromPersistence(); registerForNewExternalServers(hzinstance.getMap("channelArchiverDataServers")); // Cache the aggregate of all the PVs that are registered to this appliance. logger.debug("Building a local aggregate of PV infos that are registered to this appliance"); for (String pvName : getPVsForThisAppliance()) { if (!pvsForThisAppliance.contains(pvName)) { applianceAggregateInfo.addInfoForPV(pvName, this.getTypeInfoForPV(pvName), this); } } } // Register for changes to the typeinfo map. logger.info("Registering for changes to typeinfos"); hzinstance.getMap("typeinfo").addEntryListener(new EntryAddedListener<Object, Object>() { @Override public void entryAdded(EntryEvent<Object, Object> entryEvent) { logger.debug("Received entryAdded for pvTypeInfo"); PVTypeInfo typeInfo = (PVTypeInfo) entryEvent.getValue(); String pvName = typeInfo.getPvName(); eventBus.post(new PVTypeInfoEvent(pvName, typeInfo, ChangeType.TYPEINFO_ADDED)); if (persistanceLayer != null) { try { persistanceLayer.putTypeInfo(pvName, typeInfo); } catch (Exception ex) { logger.error("Exception persisting pvTypeInfo for pv " + pvName, ex); } } } }, true); hzinstance.getMap("typeinfo").addEntryListener(new EntryRemovedListener<Object, Object>() { @Override public void entryRemoved(EntryEvent<Object, Object> entryEvent) { PVTypeInfo typeInfo = (PVTypeInfo) entryEvent.getOldValue(); String pvName = typeInfo.getPvName(); logger.info("Received entryRemoved for pvTypeInfo " + pvName); eventBus.post(new PVTypeInfoEvent(pvName, typeInfo, ChangeType.TYPEINFO_DELETED)); if (persistanceLayer != null) { try { persistanceLayer.deleteTypeInfo(pvName); } catch (Exception ex) { logger.error("Exception deleting pvTypeInfo for pv " + pvName, ex); } } } }, true); hzinstance.getMap("typeinfo").addEntryListener(new EntryUpdatedListener<Object, Object>() { @Override public void entryUpdated(EntryEvent<Object, Object> entryEvent) { PVTypeInfo typeInfo = (PVTypeInfo) entryEvent.getValue(); String pvName = typeInfo.getPvName(); eventBus.post(new PVTypeInfoEvent(pvName, typeInfo, ChangeType.TYPEINFO_MODIFIED)); logger.debug("Received entryUpdated for pvTypeInfo"); if (persistanceLayer != null) { try { persistanceLayer.putTypeInfo(pvName, typeInfo); } catch (Exception ex) { logger.error("Exception persisting pvTypeInfo for pv " + pvName, ex); } } } }, true); eventBus.register(this); pubSub.addMessageListener(new MessageListener<PubSubEvent>() { @Override public void onMessage(Message<PubSubEvent> pubSubEventMsg) { PubSubEvent pubSubEvent = pubSubEventMsg.getMessageObject(); if (pubSubEvent.getDestination() != null) { if (pubSubEvent.getDestination().equals("ALL") || (pubSubEvent.getDestination().startsWith(myIdentity) && pubSubEvent.getDestination() .endsWith(DefaultConfigService.this.warFile.toString()))) { // We publish messages from hazelcast into this VM only if the intened WAR file is us. logger.debug("Publishing event into this JVM " + pubSubEvent.generateEventDescription()); // In this case, we set the source as being the cluster to prevent republishing back into the cluster. pubSubEvent.markSourceAsCluster(); eventBus.post(pubSubEvent); } else { logger.debug("Skipping publishing event into this JVM " + pubSubEvent.generateEventDescription() + " as destination is not me " + DefaultConfigService.this.warFile.toString()); } } else { logger.debug("Skipping publishing event with null destination"); } } }); logger.info("Done registering for changes to typeinfos"); this.startupState = STARTUP_SEQUENCE.STARTUP_COMPLETE; configlogger.info("Start complete for webapp " + this.warFile); }