Search in sources :

Example 6 with SourceTagSubmissionTask

use of com.wavefront.agent.data.SourceTagSubmissionTask in project java by wavefrontHQ.

the class QueueExporter method processTask.

@VisibleForTesting
<T extends DataSubmissionTask<T>> void processTask(T task, BufferedWriter writer) throws IOException {
    if (task instanceof LineDelimitedDataSubmissionTask) {
        for (String line : ((LineDelimitedDataSubmissionTask) task).payload()) {
            writer.write(line);
            writer.newLine();
        }
    } else if (task instanceof SourceTagSubmissionTask) {
        writer.write(((SourceTagSubmissionTask) task).payload().toString());
        writer.newLine();
    } else if (task instanceof EventDataSubmissionTask) {
        for (Event event : ((EventDataSubmissionTask) task).payload()) {
            writer.write(event.toString());
            writer.newLine();
        }
    }
}
Also used : SourceTagSubmissionTask(com.wavefront.agent.data.SourceTagSubmissionTask) EventDataSubmissionTask(com.wavefront.agent.data.EventDataSubmissionTask) Event(com.wavefront.dto.Event) LineDelimitedDataSubmissionTask(com.wavefront.agent.data.LineDelimitedDataSubmissionTask) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 7 with SourceTagSubmissionTask

use of com.wavefront.agent.data.SourceTagSubmissionTask in project java by wavefrontHQ.

the class InstrumentedTaskQueueDelegateTest method testSourceTagTask.

@Test
public void testSourceTagTask() throws Exception {
    for (RetryTaskConverter.CompressionType type : RetryTaskConverter.CompressionType.values()) {
        System.out.println("SourceTag task, compression type: " + type);
        File file = new File(File.createTempFile("proxyTestConverter", null).getPath() + ".queue");
        file.deleteOnExit();
        TaskQueue<SourceTagSubmissionTask> queue = getTaskQueue(file, type);
        queue.clear();
        SourceTagSubmissionTask task = new SourceTagSubmissionTask(null, new DefaultEntityPropertiesForTesting(), queue, "2878", new SourceTag(ReportSourceTag.newBuilder().setOperation(SourceOperationType.SOURCE_TAG).setAction(SourceTagAction.SAVE).setSource("testSource").setAnnotations(ImmutableList.of("newtag1", "newtag2")).build()), () -> 77777L);
        task.enqueue(QueueingReason.RETRY);
        queue.close();
        TaskQueue<SourceTagSubmissionTask> readQueue = getTaskQueue(file, type);
        SourceTagSubmissionTask readTask = readQueue.peek();
        assertEquals(task.payload(), readTask.payload());
        assertEquals(77777, readTask.getEnqueuedMillis());
    }
}
Also used : SourceTagSubmissionTask(com.wavefront.agent.data.SourceTagSubmissionTask) ReportSourceTag(wavefront.report.ReportSourceTag) SourceTag(com.wavefront.dto.SourceTag) DefaultEntityPropertiesForTesting(com.wavefront.agent.data.DefaultEntityPropertiesForTesting) File(java.io.File) QueueFile(com.squareup.tape2.QueueFile) Test(org.junit.Test)

Aggregations

SourceTagSubmissionTask (com.wavefront.agent.data.SourceTagSubmissionTask)7 SourceTag (com.wavefront.dto.SourceTag)5 EventDataSubmissionTask (com.wavefront.agent.data.EventDataSubmissionTask)4 LineDelimitedDataSubmissionTask (com.wavefront.agent.data.LineDelimitedDataSubmissionTask)4 DefaultEntityPropertiesForTesting (com.wavefront.agent.data.DefaultEntityPropertiesForTesting)3 Event (com.wavefront.dto.Event)3 Test (org.junit.Test)3 ReportSourceTag (wavefront.report.ReportSourceTag)3 File (java.io.File)2 ArrayList (java.util.ArrayList)2 UUID (java.util.UUID)2 ReportEvent (wavefront.report.ReportEvent)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Charsets (com.google.common.base.Charsets)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Files (com.google.common.io.Files)1 QueueFile (com.squareup.tape2.QueueFile)1 DefaultEntityPropertiesFactoryForTesting (com.wavefront.agent.data.DefaultEntityPropertiesFactoryForTesting)1 EntityPropertiesFactory (com.wavefront.agent.data.EntityPropertiesFactory)1