use of com.wavefront.agent.data.EventDataSubmissionTask 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();
}
}
}
use of com.wavefront.agent.data.EventDataSubmissionTask in project java by wavefrontHQ.
the class SQSSubmissionQueueTest method scenarios.
@Parameterized.Parameters
public static Collection<Object[]> scenarios() {
Collection<Object[]> scenarios = new ArrayList<>();
for (TaskConverter.CompressionType type : TaskConverter.CompressionType.values()) {
RetryTaskConverter<LineDelimitedDataSubmissionTask> converter = new RetryTaskConverter<>("2878", type);
LineDelimitedDataSubmissionTask task = converter.fromBytes("WF\u0001\u0001{\"__CLASS\":\"com.wavefront.agent.data.LineDelimitedDataSubmissionTask\",\"enqueuedTimeMillis\":77777,\"attempts\":0,\"serverErrors\":0,\"handle\":\"2878\",\"entityType\":\"POINT\",\"format\":\"wavefront\",\"payload\":[\"java.util.ArrayList\",[\"item1\",\"item2\",\"item3\"]],\"enqueuedMillis\":77777}".getBytes());
scenarios.add(new Object[] { type, converter, task });
}
for (TaskConverter.CompressionType type : TaskConverter.CompressionType.values()) {
RetryTaskConverter<EventDataSubmissionTask> converter = new RetryTaskConverter<>("2878", type);
EventDataSubmissionTask task = converter.fromBytes("WF\u0001\u0001{\"__CLASS\":\"com.wavefront.agent.data.EventDataSubmissionTask\",\"enqueuedTimeMillis\":77777,\"attempts\":0,\"serverErrors\":0,\"handle\":\"2878\",\"entityType\":\"EVENT\",\"events\":[\"java.util.ArrayList\",[{\"name\":\"Event name for testing\",\"startTime\":77777000,\"endTime\":77777001,\"annotations\":[\"java.util.HashMap\",{\"severity\":\"INFO\"}],\"dimensions\":[\"java.util.HashMap\",{\"multi\":[\"java.util.ArrayList\",[\"bar\",\"baz\"]]}],\"hosts\":[\"java.util.ArrayList\",[\"host1\",\"host2\"]],\"tags\":[\"java.util.ArrayList\",[\"tag1\"]]}]],\"enqueuedMillis\":77777}".getBytes());
scenarios.add(new Object[] { type, converter, task });
}
return scenarios;
}
use of com.wavefront.agent.data.EventDataSubmissionTask in project java by wavefrontHQ.
the class SQSSubmissionQueueTest method testTaskRead.
@Test
public void testTaskRead() throws IOException {
SQSSubmissionQueue queue = getTaskQueue();
UUID proxyId = UUID.randomUUID();
DataSubmissionTask<? extends DataSubmissionTask<?>> task;
if (this.expectedTask instanceof LineDelimitedDataSubmissionTask) {
task = new LineDelimitedDataSubmissionTask(null, proxyId, new DefaultEntityPropertiesForTesting(), queue, "wavefront", ReportableEntityType.POINT, "2878", ImmutableList.of("item1", "item2", "item3"), time::get);
} else if (this.expectedTask instanceof EventDataSubmissionTask) {
task = new EventDataSubmissionTask(null, proxyId, new DefaultEntityPropertiesForTesting(), queue, "2878", ImmutableList.of(new Event(ReportEvent.newBuilder().setStartTime(time.get() * 1000).setEndTime(time.get() * 1000 + 1).setName("Event name for testing").setHosts(ImmutableList.of("host1", "host2")).setDimensions(ImmutableMap.of("multi", ImmutableList.of("bar", "baz"))).setAnnotations(ImmutableMap.of("severity", "INFO")).setTags(ImmutableList.of("tag1")).build())), time::get);
} else {
task = null;
}
expect(client.sendMessage(new SendMessageRequest(queueUrl, queue.encodeMessageForDelivery(this.expectedTask)))).andReturn(null);
replay(client);
task.enqueue(QueueingReason.RETRY);
reset(client);
ReceiveMessageRequest msgRequest = new ReceiveMessageRequest().withMaxNumberOfMessages(1).withWaitTimeSeconds(1).withQueueUrl(queueUrl);
ReceiveMessageResult msgResult = new ReceiveMessageResult().withMessages(new Message().withBody(queue.encodeMessageForDelivery(task)).withReceiptHandle("handle1"));
expect(client.receiveMessage(msgRequest)).andReturn(msgResult);
replay(client);
if (this.expectedTask instanceof LineDelimitedDataSubmissionTask) {
LineDelimitedDataSubmissionTask readTask = (LineDelimitedDataSubmissionTask) queue.peek();
assertEquals(((LineDelimitedDataSubmissionTask) task).payload(), readTask.payload());
assertEquals(((LineDelimitedDataSubmissionTask) this.expectedTask).payload(), readTask.payload());
assertEquals(77777, readTask.getEnqueuedMillis());
}
if (this.expectedTask instanceof EventDataSubmissionTask) {
EventDataSubmissionTask readTask = (EventDataSubmissionTask) queue.peek();
assertEquals(((EventDataSubmissionTask) task).payload(), readTask.payload());
assertEquals(((EventDataSubmissionTask) this.expectedTask).payload(), readTask.payload());
assertEquals(77777, readTask.getEnqueuedMillis());
}
}
Aggregations