Package org.apache.hadoop.hdfs.notifier

Examples of org.apache.hadoop.hdfs.notifier.NamespaceEvent


  public void testBasicDispatch() throws Exception {
    DummyServerCore core = new DummyServerCore();
    ServerDispatcher dispatcher = new ServerDispatcher(core);
    long clientId = 1000;
    DummyClientHandler handler = new DummyClientHandler();
    NamespaceEvent event = new NamespaceEvent("/a",
        EventType.FILE_ADDED.getByteValue());
    Set<Long> subscriptions = new HashSet<Long>();
    Thread dispatcherThread = new Thread(dispatcher);
   
    // Add only one client with one subscription
View Full Code Here


  public void testDispatchOrder() throws Exception {
    DummyServerCore core = new DummyServerCore();
    ServerDispatcher dispatcher = new ServerDispatcher(core);
    long clientId = 1000;
    DummyClientHandler handler = new DummyClientHandler();
    NamespaceEvent event = new NamespaceEvent("/a",
        EventType.FILE_ADDED.getByteValue());
    NamespaceEvent event2 = new NamespaceEvent("/a/c",
        EventType.FILE_CLOSED.getByteValue());
    Set<Long> subscriptions = new HashSet<Long>();
    Thread dispatcherThread = new Thread(dispatcher);
   
    // Add only one client with one subscription
View Full Code Here

  public void testDispatchOrderClientFailing() throws Exception {
    DummyServerCore core = new DummyServerCore();
    ServerDispatcher dispatcher = new ServerDispatcher(core);
    long clientId = 1000;
    DummyClientHandler handler = new DummyClientHandler();
    NamespaceEvent event = new NamespaceEvent("/a",
        EventType.FILE_ADDED.getByteValue());
    NamespaceEvent event2 = new NamespaceEvent("/a/c",
        EventType.FILE_CLOSED.getByteValue());
    Set<Long> subscriptions = new HashSet<Long>();
    Thread dispatcherThread = new Thread(dispatcher);
   
    // Add only one client with one subscription
View Full Code Here

    DummyServerCore core = new DummyServerCore();
    ServerDispatcher dispatcher = new ServerDispatcher(core);
    long client1Id = 1000, client2Id = 2000;
    DummyClientHandler handler1 = new DummyClientHandler(),
        handler2 = new DummyClientHandler();
    NamespaceEvent event1 = new NamespaceEvent("/a",
        EventType.FILE_ADDED.getByteValue());
    NamespaceEvent event2 = new NamespaceEvent("/b",
        EventType.FILE_ADDED.getByteValue());
    NamespaceEvent eventCommon = new NamespaceEvent("/c",
        EventType.FILE_ADDED.getByteValue());
    Set<Long> subscriptions = new HashSet<Long>();
    Thread dispatcherThread = new Thread(dispatcher);
   
    // Add only one client with one subscription
View Full Code Here

  public void testDispatchFailing() throws Exception {
    DummyServerCore core = new DummyServerCore();
    ServerDispatcher dispatcher = new ServerDispatcher(core);
    long clientId = 1000;
    DummyClientHandler handler = new DummyClientHandler();
    NamespaceEvent event = new NamespaceEvent("/a",
        EventType.FILE_ADDED.getByteValue());
    NamespaceEvent event2 = new NamespaceEvent("/a/c",
        EventType.FILE_CLOSED.getByteValue());
    Set<Long> subscriptions = new HashSet<Long>();
    Thread dispatcherThread = new Thread(dispatcher);
   
    // Add only one client with one subscription
View Full Code Here

    history.storeNotification(new NamespaceNotification("/a/b",
        EventType.FILE_ADDED.getByteValue(), 10));
    history.storeNotification(new NamespaceNotification("/a/c",
        EventType.FILE_ADDED.getByteValue(), 11));
    historyNotifications = new LinkedList<NamespaceNotification>();
    history.addNotificationsToQueue(new NamespaceEvent("/a",
        EventType.FILE_ADDED.getByteValue()), 10, historyNotifications);
    Assert.assertEquals(1, historyNotifications.size());
    Assert.assertEquals(11, historyNotifications.peek().txId);
    Assert.assertEquals("/a/c", historyNotifications.peek().path);
   
    // Step 2 - test with FILE_CLOSED
    history.storeNotification(new NamespaceNotification("/a/d",
        EventType.FILE_CLOSED.getByteValue(), 12));
    history.storeNotification(new NamespaceNotification("/a/e",
        EventType.FILE_CLOSED.getByteValue(), 13));
    historyNotifications = new LinkedList<NamespaceNotification>();
    history.addNotificationsToQueue(new NamespaceEvent("/a",
        EventType.FILE_CLOSED.getByteValue()), 12, historyNotifications);
    Assert.assertEquals(1, historyNotifications.size());
    Assert.assertEquals(13, historyNotifications.peek().txId);
    Assert.assertEquals("/a/e", historyNotifications.peek().path);
   
    // test the sub directories
    historyNotifications = new LinkedList<NamespaceNotification>();
    history.addNotificationsToQueue(new NamespaceEvent("/",
        EventType.FILE_ADDED.getByteValue()), 10, historyNotifications);
    Assert.assertEquals(1, historyNotifications.size());
    history.addNotificationsToQueue(new NamespaceEvent("/",
        EventType.FILE_CLOSED.getByteValue()), 10, historyNotifications);
    Assert.assertEquals(3, historyNotifications.size());
   
    core.shutdown();
  }
View Full Code Here

    history.storeNotification(new NamespaceNotification("/a/c",
        EventType.FILE_ADDED.getByteValue(), 11));
    historyNotifications = new LinkedList<NamespaceNotification>();
    try {
      Thread.sleep(historyLength - 30);
      history.addNotificationsToQueue(new NamespaceEvent("/a",
          EventType.FILE_ADDED.getByteValue()), 10, historyNotifications);
    } catch (TransactionIdTooOldException e) {
      Assert.fail();
    }
   
View Full Code Here

    history.storeNotification(new NamespaceNotification("/a/c",
        EventType.FILE_ADDED.getByteValue(), 11));
    historyNotifications = new LinkedList<NamespaceNotification>();
    try {
      Thread.sleep(historyLength + 50);
      history.addNotificationsToQueue(new NamespaceEvent("/a",
          EventType.FILE_ADDED.getByteValue()), 10, historyNotifications);
      Assert.fail(); // should receive the exception
    } catch (TransactionIdTooOldException e) {}
   
    core.shutdown();
View Full Code Here

          EventType.FILE_ADDED.getByteValue(), txId));
    }

    // Part 1 - Get all notifications
    historyNotifications = new LinkedList<NamespaceNotification>();
    history.addNotificationsToQueue(new NamespaceEvent("/a",
        EventType.FILE_ADDED.getByteValue()), 0, historyNotifications);
    Assert.assertEquals(1000, historyNotifications.size());
    for (long txId = 1; txId < txCount; txId ++) {
      NamespaceNotification n = historyNotifications.poll();
      Assert.assertEquals(txId, n.txId);
      Assert.assertEquals("/a/" + txId, n.path);
      Assert.assertEquals(EventType.FILE_ADDED.getByteValue(), n.type);
    }
   
    // Part 2 - Get half of the notifications
    historyNotifications = new LinkedList<NamespaceNotification>();
    history.addNotificationsToQueue(new NamespaceEvent("/a",
        EventType.FILE_ADDED.getByteValue()), 500, historyNotifications);
    Assert.assertEquals(500, historyNotifications.size());
    for (long txId = 501; txId < txCount; txId ++) {
      NamespaceNotification n = historyNotifications.poll();
      Assert.assertEquals(txId, n.txId);
View Full Code Here

    core.init(new EmptyServerLogReader(), new TestSubscriptionHistory(),
        new EmptyServerDispatcher(), new EmptyServerHandler());
    long id1 = 1000, id2 = 2000;
    EmptyClientHandler handler1 = new EmptyClientHandler(),
        handler2 = new EmptyClientHandler();
    NamespaceEvent event = new NamespaceEvent("/a",
        EventType.FILE_ADDED.getByteValue());
   
    core.addClient(new ClientData(id1, handler1, "host", 3000));
    core.addClient(new ClientData(id2, handler2, "host", 3001));
   
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hdfs.notifier.NamespaceEvent

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.