forked from sakaiproject/sakai
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Patch from Cris Holdorph As documented in this area of Sakai confluence http://confluence.sakaiproject.org/confluence/display/TERRA/Home This is the work that enables Sakai sessions to be clustered using Terracotta. Additional work must still be done for any tool that would like to support clustering. This is also documented in the confluence space above. Thanks git-svn-id: https://source.sakaiproject.org/svn/kernel/trunk@54470 66ffb92e-73f9-0310-93c1-f5514f145a0a
- Loading branch information
Showing
31 changed files
with
4,870 additions
and
1,322 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
kernel/api/src/main/java/org/sakaiproject/tool/api/NonPortableSession.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/********************************************************************************** | ||
* | ||
* Copyright (c) 2008 The Sakai Foundation. | ||
* | ||
* Licensed under the Educational Community License, Version 1.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.opensource.org/licenses/ecl1.php | ||
* | ||
* 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.sakaiproject.tool.api; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* NonPortableSession stores a users session data that can not be 'shared' | ||
* in a Terracotta (or similar) cluster. | ||
*/ | ||
public interface NonPortableSession { | ||
|
||
/** | ||
* Returns the object bound with the specified name in this session, or <code>null</code> if no object is bound under the name. | ||
* | ||
* @param name | ||
* a string specifying the name of the object | ||
* @return the object with the specified name | ||
* @exception IllegalStateException | ||
* if this method is called on an invalidated session | ||
*/ | ||
public Object getAttribute(String name); | ||
|
||
/** | ||
* Removes the object bound with the specified name from this session. If the session does not have an object bound with the specified name, this method does nothing. | ||
* <p> | ||
* After this method executes, and if the object implements <code>SessionBindingListener</code>, Sakai calls <code>SessionBindingListener.valueUnbound</code>. | ||
* | ||
* @param name | ||
* the name of the object to remove from this session | ||
* @return the attribute with the specified name if it existed | ||
* @exception IllegalStateException | ||
* if this method is called on an invalidated session | ||
*/ | ||
public Object removeAttribute(String name); | ||
|
||
/** | ||
* Binds an object to this session, using the name specified. If an object of the same name is already bound to the session, the object is replaced. | ||
* <p> | ||
* After this method executes, and if the new object implements <code>SessionBindingListener</code>, Sakai calls <code>SessionBindingListener.valueBound</code>. | ||
* <p> | ||
* If an object was already bound to this session of this name that implements <code>SessionBindingListener</code>, its <code>SessionBindingListener.valueUnbound</code> method is called. | ||
* <p> | ||
* If the value passed in is null, this has the same effect as calling <code>removeAttribute()<code>. | ||
* | ||
* @param name the name to which the object is bound; | ||
* cannot be null | ||
* | ||
* @param value the object to be bound | ||
* @return the old attribute with the specified name if it existed | ||
* @exception IllegalStateException if this method is called on an | ||
* invalidated session | ||
*/ | ||
public Object setAttribute(String name, Object value); | ||
|
||
/** | ||
* Get all the attributes in this Session. The returned data structure is a copy of all the attributes in this Session and does not | ||
* represent the backing data structure of the Session itself. | ||
* @return a new Map object representing the key/value pair of all attributes in this session | ||
*/ | ||
public Map<String,Object> getAllAttributes(); | ||
|
||
/** | ||
* Remove all attributes from this session | ||
*/ | ||
public void clear(); | ||
} |
8 changes: 8 additions & 0 deletions
8
kernel/api/src/main/java/org/sakaiproject/tool/api/SessionAttributeListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.sakaiproject.tool.api; | ||
|
||
public interface SessionAttributeListener { | ||
|
||
public void attributeAdded(SessionBindingEvent se); | ||
public void attributeRemoved(SessionBindingEvent se); | ||
|
||
} |
46 changes: 46 additions & 0 deletions
46
kernel/api/src/main/java/org/sakaiproject/tool/api/SessionStore.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/********************************************************************************** | ||
* $URL$ | ||
* $Id$ | ||
*********************************************************************************** | ||
* | ||
* Copyright (c) 2008 The Sakai Foundation. | ||
* | ||
* Licensed under the Educational Community License, Version 1.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.opensource.org/licenses/ecl1.php | ||
* | ||
* 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.sakaiproject.tool.api; | ||
|
||
/** | ||
* SessionStore it a mix-in interface for use most commonly with SessionManager. | ||
* This interface is to represent the ability to manipulate the underlying storage | ||
* of Sessions that the SessionManager is managing. | ||
* | ||
* @author holdorph | ||
*/ | ||
public interface SessionStore { | ||
|
||
/** | ||
* Remove the Session corresponding to this id from the | ||
* Session storage. | ||
* | ||
* @param id the session identifier | ||
*/ | ||
public void remove(String id); | ||
|
||
/** | ||
* Checks the current Tool ID to determine if this tool is marked for clustering. | ||
* | ||
* @return true if the tool is marked for clustering, false otherwise. | ||
*/ | ||
public boolean isCurrentToolClusterable(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
kernel/component-manager/src/main/java/org/sakaiproject/util/TerracottaClassLoader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package org.sakaiproject.util; | ||
|
||
import java.lang.reflect.Method; | ||
import java.net.URL; | ||
import java.net.URLClassLoader; | ||
|
||
import org.apache.commons.logging.Log; | ||
import org.apache.commons.logging.LogFactory; | ||
|
||
class TerracottaClassLoader extends URLClassLoader { | ||
/** Our logger */ | ||
private static Log log = LogFactory.getLog(ComponentsLoader.class); | ||
|
||
private String classLoaderName; | ||
|
||
public TerracottaClassLoader(URL[] urls, ClassLoader parent, String classLoaderName) { | ||
super(urls, parent); | ||
|
||
this.classLoaderName = classLoaderName; | ||
|
||
boolean registeredWithTerracotta = false; | ||
|
||
try { | ||
if (parent == null) { | ||
log.error("Parent classloader is set to null."); | ||
} else { | ||
Class<?> namedClassLoader = parent.loadClass("com.tc.object.loaders.NamedClassLoader"); | ||
if (namedClassLoader == null) { | ||
log.error("Could not load Terracotta NamedClassLoader"); | ||
} else { | ||
Class<?> helper = parent.loadClass("com.tc.object.bytecode.hook.impl.ClassProcessorHelper"); | ||
if (helper == null) { | ||
log.error("Could not load Terracotta ClassProcessorHelper"); | ||
} else { | ||
Method m = helper.getMethod("registerGlobalLoader", new Class<?>[] { namedClassLoader }); | ||
if (m == null) { | ||
log.error("Could not find Terracotta Method - \"registerGlobalLoader\""); | ||
} else { | ||
m.invoke(null, new Object[] { this }); | ||
registeredWithTerracotta = true; | ||
if (log.isInfoEnabled()) { | ||
log.info("Registered the [" + classLoaderName + | ||
"] class loader with Terracotta."); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} catch (Throwable t) { | ||
// It is important that normal startup not suffer if Terracotta is not running | ||
// so catch any error that occurs in this block of code dealing with Terracotta | ||
// class loader registering | ||
log.error("Unexpected error occurred trying to register class loader [" + | ||
classLoaderName + "] with Terracotta",t); | ||
} | ||
if (!registeredWithTerracotta) { | ||
log.warn("The [" + classLoaderName + | ||
"] class loader is not registered with Terracotta. Objects from this " + | ||
"class loader will not be shared."); | ||
} | ||
} | ||
|
||
// needed for Terracotta Clustering to work. Harmless for non-Terracotta environments | ||
public String __tc_getClassLoaderName() { | ||
return classLoaderName; | ||
} | ||
} |
Oops, something went wrong.