Modified: river/jtsk/trunk/src/org/apache/river/mercury/MailboxImplInit.java URL: http://svn.apache.org/viewvc/river/jtsk/trunk/src/org/apache/river/mercury/MailboxImplInit.java?rev=1719761&r1=1719760&r2=1719761&view=diff ============================================================================== --- river/jtsk/trunk/src/org/apache/river/mercury/MailboxImplInit.java (original) +++ river/jtsk/trunk/src/org/apache/river/mercury/MailboxImplInit.java Sun Dec 13 04:43:42 2015 @@ -42,6 +42,7 @@ import java.util.List; import java.util.Map; import java.util.TreeMap; import java.util.logging.Level; +import javax.security.auth.login.LoginContext; import net.jini.activation.ActivationExporter; import net.jini.config.Configuration; import net.jini.config.ConfigurationException; @@ -67,12 +68,12 @@ class MailboxImplInit { boolean activationPrepared; Exporter exporter; ProxyPreparer listenerPreparer; + ProxyPreparer recoveredListenerPreparer; ProxyPreparer locatorToJoinPreparer; LeasePeriodPolicy leasePolicy; String persistenceDirectory; ProxyPreparer recoveredLocatorToJoinPreparer; int logToSnapshotThreshold; - ReliableLog log; Uuid serviceID; String[] lookupGroups; LookupLocator[] lookupLocators; @@ -86,290 +87,85 @@ class MailboxImplInit { /** <code>EventLogIterator</code> generator */ EventLogFactory eventLogFactory = new EventLogFactory(); List<Uuid> pendingReg = new ArrayList<Uuid>(); - Thread snapshotter; - Thread notifier; - Thread expirer; Configuration config; AccessControlContext context; + LoginContext loginContext; + boolean persistent; MailboxImplInit(Configuration config, boolean persistent, ActivationID activationID, - Entry[] baseLookupAttrs, - LogHandler localLogHandler, - Thread snapshotter, - Thread notifier, - Thread expirer) - throws ConfigurationException, RemoteException, ActivationException, IOException + Entry[] baseLookupAttrs + ) throws ConfigurationException, RemoteException, ActivationException { - this.notifier = notifier; - this.expirer = expirer; + this.persistent = persistent; this.config = config; context = AccessController.getContext(); // Get activation specific configuration items, if activated if (activationID != null) { ProxyPreparer activationSystemPreparer = (ProxyPreparer) Config.getNonNullEntry(config, MailboxImpl.MERCURY, "activationSystemPreparer", ProxyPreparer.class, new BasicProxyPreparer()); - if (MailboxImpl.initLogger.isLoggable(Level.CONFIG)) { - MailboxImpl.initLogger.log(Level.CONFIG, "activationSystemPreparer: {0}", activationSystemPreparer); + if (MailboxImpl.INIT_LOGGER.isLoggable(Level.CONFIG)) { + MailboxImpl.INIT_LOGGER.log(Level.CONFIG, "activationSystemPreparer: {0}", activationSystemPreparer); } activationSystem = (ActivationSystem) activationSystemPreparer.prepareProxy(ActivationGroup.getSystem()); - if (MailboxImpl.initLogger.isLoggable(Level.FINEST)) { - MailboxImpl.initLogger.log(Level.FINEST, "Prepared activation system is: {0}", activationSystem); + if (MailboxImpl.INIT_LOGGER.isLoggable(Level.FINEST)) { + MailboxImpl.INIT_LOGGER.log(Level.FINEST, "Prepared activation system is: {0}", activationSystem); } ProxyPreparer activationIdPreparer = (ProxyPreparer) Config.getNonNullEntry(config, MailboxImpl.MERCURY, "activationIdPreparer", ProxyPreparer.class, new BasicProxyPreparer()); - if (MailboxImpl.initLogger.isLoggable(Level.CONFIG)) { - MailboxImpl.initLogger.log(Level.CONFIG, "activationIdPreparer: {0}", activationIdPreparer); + if (MailboxImpl.INIT_LOGGER.isLoggable(Level.CONFIG)) { + MailboxImpl.INIT_LOGGER.log(Level.CONFIG, "activationIdPreparer: {0}", activationIdPreparer); } activationID = (ActivationID) activationIdPreparer.prepareProxy(activationID); - if (MailboxImpl.initLogger.isLoggable(Level.FINEST)) { - MailboxImpl.initLogger.log(Level.FINEST, "Prepared activationID is: {0}", activationID); + if (MailboxImpl.INIT_LOGGER.isLoggable(Level.FINEST)) { + MailboxImpl.INIT_LOGGER.log(Level.FINEST, "Prepared activationID is: {0}", activationID); } activationPrepared = true; exporter = (Exporter) Config.getNonNullEntry(config, MailboxImpl.MERCURY, "serverExporter", Exporter.class, new ActivationExporter(activationID, new BasicJeriExporter(TcpServerEndpoint.getInstance(0), new BasicILFactory(), false, true)), activationID); - if (MailboxImpl.initLogger.isLoggable(Level.CONFIG)) { - MailboxImpl.initLogger.log(Level.CONFIG, "Activatable service exporter is: {0}", exporter); + if (MailboxImpl.INIT_LOGGER.isLoggable(Level.CONFIG)) { + MailboxImpl.INIT_LOGGER.log(Level.CONFIG, "Activatable service exporter is: {0}", exporter); } this.activationID = activationID; } else { //Get non-activatable configuration items exporter = (Exporter) Config.getNonNullEntry(config, MailboxImpl.MERCURY, "serverExporter", Exporter.class, new BasicJeriExporter(TcpServerEndpoint.getInstance(0), new BasicILFactory(), false, true)); - if (MailboxImpl.initLogger.isLoggable(Level.CONFIG)) { - MailboxImpl.initLogger.log(Level.CONFIG, "Non-activatable service exporter is: {0}", exporter); + if (MailboxImpl.INIT_LOGGER.isLoggable(Level.CONFIG)) { + MailboxImpl.INIT_LOGGER.log(Level.CONFIG, "Non-activatable service exporter is: {0}", exporter); } } listenerPreparer = (ProxyPreparer) Config.getNonNullEntry(config, MailboxImpl.MERCURY, "listenerPreparer", ProxyPreparer.class, new BasicProxyPreparer()); - if (MailboxImpl.initLogger.isLoggable(Level.CONFIG)) { - MailboxImpl.initLogger.log(Level.CONFIG, "Listener preparer is: {0}", listenerPreparer); + if (MailboxImpl.INIT_LOGGER.isLoggable(Level.CONFIG)) { + MailboxImpl.INIT_LOGGER.log(Level.CONFIG, "Listener preparer is: {0}", listenerPreparer); } /* Get the proxy preparers for the lookup locators to join */ locatorToJoinPreparer = (ProxyPreparer) Config.getNonNullEntry(config, MailboxImpl.MERCURY, "locatorToJoinPreparer", ProxyPreparer.class, new BasicProxyPreparer()); - if (MailboxImpl.initLogger.isLoggable(Level.CONFIG)) { - MailboxImpl.initLogger.log(Level.CONFIG, "Locator preparer is: {0}", locatorToJoinPreparer); + if (MailboxImpl.INIT_LOGGER.isLoggable(Level.CONFIG)) { + MailboxImpl.INIT_LOGGER.log(Level.CONFIG, "Locator preparer is: {0}", locatorToJoinPreparer); } // Create lease policy -- used by recovery logic, below leasePolicy = (LeasePeriodPolicy) Config.getNonNullEntry(config, MailboxImpl.MERCURY, "leasePeriodPolicy", LeasePeriodPolicy.class, new FixedLeasePeriodPolicy(3 * TimeConstants.HOURS, 1 * TimeConstants.HOURS)); - if (MailboxImpl.initLogger.isLoggable(Level.CONFIG)) { - MailboxImpl.initLogger.log(Level.CONFIG, "LeasePeriodPolicy is: {0}", leasePolicy); + if (MailboxImpl.INIT_LOGGER.isLoggable(Level.CONFIG)) { + MailboxImpl.INIT_LOGGER.log(Level.CONFIG, "LeasePeriodPolicy is: {0}", leasePolicy); } // Note: referenced by recovery logic in rebuildTransientState() - ProxyPreparer recoveredListenerPreparer = null; if (persistent) { persistenceDirectory = (String) Config.getNonNullEntry(config, MailboxImpl.MERCURY, "persistenceDirectory", String.class); - if (MailboxImpl.initLogger.isLoggable(Level.CONFIG)) { - MailboxImpl.initLogger.log(Level.CONFIG, "Persistence directory is: {0}", persistenceDirectory); + if (MailboxImpl.INIT_LOGGER.isLoggable(Level.CONFIG)) { + MailboxImpl.INIT_LOGGER.log(Level.CONFIG, "Persistence directory is: {0}", persistenceDirectory); } // Note: referenced by recovery logic in rebuildTransientState() recoveredListenerPreparer = (ProxyPreparer) Config.getNonNullEntry(config, MailboxImpl.MERCURY, "recoveredListenerPreparer", ProxyPreparer.class, new BasicProxyPreparer()); - if (MailboxImpl.initLogger.isLoggable(Level.CONFIG)) { - MailboxImpl.initLogger.log(Level.CONFIG, "Recovered listener preparer is: {0}", recoveredListenerPreparer); + if (MailboxImpl.INIT_LOGGER.isLoggable(Level.CONFIG)) { + MailboxImpl.INIT_LOGGER.log(Level.CONFIG, "Recovered listener preparer is: {0}", recoveredListenerPreparer); } // Note: referenced by recovery logic, below recoveredLocatorToJoinPreparer = (ProxyPreparer) Config.getNonNullEntry(config, MailboxImpl.MERCURY, "recoveredLocatorToJoinPreparer", ProxyPreparer.class, new BasicProxyPreparer()); - if (MailboxImpl.initLogger.isLoggable(Level.CONFIG)) { - MailboxImpl.initLogger.log(Level.CONFIG, "Recovered locator preparer is: {0}", recoveredLocatorToJoinPreparer); + if (MailboxImpl.INIT_LOGGER.isLoggable(Level.CONFIG)) { + MailboxImpl.INIT_LOGGER.log(Level.CONFIG, "Recovered locator preparer is: {0}", recoveredLocatorToJoinPreparer); } logToSnapshotThreshold = Config.getIntEntry(config, MailboxImpl.MERCURY, "logToSnapshotThreshold", 50, 0, Integer.MAX_VALUE); - log = new ReliableLog(persistenceDirectory, localLogHandler); - if (MailboxImpl.initLogger.isLoggable(Level.FINEST)) { - MailboxImpl.initLogger.log(Level.FINEST, "Recovering persistent state"); - } - log.recover(); - } - if (serviceID == null) { - // First time up, get initial values - if (MailboxImpl.initLogger.isLoggable(Level.FINEST)) { - MailboxImpl.initLogger.log(Level.FINEST, "Getting initial values."); - } - serviceID = UuidFactory.generate(); - if (MailboxImpl.initLogger.isLoggable(Level.FINEST)) { - MailboxImpl.initLogger.log(Level.FINEST, "ServiceID: {0}", serviceID); - } - // Can be null for ALL_GROUPS - lookupGroups = (String[]) config.getEntry(MailboxImpl.MERCURY, "initialLookupGroups", String[].class, new String[]{""}); //default to public group - //default to public group - if (MailboxImpl.initLogger.isLoggable(Level.CONFIG)) { - MailboxImpl.initLogger.log(Level.CONFIG, "Initial groups:"); - MailboxImpl.dumpGroups(lookupGroups, MailboxImpl.initLogger, Level.CONFIG); - } - /* - * Note: Configuration provided locators are assumed to be - * prepared already. - */ - lookupLocators = (LookupLocator[]) Config.getNonNullEntry(config, MailboxImpl.MERCURY, "initialLookupLocators", LookupLocator[].class, new LookupLocator[0]); - if (MailboxImpl.initLogger.isLoggable(Level.CONFIG)) { - MailboxImpl.initLogger.log(Level.CONFIG, "Initial locators:"); - MailboxImpl.dumpLocators(lookupLocators, MailboxImpl.initLogger, Level.CONFIG); - } - final Entry[] initialAttrs = (Entry[]) Config.getNonNullEntry(config, MailboxImpl.MERCURY, "initialLookupAttributes", Entry[].class, new Entry[0]); - if (MailboxImpl.initLogger.isLoggable(Level.CONFIG)) { - MailboxImpl.initLogger.log(Level.CONFIG, "Initial lookup attributes:"); - MailboxImpl.dumpAttrs(initialAttrs, MailboxImpl.initLogger, Level.CONFIG); - } - if (initialAttrs.length == 0) { - lookupAttrs = baseLookupAttrs; - } else { - lookupAttrs = new Entry[initialAttrs.length + baseLookupAttrs.length]; - int i = 0; - for (int j = 0; j < baseLookupAttrs.length; j++, i++) { - lookupAttrs[i] = baseLookupAttrs[j]; - } - for (int j = 0; j < initialAttrs.length; j++, i++) { - lookupAttrs[i] = initialAttrs[j]; - } - } - if (MailboxImpl.initLogger.isLoggable(Level.FINEST)) { - MailboxImpl.initLogger.log(Level.FINEST, "Combined lookup attributes:"); - MailboxImpl.dumpAttrs(lookupAttrs, MailboxImpl.initLogger, Level.FINEST); - } - } else { - // recovered logic - if (MailboxImpl.initLogger.isLoggable(Level.FINEST)) { - MailboxImpl.initLogger.log(Level.FINEST, "Preparing recovered locators:"); - MailboxImpl.dumpLocators(lookupLocators, MailboxImpl.initLogger, Level.FINEST); - } - MailboxImpl.prepareExistingLocators(recoveredLocatorToJoinPreparer, lookupLocators); - //TODO - Add recovered state debug: groups, locators, etc. - } - if (persistent) { - // Take snapshot of current state. - if (MailboxImpl.initLogger.isLoggable(Level.FINEST)) { - MailboxImpl.initLogger.log(Level.FINEST, "Taking snapshot."); - } - log.snapshot(); - // Reconstruct any transient state, if necessary. - //rebuildTransientState(recoveredListenerPreparer); - if (MailboxImpl.operationsLogger.isLoggable(Level.FINER)) { - MailboxImpl.operationsLogger.entering(MailboxImpl.mailboxSourceClass, "rebuildTransientState", recoveredListenerPreparer); - } - this.snapshotter = snapshotter; - // Reconstruct regByExpiration and pendingReg data structures, - // if necessary. - if (!regByID.isEmpty()) { - if (MailboxImpl.recoveryLogger.isLoggable(Level.FINEST)) { - MailboxImpl.recoveryLogger.log(Level.FINEST, "Rebuilding transient state ..."); - } - Collection<ServiceRegistration> regs = regByID.values(); - Iterator<ServiceRegistration> iter = regs.iterator(); - ServiceRegistration reg = null; - Uuid uuid = null; - EventLogIterator eli = null; - while (iter.hasNext()) { - reg = iter.next(); // get Reg - // get Reg - uuid = reg.getCookie(); // get its Uuid - // get its Uuid - if (MailboxImpl.recoveryLogger.isLoggable(Level.FINEST)) { - MailboxImpl.recoveryLogger.log(Level.FINEST, "Checking reg : {0}", reg); - } - // Check if registration is still current - if (MailboxImpl.ensureCurrent(reg)) { - if (MailboxImpl.recoveryLogger.isLoggable(Level.FINEST)) { - MailboxImpl.recoveryLogger.log(Level.FINEST, "Restoring reg transient state ..."); - } - try { - reg.restoreTransientState(recoveredListenerPreparer); - } catch (Exception e) { - if (MailboxImpl.recoveryLogger.isLoggable(Levels.HANDLED)) { - MailboxImpl.recoveryLogger.log(Levels.HANDLED, "Trouble restoring reg transient state", e); - } - try { - reg.setEventTarget(null); - } catch (IOException ioe) { - throw new AssertionError("Setting a null target threw an exception: " + ioe); - } - } - if (MailboxImpl.recoveryLogger.isLoggable(Level.FINEST)) { - MailboxImpl.recoveryLogger.log(Level.FINEST, "Reinitializing iterator ..."); - } - // regenerate an EventLogIterator for this Reg - // Note that event state is maintained separately - // through the event log mechanism. - eli = persistent ? eventLogFactory.iterator(uuid, MailboxImpl.getEventLogPath(persistenceDirectory, uuid)) : eventLogFactory.iterator(uuid); - reg.setIterator(eli); - if (MailboxImpl.recoveryLogger.isLoggable(Level.FINEST)) { - MailboxImpl.recoveryLogger.log(Level.FINEST, "Adding registration to expiration watch list"); - } - // Put Reg into time sorted collection - regByExpiration.put(reg, reg); - // Check if registration needs to be added to the - // pending list. Note, we could have processed - // an "enabled" log record during recovery, so - // only add it if it's not already there. - // We don't need to check activeReg since the - // the notifier hasn't kicked in yet. Don't call - // enableRegistration() since it clears the "unknown - // events" list which we want to maintain. - if (reg.hasEventTarget() && !pendingReg.contains(uuid)) { - if (MailboxImpl.recoveryLogger.isLoggable(Level.FINEST)) { - MailboxImpl.recoveryLogger.log(Level.FINEST, "Adding registration to pending task list"); - } - pendingReg.add(uuid); - } - } else { - /* Registration has expired, so remove it via the iterator, - * which is the only "safe" way to do it during a traversal. - * Call the overloaded version of removeRegistration() - * which will avoid directly removing the registration - * from regByID (which would result in a - * ConcurrentModificationException). See Bug 4507320. - */ - if (MailboxImpl.recoveryLogger.isLoggable(Level.FINEST)) { - MailboxImpl.recoveryLogger.log(Level.FINEST, "Removing expired registration: "); - } - iter.remove(); - // removeRegistration(uuid, reg, true); - /**/ - // Remove Reg from data structures, if present. - // If initializing, don't remove directly from regByID since we - // currently traversing it via an iterator. Assumption is that - // the caller has already removed it via the iterator. - // See Bug 4507320. - // if (!initializing) { - // regByID.remove(uuid); - // } - regByExpiration.remove(reg); - boolean exists = pendingReg.remove(uuid); - MailboxImpl.NotifyTask task = activeReg.remove(uuid); - if (task != null) { - // cancel active task, if any - task.cancel(false); - if (MailboxImpl.deliveryLogger.isLoggable(Level.FINEST)) { - MailboxImpl.deliveryLogger.log(Level.FINEST, "Cancelling active notification task for {0}", uuid); - } - } - // Delete any associated resources - try { - if (MailboxImpl.persistenceLogger.isLoggable(Level.FINEST)) { - MailboxImpl.persistenceLogger.log(Level.FINEST, "Removing logs for {0}", reg); - } - EventLogIterator it = reg.iterator(); - if (it != null) { - it.destroy(); - } - } catch (IOException ioe) { - if (MailboxImpl.persistenceLogger.isLoggable(Levels.HANDLED)) { - MailboxImpl.persistenceLogger.log(Levels.HANDLED, "Trouble removing logs", ioe); - } - // Did the best we could ... continue. - } - // Sanity check - if (exists && task != null) { - if (MailboxImpl.leaseLogger.isLoggable(Level.SEVERE)) { - MailboxImpl.leaseLogger.log(Level.SEVERE, "ERROR: Registration was found " + "on both the active and pending lists"); - } - // TODO (FCS)- throw assertion error - } - if (MailboxImpl.operationsLogger.isLoggable(Level.FINER)) { - MailboxImpl.operationsLogger.exiting(MailboxImpl.mailboxSourceClass, "removeRegistration"); - } - /**/ - } - } - } - if (MailboxImpl.operationsLogger.isLoggable(Level.FINER)) { - MailboxImpl.operationsLogger.exiting(MailboxImpl.mailboxSourceClass, "rebuildTransientState"); - } + } + maxUnexportDelay = Config.getLongEntry(config, MailboxImpl.MERCURY, "maxUnexportDelay", 2 * TimeConstants.MINUTES, 0, Long.MAX_VALUE); unexportRetryDelay = Config.getLongEntry(config, MailboxImpl.MERCURY, "unexportRetryDelay", TimeConstants.SECONDS, 1, Long.MAX_VALUE); }
Modified: river/jtsk/trunk/src/org/apache/river/mercury/PersistentEventLog.java URL: http://svn.apache.org/viewvc/river/jtsk/trunk/src/org/apache/river/mercury/PersistentEventLog.java?rev=1719761&r1=1719760&r2=1719761&view=diff ============================================================================== --- river/jtsk/trunk/src/org/apache/river/mercury/PersistentEventLog.java (original) +++ river/jtsk/trunk/src/org/apache/river/mercury/PersistentEventLog.java Sun Dec 13 04:43:42 2015 @@ -88,7 +88,7 @@ class PersistentEventLog implements Even /** <tt>Logger</tt> used for persistence-related debugging messages */ private static final Logger persistenceLogger = - MailboxImpl.persistenceLogger; + MailboxImpl.PERSISTENCE_LOGGER; /** Size of control data file: 4 longs * 8 bytes per long */ private static final int CTLBLOCK_LEN = 8 * 4; Modified: river/jtsk/trunk/src/org/apache/river/mercury/StreamPool.java URL: http://svn.apache.org/viewvc/river/jtsk/trunk/src/org/apache/river/mercury/StreamPool.java?rev=1719761&r1=1719760&r2=1719761&view=diff ============================================================================== --- river/jtsk/trunk/src/org/apache/river/mercury/StreamPool.java (original) +++ river/jtsk/trunk/src/org/apache/river/mercury/StreamPool.java Sun Dec 13 04:43:42 2015 @@ -44,7 +44,7 @@ class StreamPool { // Class fields /** Logger for lease related messages */ private static final Logger persistenceLogger = - MailboxImpl.persistenceLogger; + MailboxImpl.PERSISTENCE_LOGGER; /** * Maximum limit for the number of concurrent <tt>LogStream</tt>s Modified: river/jtsk/trunk/src/org/apache/river/mercury/TransientEventLog.java URL: http://svn.apache.org/viewvc/river/jtsk/trunk/src/org/apache/river/mercury/TransientEventLog.java?rev=1719761&r1=1719760&r2=1719761&view=diff ============================================================================== --- river/jtsk/trunk/src/org/apache/river/mercury/TransientEventLog.java (original) +++ river/jtsk/trunk/src/org/apache/river/mercury/TransientEventLog.java Sun Dec 13 04:43:42 2015 @@ -60,7 +60,7 @@ class TransientEventLog implements Event /** <tt>Logger</tt> used for persistence-related debugging messages */ private static final Logger persistenceLogger = - MailboxImpl.persistenceLogger; + MailboxImpl.PERSISTENCE_LOGGER; // // Object fields
