import java.util.Map;
import java.util.Optional;
import java.util.Set;
-import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import javax.annotation.concurrent.GuardedBy;
setAfiSafiGracefulRestartState(0, false, false);
onSessionTerminated(this.session, new BGPTerminationReason(BGPError.HOLD_TIMER_EXPIRED));
}
- new ScheduledThreadPoolExecutor(1)
- .schedule(this::handleRestartTimer, peerRestartTimeNanos - elapsedNanos, TimeUnit.NANOSECONDS);
+
+ this.session.schedule(this::handleRestartTimer, peerRestartTimeNanos - elapsedNanos, TimeUnit.NANOSECONDS);
}
private synchronized void handleSelectionReferralTimer() {
this.missingEOT.clear();
handleGracefulEndOfRib();
}
- new ScheduledThreadPoolExecutor(1)
- .schedule(this::handleSelectionReferralTimer, referalTimerNanos - elapsedNanos, TimeUnit.NANOSECONDS);
+ this.session.schedule(this::handleSelectionReferralTimer, referalTimerNanos - elapsedNanos,
+ TimeUnit.NANOSECONDS);
}
private void releaseConnectionGracefully() {
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
+import io.netty.util.concurrent.ScheduledFuture;
import java.io.IOException;
import java.nio.channels.NonWritableChannelException;
import java.util.ArrayList;
public <T extends PeerConstraint> void addDecoderConstraint(final Class<T> constraintClass, final T constraint) {
this.channel.pipeline().get(BGPByteToMessageDecoder.class).addDecoderConstraint(constraintClass, constraint);
}
+
+ @Override
+ public ScheduledFuture<?> schedule(final Runnable command, final long delay, final TimeUnit unit) {
+ return this.channel.eventLoop().schedule(command, delay, unit);
+ }
}
<groupId>io.netty</groupId>
<artifactId>netty-buffer</artifactId>
</dependency>
+ <dependency>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-common</artifactId>
+ </dependency>
<!-- Testing dependencies -->
<dependency>
import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;
import io.netty.channel.ChannelHandlerContext;
+import io.netty.util.concurrent.ScheduledFuture;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import java.util.concurrent.TimeUnit;
import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
import org.opendaylight.protocol.bgp.parser.BGPError;
import org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl;
final T constraint) {
// No-op
}
+
+ @Override
+ public ScheduledFuture<?> schedule(final Runnable command, final long delay, final TimeUnit unit) {
+ return null;
+ }
}
}
package org.opendaylight.protocol.bgp.rib.spi;
import io.netty.channel.ChannelInboundHandler;
+import io.netty.util.concurrent.ScheduledFuture;
import java.util.List;
import java.util.Set;
+import java.util.concurrent.TimeUnit;
import javax.annotation.Nonnull;
import org.opendaylight.protocol.bgp.parser.GracefulRestartUtil;
import org.opendaylight.protocol.bgp.parser.spi.PeerConstraint;
* Add peer constraint to session pipeline decoder.
*/
<T extends PeerConstraint> void addDecoderConstraint(Class<T> constraintClass, T constraint);
+
+ /**
+ * Schedule a task to be executed in the context of the session handling thread.
+ *
+ * @param command the task to execute
+ * @param delay the time from now to delay execution
+ * @param unit the time unit of the delay parameter
+ * @return Future representing the scheduled task.
+ */
+ ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit);
}