Search in sources :

Example 1 with GetBreakpointResponse

use of com.google.api.services.clouddebugger.v2.model.GetBreakpointResponse in project google-cloud-intellij by GoogleCloudPlatform.

the class CloudDebugProcessStateController method resolveBreakpointAsync.

/**
 * Returns a fully realized {@link Breakpoint} with all results possibly asynchronously.
 */
@SuppressWarnings("FutureReturnValueIgnored")
public void resolveBreakpointAsync(@NotNull final String id, @NotNull final ResolveBreakpointHandler handler) {
    if (fullFinalBreakpoints.containsKey(id)) {
        handler.onSuccess(fullFinalBreakpoints.get(id));
        return;
    }
    if (state == null) {
        handler.onError(GctBundle.getString("clouddebug.invalid.state"));
        return;
    }
    final Debugger client = CloudDebuggerClient.getLongTimeoutClient(state);
    if (client == null) {
        LOG.warn("no client available attempting to resolveBreakpointAsync");
        handler.onError(GctBundle.getString("clouddebug.bad.login.message"));
        return;
    }
    List<Breakpoint> currentList = state.getCurrentServerBreakpointList();
    for (Breakpoint serverBreakpointCandidate : currentList) {
        if (serverBreakpointCandidate.getId().equals(id) && !Boolean.TRUE.equals(serverBreakpointCandidate.getIsFinalState())) {
            handler.onSuccess(serverBreakpointCandidate);
            return;
        }
    }
    ApplicationManager.getApplication().executeOnPooledThread(() -> {
        // At this point, the user has selected a final state breakpoint which is not yet
        // hydrated.
        // So we query the server to get this final on a worker thread and then run the
        // runnable
        // back on ui
        GetBreakpointResponse response;
        try {
            response = client.debuggees().breakpoints().get(state.getDebuggeeId(), id).setClientVersion(ServiceManager.getService(PluginInfoService.class).getClientVersionForCloudDebugger()).execute();
            Breakpoint result = response.getBreakpoint();
            if (result != null) {
                fullFinalBreakpoints.put(id, result);
                handler.onSuccess(result);
            } else {
                handler.onError(GctBundle.getString("clouddebug.no.response"));
            }
        } catch (IOException ex) {
            LOG.warn("IOException hydrating a snapshot.  User may have deleted the snapshot", ex);
            handler.onError(ex.toString());
        }
    });
}
Also used : Debugger(com.google.api.services.clouddebugger.v2.Clouddebugger.Debugger) Breakpoint(com.google.api.services.clouddebugger.v2.model.Breakpoint) IOException(java.io.IOException) GetBreakpointResponse(com.google.api.services.clouddebugger.v2.model.GetBreakpointResponse)

Aggregations

Debugger (com.google.api.services.clouddebugger.v2.Clouddebugger.Debugger)1 Breakpoint (com.google.api.services.clouddebugger.v2.model.Breakpoint)1 GetBreakpointResponse (com.google.api.services.clouddebugger.v2.model.GetBreakpointResponse)1 IOException (java.io.IOException)1