Search in sources :

Example 1 with HaInfo

use of com.sun.xml.ws.api.ha.HaInfo in project metro-jax-ws by eclipse-ee4j.

the class ServletConnectionImpl method getHaInfo.

@Property(Packet.HA_INFO)
public HaInfo getHaInfo() {
    if (haInfo == null) {
        String replicaInstance = null;
        String key = null;
        String jrouteId = null;
        Cookie[] cookies = request.getCookies();
        if (cookies != null) {
            for (Cookie cookie : cookies) {
                if (replicaInstance == null && cookie.getName().equals("JREPLICA")) {
                    replicaInstance = cookie.getValue();
                } else if (key == null && cookie.getName().equals("METRO_KEY")) {
                    key = cookie.getValue();
                } else if (jrouteId == null && cookie.getName().equals("JROUTE")) {
                    jrouteId = cookie.getValue();
                }
            }
            if (replicaInstance != null && key != null) {
                String proxyJroute = request.getHeader("proxy-jroute");
                boolean failOver = jrouteId != null && proxyJroute != null && !jrouteId.equals(proxyJroute);
                haInfo = new HaInfo(key, replicaInstance, failOver);
            }
        }
    }
    return haInfo;
}
Also used : Cookie(jakarta.servlet.http.Cookie) HaInfo(com.sun.xml.ws.api.ha.HaInfo)

Example 2 with HaInfo

use of com.sun.xml.ws.api.ha.HaInfo in project metro-jax-ws by eclipse-ee4j.

the class HelloServiceImpl method testHa.

public void testHa() {
    MessageContext ctxt = wsc.getMessageContext();
    HaInfo haInfo = (HaInfo) ctxt.get(Packet.HA_INFO);
    if (haInfo == null) {
        throw new WebServiceException("Packet.HA_INFO is not populated.");
    }
    String replica = (String) haInfo.getReplicaInstance();
    if (replica == null || !replica.equals("replica1")) {
        throw new WebServiceException("Expecting getReplicaInstance()=replica1 but got=" + replica);
    }
    String key = (String) haInfo.getKey();
    if (key == null || !key.equals("key1")) {
        throw new WebServiceException("Expecting getKey()=key1 but got=" + key);
    }
    Boolean failOver = (Boolean) haInfo.isFailOver();
    if (failOver == null || !failOver) {
        throw new WebServiceException("Expecting isFailOver()=true but got=" + failOver);
    }
}
Also used : HaInfo(com.sun.xml.ws.api.ha.HaInfo) WebServiceException(jakarta.xml.ws.WebServiceException) MessageContext(jakarta.xml.ws.handler.MessageContext)

Example 3 with HaInfo

use of com.sun.xml.ws.api.ha.HaInfo in project metro-jax-ws by eclipse-ee4j.

the class HelidonConnectionImpl method getHaInfo.

@Property(Packet.HA_INFO)
public HaInfo getHaInfo() {
    if (haInfo == null) {
        Parameters cookies = req.headers().cookies();
        String replicaInstance = cookies.first("JREPLICA").orElse(null);
        String key = cookies.first("METRO_KEY").orElse(null);
        String jrouteId = cookies.first("JROUTE").orElse(null);
        if (replicaInstance != null && key != null) {
            String proxyJroute = getRequestHeader("proxy-jroute");
            boolean failOver = jrouteId != null && proxyJroute != null && !jrouteId.equals(proxyJroute);
            haInfo = new HaInfo(key, replicaInstance, failOver);
        }
    }
    return haInfo;
}
Also used : HaInfo(com.sun.xml.ws.api.ha.HaInfo) Parameters(io.helidon.common.http.Parameters)

Aggregations

HaInfo (com.sun.xml.ws.api.ha.HaInfo)3 Parameters (io.helidon.common.http.Parameters)1 Cookie (jakarta.servlet.http.Cookie)1 WebServiceException (jakarta.xml.ws.WebServiceException)1 MessageContext (jakarta.xml.ws.handler.MessageContext)1