public void startMockDaemon() {
   daemon = getMockLockssDaemon();
   pluginMgr = daemon.getPluginManager();
   pluginMgr.setLoadablePluginsReady(true);
   daemon.setDaemonInited(true);
   pluginMgr.startService();
   daemon.getAlertManager();
   daemon.getCrawlManager();
 }
  public void setUp() throws Exception {
    super.setUp();
    tempDirPath = getTempDir().getAbsolutePath() + File.separator;

    theDaemon = getMockLockssDaemon();
    theDaemon.getAlertManager();
    theDaemon.getPluginManager().setLoadablePluginsReady(true);
    theDaemon.getHashService();
    MockSystemMetrics metrics = new MyMockSystemMetrics();
    metrics.initService(theDaemon);
    theDaemon.setSystemMetrics(metrics);

    theDaemon.setDaemonInited(true);

    Properties props = new Properties();
    props.setProperty(SystemMetrics.PARAM_HASH_TEST_DURATION, "1000");
    props.setProperty(SystemMetrics.PARAM_HASH_TEST_BYTE_STEP, "1024");
    props.setProperty(ConfigManager.PARAM_PLATFORM_DISK_SPACE_LIST, tempDirPath);
    ConfigurationUtil.setCurrentConfigFromProps(props);

    pluginMgr = theDaemon.getPluginManager();
    pluginMgr.startService();
    theDaemon.getHashService().startService();
    metrics.startService();
    metrics.setHashSpeed(100);

    simPlugin = PluginTestUtil.findPlugin(SimulatedPlugin.class);
  }
示例#3
0
 ArchivalUnit getAu() {
   if (StringUtil.isNullString(formAuid)) {
     errMsg = "Select an AU";
     return null;
   }
   ArchivalUnit au = pluginMgr.getAuFromId(formAuid);
   if (au == null) {
     errMsg = "No such AU.  Select an AU";
     return null;
   }
   return au;
 }
示例#4
0
 private void crawlPluginRegistries() {
   StringBuilder sb = new StringBuilder();
   for (ArchivalUnit au : pluginMgr.getAllRegistryAus()) {
     sb.append(au.getName());
     sb.append(": ");
     try {
       startCrawl(au, true, false);
       sb.append("Queued.");
     } catch (CrawlManagerImpl.NotEligibleException e) {
       sb.append("Failed: ");
       sb.append(e.getMessage());
     }
     sb.append("\n");
   }
   statusMsg = sb.toString();
 }
