All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.bdware.doip.cluster.callback.ForkCallBack Maven / Gradle / Ivy

The newest version!
package org.bdware.doip.cluster.callback;

import org.bdware.doip.cluster.client.DoaClusterClient;
import org.bdware.doip.cluster.client.TraceableDoaClusterClient;
import org.bdware.doip.codec.doipMessage.DoipMessage;

import java.util.Map;

public class ForkCallBack extends CookieJSResultCallback {

    private DoipMessage msg;
    private DDOClusterDoipInvocationCallback ddoClusterDoipInvocationCallback;
    private String[] doidList;
    private DoaClusterClient doaClusterClient;

    public ForkCallBack(Map cookie, DoaClusterClient doaClusterClient, DoipMessage msg, String[] doIdList, DDOClusterDoipInvocationCallback ddoClusterDoipMessageCallback) {
        super(cookie);
        this.msg = msg;
        this.ddoClusterDoipInvocationCallback = ddoClusterDoipMessageCallback;
        this.doidList = doIdList;
        this.doaClusterClient = doaClusterClient;
    }

    @Override
    public void onResult(DoipMessage[] result) {
        //正常发送并join fork之后的消息
        assert doidList.length == result.length;
        for (int i = 0; i < doidList.length; i++) {
            String doid = doidList[i];
            DoipMessage toCallDoipMessage;
            if (doaClusterClient instanceof TraceableDoaClusterClient) {
                toCallDoipMessage = ((TraceableDoaClusterClient) doaClusterClient).wrapSpanWithParent(result[i], msg, "Fork");
            } else {
                toCallDoipMessage = result[i];
            }
            DOIPInvocationCallback doipInvocationCallback = new DOIPInvocationCallback(doid, toCallDoipMessage, this.ddoClusterDoipInvocationCallback);
            this.doaClusterClient.sendMessage(doid, toCallDoipMessage, doipInvocationCallback, false);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy