Search in sources :

Example 1 with PointHandler

use of com.wavefront.agent.PointHandler in project java by wavefrontHQ.

the class PointHandlerDispatcherTest method setup.

@Before
public void setup() {
    timeMillis = new AtomicLong(0L);
    backingStore = new ConcurrentHashMap<>();
    in = new AccumulationCache(backingStore, 0, timeMillis::get);
    pointOut = new LinkedList<>();
    debugLineOut = new LinkedList<>();
    blockedOut = new LinkedList<>();
    digestA = new AgentDigest(COMPRESSION, 100L);
    digestB = new AgentDigest(COMPRESSION, 1000L);
    subject = new PointHandlerDispatcher(in, new PointHandler() {

        @Override
        public void reportPoint(ReportPoint point, String debugLine) {
            pointOut.add(point);
            debugLineOut.add(debugLine);
        }

        @Override
        public void reportPoints(List<ReportPoint> points) {
            pointOut.addAll(points);
        }

        @Override
        public void handleBlockedPoint(String pointLine) {
            blockedOut.add(pointLine);
        }
    }, timeMillis::get, null);
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) AccumulationCache(com.wavefront.agent.histogram.accumulator.AccumulationCache) AgentDigest(com.tdunning.math.stats.AgentDigest) PointHandler(com.wavefront.agent.PointHandler) List(java.util.List) LinkedList(java.util.LinkedList) ReportPoint(wavefront.report.ReportPoint) Before(org.junit.Before)

Example 2 with PointHandler

use of com.wavefront.agent.PointHandler in project java by wavefrontHQ.

the class InteractiveLogsTester method interactiveTest.

/**
 * Read one line of stdin and print a message to stdout.
 */
public boolean interactiveTest() throws ConfigurationException {
    final AtomicBoolean reported = new AtomicBoolean(false);
    LogsIngester logsIngester = new LogsIngester(new PointHandler() {

        @Override
        public void reportPoint(ReportPoint point, @Nullable String debugLine) {
            reported.set(true);
            System.out.println(PointHandlerImpl.pointToString(point));
        }

        @Override
        public void reportPoints(List<ReportPoint> points) {
            for (ReportPoint point : points) reportPoint(point, "");
        }

        @Override
        public void handleBlockedPoint(@Nullable String pointLine) {
            System.out.println("Blocked point: " + pointLine);
        }
    }, logsIngestionConfigSupplier, prefix, System::currentTimeMillis);
    String line = stdin.nextLine();
    logsIngester.ingestLog(new LogsMessage() {

        @Override
        public String getLogLine() {
            return line;
        }

        @Override
        public String hostOrDefault(String fallbackHost) {
            try {
                return InetAddress.getLocalHost().getHostName();
            } catch (UnknownHostException e) {
                return "localhost";
            }
        }
    });
    logsIngester.flush();
    if (!reported.get()) {
        System.out.println("Input matched no groks.");
    }
    return stdin.hasNext();
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) UnknownHostException(java.net.UnknownHostException) PointHandler(com.wavefront.agent.PointHandler) ReportPoint(wavefront.report.ReportPoint)

Example 3 with PointHandler

use of com.wavefront.agent.PointHandler in project java by wavefrontHQ.

the class AccumulationTaskTest method setUp.

@Before
public void setUp() throws Exception {
    AtomicInteger timeMillis = new AtomicInteger(0);
    in = new InMemoryObjectQueue<>();
    out = new ConcurrentHashMap<>();
    cache = new AccumulationCache(out, 0, timeMillis::get);
    badPointsOut = Lists.newArrayList();
    PointHandler pointHandler = new PointHandler() {

        @Override
        public void reportPoint(ReportPoint point, String debugLine) {
            throw new UnsupportedOperationException();
        }

        @Override
        public void reportPoints(List<ReportPoint> points) {
            throw new UnsupportedOperationException();
        }

        @Override
        public void handleBlockedPoint(String pointLine) {
            badPointsOut.add(pointLine);
        }
    };
    eventSubject = new AccumulationTask(in, cache, new GraphiteDecoder("unknown", ImmutableList.of()), pointHandler, Validation.Level.NUMERIC_ONLY, TTL, MINUTE, COMPRESSION);
    histoSubject = new AccumulationTask(in, cache, new HistogramDecoder(), pointHandler, Validation.Level.NUMERIC_ONLY, TTL, MINUTE, COMPRESSION);
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) PointHandler(com.wavefront.agent.PointHandler) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) HistogramDecoder(com.wavefront.ingester.HistogramDecoder) ReportPoint(wavefront.report.ReportPoint) GraphiteDecoder(com.wavefront.ingester.GraphiteDecoder) Before(org.junit.Before)

Aggregations

PointHandler (com.wavefront.agent.PointHandler)3 ReportPoint (wavefront.report.ReportPoint)3 List (java.util.List)2 Before (org.junit.Before)2 ImmutableList (com.google.common.collect.ImmutableList)1 AgentDigest (com.tdunning.math.stats.AgentDigest)1 AccumulationCache (com.wavefront.agent.histogram.accumulator.AccumulationCache)1 GraphiteDecoder (com.wavefront.ingester.GraphiteDecoder)1 HistogramDecoder (com.wavefront.ingester.HistogramDecoder)1 UnknownHostException (java.net.UnknownHostException)1 LinkedList (java.util.LinkedList)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1