/** Main entry point, should be called by a scheduler. */
  public void run() {
    Security.runAsAdmin(
        () -> {
          Subject runSubject =
              subject != null ? subject : Security.getInstance().getSystemSubject();

          return runSubject.execute(
              () -> {
                LOGGER.trace("running workspace query service");

                Map<String, Pair<WorkspaceMetacardImpl, List<QueryMetacardImpl>>> queryMetacards =
                    workspaceService.getQueryMetacards();

                LOGGER.debug("queryMetacards: size={}", queryMetacards.size());

                List<WorkspaceTask> workspaceTasks = createWorkspaceTasks(queryMetacards);

                LOGGER.debug("workspaceTasks: size={}", workspaceTasks.size());

                Map<String, Pair<WorkspaceMetacardImpl, Long>> results =
                    executeWorkspaceTasks(workspaceTasks, queryTimeoutMinutes, TimeUnit.MINUTES);

                LOGGER.debug("results: {}", results);

                queryUpdateSubscriber.notify(results);

                return null;
              });
        });
  }
Exemple #2
0
  @Test
  public void testIsAvailableSubjectExperation() throws Exception {
    when(webclient.invoke(eq("HEAD"), isNull())).thenReturn(response);
    when(mockSecurity.getExpires(subject))
        .thenReturn(new Date(System.currentTimeMillis() + 600000L))
        .thenReturn(new Date(System.currentTimeMillis() + 600000L))
        .thenReturn(new Date());
    sendEvent.setSubject(subject);
    boolean available = false;
    while (!sendEvent.ping()) {}

    long lastPing = sendEvent.getLastPing();
    // sleep incase the test runs too fast we want to make sure their is a time difference
    Thread.sleep(1);
    // run within the expiration period of the assertion
    available = sendEvent.ping();
    assertTrue(available);
    assertEquals(lastPing, sendEvent.getLastPing());
    // sleep incase the test runs too fast we want to make sure their is a time difference
    Thread.sleep(1);
    // run with expired assertion
    available = sendEvent.ping();
    assertTrue(available);
    assertNotEquals(lastPing, sendEvent.getLastPing());
  }