Search in sources :

Example 6 with IMessage

use of edu.iu.dsc.tws.api.compute.IMessage in project twister2 by DSC-SPIDAL.

the class WindowManager method bundleWindowMessage.

public IWindowMessage<T> bundleWindowMessage(List<Event<T>> events) {
    WindowMessageImpl winMessage = null;
    List<IMessage<T>> messages = new ArrayList<>();
    for (Event<T> event : events) {
        IMessage<T> m = event.get();
        messages.add(m);
    }
    winMessage = new WindowMessageImpl(messages);
    return winMessage;
}
Also used : WindowMessageImpl(edu.iu.dsc.tws.task.window.api.WindowMessageImpl) IMessage(edu.iu.dsc.tws.api.compute.IMessage) ArrayList(java.util.ArrayList)

Example 7 with IMessage

use of edu.iu.dsc.tws.api.compute.IMessage in project twister2 by DSC-SPIDAL.

the class WindowManager method bundleExpiredWindowIMessage.

/**
 * This method bundles data into a IWindowMessage for creating expired IWindowMessages
 *
 * @param events list of elements that need to be passed into a window
 * @return a bundled IWindowMessage considering a list of IMessages of a given data type
 */
public IWindowMessage<T> bundleExpiredWindowIMessage(List<IMessage<T>> events) {
    WindowMessageImpl winMessage = null;
    List<IMessage<T>> messages = new ArrayList<>();
    for (IMessage<T> m : events) {
        messages.add(m);
    }
    winMessage = new WindowMessageImpl(null, messages);
    return winMessage;
}
Also used : WindowMessageImpl(edu.iu.dsc.tws.task.window.api.WindowMessageImpl) IMessage(edu.iu.dsc.tws.api.compute.IMessage) ArrayList(java.util.ArrayList)

Example 8 with IMessage

use of edu.iu.dsc.tws.api.compute.IMessage in project twister2 by DSC-SPIDAL.

the class SourceStreamingInstance method execute.

/**
 * Execution Method calls the SourceTasks run method to get context
 */
public boolean execute() {
    if (outStreamingQueue.size() < lowWaterMark && !(this.checkpointable && this.pendingCheckpoint.isPending())) {
        // lets execute the task
        streamingTask.execute();
        if (this.checkpointable && (executions++ % this.checkPointingFrequency) == 0) {
            this.scheduleCheckpoint(checkpointVersion++);
        }
    }
    // we start with setting nothing to execute true
    boolean nothingToProcess = true;
    // now check the output queue
    while (!outStreamingQueue.isEmpty()) {
        IMessage message = outStreamingQueue.peek();
        if (message != null) {
            String edge = message.edge();
            IParallelOperation op = outStreamingParOps.get(edge);
            boolean barrierMessage = (message.getFlag() & MessageFlags.SYNC_BARRIER) == MessageFlags.SYNC_BARRIER;
            // if we successfully send remove message
            if (barrierMessage ? op.sendBarrier(globalTaskId, (byte[]) message.getContent()) : op.send(globalTaskId, message, message.getFlag())) {
                outStreamingQueue.poll();
            } else {
                nothingToProcess = false;
                // we need to break
                break;
            }
        } else {
            break;
        }
    }
    for (int i = 0; i < outOpArray.length; i++) {
        boolean needProgress = outOpArray[i].progress();
        if (needProgress) {
            nothingToProcess = false;
        }
    }
    if (this.checkpointable && outStreamingQueue.isEmpty() && this.pendingCheckpoint.isPending()) {
        long barrier = this.pendingCheckpoint.execute();
        if (barrier != -1) {
            ((CheckpointableTask) this.streamingTask).onCheckpointPropagated(this.snapshot);
            this.scheduleBarriers(barrier);
            taskContext.write(CheckpointingSGatherSink.FT_GATHER_EDGE, barrier);
            nothingToProcess = false;
        }
    }
    return !nothingToProcess;
}
Also used : IMessage(edu.iu.dsc.tws.api.compute.IMessage) IParallelOperation(edu.iu.dsc.tws.api.compute.executor.IParallelOperation) CheckpointableTask(edu.iu.dsc.tws.checkpointing.task.CheckpointableTask)

Aggregations

IMessage (edu.iu.dsc.tws.api.compute.IMessage)8 IParallelOperation (edu.iu.dsc.tws.api.compute.executor.IParallelOperation)4 ArrayList (java.util.ArrayList)4 WindowMessageImpl (edu.iu.dsc.tws.task.window.api.WindowMessageImpl)3 CheckpointableTask (edu.iu.dsc.tws.checkpointing.task.CheckpointableTask)2 Event (edu.iu.dsc.tws.task.window.api.Event)1 Action (edu.iu.dsc.tws.task.window.constant.Action)1