public void testGetLocalNode() {
    System.setProperty("gov.nih.nci.ncia.grid.local.node.name", "disp1");
    System.setProperty("local.grid.uri", "url");

    NBIANode node = LocalNode.getLocalNode();
    assertTrue(node.isLocal());
    assertEquals(node.getDisplayName(), "disp1");
    assertEquals(node.getURL(), "url");
  }
コード例 #2
0
  /**
   * All the search requests are sent out in parallel.... wait for all of them to be done. This
   * method can be called as-is from a waiter thread with push ...that is if the push can work more
   * reliably.
   */
  private void waitForSearchResults(PatientSearchCompletionService completionService) {
    try {
      System.out.println("#################" + completionService.getNodesToSearch().size());
      List<NBIANode> noResponseNode = new ArrayList<NBIANode>();
      for (NBIANode node : completionService.getNodesToSearch()) {
        noResponseNode.add(node);
      }
      for (int i = 0; i < completionService.getNodesToSearch().size(); i++) {
        try {
          // this is a blocking call
          Future<PatientSearchResults> future =
              completionService
                  .getCompletionService()
                  .poll(NCIAConfig.getTimeoutInMin(), TimeUnit.MINUTES);
          //	this is a blocking call
          PatientSearchResults result = null;
          if (future != null) {
            result = future.get();
            System.out.println(
                "got response from node " + result.getNode().getDisplayName() + " so remove it");
            noResponseNode.remove(result.getNode()); // got response so remove it
            logResult(result);
            addNodeResult(result);
          }
        } catch (CancellationException e) {
          e.printStackTrace();
        }

        // pushToBrowser();
      }
      if (noResponseNode != null && !noResponseNode.isEmpty()) {
        //	check is there are any node from where, no response came with configurable minutes.
        for (NBIANode node : noResponseNode) {
          System.out.println("no response Node" + node.getDisplayName());
          Exception searchError = new Exception("no response from node");
          PatientSearchResults result = new PatientSearchResults(node, searchError);
          logResult(result);
          addNodeResult(result);
        }
      }

      System.out.println("done waiting for results");
    }
    //		catch(InterruptedException ie) {
    //			System.out.println("interrupted the async result waiter");
    //		}
    catch (Exception ex) {
      // shouldnt get here, the search result service should capture
      // any exceptions and results a search result that indicates
      // there was an error
      ex.printStackTrace();
    }
  }