Search in sources :

Example 1 with DebugInfo

use of org.jboss.tools.openshift.core.odo.DebugInfo in project jbosstools-openshift by jbosstools.

the class OdoCli method debugInfo.

@Override
public DebugInfo debugInfo(String project, String application, String context, String component) throws IOException {
    try {
        ExecResult result = ExecHelper.execute(command, new File(context), envVars, "debug", "info", "-o", "json");
        JSonParser parser = new JSonParser(JSON_MAPPER.readTree(result.getStdOut()));
        return parser.parseDebugInfo();
    } catch (IOException e) {
        if (e.getMessage().contains("debug is not running")) {
            return new DebugInfo(DebugStatus.NOT_RUNNING);
        }
        throw e;
    }
}
Also used : IOException(java.io.IOException) File(java.io.File) JSonParser(org.jboss.tools.openshift.core.odo.JSonParser) DebugInfo(org.jboss.tools.openshift.core.odo.DebugInfo) ExecResult(org.jboss.tools.openshift.internal.ui.odo.ExecHelper.ExecResult)

Example 2 with DebugInfo

use of org.jboss.tools.openshift.core.odo.DebugInfo in project jbosstools-openshift by jbosstools.

the class DebugHandler method execute.

@Override
public Object execute(ComponentElement component, Shell shell) throws ExecutionException {
    try {
        Odo odo = component.getRoot().getOdo();
        String project = component.getParent().getParent().getWrapped();
        String application = component.getParent().getWrapped().getName();
        ComponentInfo info = odo.getComponentInfo(project, application, component.getWrapped().getName(), component.getWrapped().getPath(), component.getWrapped().getInfo().getComponentKind());
        RemoteStackDebugger remoteDebugger = RemoteStackProviderRegistry.getInstance().findBytype(info.getComponentTypeName(), info.getComponentTypeVersion());
        if (remoteDebugger != null) {
            DebugInfo debugInfo = odo.debugInfo(project, application, component.getWrapped().getPath(), component.getWrapped().getName());
            int port = debugInfo.getStatus() == DebugStatus.RUNNING ? debugInfo.getLocalPort() : allocateLocalPort();
            if (debugInfo.getStatus() != DebugStatus.RUNNING) {
                executeInJob("Debug", monitor -> startDebug(odo, project, application, component, port));
            }
            executeInJob("Attach debugger", monitor -> createAndLaunchConfig(odo, project, application, component.getWrapped(), info, port, remoteDebugger, monitor, shell));
        } else {
            MessageDialog.openError(shell, "Debug", "Debugging is not supported for this type of component");
        }
        return Status.OK_STATUS;
    } catch (IOException e) {
        return OpenShiftUIActivator.statusFactory().errorStatus(e);
    }
}
Also used : RemoteStackDebugger(org.jboss.tools.openshift.core.stack.RemoteStackDebugger) Odo(org.jboss.tools.openshift.core.odo.Odo) ComponentInfo(org.jboss.tools.openshift.core.odo.ComponentInfo) IOException(java.io.IOException) DebugInfo(org.jboss.tools.openshift.core.odo.DebugInfo)

Aggregations

IOException (java.io.IOException)2 DebugInfo (org.jboss.tools.openshift.core.odo.DebugInfo)2 File (java.io.File)1 ComponentInfo (org.jboss.tools.openshift.core.odo.ComponentInfo)1 JSonParser (org.jboss.tools.openshift.core.odo.JSonParser)1 Odo (org.jboss.tools.openshift.core.odo.Odo)1 RemoteStackDebugger (org.jboss.tools.openshift.core.stack.RemoteStackDebugger)1 ExecResult (org.jboss.tools.openshift.internal.ui.odo.ExecHelper.ExecResult)1