Example usage for io.netty.util HashedWheelTimer HashedWheelTimer

List of usage examples for io.netty.util HashedWheelTimer HashedWheelTimer

Introduction

In this page you can find the example usage for io.netty.util HashedWheelTimer HashedWheelTimer.

Prototype

public HashedWheelTimer(long tickDuration, TimeUnit unit) 

Source Link

Document

Creates a new timer with the default thread factory ( Executors#defaultThreadFactory() ) and default number of ticks per wheel.

Usage

From source file:org.opendaylight.controller.config.yang.netty.timer.HashedWheelTimerCloseable.java

License:Open Source License

public static HashedWheelTimerCloseable newInstance(@Nullable ThreadFactory threadFactory,
        @Nullable Long duration, @Nullable Integer ticksPerWheel) {
    TimeUnit unit = TimeUnit.MILLISECONDS;
    if (!nullOrNonZero(duration) && threadFactory == null && nullOrNonZero(ticksPerWheel)) {
        return new HashedWheelTimerCloseable(new HashedWheelTimer(duration, unit));
    }/*w  w  w.  ja v a 2s  .c o  m*/

    if (!nullOrNonZero(duration) && threadFactory == null && !nullOrNonZero(ticksPerWheel)) {
        return new HashedWheelTimerCloseable(new HashedWheelTimer(duration, unit, ticksPerWheel));
    }

    if (nullOrNonZero(duration) && threadFactory != null && nullOrNonZero(ticksPerWheel)) {
        return new HashedWheelTimerCloseable(new HashedWheelTimer(threadFactory));
    }

    if (!nullOrNonZero(duration) && threadFactory != null && nullOrNonZero(ticksPerWheel)) {
        return new HashedWheelTimerCloseable(new HashedWheelTimer(threadFactory, duration, unit));
    }

    if (!nullOrNonZero(duration) && threadFactory != null && !nullOrNonZero(ticksPerWheel)) {
        return new HashedWheelTimerCloseable(
                new HashedWheelTimer(threadFactory, duration, unit, ticksPerWheel));
    }

    return new HashedWheelTimerCloseable(new HashedWheelTimer());
}

From source file:org.opendaylight.opendove.odmc.implementation.Activator.java

License:Open Source License

/**
 * Function called when the activator starts just after some
 * initializations are done by the//from   ww w  .ja v a  2  s.c o  m
 * ComponentActivatorAbstractBase.
 *
 */
@Override
public void init() {
    openDoveGC = new OpenDoveGC();
    scheduler = new HashedWheelTimer(1000, TimeUnit.MILLISECONDS);
    openDoveGC.setTimer(scheduler);
    scheduler.newTimeout(openDoveGC, 5000, TimeUnit.MILLISECONDS);
    scheduler.start();
}

From source file:sas.systems.imflux.session.rtp.AbstractRtpSession.java

License:Apache License

/**
 * //from  w w  w . j  ava  2s .  c o  m
 * @param id
 * @param payloadType 
 * @param local information about the local participant
 * @param timer timer for periodic RTCP report sending, if the timer is shared across the application
 */
public AbstractRtpSession(String id, int payloadType, RtpParticipant local, HashedWheelTimer timer) {
    if ((payloadType < 0) || (payloadType > 127)) {
        throw new IllegalArgumentException("PayloadTypes must be in range [0;127]");
    }

    if (!local.isReceiver()) {
        throw new IllegalArgumentException("Local participant must have its data & control addresses set");
    }

    this.id = id;
    this.payloadType = payloadType;
    this.localParticipant = local;
    this.participantDatabase = this.createDatabase();
    if (timer == null) {
        this.timer = new HashedWheelTimer(1, TimeUnit.SECONDS);
        this.internalTimer = true;
    } else {
        this.timer = timer;
        this.internalTimer = false;
    }

    this.running = new AtomicBoolean(false);
    // CopyOnWriteArrayList to make this class thread-safe
    this.dataListeners = new CopyOnWriteArrayList<>();
    this.controlListeners = new CopyOnWriteArrayList<>();
    this.eventListeners = new CopyOnWriteArrayList<>();
    this.sequence = new AtomicInteger(0);
    this.sentOrReceivedPackets = new AtomicBoolean(false);
    this.collisions = new AtomicInteger(0);
    this.sentPacketCounter = new AtomicLong(0);
    this.sentByteCounter = new AtomicLong(0);

    this.useNio = USE_NIO;
    this.discardOutOfOrder = DISCARD_OUT_OF_ORDER;
    this.bandwidthLimit = BANDWIDTH_LIMIT;
    this.sendBufferSize = SEND_BUFFER_SIZE;
    this.receiveBufferSize = RECEIVE_BUFFER_SIZE;
    this.maxCollisionsBeforeConsideringLoop = MAX_COLLISIONS_BEFORE_CONSIDERING_LOOP;
    this.automatedRtcpHandling = AUTOMATED_RTCP_HANDLING;
    this.tryToUpdateOnEverySdes = TRY_TO_UPDATE_ON_EVERY_SDES;
    this.participantDatabaseCleanup = PARTICIPANT_DATABASE_CLEANUP;
}