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;
}
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);
}
}
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;
}
Aggregations