Search in sources :

Example 11 with XmlRpcClient

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;
}
Also used : DynamicAttributeValue(net.sourceforge.processdash.ui.lib.binding.DynamicAttributeValue) XmlRpcClient(org.apache.xmlrpc.client.XmlRpcClient)

Example 12 with XmlRpcClient

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;
    }
}
Also used : XmlRpcClient(org.apache.xmlrpc.client.XmlRpcClient) XmlRpcException(org.apache.xmlrpc.XmlRpcException)

Example 13 with XmlRpcClient

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();
    }
}
Also used : XmlRpcClient(org.apache.xmlrpc.client.XmlRpcClient) XmlRpcException(org.apache.xmlrpc.XmlRpcException)

Example 14 with XmlRpcClient

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();
    }
}
Also used : XmlRpcClient(org.apache.xmlrpc.client.XmlRpcClient) XmlRpcException(org.apache.xmlrpc.XmlRpcException)

Example 15 with XmlRpcClient

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();
}
Also used : JPanel(javax.swing.JPanel) XmlRpcClient(org.apache.xmlrpc.client.XmlRpcClient) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) XmlRpcException(org.apache.xmlrpc.XmlRpcException) ExecutionException(java.util.concurrent.ExecutionException) URL(java.net.URL) MTConfigDialog(org.omegat.gui.exttrans.MTConfigDialog) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

XmlRpcClient (org.apache.xmlrpc.client.XmlRpcClient)21 XmlRpcException (org.apache.xmlrpc.XmlRpcException)11 URL (java.net.URL)10 XmlRpcClientConfigImpl (org.apache.xmlrpc.client.XmlRpcClientConfigImpl)7 MalformedURLException (java.net.MalformedURLException)5 Test (org.junit.Test)3 Answer (com.cloud.agent.api.Answer)2 MaintainCommand (com.cloud.agent.api.MaintainCommand)2 RebootAnswer (com.cloud.agent.api.RebootAnswer)2 CreateAnswer (com.cloud.agent.api.storage.CreateAnswer)2 XsHost (com.cloud.hypervisor.xenserver.resource.XsHost)2 Connection (com.xensource.xenapi.Connection)2 XenAPIException (com.xensource.xenapi.Types.XenAPIException)2 Hashtable (java.util.Hashtable)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 AttachAnswer (com.cloud.storage.command.AttachAnswer)1 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)1 IOException (java.io.IOException)1 StringReader (java.io.StringReader)1 ArrayList (java.util.ArrayList)1