示例#5
0
文件: AuHelper.java 项目: ravn/lockss
  /**
   * Provides the status information of an archival unit in the system.
   *
   * @param auId A String with the identifier of the archival unit.
   * @return an AuStatus with the status information of the archival unit.
   * @throws LockssWebServicesFault
   */
  AuStatus getAuStatus(String auId) throws LockssWebServicesFault {
    final String DEBUG_HEADER = "getAuStatus(): ";

    LockssDaemon theDaemon = LockssDaemon.getLockssDaemon();
    PluginManager pluginMgr = theDaemon.getPluginManager();
    ArchivalUnit au = pluginMgr.getAuFromId(auId);

    if (au == null) {
      throw new LockssWebServicesFault(
          "No Archival Unit with provided identifier",
          new LockssWebServicesFaultInfo("Archival Unit identifier = " + auId));
    }

    AuStatus result = new AuStatus();
    result.setVolume(au.getName());

    TitleConfig tc = au.getTitleConfig();
    if (tc != null) {
      result.setJournalTitle(tc.getJournalTitle());
    }

    Plugin plugin = au.getPlugin();
    result.setPluginName(plugin.getPluginName());

    result.setYear(AuUtil.getTitleAttribute(au, "year"));

    NodeManager nodeMgr = theDaemon.getNodeManager(au);
    AuState state = nodeMgr.getAuState();
    AuState.AccessType atype = state.getAccessType();

    if (atype != null) {
      result.setAccessType(atype.toString());
    }

    long contentSize = AuUtil.getAuContentSize(au, false);

    if (contentSize != -1) {
      result.setContentSize(contentSize);
    }

    long du = AuUtil.getAuDiskUsage(au, false);

    if (du != -1) {
      result.setDiskUsage(du);
    }

    String spec = LockssRepositoryImpl.getRepositorySpec(au);
    String repo =
        LockssRepositoryImpl.mapAuToFileLocation(
            LockssRepositoryImpl.getLocalRepositoryPath(spec), au);
    result.setRepository(repo);

    CachedUrlSet auCus = au.getAuCachedUrlSet();
    NodeState topNode = nodeMgr.getNodeState(auCus);

    if (AuUtil.getProtocolVersion(au) == Poll.V3_PROTOCOL) {
      if (state.getV3Agreement() < 0) {
        if (state.getLastCrawlTime() < 0) {
          result.setStatus("Waiting for Crawl");
        } else {
          result.setStatus("Waiting for Poll");
        }
      } else {
        result.setStatus(doubleToPercent(state.getHighestV3Agreement()) + "% Agreement");
        if (state.getHighestV3Agreement() != state.getV3Agreement()) {
          result.setRecentPollAgreement(state.getV3Agreement());
        }
      }
    } else {
      result.setStatus(topNode.hasDamage() ? "Repairing" : "Ok");
    }

    String publishingPlatform = plugin.getPublishingPlatform();

    if (!StringUtil.isNullString(publishingPlatform)) {
      result.setPublishingPlatform(publishingPlatform);
    }

    String publisher = AuUtil.getTitleAttribute(au, "publisher");

    if (!StringUtil.isNullString(publisher)) {
      result.setPublisher(publisher);
    }

    result.setAvailableFromPublisher(!AuUtil.isPubDown(au));
    result.setSubstanceState(state.getSubstanceState().toString());
    result.setCreationTime(state.getAuCreationTime());

    AuUtil.AuProxyInfo aupinfo = AuUtil.getAuProxyInfo(au);

    if (aupinfo.isAuOverride()) {
      String disp =
          (aupinfo.getHost() == null
              ? "Direct connection"
              : aupinfo.getHost() + ":" + aupinfo.getPort());
      result.setCrawlProxy(disp);
    }

    CrawlWindow window = au.getCrawlWindow();

    if (window != null) {
      String wmsg = window.toString();

      if (wmsg.length() > 140) {
        wmsg = "(not displayable)";
      }

      if (!window.canCrawl()) {
        wmsg = "Currently closed: " + wmsg;
      }

      result.setCrawlWindow(wmsg);
    }

    String crawlPool = au.getFetchRateLimiterKey();

    if (crawlPool == null) {
      crawlPool = "(none)";
    }

    result.setCrawlPool(crawlPool);

    result.setLastCompletedCrawl(state.getLastCrawlTime());

    long lastCrawlAttempt = state.getLastCrawlAttempt();

    if (lastCrawlAttempt > 0) {
      result.setLastCrawl(lastCrawlAttempt);
      result.setLastCrawlResult(state.getLastCrawlResultMsg());
    }

    long lastTopLevelPollTime = state.getLastTopLevelPollTime();

    if (lastTopLevelPollTime > 0) {
      result.setLastCompletedPoll(lastTopLevelPollTime);
    }

    long lastPollStart = state.getLastPollStart();

    if (lastPollStart > 0) {
      result.setLastPoll(lastPollStart);
      String pollResult = state.getLastPollResultMsg();

      if (!StringUtil.isNullString(pollResult)) {
        result.setLastPollResult(state.getLastPollResultMsg());
      }
    }

    result.setCurrentlyCrawling(
        theDaemon.getCrawlManager().getStatusSource().getStatus().isRunningNCCrawl(au));

    result.setCurrentlyPolling(theDaemon.getPollManager().isPollRunning(au));

    if (theDaemon.isDetectClockssSubscription()) {
      result.setSubscriptionStatus(AuUtil.getAuState(au).getClockssSubscriptionStatusString());
    }

    if (log.isDebug2()) log.debug2(DEBUG_HEADER + "result = " + result);
    return result;
  }