Package org.apache.hadoop.hdfs.notifier

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


    dispatcher.loopSleepTime = 20;
    dispatcher.assignClient(clientId);
   
    // Add a notification and wait for it to be delivered
    dispatcherThread.start();
    core.clientQueues.get(clientId).add(new NamespaceNotification("/a/b",
        EventType.FILE_ADDED.getByteValue(), 10));
    Thread.sleep(250);
    core.shutdown();
    dispatcherThread.join();
   
    // Check what was received
    NamespaceNotification n;
    Assert.assertEquals(1, handler.notificationQueue.size());
    n = handler.notificationQueue.element();
    Assert.assertEquals("/a/b", n.path);
    Assert.assertEquals(EventType.FILE_ADDED.getByteValue(), n.type);
    Assert.assertEquals(10, n.txId);
View Full Code Here


    core.clients.put(clientId, new ClientData(clientId, handler, "host", 3000));
    dispatcher.loopSleepTime = 20;
    dispatcher.assignClient(clientId);
   
    dispatcherThread.start();
    core.clientQueues.get(clientId).add(new NamespaceNotification("/a/a",
        EventType.FILE_ADDED.getByteValue(), 10));
    core.clientQueues.get(clientId).add(new NamespaceNotification("/a/b",
        EventType.FILE_ADDED.getByteValue(), 20));
    core.clientQueues.get(clientId).add(new NamespaceNotification("/a/c",
        EventType.FILE_ADDED.getByteValue(), 30));
    core.clientQueues.get(clientId).add(new NamespaceNotification("/a/c",
        EventType.FILE_CLOSED.getByteValue(), 40));
    Thread.sleep(250);
    core.shutdown();
    dispatcherThread.join();
   
    // Check what was received
    NamespaceNotification n;
    Assert.assertEquals(4, handler.notificationQueue.size());
   
    n = handler.notificationQueue.poll();
    Assert.assertEquals("/a/a", n.path);
    Assert.assertEquals(EventType.FILE_ADDED.getByteValue(), n.type);
View Full Code Here

   
    handler.failChance = 0.8f;
    handler.failChanceDec = 0.1f;
   
    dispatcherThread.start();
    core.clientQueues.get(clientId).add(new NamespaceNotification("/a/a",
        EventType.FILE_ADDED.getByteValue(), 10));
    core.clientQueues.get(clientId).add(new NamespaceNotification("/a/b",
        EventType.FILE_ADDED.getByteValue(), 20));
    core.clientQueues.get(clientId).add(new NamespaceNotification("/a/c",
        EventType.FILE_ADDED.getByteValue(), 30));
    core.clientQueues.get(clientId).add(new NamespaceNotification("/a/c",
        EventType.FILE_CLOSED.getByteValue(), 40));
    Thread.sleep(1000);
    core.shutdown();
    dispatcherThread.join();
   
    // Check what was received
    NamespaceNotification n;
    Assert.assertEquals(4, handler.notificationQueue.size());
   
    n = handler.notificationQueue.poll();
    Assert.assertEquals("/a/a", n.path);
    Assert.assertEquals(EventType.FILE_ADDED.getByteValue(), n.type);
View Full Code Here

    Queue<Long> client2ExpectedTxIds = new LinkedList<Long>();
    for (long txId = 0; txId < 3000; txId ++) {
      String basePath = basePaths[generator.nextInt(3)];
     
      if (basePath.equals("a") || basePath.equals("c")) {
        core.clientQueues.get(client1Id).add(new NamespaceNotification("/" + basePath +
            "/" + txId, EventType.FILE_ADDED.getByteValue(), txId));
        client1ExpectedTxIds.add(txId);
      }
      if (basePath.equals("b") || basePath.equals("c")) {
        core.clientQueues.get(client2Id).add(new NamespaceNotification("/" + basePath +
            "/" + txId, EventType.FILE_ADDED.getByteValue(), txId));
        client2ExpectedTxIds.add(txId);
      }
    }
View Full Code Here

   
    handler.failChance = 1.0f;
    handler.failChanceDec = 1.0f;
   
    dispatcherThread.start();
    core.clientQueues.get(clientId).add(new NamespaceNotification("/a/a",
        EventType.FILE_ADDED.getByteValue(), 10));
    core.clientQueues.get(clientId).add(new NamespaceNotification("/a/b",
        EventType.FILE_ADDED.getByteValue(), 20));
    core.clientQueues.get(clientId).add(new NamespaceNotification("/a/c",
        EventType.FILE_ADDED.getByteValue(), 30));
    core.clientQueues.get(clientId).add(new NamespaceNotification("/a/c",
        EventType.FILE_CLOSED.getByteValue(), 40));
    Thread.sleep(140);
    core.shutdown();
    dispatcherThread.join();
   
View Full Code Here

    Queue<NamespaceNotification> historyNotifications;
   
    new Thread(history).start();
   
    // Step 1 - test with FILE_ADDED
    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());
View Full Code Here

    Queue<NamespaceNotification> historyNotifications;
   
    new Thread(history).start();
   
    // Step 1 - test with FILE_ADDED
    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>();
    try {
      Thread.sleep(historyLength - 30);
      history.addNotificationsToQueue(new NamespaceEvent("/a",
View Full Code Here

    history.loopSleepTime = 10;
   
    new Thread(history).start();
   
    // Step 1 - test with FILE_ADDED
    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>();
    try {
      Thread.sleep(historyLength + 50);
      history.addNotificationsToQueue(new NamespaceEvent("/a",
View Full Code Here

    history.setHistoryLength(historyLength);
    history.loopSleepTime = 10;
   
    new Thread(history).start();
   
    history.storeNotification(new NamespaceNotification("/a/b",
        EventType.FILE_ADDED.getByteValue(), 10));
    history.storeNotification(new NamespaceNotification("/a/c",
        EventType.FILE_ADDED.getByteValue(), 11));
    Thread.sleep(historyLength + 50);
    Assert.assertEquals(0, history.orderedHistoryList.size());
    Assert.assertEquals(0, history.historyTree.children.size());
    core.shutdown();
View Full Code Here

    Thread historyThread = new Thread(history);
   
    historyThread.start();
   
    for (int i = 0; i < 1500; i ++) {
      history.storeNotification(new NamespaceNotification("/a/b" + i,
          EventType.FILE_ADDED.getByteValue(), i));
    }
   
    Thread.sleep(500);
    core.shutdown();
View Full Code Here

TOP

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

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.