コード例 #1
0
 @After
 public void tearDown() {
   pse.tearDown();
   pss.tearDown();
   mtf.tearDown();
   JMSConnectionFactory.getInstance().removeListener(Channels.getTheIndexServer(), listener);
   mjms.tearDown();
   rs.tearDown();
 }
コード例 #2
0
  /**
   * Returns the ReplicaStoreState of a given file in a specific replica.
   *
   * @param filename The name of the file for the ReplicaStoreState.
   * @param replicaChannelName The name of the identification channel for uniquely identifying the
   *     replica of for the ReplicaStoreState.
   * @return The ReplicaStoreState of a given file in a specific replica.
   * @throws ArgumentNotValid If the filename or the replica id is null or the empty string.
   */
  @Override
  public ReplicaStoreState getState(String filename, String replicaChannelName)
      throws ArgumentNotValid {
    ArgumentNotValid.checkNotNullOrEmpty(filename, "String filename");
    ArgumentNotValid.checkNotNullOrEmpty(replicaChannelName, "String replicaChannelName");

    Replica rep = Channels.retrieveReplicaFromIdentifierChannel(replicaChannelName);

    // retrieve the ReplicaStoreState from the database.
    return database.getReplicaStoreState(filename, rep.getId());
  }
コード例 #3
0
  /**
   * Message to signal from a BitarchiveServer to the BitarchiveMonitorServer that the Bit Archive
   * Application identified by BA_ApplicationId has completed its part of the batch job.
   *
   * <p>Holds status information: list of files processed and a list of ARC files (file names) on
   * which the batch job failed.
   *
   * @param to the channel to which this message is to be sent (must be a BAMON channel)
   * @param baAppId Identifier for the machine sending this message, usually containing the IP
   *     address and http port number
   * @param originatingBatchMsgId the Id field from the original batch message
   * @param rf he remote file reference containing the output of the batch job (may be null if no
   *     output is generated).
   * @throws ArgumentNotValid If the BA_ApplicationId or the originatingBatchMsgId are null or
   *     empty, or if the channel 'to' is null.
   */
  public BatchEndedMessage(
      ChannelID to, String baAppId, String originatingBatchMsgId, RemoteFile rf)
      throws ArgumentNotValid {
    super(to, Channels.getError());
    ArgumentNotValid.checkNotNull(to, "ChannelID to");
    ArgumentNotValid.checkNotNullOrEmpty(baAppId, "String baAppId");
    ArgumentNotValid.checkNotNullOrEmpty(originatingBatchMsgId, "String originatingBatchMsgId");

    this.baApplicationId = baAppId;
    this.originatingBatchMsgId = originatingBatchMsgId;
    this.rf = rf;
  }
コード例 #4
0
  /**
   * Sets the store state of an entry to a specific value.
   *
   * @param filename The name of the file for the entry.
   * @param repChannelId The identification channel of the replica for the entry.
   * @param state The new state for the entry.
   * @throws ArgumentNotValid If the ReplicaStoreState is null, or if either the filename or the
   *     replica identification channel is either null or the empty string.
   */
  @Override
  public void setState(String filename, String repChannelId, ReplicaStoreState state)
      throws ArgumentNotValid {
    ArgumentNotValid.checkNotNull(state, "ReplicaStoreState state");
    ArgumentNotValid.checkNotNullOrEmpty(filename, "String filename");
    ArgumentNotValid.checkNotNullOrEmpty(repChannelId, "String repChannelId");

    // retrieve the replica
    Replica rep = Channels.retrieveReplicaFromIdentifierChannel(repChannelId);

    // update the database.
    database.setReplicaStoreState(filename, rep.getId(), state);
  }
コード例 #5
0
 @Before
 public void setUp() {
   rs.setUp();
   mjms.setUp();
   listener = new CreateIndexListener();
   JMSConnectionFactory.getInstance().setListener(Channels.getTheIndexServer(), listener);
   Settings.set(
       CommonSettings.REMOTE_FILE_CLASS, "dk.netarkivet.common.distribute.NullRemoteFile");
   Settings.set(CommonSettings.CACHE_DIR, TestInfo.CACHE_DIR.getPath());
   mtf.setUp();
   pss.setUp();
   pse.setUp();
 }
コード例 #6
0
  /**
   * Message to signal from a BitarchiveServer to the BitarchiveMonitorServer that the Bit Archive
   * Application identified by BA_ApplicationId has completed its part of the batch job.
   *
   * <p>Holds status information: list of files processed and a list of ARC files (file names) on
   * which the batch job failed.
   *
   * @param to the channel to which this message is to be sent (must be a BAMON channel)
   * @param originatingBatchMsgId the Id field from the original batch message
   * @param status The object containing status info.
   */
  public BatchEndedMessage(ChannelID to, String originatingBatchMsgId, BatchStatus status) {
    super(to, Channels.getError());
    ArgumentNotValid.checkNotNull(to, "to");
    ArgumentNotValid.checkNotNullOrEmpty(originatingBatchMsgId, "String originatingBatchMsgId");
    ArgumentNotValid.checkNotNull(status, "BatchStatus status");

    this.originatingBatchMsgId = originatingBatchMsgId;
    this.baApplicationId = status.getBitArchiveAppId();
    this.rf = status.getResultFile();
    this.noOfFilesProcessed = status.getNoOfFilesProcessed();
    this.filesFailed = status.getFilesFailed();
    this.exceptions = status.getExceptions();
  }
