You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cz...@apache.org on 2020/09/15 05:08:08 UTC
[felix-dev] branch master updated: FELIX-6330 : Use term deny list
for event handlers hitting the timeout
This is an automated email from the ASF dual-hosted git repository.
cziegeler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/felix-dev.git
The following commit(s) were added to refs/heads/master by this push:
new c0cb779 FELIX-6330 : Use term deny list for event handlers hitting the timeout
c0cb779 is described below
commit c0cb779f598141fd554432ea9be1511b52f38ee6
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Tue Sep 15 07:07:56 2020 +0200
FELIX-6330 : Use term deny list for event handlers hitting the timeout
---
eventadmin/impl/changelog.txt | 2 ++
eventadmin/impl/pom.xml | 2 +-
.../apache/felix/eventadmin/impl/Activator.java | 4 +++-
.../felix/eventadmin/impl/Configuration.java | 6 ++---
.../eventadmin/impl/MetaTypeProviderImpl.java | 4 ++--
.../eventadmin/impl/handler/EventHandlerProxy.java | 26 +++++++++++-----------
.../impl/handler/EventHandlerTracker.java | 6 ++---
.../{BlacklistLatch.java => DenylistLatch.java} | 22 +++++++++---------
.../felix/eventadmin/impl/tasks/HandlerTask.java | 16 ++++++-------
.../eventadmin/impl/tasks/SyncDeliverTasks.java | 8 +++----
10 files changed, 50 insertions(+), 46 deletions(-)
diff --git a/eventadmin/impl/changelog.txt b/eventadmin/impl/changelog.txt
index 59384bf..570d04b 100644
--- a/eventadmin/impl/changelog.txt
+++ b/eventadmin/impl/changelog.txt
@@ -4,6 +4,8 @@ Changes in 1.6.0
* [FELIX-4678] - Make list of denied event handlers available via JMX
** Task
* [FELIX-6329] - Update event admin to Java 8
+ * [FELIX-6330] - Use term deny list for event handlers hitting the timeout
+
Changes in 1.5.0
----------------
diff --git a/eventadmin/impl/pom.xml b/eventadmin/impl/pom.xml
index 12f8156..9e2378f 100644
--- a/eventadmin/impl/pom.xml
+++ b/eventadmin/impl/pom.xml
@@ -29,7 +29,7 @@
<description>
This bundle provides an implementation of the OSGi R7 EventAdmin service.
</description>
- <version>1.5.1-SNAPSHOT</version>
+ <version>1.6.0-SNAPSHOT</version>
<artifactId>org.apache.felix.eventadmin</artifactId>
<scm>
<connection>scm:git:https://github.com/apache/felix-dev.git</connection>
diff --git a/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/Activator.java b/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/Activator.java
index 39378ad..53fdfaa 100644
--- a/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/Activator.java
+++ b/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/Activator.java
@@ -25,7 +25,7 @@ import org.osgi.framework.BundleContext;
/**
* The activator of the EventAdmin bundle. This class registers an implementation of
* the OSGi R4 <tt>EventAdmin</tt> service (see the Compendium 113) with the
- * framework. It features timeout-based blacklisting of event-handlers for both,
+ * framework. It features timeout-based denying of event-handlers for both,
* asynchronous and synchronous event-dispatching (as a spec conform optional
* extension).
*
@@ -51,6 +51,7 @@ public class Activator implements BundleActivator
*
* @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
*/
+ @Override
public void start(final BundleContext context)
{
// init the LogWrapper. Subsequently, the static methods of the LogWrapper
@@ -76,6 +77,7 @@ public class Activator implements BundleActivator
*
* @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
*/
+ @Override
public void stop(final BundleContext context)
{
if ( m_config != null )
diff --git a/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/Configuration.java b/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/Configuration.java
index 1429857..e0faaf9 100644
--- a/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/Configuration.java
+++ b/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/Configuration.java
@@ -61,12 +61,12 @@ import org.osgi.service.metatype.MetaTypeProvider;
* </p>
* <p>
* <p>
- * <tt>org.apache.felix.eventadmin.Timeout</tt> - The black-listing timeout in
+ * <tt>org.apache.felix.eventadmin.Timeout</tt> - The deny-listing timeout in
* milliseconds
* </p>
* The default value is 5000. Increase or decrease at own discretion. A value of less
* then 100 turns timeouts off. Any other value is the time in milliseconds granted
- * to each <tt>EventHandler</tt> before it gets blacklisted.
+ * to each <tt>EventHandler</tt> before it gets put on the denylist.
* </p>
* <p>
* <p>
@@ -288,7 +288,7 @@ public class Configuration
// The timeout in milliseconds - A value of less then 100 turns timeouts off.
// Any other value is the time in milliseconds granted to each EventHandler
- // before it gets blacklisted.
+ // before it gets denied.
m_timeout = getIntProperty(PROP_TIMEOUT,
m_bundleContext.getProperty(PROP_TIMEOUT), 5000, Integer.MIN_VALUE);
diff --git a/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/MetaTypeProviderImpl.java b/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/MetaTypeProviderImpl.java
index 46830fe..0c5e343 100644
--- a/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/MetaTypeProviderImpl.java
+++ b/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/MetaTypeProviderImpl.java
@@ -111,9 +111,9 @@ public class MetaTypeProviderImpl
m_asyncThreadPoolRatio));
adList.add( new AttributeDefinitionImpl( Configuration.PROP_TIMEOUT, "Timeout",
- "The black-listing timeout in milliseconds. The default value is 5000. Increase or decrease " +
+ "The deny-list timeout in milliseconds. The default value is 5000. Increase or decrease " +
"at own discretion. A value of less then 100 turns timeouts off. Any other value is the time " +
- "in milliseconds granted to each event handler before it gets blacklisted",
+ "in milliseconds granted to each event handler before it gets denied",
m_timeout ) );
adList.add( new AttributeDefinitionImpl( Configuration.PROP_REQUIRE_TOPIC, "Require Topic",
diff --git a/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/handler/EventHandlerProxy.java b/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/handler/EventHandlerProxy.java
index 5d46609..5ff9938 100644
--- a/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/handler/EventHandlerProxy.java
+++ b/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/handler/EventHandlerProxy.java
@@ -36,7 +36,7 @@ import org.osgi.service.event.EventHandler;
* on demand and prepares some information for faster processing.
*
* It checks the timeout handling for the implementation as well as
- * blacklisting the handler.
+ * putting the handler on the deny list.
*
* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
*/
@@ -57,8 +57,8 @@ public class EventHandlerProxy {
/** Lazy fetched event handler. */
private volatile EventHandler handler;
- /** Is this handler blacklisted? */
- private volatile boolean blacklisted;
+ /** Is this handler denied? */
+ private volatile boolean denied;
/** Use timeout. */
private boolean useTimeout;
@@ -85,7 +85,7 @@ public class EventHandlerProxy {
*/
public boolean update()
{
- this.blacklisted = false;
+ this.denied = false;
boolean valid = true;
// First check, topic
final Object topicObj = reference.getProperty(EventConstants.EVENT_TOPIC);
@@ -334,13 +334,13 @@ public class EventHandlerProxy {
/**
* Check if this handler is allowed to receive the event
- * - blacklisted
+ * - denied
* - check filter
* - check permission
*/
public boolean canDeliver(final Event event)
{
- if ( this.blacklisted )
+ if ( this.denied )
{
return false;
}
@@ -434,23 +434,23 @@ public class EventHandlerProxy {
}
/**
- * Blacklist the handler.
+ * Deny the handler.
*/
- public void blackListHandler()
+ public void denyEventHandler()
{
- if(!this.blacklisted)
+ if(!this.denied)
{
LogWrapper.getLogger().log(
LogWrapper.LOG_WARNING,
- "Blacklisting ServiceReference [" + this.reference + " | Bundle("
+ "Denying event handler from ServiceReference [" + this.reference + " | Bundle("
+ this.reference.getBundle() + ")] due to timeout!");
- this.blacklisted = true;
+ this.denied = true;
// we can free the handler now.
this.release();
}
}
- public boolean isBlacklisted() {
- return this.blacklisted;
+ public boolean isDenied() {
+ return this.denied;
}
}
diff --git a/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/handler/EventHandlerTracker.java b/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/handler/EventHandlerTracker.java
index 77037ac..7c3c5fd 100644
--- a/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/handler/EventHandlerTracker.java
+++ b/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/handler/EventHandlerTracker.java
@@ -234,21 +234,21 @@ public class EventHandlerTracker extends ServiceTracker<EventHandler, EventHandl
final Set<EventHandlerProxy> handlers = new HashSet<>();
for(final EventHandlerProxy p : this.matchingAllEvents) {
- if ( p.isBlacklisted() ) {
+ if ( p.isDenied() ) {
handlers.add(p);
}
}
for(final List<EventHandlerProxy> l : this.matchingPrefixTopic.values()) {
for(final EventHandlerProxy p :l) {
- if ( p.isBlacklisted() ) {
+ if ( p.isDenied() ) {
handlers.add(p);
}
}
}
for(final List<EventHandlerProxy> l : this.matchingTopic.values()) {
for(final EventHandlerProxy p :l) {
- if ( p.isBlacklisted() ) {
+ if ( p.isDenied() ) {
handlers.add(p);
}
}
diff --git a/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/tasks/BlacklistLatch.java b/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/tasks/DenylistLatch.java
similarity index 79%
rename from eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/tasks/BlacklistLatch.java
rename to eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/tasks/DenylistLatch.java
index 2a844ec..4d5d1b4 100644
--- a/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/tasks/BlacklistLatch.java
+++ b/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/tasks/DenylistLatch.java
@@ -28,10 +28,10 @@ import org.apache.felix.eventadmin.impl.util.LogWrapper;
/**
*
- * A latch that checks handlers for blacklisting on an interval.
+ * A latch that checks handlers for denying on an interval.
*
*/
-public class BlacklistLatch {
+public class DenylistLatch {
private final Semaphore internalSemaphore;
@@ -43,15 +43,15 @@ public class BlacklistLatch {
/**
* @param count Number of handlers that must call countdown
- * @param timeout Timeout in Milliseconds to check for blacklisting handlers
+ * @param timeout Timeout in Milliseconds to check for denying handlers
*/
- public BlacklistLatch(final int count, final long timeout)
+ public DenylistLatch(final int count, final long timeout)
{
this.handlerTasks = new ArrayList<HandlerTask>(count);
this.count = count;
this.timeout = timeout;
- internalSemaphore = new Semaphore(count);
- internalSemaphore.drainPermits();
+ this.internalSemaphore = new Semaphore(count);
+ this.internalSemaphore.drainPermits();
}
/**
@@ -66,11 +66,11 @@ public class BlacklistLatch {
/**
*
- * Adds a handler task to the timeout based blackout checking.
+ * Adds a handler task to the timeout based deny list checking.
*
* @param task
*/
- public void addToBlacklistCheck(final HandlerTask task)
+ public void addToDenylistCheck(final HandlerTask task)
{
this.handlerTasks.add(task);
}
@@ -78,10 +78,10 @@ public class BlacklistLatch {
/**
*
* Causes current thread to wait until each handler has called countDown.
- * Checks on timeout interval to determine if a handler needs blacklisting.
+ * Checks on timeout interval to determine if a handler needs deny listing.
*
*/
- public void awaitAndBlacklistCheck()
+ public void awaitAndDenylistCheck()
{
try
{
@@ -91,7 +91,7 @@ public class BlacklistLatch {
while(handlerTaskIt.hasNext())
{
HandlerTask currentTask = handlerTaskIt.next();
- currentTask.checkForBlacklist();
+ currentTask.checkForDenylist();
}
}
}
diff --git a/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/tasks/HandlerTask.java b/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/tasks/HandlerTask.java
index db39165..bf9b0d4 100644
--- a/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/tasks/HandlerTask.java
+++ b/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/tasks/HandlerTask.java
@@ -33,7 +33,7 @@ public class HandlerTask implements Runnable
private final long timeout;
- private final BlacklistLatch handlerLatch;
+ private final DenylistLatch handlerLatch;
private volatile long startTime;
@@ -44,10 +44,10 @@ public class HandlerTask implements Runnable
*
* @param task Proxy to the event handler
* @param event The event to send to the handler
- * @param timeout Timeout for handler blacklisting
+ * @param timeout Timeout for handler denying
* @param handlerLatch The latch used to ensure events fire in proper order
*/
- public HandlerTask(final EventHandlerProxy task, final Event event, final long timeout, final BlacklistLatch handlerLatch)
+ public HandlerTask(final EventHandlerProxy task, final Event event, final long timeout, final DenylistLatch handlerLatch)
{
this.task = task;
this.event = event;
@@ -69,7 +69,7 @@ public class HandlerTask implements Runnable
// execute the task
task.sendEvent(event);
endTime = System.currentTimeMillis();
- checkForBlacklist();
+ checkForDenylist();
}
finally
{
@@ -77,7 +77,7 @@ public class HandlerTask implements Runnable
}
}
- public void runWithoutBlacklistTiming()
+ public void runWithoutDenylistTiming()
{
task.sendEvent(event);
handlerLatch.countDown();
@@ -98,14 +98,14 @@ public class HandlerTask implements Runnable
}
/**
- * Check to see if we need to blacklist this handler
+ * Check to see if we need to deny this handler
*
*/
- public void checkForBlacklist()
+ public void checkForDenylist()
{
if (useTimeout() && getTaskTime() > this.timeout)
{
- task.blackListHandler();
+ task.denyEventHandler();
}
}
diff --git a/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/tasks/SyncDeliverTasks.java b/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/tasks/SyncDeliverTasks.java
index 120fc23..abec088 100644
--- a/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/tasks/SyncDeliverTasks.java
+++ b/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/tasks/SyncDeliverTasks.java
@@ -91,7 +91,7 @@ public class SyncDeliverTasks
final SyncThread syncThread = sleepingThread instanceof SyncThread ? (SyncThread)sleepingThread : null;
final Iterator<EventHandlerProxy> i = tasks.iterator();
- final BlacklistLatch handlerLatch = new BlacklistLatch(tasks.size(), this.timeout/2);
+ final DenylistLatch handlerLatch = new DenylistLatch(tasks.size(), this.timeout/2);
while ( i.hasNext() )
{
@@ -101,7 +101,7 @@ public class SyncDeliverTasks
// {
if( !handlerTask.useTimeout() )
{
- handlerTask.runWithoutBlacklistTiming();
+ handlerTask.runWithoutDenylistTiming();
}
else if ( syncThread != null )
{
@@ -112,7 +112,7 @@ public class SyncDeliverTasks
else
{
- handlerLatch.addToBlacklistCheck(handlerTask);
+ handlerLatch.addToDenylistCheck(handlerTask);
if ( !this.pool.executeTask(handlerTask) )
{
// scheduling failed: last resort, call directly
@@ -122,7 +122,7 @@ public class SyncDeliverTasks
// }
}
- handlerLatch.awaitAndBlacklistCheck();
+ handlerLatch.awaitAndDenylistCheck();
}
}