@Override
public void onFailure(Throwable caught) {
numResponses++;
ServerInstance instance = createInstanceModel(handle);
instance.setHost(host);
instance.setRunning(false);
instance.setInterfaces(new HashMap<String, String>());
instance.setSocketBindings(new HashMap<String, String>());
instanceList.add(instance);
checkComplete(instanceList, cb);
}
@Override
public void onSuccess(DMRResponse result) {
numResponses++;
ModelNode response = result.get();
ModelNode compositeResponse = response.get(RESULT);
ServerInstance instance = createInstanceModel(handle);
instance.setHost(host);
instance.setInterfaces(new HashMap<String, String>());
instance.setSocketBindings(new HashMap<String, String>());
instanceList.add(instance);
if(response.isFailure())
{
instance.setRunning(false);
}
else
{
ModelNode instanceModel = compositeResponse.get("step-1").get(RESULT);
instance.setRunning(handle.isStarted());
//instance.setProfile(instanceModel.get("profile-name").asString());
if(instanceModel.hasDefined("server-state"))
{
String state = instanceModel.get("server-state").asString();
if(state.equals("reload-required"))
{
instance.setFlag(ServerFlag.RELOAD_REQUIRED);
}
else if (state.equals("restart-required"))
{
instance.setFlag(ServerFlag.RESTART_REQUIRED);
}
}
// ---- interfaces
List<Property> interfaces = Collections.EMPTY_LIST;
if(compositeResponse.hasDefined("step-2"))
{
interfaces = compositeResponse.get("step-2").get(RESULT).asPropertyList();
for(Property intf : interfaces)
{
if(intf.getValue().hasDefined("resolved-address"))
{
instance.getInterfaces().put(
intf.getName(),
intf.getValue().get("resolved-address").asString()
);
}
}
}
// ---- socket binding
List<Property> sockets = Collections.EMPTY_LIST;
if(compositeResponse.hasDefined("step-3"))
{
sockets = compositeResponse.get("step-3").get(RESULT).asPropertyList();
for(Property socket : sockets)
{
instance.getSocketBindings().put(
socket.getName(),
socket.getValue().get("port-offset").asString()
);
}