/** * 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; }
/** * 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(); }
/** 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())); }