[Design of JBossCache] - Re: Lock striping broken for Second Level Cache use case
by bstansberry@jboss.com
I tried a locally built snapshot of trunk with dukehoops' test and the problem goes away.
Can you use a putIfAbsent instead of a get to try to preserve the original lock? Idea being that if threads are waiting on the original lock you try to keep using it rather than having them queue up on a new lock.
| ### Eclipse Workspace Patch 1.0
| #P jbosscache-core
| Index: src/main/java/org/jboss/cache/util/concurrent/locks/PerElementLockContainer.java
| ===================================================================
| --- src/main/java/org/jboss/cache/util/concurrent/locks/PerElementLockContainer.java (revision 7915)
| +++ src/main/java/org/jboss/cache/util/concurrent/locks/PerElementLockContainer.java (working copy)
| @@ -56,7 +56,8 @@
| Lock l = getLock(object);
| l.lock();
| // now check that the lock is still valid...
| - if (l != locks.get(object))
| + Lock official = locks.putIfAbsent(object, l);
| + if (official != null && l != official)
| {
| // we acquired the wrong lock!
| l.unlock();
|
(The above would be applied to the overloaded acquireLock(E, long. TimeUnit) as well.)
There is still a possibility that after the lock owner removes the lock from the map in releaseLock() another thread could sneak in and create a new lock. But that's not incorrect, just not fair.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4219185#4219185
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4219185
17 years
[Design of Messaging on JBoss (Messaging/JBoss)] - Re: Semantic on Session.stop and MessageHandler
by timfox
It should have same semantics as JMS connection.stop.
This is explained in the JMS javadoc:
anonymous wrote :
| Temporarily stops a connection's delivery of incoming messages. Delivery can be restarted using the connection's start method. When the connection is stopped, delivery to all the connection's message consumers is inhibited: synchronous receives block, and messages are not delivered to message listeners. This call blocks until receives and/or message listeners in progress have completed. Stopping a connection has no effect on its ability to send messages. A call to stop on a connection that has already been stopped is ignored. A call to stop must not return until delivery of messages has paused. This means that a client can rely on the fact that none of its message listeners will be called and that all threads of control waiting for receive calls to return will not return with a message until the connection is restarted. The receive timers for a stopped connection continue to advance, so receives may time out while the connection is stopped. If message listeners are running when stop is invoked, the stop call must wait until all of them have returned before it may return. While these message listeners are completing, they must have the full services of the connection available to them.
|
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4219142#4219142
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4219142
17 years
[Design of POJO Server] - JAXB Deployer
by anil.saldhana@jboss.com
I have an independent JAXB model for configuration from a separate project called as JBossXACML (which does not have any dependencies on JBossXB).
As part of https://jira.jboss.org/jira/browse/JBAS-6607, I tried using the SchemaResolvingDeployer but it was unable to locate the schema. Additionally, registering with JBossXB is a noop because my metadata does not have the @JBossxml annotation.
Given this, I looked at the JAXBDeployer http://anonsvn.jboss.org/repos/jbossas/projects/jboss-deployers/tags/2.0.... in deployers which is an abstract class. The issue with this is that if the JAXB metadata has a root of JAXBElement from the following schema:
http://anonsvn.jboss.org/repos/jbossas/projects/security/security-xacml/t...
then the JAXBDeployer create method falls apart because it tries to instantiate JAXBElement.
Issue with JAXBDeployer:
"context" and "properties" need to made protected.
My JAXBElementParsingDeployer looks as follows:
| package org.jboss.security.deployers;
|
| import java.io.InputStream;
| import java.util.Map;
|
| import javax.xml.bind.JAXBContext;
| import javax.xml.bind.Unmarshaller;
|
| import org.jboss.deployers.vfs.spi.deployer.JAXBDeployer;
| import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
| import org.jboss.virtual.VirtualFile;
| import org.xml.sax.InputSource;
|
| /**
| * A parsing deployer that is capable of parsing
| * a JAXB model with the root element being
| * JAXBElement<T>
| */
| @SuppressWarnings("unchecked")
| public class JAXBElementParsingDeployer<T,V> extends JAXBDeployer
| {
| /** The JAXBContext */
| protected JAXBContext context;
|
| /** The properties */
| protected Map<String, Object> properties;
|
| protected Class<V> enclosed;
|
| /**
| * CTR
| * @param output JAXBElement.class
| * @param enclosed Type enclosed by JAXBElement
| */
| public JAXBElementParsingDeployer(Class<T> output, Class<V> enclosed)
| {
| super(output);
| this.enclosed = enclosed;
| }
|
| /**
| * Create lifecycle
| *
| * @throws Exception for any problem
| */
| @Override
| public void create() throws Exception
| {
| if (properties != null)
| context = JAXBContext.newInstance(new Class[] {enclosed}, properties);
| else
| context = JAXBContext.newInstance(enclosed);
| }
|
| /**
| * Destroy lifecycle
| */
| public void destroy()
| {
| context = null;
| }
|
| @Override
| protected Object parse(VFSDeploymentUnit unit, VirtualFile file, Object root) throws Exception
| {
| Unmarshaller unmarshaller = context.createUnmarshaller();
| InputStream is = openStreamAndValidate(file);
| try
| {
| InputSource source = new InputSource(is);
| source.setSystemId(file.toURI().toString());
| Object o = unmarshaller.unmarshal(source);
| return getOutput().cast(o);
| }
| finally
| {
| try
| {
| is.close();
| }
| catch (Exception ignored)
| {
| }
| }
| }
| }
|
So if "context" and "properties" are made protected members of the JAXBDeployer then I can just override the create method to avoid the duplicated parse.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4219131#4219131
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4219131
17 years