Issue #1835 reentrant lock in AbstractConnector.
This commit is contained in:
parent
7768a781be
commit
0fa8c565bd
|
@ -364,7 +364,6 @@ public abstract class AbstractConnector extends ContainerLifeCycle implements Co
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ConnectionFactory getConnectionFactory(String protocol)
|
||||
{
|
||||
|
@ -388,8 +387,9 @@ public abstract class AbstractConnector extends ContainerLifeCycle implements Co
|
|||
|
||||
public void addConnectionFactory(ConnectionFactory factory)
|
||||
{
|
||||
try (Locker.Lock lock = _locker.lock())
|
||||
{
|
||||
if (isRunning())
|
||||
throw new IllegalStateException(getState());
|
||||
|
||||
Set<ConnectionFactory> to_remove = new HashSet<>();
|
||||
for (String key:factory.getProtocols())
|
||||
{
|
||||
|
@ -423,12 +423,12 @@ public abstract class AbstractConnector extends ContainerLifeCycle implements Co
|
|||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("{} added {}", this, factory);
|
||||
}
|
||||
}
|
||||
|
||||
public void addFirstConnectionFactory(ConnectionFactory factory)
|
||||
{
|
||||
try (Locker.Lock lock = _locker.lock())
|
||||
{
|
||||
if (isRunning())
|
||||
throw new IllegalStateException(getState());
|
||||
|
||||
List<ConnectionFactory> existings = new ArrayList<>(_factories.values());
|
||||
_factories.clear();
|
||||
addConnectionFactory(factory);
|
||||
|
@ -436,12 +436,12 @@ public abstract class AbstractConnector extends ContainerLifeCycle implements Co
|
|||
addConnectionFactory(existing);
|
||||
_defaultProtocol = factory.getProtocol();
|
||||
}
|
||||
}
|
||||
|
||||
public void addIfAbsentConnectionFactory(ConnectionFactory factory)
|
||||
{
|
||||
try (Locker.Lock lock = _locker.lock())
|
||||
{
|
||||
if (isRunning())
|
||||
throw new IllegalStateException(getState());
|
||||
|
||||
String key=StringUtil.asciiToLowerCase(factory.getProtocol());
|
||||
if (_factories.containsKey(key))
|
||||
{
|
||||
|
@ -458,31 +458,28 @@ public abstract class AbstractConnector extends ContainerLifeCycle implements Co
|
|||
LOG.debug("{} addIfAbsent added {}", this, factory);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ConnectionFactory removeConnectionFactory(String protocol)
|
||||
{
|
||||
try (Locker.Lock lock = _locker.lock())
|
||||
{
|
||||
if (isRunning())
|
||||
throw new IllegalStateException(getState());
|
||||
|
||||
ConnectionFactory factory= _factories.remove(StringUtil.asciiToLowerCase(protocol));
|
||||
removeBean(factory);
|
||||
return factory;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ConnectionFactory> getConnectionFactories()
|
||||
{
|
||||
try (Locker.Lock lock = _locker.lock())
|
||||
{
|
||||
return _factories.values();
|
||||
}
|
||||
}
|
||||
|
||||
public void setConnectionFactories(Collection<ConnectionFactory> factories)
|
||||
{
|
||||
try (Locker.Lock lock = _locker.lock())
|
||||
{
|
||||
if (isRunning())
|
||||
throw new IllegalStateException(getState());
|
||||
|
||||
List<ConnectionFactory> existing = new ArrayList<>(_factories.values());
|
||||
for (ConnectionFactory factory: existing)
|
||||
removeConnectionFactory(factory.getProtocol());
|
||||
|
@ -490,7 +487,6 @@ public abstract class AbstractConnector extends ContainerLifeCycle implements Co
|
|||
if (factory!=null)
|
||||
addConnectionFactory(factory);
|
||||
}
|
||||
}
|
||||
|
||||
@ManagedAttribute("The priority delta to apply to acceptor threads")
|
||||
public int getAcceptorPriorityDelta()
|
||||
|
@ -520,20 +516,17 @@ public abstract class AbstractConnector extends ContainerLifeCycle implements Co
|
|||
@Override
|
||||
@ManagedAttribute("Protocols supported by this connector")
|
||||
public List<String> getProtocols()
|
||||
{
|
||||
synchronized (_factories)
|
||||
{
|
||||
return new ArrayList<>(_factories.keySet());
|
||||
}
|
||||
}
|
||||
|
||||
public void clearConnectionFactories()
|
||||
{
|
||||
synchronized (_factories)
|
||||
{
|
||||
if (isRunning())
|
||||
throw new IllegalStateException(getState());
|
||||
|
||||
_factories.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@ManagedAttribute("This connector's default protocol")
|
||||
public String getDefaultProtocol()
|
||||
|
@ -616,10 +609,7 @@ public abstract class AbstractConnector extends ContainerLifeCycle implements Co
|
|||
if (_acceptorPriorityDelta!=0)
|
||||
thread.setPriority(Math.max(Thread.MIN_PRIORITY,Math.min(Thread.MAX_PRIORITY,priority+_acceptorPriorityDelta)));
|
||||
|
||||
synchronized (AbstractConnector.this)
|
||||
{
|
||||
_acceptors[_id] = thread;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -676,26 +666,6 @@ public abstract class AbstractConnector extends ContainerLifeCycle implements Co
|
|||
}
|
||||
|
||||
|
||||
// protected void connectionOpened(Connection connection)
|
||||
// {
|
||||
// _stats.connectionOpened();
|
||||
// connection.onOpen();
|
||||
// }
|
||||
//
|
||||
// protected void connectionClosed(Connection connection)
|
||||
// {
|
||||
// connection.onClose();
|
||||
// long duration = System.currentTimeMillis() - connection.getEndPoint().getCreatedTimeStamp();
|
||||
// _stats.connectionClosed(duration, connection.getMessagesIn(), connection.getMessagesOut());
|
||||
// }
|
||||
//
|
||||
// public void connectionUpgraded(Connection oldConnection, Connection newConnection)
|
||||
// {
|
||||
// oldConnection.onClose();
|
||||
// _stats.connectionUpgraded(oldConnection.getMessagesIn(), oldConnection.getMessagesOut());
|
||||
// newConnection.onOpen();
|
||||
// }
|
||||
|
||||
@Override
|
||||
public Collection<EndPoint> getConnectedEndPoints()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue