Search in sources :

Example 1 with CollectorDescriptor

use of org.openkilda.wfm.topology.ping.model.CollectorDescriptor in project open-kilda by telstra.

the class GroupCollector method saveCurrentRecord.

private CollectorDescriptor saveCurrentRecord(Tuple input) throws Exception {
    final PingContext pingContext = pullPingContext(input);
    // expiring is only a memory leakage protection in this place
    // waiting ping command timeout + storm internal processing delay milliseconds
    long expireAt = System.currentTimeMillis() + pingContext.getTimeout() + expireDelay;
    CollectorDescriptor descriptor = new CollectorDescriptor(expireAt, pingContext.getGroup());
    descriptor = cache.addIfAbsent(descriptor);
    try {
        int size = descriptor.add(pingContext);
        GroupId group = descriptor.getGroupId();
        log.debug("Group {} add {} of {} response {}", group.getId(), size, group.getSize(), pingContext);
    } catch (IllegalArgumentException e) {
        throw new WorkflowException(this, input, e.toString());
    }
    return descriptor;
}
Also used : WorkflowException(org.openkilda.wfm.error.WorkflowException) CollectorDescriptor(org.openkilda.wfm.topology.ping.model.CollectorDescriptor) PingContext(org.openkilda.wfm.topology.ping.model.PingContext) GroupId(org.openkilda.wfm.topology.ping.model.GroupId)

Example 2 with CollectorDescriptor

use of org.openkilda.wfm.topology.ping.model.CollectorDescriptor in project open-kilda by telstra.

the class GroupCollector method collect.

private void collect(Tuple input) throws Exception {
    CollectorDescriptor descriptor = saveCurrentRecord(input);
    if (descriptor.isCompleted()) {
        try {
            Group group = descriptor.makeGroup();
            emitGroup(input, group);
        } catch (IllegalStateException e) {
            throw new WorkflowException(this, input, e.toString());
        }
    }
}
Also used : Group(org.openkilda.wfm.topology.ping.model.Group) WorkflowException(org.openkilda.wfm.error.WorkflowException) CollectorDescriptor(org.openkilda.wfm.topology.ping.model.CollectorDescriptor)

Aggregations

WorkflowException (org.openkilda.wfm.error.WorkflowException)2 CollectorDescriptor (org.openkilda.wfm.topology.ping.model.CollectorDescriptor)2 Group (org.openkilda.wfm.topology.ping.model.Group)1 GroupId (org.openkilda.wfm.topology.ping.model.GroupId)1 PingContext (org.openkilda.wfm.topology.ping.model.PingContext)1