Search in sources :

Example 1 with Timestamp

use of com.metabroadcast.common.time.Timestamp in project atlas-persistence by atlasapi.

the class EquivalenceChangeMessenger method sendMessage.

public void sendMessage(LookupEntry subject, Set<Long> outgoingIdsAdded, Set<Long> outgoingIdsRemoved, Set<Long> outgoingIdsUnchanged, Set<String> sources) {
    try {
        String messageId = UUID.randomUUID().toString();
        Timestamp timestamp = timestamper.timestamp();
        EquivalenceChangeMessage message = new EquivalenceChangeMessage(messageId, timestamp, subject.id(), outgoingIdsAdded, outgoingIdsRemoved, outgoingIdsUnchanged, sources);
        sender.sendMessage(message, getMessagePartitionKey(subject));
    } catch (Exception e) {
        log.error("Failed to send equiv result message: " + subject, e);
    }
}
Also used : Timestamp(com.metabroadcast.common.time.Timestamp)

Example 2 with Timestamp

use of com.metabroadcast.common.time.Timestamp in project atlas-deer by atlasapi.

the class AbstractScheduleStore method sendUpdateMessage.

private void sendUpdateMessage(Publisher source, List<ScheduleHierarchy> content, ScheduleBlocksUpdate update, Channel channel, Interval interval) throws WriteException {
    try {
        String messageId = UUID.randomUUID().toString();
        Timestamp messageTimestamp = Timestamp.of(DateTime.now(DateTimeZones.UTC));
        ScheduleRef updateRef = scheduleRef(content, channel, interval);
        ImmutableSet<BroadcastRef> staleRefs = broadcastRefs(update.getStaleEntries());
        ScheduleUpdateMessage message = new ScheduleUpdateMessage(messageId, messageTimestamp, new ScheduleUpdate(source, updateRef, staleRefs));
        Id channelId = message.getScheduleUpdate().getSchedule().getChannel();
        messageSender.sendMessage(message, Longs.toByteArray(channelId.longValue()));
    } catch (MessagingException e) {
        throw new WriteException(e);
    }
}
Also used : WriteException(org.atlasapi.entity.util.WriteException) MessagingException(com.metabroadcast.common.queue.MessagingException) BroadcastRef(org.atlasapi.content.BroadcastRef) Id(org.atlasapi.entity.Id) Timestamp(com.metabroadcast.common.time.Timestamp)

Example 3 with Timestamp

use of com.metabroadcast.common.time.Timestamp in project atlas-deer by atlasapi.

the class ContentEquivalenceAssertionLegacyTransformer method transform.

public EquivalenceAssertionMessage transform(ContentEquivalenceAssertionMessage leg) {
    String mid = leg.getMessageId();
    Timestamp ts = leg.getTimestamp();
    ResourceRef subj = LegacyTransformer.resourceRef(leg.getEntityId(), leg.getEntitySource(), leg.getEntityType(), leg.getTimestamp());
    Set<ResourceRef> adjacents = toResourceRef(leg);
    Set<Publisher> srcs = ImmutableSet.copyOf(Iterables.transform(leg.getSources(), Publisher.FROM_KEY));
    return new EquivalenceAssertionMessage(mid, ts, subj, adjacents, srcs);
}
Also used : EquivalenceAssertionMessage(org.atlasapi.messaging.EquivalenceAssertionMessage) ContentEquivalenceAssertionMessage(org.atlasapi.messaging.v3.ContentEquivalenceAssertionMessage) ResourceRef(org.atlasapi.entity.ResourceRef) Publisher(org.atlasapi.media.entity.Publisher) Timestamp(com.metabroadcast.common.time.Timestamp)

Example 4 with Timestamp

use of com.metabroadcast.common.time.Timestamp in project atlas-persistence by atlasapi.

the class MongoScheduleStore method sendUpdateMessage.

private void sendUpdateMessage(Publisher publisher, Channel channel, Interval interval) {
    String mid = UUID.randomUUID().toString();
    Timestamp ts = timestamper.timestamp();
    String src = publisher.key();
    String cid = idCodec.encode(BigInteger.valueOf(channel.getId()));
    DateTime start = interval.getStart();
    DateTime end = interval.getEnd();
    ScheduleUpdateMessage msg = new ScheduleUpdateMessage(mid, ts, src, cid, start, end);
    try {
        messageSender.sendMessage(msg, msg.getChannel().getBytes());
    } catch (MessagingException e) {
        String errMsg = String.format("%s %s %s", src, cid, interval);
        log.error(errMsg, e);
    }
}
Also used : MessagingException(com.metabroadcast.common.queue.MessagingException) Timestamp(com.metabroadcast.common.time.Timestamp) DateTime(org.joda.time.DateTime) ScheduleUpdateMessage(org.atlasapi.messaging.v3.ScheduleUpdateMessage)

Example 5 with Timestamp

use of com.metabroadcast.common.time.Timestamp in project atlas-persistence by atlasapi.

the class ContentEquivalenceAssertionMessenger method messageFrom.

private ContentEquivalenceAssertionMessage messageFrom(Content subject, ImmutableList<Content> adjacents, ImmutableSet<String> sources) {
    String messageId = UUID.randomUUID().toString();
    Timestamp timestamp = timestamper.timestamp();
    String subjectId = entityIdCodec.encode(BigInteger.valueOf(subject.getId()));
    String subjectType = subject.getClass().getSimpleName().toLowerCase();
    String subjectSource = subject.getPublisher().key();
    ImmutableList<ContentEquivalenceAssertionMessage.AdjacentRef> adjacentRefs = adjacents(adjacents);
    return new ContentEquivalenceAssertionMessage(messageId, timestamp, subjectId, subjectType, subjectSource, adjacentRefs, sources);
}
Also used : Timestamp(com.metabroadcast.common.time.Timestamp)

Aggregations

Timestamp (com.metabroadcast.common.time.Timestamp)5 MessagingException (com.metabroadcast.common.queue.MessagingException)2 BroadcastRef (org.atlasapi.content.BroadcastRef)1 Id (org.atlasapi.entity.Id)1 ResourceRef (org.atlasapi.entity.ResourceRef)1 WriteException (org.atlasapi.entity.util.WriteException)1 Publisher (org.atlasapi.media.entity.Publisher)1 EquivalenceAssertionMessage (org.atlasapi.messaging.EquivalenceAssertionMessage)1 ContentEquivalenceAssertionMessage (org.atlasapi.messaging.v3.ContentEquivalenceAssertionMessage)1 ScheduleUpdateMessage (org.atlasapi.messaging.v3.ScheduleUpdateMessage)1 DateTime (org.joda.time.DateTime)1