Search in sources :

Example 1 with CommandTimeoutException

use of org.jboss.tools.openshift.cdk.server.core.internal.adapter.controllers.CommandTimeoutException in project jbosstools-openshift by jbosstools.

the class VagrantPoller method onePing.

protected IStatus onePing(IServer server, Map<String, String> env) throws PollingException, IOException, TimeoutException {
    String[] args = new String[] { CDKConstants.VAGRANT_CMD_STATUS, CDKConstants.VAGRANT_FLAG_MACHINE_READABLE, CDKConstants.VAGRANT_FLAG_NO_COLOR };
    String vagrantcmdloc = VagrantBinaryUtility.getVagrantLocation(server);
    try {
        String[] lines = CDKLaunchUtility.callMachineReadable(vagrantcmdloc, args, getWorkingDirectory(server), env);
        IStatus vmStatus = parseOutput(lines);
        if (vmStatus.isOK()) {
            // throws OpenShiftNotReadyPollingException on failure
            checkOpenShiftHealth(server, 4000);
        }
        return vmStatus;
    } catch (CommandTimeoutException vte) {
        // Try to salvage it, it could be the process never terminated but
        // it got all the output
        List<String> inLines = vte.getInLines();
        if (inLines != null) {
            String[] asArr = inLines.toArray(new String[inLines.size()]);
            IStatus ret = parseOutput(asArr);
            if (ret != null) {
                return ret;
            }
        }
        CDKCoreActivator.pluginLog().logError("Unable to successfully complete a call to vagrant status. ", vte);
        throw vte;
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) CommandTimeoutException(org.jboss.tools.openshift.cdk.server.core.internal.adapter.controllers.CommandTimeoutException) List(java.util.List)

Example 2 with CommandTimeoutException

use of org.jboss.tools.openshift.cdk.server.core.internal.adapter.controllers.CommandTimeoutException in project jbosstools-openshift by jbosstools.

the class MinishiftPoller method onePing.

protected IStatus onePing(IServer server, Map<String, String> env) throws PollingException, IOException, TimeoutException {
    String[] args = new String[] { CDKConstants.VAGRANT_CMD_STATUS };
    args = CDK32Server.getArgsWithProfile(server, args);
    String vagrantcmdloc = MinishiftBinaryUtility.getMinishiftLocation(server);
    try {
        String[] lines = CDKLaunchUtility.callMachineReadable(vagrantcmdloc, args, getWorkingDirectory(server), env);
        IStatus stat = parseOutput(lines);
        if (stat.isOK()) {
            checkOpenShiftHealth(server, 4000);
            return stat;
        } else {
            return stat;
        }
    } catch (CommandTimeoutException vte) {
        // Try to salvage it, it could be the process never terminated but
        // it got all the output
        List<String> inLines = vte.getInLines();
        if (inLines != null) {
            String[] asArr = (String[]) inLines.toArray(new String[inLines.size()]);
            IStatus stat = parseOutput(asArr);
            if (stat.isOK()) {
                checkOpenShiftHealth(server, 4000);
            } else {
                return stat;
            }
        }
        CDKCoreActivator.pluginLog().logError("Unable to successfully complete a call to vagrant status. ", vte);
        throw vte;
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) CommandTimeoutException(org.jboss.tools.openshift.cdk.server.core.internal.adapter.controllers.CommandTimeoutException) ArrayList(java.util.ArrayList) List(java.util.List)

Example 3 with CommandTimeoutException

use of org.jboss.tools.openshift.cdk.server.core.internal.adapter.controllers.CommandTimeoutException in project jbosstools-openshift by jbosstools.

the class ServiceManagerEnvironmentLoader method callAndParseProperties.

protected Properties callAndParseProperties(Map<String, String> env, String[] args, String cmdLoc, File wd) throws IOException {
    String[] lines = null;
    try {
        lines = CDKLaunchUtility.call(cmdLoc, args, wd, env, 30000, false);
    } catch (IOException ioe) {
        throw ioe;
    } catch (CommandTimeoutException ce) {
        if (ce.getInLines() == null) {
            throw new IOException(ce);
        }
        // Try to salvage it, it could be the process never terminated but it got all the output
        lines = ce.getInLines() == null ? null : (String[]) ce.getInLines().toArray(new String[ce.getInLines().size()]);
    }
    String imploded = String.join("\n", Arrays.asList(lines));
    Properties ret = new Properties();
    ret.load(new ByteArrayInputStream(imploded.getBytes()));
    return ret;
}
Also used : CommandTimeoutException(org.jboss.tools.openshift.cdk.server.core.internal.adapter.controllers.CommandTimeoutException) ByteArrayInputStream(java.io.ByteArrayInputStream) IOException(java.io.IOException) Properties(java.util.Properties)

Aggregations

CommandTimeoutException (org.jboss.tools.openshift.cdk.server.core.internal.adapter.controllers.CommandTimeoutException)3 List (java.util.List)2 IStatus (org.eclipse.core.runtime.IStatus)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Properties (java.util.Properties)1