Search in sources :

Example 1 with ListBreakpointsResponse

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

the class CloudDebugGlobalPoller method queryServerForBreakpoints.

private void queryServerForBreakpoints(CloudDebugProcessState state, Debugger client) throws IOException {
    if (state.getDebuggeeId() == null) {
        throw new IllegalStateException("CloudDebugProcessState.getDebuggeeId() was null");
    }
    Debuggees debuggees = client.debuggees();
    Breakpoints breakpoints = debuggees.breakpoints();
    Breakpoints.List listRequest = breakpoints.list(state.getDebuggeeId()).setIncludeInactive(Boolean.TRUE).setActionValue("CAPTURE").setStripResults(Boolean.TRUE).setWaitToken(state.getWaitToken());
    ListBreakpointsResponse response = listRequest.setClientVersion(ServiceManager.getService(PluginInfoService.class).getClientVersionForCloudDebugger()).execute();
    List<Breakpoint> currentList = response.getBreakpoints();
    String responseWaitToken = response.getNextWaitToken();
    state.setWaitToken(responseWaitToken);
    if (currentList != null) {
        Collections.sort(currentList, BreakpointComparer.getDefaultInstance());
    }
    state.setCurrentServerBreakpointList(currentList != null ? ContainerUtil.immutableList(currentList) : ContainerUtil.immutableList(new ArrayList<Breakpoint>()));
}
Also used : Breakpoints(com.google.api.services.clouddebugger.v2.Clouddebugger.Debugger.Debuggees.Breakpoints) Breakpoint(com.google.api.services.clouddebugger.v2.model.Breakpoint) ListBreakpointsResponse(com.google.api.services.clouddebugger.v2.model.ListBreakpointsResponse) Debuggees(com.google.api.services.clouddebugger.v2.Clouddebugger.Debugger.Debuggees) PluginInfoService(com.google.cloud.tools.intellij.service.PluginInfoService)

Example 2 with ListBreakpointsResponse

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

the class CloudDebugProcessStateController method queryServerForBreakpoints.

private List<Breakpoint> queryServerForBreakpoints(CloudDebugProcessState state, Debugger client, String tokenToSend) throws IOException {
    List<Breakpoint> currentList = null;
    String responseWaitToken = tokenToSend;
    while (tokenToSend == null || tokenToSend.equals(responseWaitToken)) {
        if (tokenToSend != null && !isBackgroundListening()) {
            return null;
        }
        ListBreakpointsResponse response = client.debuggees().breakpoints().list(state.getDebuggeeId()).setIncludeInactive(Boolean.TRUE).setActionValue("CAPTURE").setStripResults(Boolean.TRUE).setWaitToken(CloudDebugConfigType.useWaitToken() ? tokenToSend : null).setClientVersion(ServiceManager.getService(PluginInfoService.class).getClientVersionForCloudDebugger()).execute();
        // up the background watcher.
        if (tokenToSend != null && !isBackgroundListening()) {
            return null;
        }
        currentList = response.getBreakpoints();
        responseWaitToken = response.getNextWaitToken();
        if (tokenToSend == null) {
            break;
        }
        if (!CloudDebugConfigType.useWaitToken() && tokenToSend.equals(responseWaitToken)) {
            try {
                // our fallback polling mode has a 1 second loop.
                Thread.currentThread().sleep(1000);
            } catch (InterruptedException ex) {
                return null;
            }
        }
    }
    state.setWaitToken(responseWaitToken);
    if (currentList != null) {
        Collections.sort(currentList, BreakpointComparer.getDefaultInstance());
    }
    state.setCurrentServerBreakpointList(currentList != null ? ContainerUtil.immutableList(currentList) : ContainerUtil.immutableList(new ArrayList<>()));
    return currentList;
}
Also used : Breakpoint(com.google.api.services.clouddebugger.v2.model.Breakpoint) ListBreakpointsResponse(com.google.api.services.clouddebugger.v2.model.ListBreakpointsResponse) PluginInfoService(com.google.cloud.tools.intellij.service.PluginInfoService)

Example 3 with ListBreakpointsResponse

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

the class CloudDebugProcessStateTest method createMockClient.

private Debugger createMockClient(final List<Breakpoint> returnedBreakpoints) throws IOException {
    Debugger client = Mockito.mock(Debugger.class);
    Debugger.Debuggees debuggees = Mockito.mock(Debugger.Debuggees.class);
    Debugger.Debuggees.Breakpoints breakpoints = Mockito.mock(Debugger.Debuggees.Breakpoints.class);
    Debugger.Debuggees.Breakpoints.List list = Mockito.mock(Debugger.Debuggees.Breakpoints.List.class);
    when(client.debuggees()).thenReturn(debuggees);
    when(debuggees.breakpoints()).thenReturn(breakpoints);
    when(breakpoints.list(DEBUGEE_ID)).thenReturn(list);
    when(list.setIncludeInactive(Boolean.TRUE)).thenReturn(list);
    when(list.setActionValue("CAPTURE")).thenReturn(list);
    when(list.setStripResults(Boolean.TRUE)).thenReturn(list);
    when(list.setWaitToken(null)).thenReturn(list);
    when(list.setClientVersion(ServiceManager.getService(PluginInfoService.class).getClientVersionForCloudDebugger())).thenReturn(list);
    when(list.execute()).thenAnswer(new Answer<Object>() {

        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            ListBreakpointsResponse response = new ListBreakpointsResponse();
            List<Breakpoint> copy = new ArrayList<Breakpoint>(returnedBreakpoints);
            response.setBreakpoints(copy);
            return response;
        }
    });
    return client;
}
Also used : Debugger(com.google.api.services.clouddebugger.v2.Clouddebugger.Debugger) Breakpoint(com.google.api.services.clouddebugger.v2.model.Breakpoint) ListBreakpointsResponse(com.google.api.services.clouddebugger.v2.model.ListBreakpointsResponse) InvocationOnMock(org.mockito.invocation.InvocationOnMock) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

Breakpoint (com.google.api.services.clouddebugger.v2.model.Breakpoint)3 ListBreakpointsResponse (com.google.api.services.clouddebugger.v2.model.ListBreakpointsResponse)3 PluginInfoService (com.google.cloud.tools.intellij.service.PluginInfoService)2 Debugger (com.google.api.services.clouddebugger.v2.Clouddebugger.Debugger)1 Debuggees (com.google.api.services.clouddebugger.v2.Clouddebugger.Debugger.Debuggees)1 Breakpoints (com.google.api.services.clouddebugger.v2.Clouddebugger.Debugger.Debuggees.Breakpoints)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1