Package com.linkedin.d2.discovery.event

Examples of com.linkedin.d2.discovery.event.PropertyEventThread


public class PropertyEventThreadTest
{
  @Test(groups = { "small", "back-end" })
  public void testUnstartedThread()
  {
    PropertyEventThread thread = new PropertyEventThread("test", 1001);

    assertEquals(thread.getRemainingCapacity(), 1001);
    assertEquals(thread.getQueuedMessageCount(), 0);
    assertFalse(thread.isAlive());
    assertTrue(thread.isDaemon());

    //assertFalse(thread.send(null));
    //assertFalse(thread.send(new PropertyTestEvent("donothing")));
  }
View Full Code Here


  }

  @Test(groups = { "small", "back-end" })
  public void testThread() throws InterruptedException
  {
    PropertyEventThread thread = new PropertyEventThread("test");
    PropertyTestEvent testEvent = new PropertyTestEvent("counter");

    // Test doesn't make sense with hacked PropertyEventThread
    //assertFalse(thread.send(testEvent));

    thread.start();

    assertTrue(thread.send(testEvent));
    assertTrue(thread.send(testEvent));

    thread.interrupt();
    thread.join(0);

    // Also doesn't make sense with hack
    //assertFalse(thread.send(testEvent));
    assertEquals(testEvent.getCount(), 2);
  }
View Full Code Here

  }

  @Override
  public void register(final PropertyEventSubscriber<T> listener)
  {
    _thread.send(new PropertyEvent("PropertyEventBus.registerAll")
    {
      @Override
      public void innerRun()
      {
        _allPropertySubscribers.add(listener);
View Full Code Here

  }

  @Override
  public void unregister(final PropertyEventSubscriber<T> listener)
  {
    _thread.send(new PropertyEvent("PropertyEventBus.unregisterAll")
    {
      @Override
      public void innerRun()
      {
        _allPropertySubscribers.remove(listener);
View Full Code Here

  @Override
  public void register(final Set<String> propertyNames,
                       final PropertyEventSubscriber<T> subscriber)
  {
    _thread.send(new PropertyEvent("PropertyEventBus.register " + propertyNames)
    {
      public void innerRun()
      {
        for (final String prop : propertyNames)
        {
View Full Code Here

  @Override
  public void unregister(final Set<String> propertyNames,
                         final PropertyEventSubscriber<T> subscriber)
  {
    _thread.send(new PropertyEvent("PropertyEventBus.unregister " + propertyNames)
    {
      public void innerRun()
      {
        for (final String prop : propertyNames)
        {
View Full Code Here

  @Override
  public void setPublisher(final PropertyEventPublisher<T> publisher)
  {

    _thread.send(new PropertyEvent("PropertyEventBus.setPublisher")
    {
      public void innerRun()
      {
        if (_publisher != null)
        {
View Full Code Here

    if (value == null)
    {
      _log.warn("Received a null event during publishInitialize for String prop = " + prop +
                    ". Still publishing the null event.");
    }
    _thread.send(new PropertyEvent("PropertyEventBus.publishInitialize " + prop)
    {
      public void innerRun()
      {
        // Because the bus can switch publishers, a new publisher may consider an event
        // an "initialize", but if the bus has previously seen that property, we will treat
View Full Code Here

    if (value == null)
    {
      _log.warn("Received a null event during publishAdd for String prop = " + prop +
                    ". Still publishing the null event.");
    }
    _thread.send(new PropertyEvent("PropertyEventBus.publishAdd " + prop)
    {
      public void innerRun()
      {
        // Ignore unless the property has been initialized
        if (_properties.containsKey(prop))
View Full Code Here

  }

  @Override
  public void publishRemove(final String prop)
  {
    _thread.send(new PropertyEvent("PropertyEventBus.publishRemove " + prop)
    {
      public void innerRun()
      {
        // Ignore unless the property has been initialized
        if (_properties.containsKey(prop))
View Full Code Here

TOP

Related Classes of com.linkedin.d2.discovery.event.PropertyEventThread

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.