--- /dev/null
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.catalina;
+
+import java.util.Set;
+
+/**
+ * Interface implemented by session managers that do not keep a complete copy
+ * of all sessions on the local node but do know where every session is. The
+ * BackupManager is an example of such a Manager. Sessions can be primary
+ * (master copy on this node), backup (backup copy on this node) or proxy (only
+ * the session ID on this node). The identity of the primary and backup nodes
+ * are known for all sessions, including proxy sessions.
+ */
+public interface DistributedManager {
+
+ /**
+ * Returns the total session count for primary, backup and proxy.
+ *
+ * @return The total session count across the cluster.
+ */
+ public int getActiveSessionsFull();
+
+ /**
+ * Returns the list of all sessions IDS (primary, backup and proxy).
+ *
+ * @return The complete set of sessions IDs across the cluster.
+ */
+ public Set<String> getSessionIdsFull();
+}
import java.util.Iterator;
import java.util.Set;
+import org.apache.catalina.DistributedManager;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.LifecycleState;
import org.apache.catalina.Session;
*@author Filip Hanik
*@version 1.0
*/
-public class BackupManager extends ClusterManagerBase implements MapOwner {
+public class BackupManager extends ClusterManagerBase
+ implements MapOwner, DistributedManager {
private static final Log log = LogFactory.getLog(BackupManager.class);
return result;
}
+ @Override
public int getActiveSessionsFull() {
LazyReplicatedMap map = (LazyReplicatedMap)sessions;
return map.sizeFull();
}
- public String listSessionIdsFull() {
- StringBuilder sb=new StringBuilder();
- LazyReplicatedMap map = (LazyReplicatedMap)sessions;
- @SuppressWarnings("unchecked") // sessions is of type Map<String, Session>
- Iterator<String> keys = map.keySetFull().iterator();
- while (keys.hasNext()) {
- sb.append(keys.next()).append(" ");
- }
- return sb.toString();
- }
-
+ @Override
public Set<String> getSessionIdsFull() {
Set<String> sessionIds = new HashSet<String>();
LazyReplicatedMap map = (LazyReplicatedMap)sessions;
import org.apache.catalina.Container;
import org.apache.catalina.Context;
+import org.apache.catalina.DistributedManager;
import org.apache.catalina.Manager;
import org.apache.catalina.Session;
-import org.apache.catalina.ha.session.BackupManager;
import org.apache.catalina.manager.util.BaseSessionComparator;
import org.apache.catalina.manager.util.ReverseComparator;
import org.apache.catalina.manager.util.SessionUtils;
(request.getContextPath() +
"/html/sessions?path=" + URL_ENCODER.encode(displayPath));
Manager manager = ctxt.getManager();
- if (manager instanceof BackupManager && showProxySessions) {
+ if (manager instanceof DistributedManager && showProxySessions) {
args[5] = new Integer(
- ((BackupManager)manager).getActiveSessionsFull());
+ ((DistributedManager)manager).getActiveSessionsFull());
} else if (ctxt.getManager() != null){
args[5] = new Integer(manager.getActiveSessions());
} else {
Manager manager = ctxt.getManager();
List<Session> sessions = new ArrayList<Session>();
sessions.addAll(Arrays.asList(manager.findSessions()));
- if (manager instanceof BackupManager && showProxySessions) {
+ if (manager instanceof DistributedManager && showProxySessions) {
// Add dummy proxy sessions
Set<String> sessionIds =
- ((BackupManager) manager).getSessionIdsFull();
+ ((DistributedManager) manager).getSessionIdsFull();
// Remove active (primary and backup) session IDs from full list
for (Session session : sessions) {
sessionIds.remove(session.getId());
<fix>
Correct broken links for on-line JavaDocs. (markt)
</fix>
+ <fix>
+ <bug>50230</bug>: Add new DistributedManager interface that is
+ implemented by the Backup Manager to remove circular dependency between
+ tomcat-catalina-ha and tomcat-catalina modules. Also allows third-party
+ distributed Manager implementations to report full session information
+ through the HTML Manager. (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="Other">