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

org.bdware.doip.cluster.entity.SendMsgReqPack Maven / Gradle / Ivy

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

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.bdware.doip.cluster.client.DoaClusterClient;
import org.bdware.doip.codec.doipMessage.DoipMessage;
import org.bdware.doip.endpoint.client.DoipMessageCallback;

public class SendMsgReqPack extends RequestPackIntf {
    static Logger LOGGER = LogManager.getLogger(SendMsgReqPack.class);
    private final long createTime;
    DOEntity doEntity;
    DoipMessage doipMessage;
    DoipMessageCallback doipMessageCallback;
    boolean needFlowControl;
    DoaClusterClient doaClusterClient;

    public SendMsgReqPack(DoaClusterClient doaClusterClient, DOEntity cachedDO, DoipMessage message, DoipMessageCallback callback, boolean needFlowControl) {
        this.doaClusterClient = doaClusterClient;
        this.doEntity = cachedDO;
        this.doipMessage = message;
        this.doipMessageCallback = callback;
        this.needFlowControl = needFlowControl;
        this.createTime = System.currentTimeMillis();
    }

    public void setDoipMessage(DoipMessage message) {
        this.doipMessage = message;
    }

    public DOEntity getDoEntity() {
        return doEntity;
    }

    public DoipMessage getDoipMessage() {
        return doipMessage;
    }

    public DoipMessageCallback getDoipMessageCallback() {
        return doipMessageCallback;
    }

    public boolean needFlowControl() {
        return needFlowControl;
    }


    @Override
    public long getPriority() {
        return createTime + doEntity.getType().ordinal() * 100;
    }

    @Override
    public void run() {
        doEntity.sendMessage(doaClusterClient, doipMessage, doipMessageCallback);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy