use of org.apache.xmlrpc.client.XmlRpcClient in project processdash by dtuma.
the class CCWebService method openConnectionImpl.
@Override
protected XmlRpcClient openConnectionImpl() throws ErrorDataValueException {
// assume the most recent version of the server, and try to connect.
this.urlSuffix = new DynamicAttributeValue(URL_SUFFIX_4);
this.namespace = NAMESPACE4;
this.testMethodName = NAMESPACE4 + TEST_METHOD_NAME;
XmlRpcClient result = super.openConnectionImpl(true);
// if that fails, try connecting to the older server API.
if (result == null) {
this.urlSuffix = new DynamicAttributeValue(URL_SUFFIX_3);
this.namespace = NAMESPACE3;
this.testMethodName = NAMESPACE3 + TEST_METHOD_NAME;
result = super.openConnectionImpl(true);
}
return result;
}
use of org.apache.xmlrpc.client.XmlRpcClient in project ovirt-engine by oVirt.
the class ExternalSchedulerBrokerImpl method runFilters.
@Override
public List<Guid> runFilters(List<String> filterNames, List<Guid> hostIDs, Guid vmID, Map<String, String> propertiesMap) {
try {
// Do not call the scheduler when there is no operation requested from it
if (filterNames.isEmpty()) {
return hostIDs;
}
XmlRpcClient client = new XmlRpcClient();
client.setConfig(config);
Object xmlRpcStruct = client.execute(FILTER, createFilterArgs(filterNames, hostIDs, vmID, propertiesMap));
return ExternalSchedulerBrokerObjectBuilder.getFilteringResult(xmlRpcStruct).getHosts();
} catch (XmlRpcException e) {
log.error("Error communicating with the external scheduler while filtering: {}", e.getMessage());
log.debug("Exception", e);
auditLogFailedToConnect();
return hostIDs;
}
}
use of org.apache.xmlrpc.client.XmlRpcClient in project ovirt-engine by oVirt.
the class ExternalSchedulerBrokerImpl method runScores.
@Override
public List<WeightResultEntry> runScores(List<Pair<String, Integer>> scoreNameAndWeight, List<Guid> hostIDs, Guid vmID, Map<String, String> propertiesMap) {
try {
// Do not call the scheduler when there is no operation requested from it
if (scoreNameAndWeight.isEmpty()) {
return Collections.emptyList();
}
XmlRpcClient client = new XmlRpcClient();
client.setConfig(config);
Object result = client.execute(SCORE, createScoreArgs(scoreNameAndWeight, hostIDs, vmID, propertiesMap));
return ExternalSchedulerBrokerObjectBuilder.getScoreResult(result).getHosts();
} catch (XmlRpcException e) {
log.error("Error communicating with the external scheduler while running weight modules: {}", e.getMessage());
log.debug("Exception", e);
auditLogFailedToConnect();
return Collections.emptyList();
}
}
use of org.apache.xmlrpc.client.XmlRpcClient in project ovirt-engine by oVirt.
the class ExternalSchedulerBrokerImpl method runDiscover.
@Override
public Optional<ExternalSchedulerDiscoveryResult> runDiscover() {
try {
XmlRpcClient client = new XmlRpcClient();
client.setConfig(config);
Object result = client.execute(DISCOVER, EMPTY);
return parseDiscoverResults(result);
} catch (XmlRpcException e) {
log.error("Error communicating with the external scheduler while discovering: {}", e.getMessage());
log.debug("Exception", e);
return Optional.empty();
}
}
use of org.apache.xmlrpc.client.XmlRpcClient in project omegat by omegat-org.
the class MosesTranslate method showConfigurationUI.
@Override
public void showConfigurationUI(Window parent) {
MTConfigDialog dialog = new MTConfigDialog(parent, getName()) {
@Override
protected void onConfirm() {
String url = panel.valueField1.getText().trim();
System.setProperty(PROPERTY_MOSES_URL, url);
Preferences.setPreference(PROPERTY_MOSES_URL, url);
}
};
JLabel messageLabel = new JLabel();
JButton testButton = new JButton(OStrings.getString("MT_ENGINE_MOSES_TEST_BUTTON"));
testButton.addActionListener(e -> {
messageLabel.setText(OStrings.getString("MT_ENGINE_MOSES_TEST_TESTING"));
String url = dialog.panel.valueField1.getText().trim();
new SwingWorker<String, Void>() {
@Override
protected String doInBackground() throws Exception {
XmlRpcClient client = getClient(new URL(url));
Object response = client.execute("system.listMethods", (Object[]) null);
if (Arrays.asList(((Object[]) response)).contains("translate")) {
return OStrings.getString("MT_ENGINE_MOSES_TEST_RESULT_OK");
} else {
return OStrings.getString("MT_ENGINE_MOSES_TEST_RESULT_NO_TRANSLATE");
}
}
@Override
protected void done() {
String message = null;
try {
message = get();
} catch (ExecutionException e) {
message = e.getCause().getLocalizedMessage();
Logger.getLogger(getClass().getName()).log(Level.SEVERE, message, e);
} catch (Exception e) {
message = e.getLocalizedMessage();
Logger.getLogger(getClass().getName()).log(Level.SEVERE, message, e);
}
messageLabel.setText(message);
}
}.execute();
});
JPanel testPanel = new JPanel();
testPanel.setLayout(new BoxLayout(testPanel, BoxLayout.LINE_AXIS));
testPanel.add(testButton);
testPanel.add(messageLabel);
testPanel.setAlignmentX(0);
dialog.panel.itemsPanel.add(testPanel);
dialog.panel.valueLabel1.setText(OStrings.getString("MT_ENGINE_MOSES_URL_LABEL"));
dialog.panel.valueField1.setText(getServerUrl());
dialog.panel.valueField1.setColumns(20);
dialog.panel.valueLabel2.setVisible(false);
dialog.panel.valueField2.setVisible(false);
dialog.panel.temporaryCheckBox.setVisible(false);
dialog.show();
}
Aggregations