コード例 #7
0
  /**
   * Determines whether a given file in a specific replica has a valid replica store state. By valid
   * means a replica store state other that UNKNOWN_UPLOAD_STATE.
   *
   * <p>TODO Find out if the assumption that all upload states besides UNKNOWN_UPLOAD_STATE are
   * acceptable!
   *
   * @param filename The name of the file for the ReplicaStoreState.
   * @param repChannelId The identification channel of the replica for the ReplicaStoreState.
   * @return Whether a given file in a specific replica has a valid store state.
   * @throws ArgumentNotValid If either the filenames or the replica identification channel is null
   *     or the empty string.
   */
  @Override
  public boolean hasState(String filename, String repChannelId) throws ArgumentNotValid {
    ArgumentNotValid.checkNotNullOrEmpty(filename, "String filename");
    ArgumentNotValid.checkNotNullOrEmpty(repChannelId, "String repChannelId");

    // retrieve the replica
    Replica rep = Channels.retrieveReplicaFromIdentifierChannel(repChannelId);

    // retrieve the state for the entry for the replica and filename
    ReplicaStoreState state = database.getReplicaStoreState(filename, rep.getId());

    // return whether the entry has a known upload state
    return state != ReplicaStoreState.UNKNOWN_UPLOAD_STATE;
  }
  /** Disabled, fails on Jenkins */
  public void failingTestArcRepositoryCalls() {
    DatabaseAdmin da = DatabaseAdmin.getInstance();

    assertFalse("Should not contain NON-EXISTING-FILE", da.hasEntry("NON-EXISTING-FILE"));
    assertFalse(
        "Should not contain StoreMessage for NON-EXISTING-FILE",
        da.hasReplyInfo("NON-EXISTING-FILE"));

    StoreMessage storeMsg1 = new StoreMessage(Channels.getError(), TestInfo.TEST_FILE_1);
    JMSConnectionMockupMQ.updateMsgID(storeMsg1, "store1");

    da.addEntry(TestInfo.TEST_FILE_1.getName(), storeMsg1, "1234567890");

    // make sure that the test instance can now be found.
    assertTrue(
        "Should contain " + TestInfo.TEST_FILE_1.getName(),
        da.hasEntry(TestInfo.TEST_FILE_1.getName()));
    assertTrue(
        "Should have replyInfo for " + TestInfo.TEST_FILE_1.getName(),
        da.hasReplyInfo(TestInfo.TEST_FILE_1.getName()));
    assertEquals(
        "Should have the given checksum",
        "1234567890",
        da.getCheckSum(TestInfo.TEST_FILE_1.getName()));

    // Test the hasState.
    assertFalse(
        "Should not yet have a acceptable state",
        da.hasState(TestInfo.TEST_FILE_1.getName(), ONE.getIdentificationChannel().getName()));
    da.setState(
        TestInfo.TEST_FILE_1.getName(),
        ONE.getIdentificationChannel().getName(),
        ReplicaStoreState.UPLOAD_STARTED);
    assertTrue(
        "Should now have a acceptable state",
        da.hasState(TestInfo.TEST_FILE_1.getName(), ONE.getIdentificationChannel().getName()));
    assertEquals(
        "Should have the same state",
        da.getState(TestInfo.TEST_FILE_1.getName(), ONE.getIdentificationChannel().getName()),
        ReplicaStoreState.UPLOAD_STARTED);

    StoreMessage storeMsg2 = new StoreMessage(Channels.getError(), TestInfo.TEST_FILE_1);
    JMSConnectionMockupMQ.updateMsgID(storeMsg2, "store2");

    da.setReplyInfo(storeMsg2.getArcfileName(), storeMsg2);

    da.setState(
        TestInfo.TEST_FILE_1.getName(),
        ONE.getIdentificationChannel().getName(),
        ReplicaStoreState.UPLOAD_COMPLETED);
    da.setState(
        TestInfo.TEST_FILE_1.getName(),
        TWO.getIdentificationChannel().getName(),
        ReplicaStoreState.UPLOAD_COMPLETED);
    da.setState(
        TestInfo.TEST_FILE_1.getName(),
        THREE.getIdentificationChannel().getName(),
        ReplicaStoreState.UPLOAD_COMPLETED);

    StoreMessage retrievedMsg = da.removeReplyInfo(TestInfo.TEST_FILE_1.getName());

    assertEquals("The message should have the new ID.", "store2", retrievedMsg.getID());

    try {
      da.setCheckSum(TestInfo.TEST_FILE_1.getName(), "0987654321");
      fail("An illegal state exception should be thrown here.");
    } catch (IllegalState e) {
      // expected
    }

    Set<String> filenames = da.getAllFileNames();
    assertTrue(
        "Should contain the file '" + TestInfo.TEST_FILE_1.getName() + "' but was '" + filenames,
        filenames.contains(TestInfo.TEST_FILE_1.getName()));

    filenames = da.getAllFileNames(THREE, ReplicaStoreState.UPLOAD_FAILED);
    assertTrue(
        "The list of files with state UPLOAD_FAILED for replica "
            + "THREE should be empty, but it was: "
            + filenames,
        filenames.isEmpty());

    filenames = da.getAllFileNames(THREE, ReplicaStoreState.UPLOAD_COMPLETED);
    assertTrue(
        "The list of files with state UPLOAD_COMPLETED for replica "
            + "THREE should contain the file: '"
            + TestInfo.TEST_FILE_1.getName()
            + "', but it contained: "
            + filenames,
        filenames.contains(TestInfo.TEST_FILE_1.getName()));
  }