Search in sources :

Example 1 with PrototypeRequest

use of io.s4.message.PrototypeRequest in project core by s4.

the class ControlEventProcessor method execute.

protected void execute(EventWrapper e, PrototypeWrapper p) {
    List<CompoundKeyInfo> keyInfoList = e.getCompoundKeys();
    Object event = e.getEvent();
    if (event instanceof SinglePERequest) {
        // Handle Requests to individual PEs
        if (keyInfoList.isEmpty())
            return;
        CompoundKeyInfo keyInfo = keyInfoList.get(0);
        String keyVal = keyInfo.getCompoundValue();
        ProcessingElement pe = p.lookupPE(keyVal);
        Response response = ((SinglePERequest) event).evaluate(pe);
        String stream = response.getRInfo().getStream();
        dispatcher.dispatchEvent(stream, response);
    } else if (event instanceof PrototypeRequest) {
        // Or handle aggregate requests to Prototypes.
        Response response = ((PrototypeRequest) event).evaluate(p);
        String stream = response.getRInfo().getStream();
        dispatcher.dispatchEvent(stream, response);
    }
}
Also used : Response(io.s4.message.Response) SinglePERequest(io.s4.message.SinglePERequest) CompoundKeyInfo(io.s4.dispatcher.partitioner.CompoundKeyInfo) PrototypeRequest(io.s4.message.PrototypeRequest)

Aggregations

CompoundKeyInfo (io.s4.dispatcher.partitioner.CompoundKeyInfo)1 PrototypeRequest (io.s4.message.PrototypeRequest)1 Response (io.s4.message.Response)1 SinglePERequest (io.s4.message.SinglePERequest)1