/jboss-as-7.1.1.Final/web/src/main/java/org/jboss/as/web/session/DistributableSessionManagerMBean.java
Java | 197 lines | 27 code | 22 blank | 148 comment | 0 complexity | 6128273dd6c9ba5aecfee36875f5f0b3 MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0
1/*
2 * JBoss, Home of Professional Open Source.
3 * Copyright 2008, Red Hat Middleware LLC, and individual contributors
4 * as indicated by the @author tags. See the copyright.txt file in the
5 * distribution for a full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */
22package org.jboss.as.web.session;
23
24import org.jboss.metadata.web.jboss.ReplicationGranularity;
25import org.jboss.metadata.web.jboss.ReplicationTrigger;
26import org.jboss.metadata.web.jboss.SnapshotMode;
27
28public interface DistributableSessionManagerMBean extends SessionManagerMBean {
29 /**
30 * Gets the value of the attribute with the given key from the given session. If the session is in the distributed store but
31 * hasn't been loaded on this node, invoking this method will cause it to be loaded.
32 *
33 * @param sessionId the id of the session
34 * @param key the attribute key
35 * @return the value, converted to a String via toString(), or <code>null</code> if the session or key does not exist.
36 */
37 String getSessionAttribute(String sessionId, String key);
38
39 /**
40 * Expires the given session. If the session is in the distributed store but hasn't been loaded on this node, invoking this
41 * method will cause it to be loaded.
42 *
43 * @param sessionId the id of the session
44 */
45 void expireSession(String sessionId);
46
47 /**
48 * Gets the last time the given session was accessed. If the session is in the distributed store but hasn't been loaded on
49 * this node, invoking this method will cause it to be loaded.
50 *
51 * @param sessionId
52 * @return the last accessed time, or the empty string if the session doesn't exist.
53 */
54 String getLastAccessedTime(String sessionId);
55
56 /**
57 * Gets the creation time of the given session. If the session is in the distributed store but hasn't been loaded on this
58 * node, invoking this method will cause it to be loaded.
59 *
60 * @param sessionId
61 * @return the creation time, or or the empty string if the session doesn't exist.
62 */
63 String getCreationTime(String sessionId);
64
65 /**
66 * Gets the cache config name used to get the underlying cache from a cache manager.
67 *
68 * @return the config name, or <code>null</code> if this has not yet been configured or the cache was directly injected.
69 */
70 String getCacheConfigName();
71
72 /**
73 * Gets the replication granularity.
74 *
75 * @return SESSION, ATTRIBUTE or FIELD, or <code>null</code> if this has not yet been configured.
76 */
77 ReplicationGranularity getReplicationGranularity();
78
79 /**
80 * Gets the replication trigger.
81 *
82 * @return SET, SET_AND_GET, SET_AND_NON_PRIMITIVE_GET or <code>null</code> if this has not yet been configured.
83 */
84 ReplicationTrigger getReplicationTrigger();
85
86 /**
87 * Gets whether JK is being used and special handling of a jvmRoute portion of session ids is needed.
88 */
89 boolean getUseJK();
90
91 /**
92 * Gets the snapshot mode.
93 *
94 * @return "instant" or "interval"
95 */
96 SnapshotMode getSnapshotMode();
97
98 /**
99 * Gets the number of milliseconds between replications if "interval" mode is used.
100 */
101 int getSnapshotInterval();
102
103 /**
104 * Get the maximum interval between requests, in seconds, after which a request will trigger replication of the session's
105 * metadata regardless of whether the request has otherwise made the session dirty. Such replication ensures that other
106 * nodes in the cluster are aware of a relatively recent value for the session's timestamp and won't incorrectly expire an
107 * unreplicated session upon failover.
108 * <p/>
109 * Default value is <code>-1</code>.
110 * <p/>
111 * The cost of the metadata replication depends on the configured {@link #setReplicationGranularityString(String)
112 * replication granularity}. With <code>SESSION</code>, the session's attribute map is replicated along with the metadata,
113 * so it can be fairly costly. With other granularities, the metadata object is replicated separately from the attributes
114 * and only contains a String, and a few longs, ints and booleans.
115 *
116 * @return the maximum interval since last replication after which a request will trigger session metadata replication. A
117 * value of <code>0</code> means replicate metadata on every request; a value of <code>-1</code> means never
118 * replicate metadata unless the session is otherwise dirty.
119 */
120 int getMaxUnreplicatedInterval();
121
122 /**
123 * Sets the maximum interval between requests, in seconds, after which a request will trigger replication of the session's
124 * metadata regardless of whether the request has otherwise made the session dirty.
125 *
126 * @param maxUnreplicatedInterval the maximum interval since last replication after which a request will trigger session
127 * metadata replication. A value of <code>0</code> means replicate metadata on every request; a value of
128 * <code>-1</code> means never replicate metadata unless the session is otherwise dirty.
129 */
130 void setMaxUnreplicatedInterval(int maxUnreplicatedInterval);
131
132 /**
133 * Lists all session ids known to this manager, including those in the distributed store that have not been accessed on this
134 * node.
135 *
136 * @return a comma-separated list of session ids
137 */
138 String listSessionIds();
139
140 /**
141 * Lists all session ids known to this manager, excluding those in the distributed store that have not been accessed on this
142 * node.
143 *
144 * @return a comma-separated list of session ids
145 */
146 String listLocalSessionIds();
147
148 /**
149 * Gets whether passivation was enabled in jboss-web.xml and in the underlying cache.
150 *
151 * @return <code>true</code> if passivation is enabled in both jboss-web.xml and in the cache; <code>false</code> otherwise
152 */
153 boolean isPassivationEnabled();
154
155 /**
156 * Gets the number of passivated sessions
157 *
158 * @return
159 */
160 long getPassivatedSessionCount();
161
162 /**
163 * Gets the highest number of passivated sessions seen.
164 *
165 * @return
166 */
167 long getMaxPassivatedSessionCount();
168
169 /**
170 * Elapsed time after which an inactive session will be passivated to persistent storage if {@link #isPassivationEnabled()
171 * passivation is enabled}.
172 *
173 * @return
174 */
175 long getPassivationMaxIdleTime();
176
177 /**
178 * Elapsed time after which an inactive session will be passivated to persistent storage if {@link #isPassivationEnabled()
179 * passivation is enabled} and the manager needs to passivate sessions early in order to comply with a
180 * {@link SessionManagerMBean#getMaxActiveAllowed()} setting.
181 *
182 * @return
183 */
184 long getPassivationMinIdleTime();
185
186 /**
187 * Gets the number of duplicated session ids generated.
188 */
189 int getDuplicates();
190
191 /**
192 * Sets the number of duplicated session ids generated.
193 *
194 * @param duplicates the number of duplicates session ids
195 */
196 void setDuplicates(int duplicates);
197}