Package com.cloudera.flume.core

Examples of com.cloudera.flume.core.Event


      int remaining = buf.remaining();
      if (remaining > 0) {
        byte[] body = new byte[remaining];
        buf.get(body, 0, remaining); // read all data

        Event e = new EventImpl(body);
        e.set(A_TAILSRCFILE, file.getName().getBytes());
        try {
          sync.put(e);
        } catch (InterruptedException e1) {
          LOG.error("interruptedException! " + e1.getMessage(), e1);
          throw e1;
View Full Code Here


          buf.get(body, 0, sz - 1); // read data
          buf.get(); // read '\n'
          buf.mark(); // new mark.
          start = buf.position();

          Event e = new EventImpl(body);
          e.set(A_TAILSRCFILE, file.getName().getBytes());
          sync.put(e);
          madeProgress = true;
        }
      }
View Full Code Here

   * {@inheritDoc}
   */
  @Override
  public Event next() throws IOException {
    try {
      Event e = null;
      // block until an event shows up
      while ((e = q.poll(100, TimeUnit.MILLISECONDS)) == null) {

        synchronized (this) {
          // or bail out if closed
          if (closed) {
            return null;
          }
        }
      }
      // return the event
      synchronized (this) {
        dequeued.getAndIncrement();
        updateEventProcessingStats(e);
        return e;
      }
    } catch (InterruptedException e) {
      throw new IOException("Waiting for queue element was interrupted! "
          + e.getMessage(), e);
    }
  }
View Full Code Here

        .getCollectorPort());
    try {
      sink.open();

      for (int i = 0; i < 100; i++) {
        Event e = new EventImpl(("This is a test " + i).getBytes());
        sink.append(e);
        Thread.sleep(200);
      }
    } catch (IOException e) {
      e.printStackTrace();
    } catch (InterruptedException e) {
      e.printStackTrace();
    }

  }
View Full Code Here

    Map<String, byte[]> fields = new HashMap<String, byte[]>();
    if (service != null)
      fields.put("service", service.getBytes());
    // Event e = new EventImpl(body.getBytes(), d.getTime(), Priority.INFO,
    Event e = new EventImpl(s.getBytes(), d.getTime(), Priority.INFO,
        Clock.nanos(), host, fields);
    return e;

  }
View Full Code Here

   * of.
   *
   * Use the host and the nanos as a tag at the collector side.
   */
  private Event openEvent() {
    Event e = new EventImpl(new byte[0]);
    e.set(ATTR_ACK_TYPE, CHECKSUM_START);
    checksum = e.getTimestamp();
    e.set(ATTR_ACK_HASH, ByteBuffer.allocate(8).putLong(checksum).array());
    e.set(ATTR_ACK_TAG, tag);

    return e;
  }
View Full Code Here

  /**
   * Close events has the cumulative checksum value
   */
  private Event closeEvent() {
    Event e = new EventImpl(new byte[0]);
    e.set(ATTR_ACK_TYPE, CHECKSUM_STOP);
    e.set(ATTR_ACK_HASH, ByteBuffer.allocate(8).putLong(checksum).array());
    e.set(ATTR_ACK_TAG, tag);
    return e;
  }
View Full Code Here

      }
    };

    Event[] ordered = { e1, e2, e3, e4 };
    for (int i = 0; i < ordered.length; i++) {
      Event qe = q.take();
      System.out.println("take   " + qe.getTimestamp() + " " + qe.getNanos()
          + " " + qe);
      Assert.assertEquals(ordered[i], qe);
    }

  }
View Full Code Here

  @SuppressWarnings("serial")
  @Test
  public void testEventQueueMillis() throws InterruptedException {
    Thread.sleep(100);

    final Event e = new EventImpl("test".getBytes());
    EventQueue q = new EventQueue(10) {
      {
        add(e);
        System.out.println("insert " + e.getTimestamp() + " " + e.getNanos()
            + " " + e);
        add(e4);
        System.out.println("insert " + e4.getTimestamp() + " " + e4.getNanos()
            + " " + e4);
        add(e2);
        System.out.println("insert " + e2.getTimestamp() + " " + e2.getNanos()
            + " " + e2);
        add(e1);
        System.out.println("insert " + e1.getTimestamp() + " " + e1.getNanos()
            + " " + e1);
        add(e3);
        System.out.println("insert " + e3.getTimestamp() + " " + e3.getNanos()
            + " " + e3);
      }
    };

    Event[] ordered = { e1, e2, e3, e4, e };
    for (int i = 0; i < ordered.length; i++) {
      Event qe = q.take();
      System.out.println("take   " + qe.getTimestamp() + " " + qe.getNanos()
          + " " + qe);
      Assert.assertEquals(ordered[i], qe);
    }

  }
View Full Code Here

   * Gets the current source and returns next value or null if it is done or
   * encountered an error
   */
  Event getValidNext() {
    try {
      Event e = curSource.next();
      return e;
    } catch (Exception ex) {
      LOG.warn("Exception getting next", ex);
      return null;
    }
View Full Code Here

TOP

Related Classes of com.cloudera.flume.core.Event

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.