Search in sources :

Example 6 with Event

use of com.google.cloud.video.livestream.v1.Event in project incubator-skywalking by apache.

the class EventRestServiceHandler method doPost.

@Override
protected void doPost(final HttpServletRequest req, final HttpServletResponse resp) {
    try (HistogramMetrics.Timer ignored = histogram.createTimer()) {
        List<Event> events = Lists.newArrayList();
        JsonArray array = gson.fromJson(req.getReader(), JsonArray.class);
        for (JsonElement element : array) {
            Event.Builder builder = Event.newBuilder();
            ProtoBufJsonUtils.fromJSON(element.toString(), builder);
            events.add(builder.build());
        }
        events.forEach(eventAnalyzerService::analyze);
    } catch (Exception e) {
        errorCounter.inc();
        log.error(e.getMessage(), e);
    }
}
Also used : JsonArray(com.google.gson.JsonArray) JsonElement(com.google.gson.JsonElement) Event(org.apache.skywalking.apm.network.event.v3.Event) HistogramMetrics(org.apache.skywalking.oap.server.telemetry.api.HistogramMetrics)

Example 7 with Event

use of com.google.cloud.video.livestream.v1.Event in project requery by requery.

the class JacksonTest method testOneToManySerialize.

@Test
public void testOneToManySerialize() {
    Event event = new Event();
    UUID id = UUID.randomUUID();
    event.setId(id);
    event.setName("test");
    Tag t1 = new Tag();
    t1.setId(UUID.randomUUID());
    Tag t2 = new Tag();
    t2.setId(UUID.randomUUID());
    event.getTags().add(t1);
    event.getTags().add(t2);
    Place p = new Place();
    p.setId("SF");
    p.setName("San Francisco, CA");
    event.setPlace(p);
    data.insert(event);
    ObjectMapper mapper = new EntityMapper(Models.MODEL3, data);
    StringWriter writer = new StringWriter();
    try {
        mapper.writeValue(writer, event);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    String value = writer.toString();
    System.out.println(value);
    try {
        Event read = mapper.readValue(value, Event.class);
        assertSame(event, read);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : StringWriter(java.io.StringWriter) Event(io.requery.test.model3.Event) Tag(io.requery.test.model3.Tag) IOException(java.io.IOException) UUID(java.util.UUID) Place(io.requery.test.model3.Place) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) EntityMapper(io.requery.jackson.EntityMapper) Test(org.junit.Test)

Example 8 with Event

use of com.google.cloud.video.livestream.v1.Event in project requery by requery.

the class JacksonTest method testManyToManySerialize.

@Test
public void testManyToManySerialize() {
    Tag t1 = new Tag();
    t1.setId(UUID.randomUUID());
    for (int i = 0; i < 3; i++) {
        Event event = new Event();
        UUID id = UUID.randomUUID();
        event.setId(id);
        event.setName("event" + i);
        t1.getEvents().add(event);
    }
    data.insert(t1);
    ObjectMapper mapper = new EntityMapper(Models.MODEL3, data);
    StringWriter writer = new StringWriter();
    try {
        mapper.writeValue(writer, t1);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    String value = writer.toString();
    System.out.println(value);
    try {
        Tag tag = mapper.readValue(value, Tag.class);
        assertSame(t1, tag);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : StringWriter(java.io.StringWriter) Event(io.requery.test.model3.Event) Tag(io.requery.test.model3.Tag) IOException(java.io.IOException) UUID(java.util.UUID) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) EntityMapper(io.requery.jackson.EntityMapper) Test(org.junit.Test)

Example 9 with Event

use of com.google.cloud.video.livestream.v1.Event in project requery by requery.

the class TimeConversionsTest method testInsertReadDateTime.

@Test
public void testInsertReadDateTime() {
    Event event = new Event();
    UUID id = UUID.randomUUID();
    LocalDateTime localDateTimeNow = LocalDateTime.now().withNano(0);
    OffsetDateTime offsetDateTimeNow = OffsetDateTime.now(ZoneId.systemDefault()).withNano(0);
    ZonedDateTime zonedDateTimeNow = ZonedDateTime.now(ZoneId.systemDefault()).withNano(0);
    event.setId(id);
    event.setLocalDateTime(localDateTimeNow);
    event.setOffsetDateTime(offsetDateTimeNow);
    event.setZonedDateTime(zonedDateTimeNow);
    data.insert(event);
    event = data.findByKey(Event.class, id);
    Assert.assertEquals(localDateTimeNow, event.getLocalDateTime());
    Assert.assertEquals(offsetDateTimeNow, event.getOffsetDateTime());
    Assert.assertEquals(zonedDateTimeNow.toInstant(), event.getZonedDateTime().toInstant());
}
Also used : LocalDateTime(java.time.LocalDateTime) OffsetDateTime(java.time.OffsetDateTime) ZonedDateTime(java.time.ZonedDateTime) Event(io.requery.test.model2.Event) UUID(java.util.UUID) Test(org.junit.Test)

Example 10 with Event

use of com.google.cloud.video.livestream.v1.Event in project requery by requery.

the class TimeConversionsTest method testInsertReadLocalTime.

@Test
public void testInsertReadLocalTime() {
    Event event = new Event();
    UUID id = UUID.randomUUID();
    LocalTime localTimeNow = LocalTime.now();
    event.setId(id);
    event.setLocalTime(localTimeNow);
    data.insert(event);
    event = data.findByKey(Event.class, id);
    Assert.assertEquals(localTimeNow.withNano(0), event.getLocalTime());
}
Also used : LocalTime(java.time.LocalTime) Event(io.requery.test.model2.Event) UUID(java.util.UUID) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)18 Event (io.requery.test.model3.Event)9 UUID (java.util.UUID)9 Event (org.apache.skywalking.apm.network.event.v3.Event)9 Test (org.junit.jupiter.api.Test)9 LivestreamServiceClient (com.google.cloud.video.livestream.v1.LivestreamServiceClient)5 Event (org.eclipse.bpmn2.Event)5 Event (com.google.cloud.video.livestream.v1.Event)4 Place (io.requery.test.model3.Place)4 Tag (io.requery.test.model3.Tag)4 AlarmMessage (org.apache.skywalking.oap.server.core.alarm.AlarmMessage)4 ListNamespacedEvent (com.marcnuri.yakc.api.events.v1.EventsV1Api.ListNamespacedEvent)3 Event (com.marcnuri.yakc.model.io.k8s.api.events.v1.Event)3 Event (io.fabric8.kubernetes.api.model.events.v1.Event)3 Event (io.requery.test.model2.Event)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 Event (uk.gov.justice.hmpps.prison.api.model.v1.Event)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 JsonArray (com.google.gson.JsonArray)2