Search in sources :

Example 1 with TransferEventCommittingStatus

use of org.alfresco.service.cmr.transfer.TransferEventCommittingStatus in project alfresco-repository by Alfresco.

the class TransferServiceCallbackTest method testErrorDuringCommit.

public void testErrorDuringCommit() {
    Exception error = new TransferException("Commit failed");
    TransferProgress status0 = new TransferProgress();
    status0.setStatus(Status.COMMIT_REQUESTED);
    status0.setCurrentPosition(0);
    status0.setEndPosition(0);
    TransferProgress status1 = new TransferProgress();
    status1.setStatus(Status.COMMITTING);
    status1.setCurrentPosition(0);
    status1.setEndPosition(4);
    TransferProgress status2 = new TransferProgress();
    status2.setStatus(Status.COMMITTING);
    status2.setCurrentPosition(3);
    status2.setEndPosition(4);
    TransferProgress status3 = new TransferProgress();
    status3.setStatus(Status.COMMITTING);
    status3.setCurrentPosition(5);
    status3.setEndPosition(8);
    TransferProgress status4 = new TransferProgress();
    status4.setStatus(Status.ERROR);
    status4.setCurrentPosition(8);
    status4.setEndPosition(8);
    status4.setError(error);
    TransferProgress[] statuses = new TransferProgress[] { status0, status1, status2, status3, status4 };
    configureBasicMockTransmitter(statuses);
    when(mockedTransferTransmitter.begin(target, localRepositoryId, version)).thenReturn(transfer);
    TransferDefinition transferDef = new TransferDefinition();
    transferDef.setNodes(folder1, file1, file2, file3);
    try {
        transferService.transfer(TRANSFER_TARGET_NAME, transferDef, mockedCallback);
        fail();
    } catch (TransferFailureException ex) {
        List<TransferEvent> expectedEvents = new ArrayList<TransferEvent>();
        TransferEventImpl event;
        event = new TransferEventEnterState();
        event.setTransferState(TransferState.START);
        expectedEvents.add(event);
        event = new TransferEventBegin();
        event.setTransferState(TransferState.START);
        expectedEvents.add(event);
        event = new TransferEventEndState();
        event.setTransferState(TransferState.START);
        expectedEvents.add(event);
        event = new TransferEventEnterState();
        event.setTransferState(TransferState.SENDING_SNAPSHOT);
        expectedEvents.add(event);
        event = new TransferEventSendingSnapshot();
        event.setTransferState(TransferState.SENDING_SNAPSHOT);
        expectedEvents.add(event);
        event = new TransferEventEndState();
        event.setTransferState(TransferState.SENDING_SNAPSHOT);
        expectedEvents.add(event);
        event = new TransferEventEnterState();
        event.setTransferState(TransferState.SENDING_CONTENT);
        expectedEvents.add(event);
        event = new TransferEventSendingContent();
        event.setTransferState(TransferState.SENDING_CONTENT);
        expectedEvents.add(event);
        event = new TransferEventSendingContent();
        event.setTransferState(TransferState.SENDING_CONTENT);
        expectedEvents.add(event);
        event = new TransferEventSendingContent();
        event.setTransferState(TransferState.SENDING_CONTENT);
        expectedEvents.add(event);
        event = new TransferEventEndState();
        event.setTransferState(TransferState.SENDING_CONTENT);
        expectedEvents.add(event);
        event = new TransferEventEnterState();
        event.setTransferState(TransferState.PREPARING);
        expectedEvents.add(event);
        event = new TransferEventEndState();
        event.setTransferState(TransferState.PREPARING);
        expectedEvents.add(event);
        event = new TransferEventEnterState();
        event.setTransferState(TransferState.COMMITTING);
        expectedEvents.add(event);
        event = new TransferEventCommittingStatus();
        event.setTransferState(TransferState.COMMITTING);
        expectedEvents.add(event);
        event = new TransferEventCommittingStatus();
        event.setTransferState(TransferState.COMMITTING);
        expectedEvents.add(event);
        event = new TransferEventCommittingStatus();
        event.setTransferState(TransferState.COMMITTING);
        expectedEvents.add(event);
        event = new TransferEventEndState();
        event.setTransferState(TransferState.COMMITTING);
        expectedEvents.add(event);
        event = new TransferEventEnterState();
        event.setTransferState(TransferState.ERROR);
        expectedEvents.add(event);
        event = new TransferEventReport();
        event.setTransferState(TransferState.ERROR);
        expectedEvents.add(event);
        event = new TransferEventReport();
        event.setTransferState(TransferState.ERROR);
        expectedEvents.add(event);
        event = new TransferEventError();
        event.setTransferState(TransferState.ERROR);
        ((TransferEventError) event).setException(error);
        expectedEvents.add(event);
        verifyCallback(expectedEvents);
    }
}
Also used : TransferEvent(org.alfresco.service.cmr.transfer.TransferEvent) TransferEventBegin(org.alfresco.service.cmr.transfer.TransferEventBegin) TransferEventReport(org.alfresco.service.cmr.transfer.TransferEventReport) TransferFailureException(org.alfresco.service.cmr.transfer.TransferFailureException) TransferException(org.alfresco.service.cmr.transfer.TransferException) TransferEventEndState(org.alfresco.service.cmr.transfer.TransferEventEndState) TransferProgress(org.alfresco.service.cmr.transfer.TransferProgress) TransferDefinition(org.alfresco.service.cmr.transfer.TransferDefinition) TransferException(org.alfresco.service.cmr.transfer.TransferException) TransferEventEnterState(org.alfresco.service.cmr.transfer.TransferEventEnterState) TransferEventSendingSnapshot(org.alfresco.service.cmr.transfer.TransferEventSendingSnapshot) List(java.util.List) ArrayList(java.util.ArrayList) TransferEventCommittingStatus(org.alfresco.service.cmr.transfer.TransferEventCommittingStatus) TransferEventError(org.alfresco.service.cmr.transfer.TransferEventError) TransferFailureException(org.alfresco.service.cmr.transfer.TransferFailureException) TransferEventSendingContent(org.alfresco.service.cmr.transfer.TransferEventSendingContent)

Example 2 with TransferEventCommittingStatus

use of org.alfresco.service.cmr.transfer.TransferEventCommittingStatus in project alfresco-repository by Alfresco.

the class TransferServiceCallbackTest method testCompleteSuccess.

public void testCompleteSuccess() {
    TransferProgress status0 = new TransferProgress();
    status0.setStatus(Status.COMMIT_REQUESTED);
    status0.setCurrentPosition(0);
    status0.setEndPosition(0);
    TransferProgress status1 = new TransferProgress();
    status1.setStatus(Status.COMMITTING);
    status1.setCurrentPosition(0);
    status1.setEndPosition(4);
    TransferProgress status2 = new TransferProgress();
    status2.setStatus(Status.COMMITTING);
    status2.setCurrentPosition(3);
    status2.setEndPosition(4);
    TransferProgress status3 = new TransferProgress();
    status3.setStatus(Status.COMMITTING);
    status3.setCurrentPosition(5);
    status3.setEndPosition(8);
    TransferProgress status4 = new TransferProgress();
    status4.setStatus(Status.COMPLETE);
    status4.setCurrentPosition(8);
    status4.setEndPosition(8);
    TransferProgress[] statuses = new TransferProgress[] { status0, status1, status2, status3, status4 };
    configureBasicMockTransmitter(statuses);
    when(mockedTransferTransmitter.begin(target, localRepositoryId, version)).thenReturn(transfer);
    TransferDefinition transferDef = new TransferDefinition();
    transferDef.setNodes(folder1, file1, file2, file3);
    transferService.transfer(TRANSFER_TARGET_NAME, transferDef, mockedCallback);
    List<TransferEvent> expectedEvents = new ArrayList<TransferEvent>();
    TransferEventImpl event;
    event = new TransferEventEnterState();
    event.setTransferState(TransferState.START);
    expectedEvents.add(event);
    event = new TransferEventBegin();
    event.setTransferState(TransferState.START);
    expectedEvents.add(event);
    event = new TransferEventEndState();
    event.setTransferState(TransferState.START);
    expectedEvents.add(event);
    event = new TransferEventEnterState();
    event.setTransferState(TransferState.SENDING_SNAPSHOT);
    expectedEvents.add(event);
    event = new TransferEventSendingSnapshot();
    event.setTransferState(TransferState.SENDING_SNAPSHOT);
    expectedEvents.add(event);
    event = new TransferEventEndState();
    event.setTransferState(TransferState.SENDING_SNAPSHOT);
    expectedEvents.add(event);
    event = new TransferEventEnterState();
    event.setTransferState(TransferState.SENDING_CONTENT);
    expectedEvents.add(event);
    event = new TransferEventSendingContent();
    event.setTransferState(TransferState.SENDING_CONTENT);
    expectedEvents.add(event);
    event = new TransferEventSendingContent();
    event.setTransferState(TransferState.SENDING_CONTENT);
    expectedEvents.add(event);
    event = new TransferEventSendingContent();
    event.setTransferState(TransferState.SENDING_CONTENT);
    expectedEvents.add(event);
    event = new TransferEventEndState();
    event.setTransferState(TransferState.SENDING_CONTENT);
    expectedEvents.add(event);
    event = new TransferEventEnterState();
    event.setTransferState(TransferState.PREPARING);
    expectedEvents.add(event);
    event = new TransferEventEndState();
    event.setTransferState(TransferState.PREPARING);
    expectedEvents.add(event);
    event = new TransferEventEnterState();
    event.setTransferState(TransferState.COMMITTING);
    expectedEvents.add(event);
    event = new TransferEventCommittingStatus();
    event.setTransferState(TransferState.COMMITTING);
    expectedEvents.add(event);
    event = new TransferEventCommittingStatus();
    event.setTransferState(TransferState.COMMITTING);
    expectedEvents.add(event);
    event = new TransferEventCommittingStatus();
    event.setTransferState(TransferState.COMMITTING);
    expectedEvents.add(event);
    event = new TransferEventCommittingStatus();
    event.setTransferState(TransferState.COMMITTING);
    expectedEvents.add(event);
    event = new TransferEventEndState();
    event.setTransferState(TransferState.COMMITTING);
    expectedEvents.add(event);
    event = new TransferEventEnterState();
    event.setTransferState(TransferState.SUCCESS);
    expectedEvents.add(event);
    event = new TransferEventReport();
    event.setTransferState(TransferState.SUCCESS);
    expectedEvents.add(event);
    event = new TransferEventReport();
    event.setTransferState(TransferState.SUCCESS);
    expectedEvents.add(event);
    event = new TransferEventSuccess();
    event.setTransferState(TransferState.SUCCESS);
    expectedEvents.add(event);
    verifyCallback(expectedEvents);
}
Also used : TransferEvent(org.alfresco.service.cmr.transfer.TransferEvent) ArrayList(java.util.ArrayList) TransferEventBegin(org.alfresco.service.cmr.transfer.TransferEventBegin) TransferEventReport(org.alfresco.service.cmr.transfer.TransferEventReport) TransferEventEndState(org.alfresco.service.cmr.transfer.TransferEventEndState) TransferProgress(org.alfresco.service.cmr.transfer.TransferProgress) TransferDefinition(org.alfresco.service.cmr.transfer.TransferDefinition) TransferEventEnterState(org.alfresco.service.cmr.transfer.TransferEventEnterState) TransferEventSendingSnapshot(org.alfresco.service.cmr.transfer.TransferEventSendingSnapshot) TransferEventSuccess(org.alfresco.service.cmr.transfer.TransferEventSuccess) TransferEventCommittingStatus(org.alfresco.service.cmr.transfer.TransferEventCommittingStatus) TransferEventSendingContent(org.alfresco.service.cmr.transfer.TransferEventSendingContent)

Example 3 with TransferEventCommittingStatus

use of org.alfresco.service.cmr.transfer.TransferEventCommittingStatus in project alfresco-repository by Alfresco.

the class TransferTreeWithCancelActionExecuter method executeImpl.

/* (non-Javadoc)
     * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef)
     */
@Override
protected void executeImpl(Action action, NodeRef actionedUponNodeRef) {
    TransferTarget target = serviceRegistry.getTransactionService().getRetryingTransactionHelper().doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<TransferTarget>() {

        public TransferTarget execute() throws Throwable {
            return TransferTestUtil.getTestTarget(transferService);
        }
    }, false, true);
    NodeCrawler crawler = new StandardNodeCrawlerImpl(serviceRegistry);
    crawler.setNodeFinders(new ChildAssociatedNodeFinder(ContentModel.ASSOC_CONTAINS));
    Set<NodeRef> nodes = crawler.crawl(actionedUponNodeRef);
    TransferDefinition td = new TransferDefinition();
    td.setNodes(nodes);
    transferService.transferAsync(target.getName(), td, new TransferCallback() {

        private String transferId;

        public void processEvent(TransferEvent event) {
            if (event instanceof TransferEventBegin) {
                transferId = ((TransferEventBegin) event).getTransferId();
            } else if (event instanceof TransferEventCommittingStatus) {
                transferService.cancelAsync(transferId);
            }
        }
    });
}
Also used : NodeCrawler(org.alfresco.service.cmr.transfer.NodeCrawler) RetryingTransactionHelper(org.alfresco.repo.transaction.RetryingTransactionHelper) TransferEvent(org.alfresco.service.cmr.transfer.TransferEvent) TransferEventBegin(org.alfresco.service.cmr.transfer.TransferEventBegin) TransferTarget(org.alfresco.service.cmr.transfer.TransferTarget) TransferCallback(org.alfresco.service.cmr.transfer.TransferCallback) TransferDefinition(org.alfresco.service.cmr.transfer.TransferDefinition) NodeRef(org.alfresco.service.cmr.repository.NodeRef) TransferEventCommittingStatus(org.alfresco.service.cmr.transfer.TransferEventCommittingStatus)

Example 4 with TransferEventCommittingStatus

use of org.alfresco.service.cmr.transfer.TransferEventCommittingStatus in project alfresco-repository by Alfresco.

the class TransferEventProcessor method committing.

/**
 * @param range long
 * @param position long
 */
public void committing(long range, long position) {
    setState(TransferEvent.TransferState.COMMITTING);
    TransferEventCommittingStatus event = new TransferEventCommittingStatus();
    event.setTransferState(TransferEvent.TransferState.COMMITTING);
    event.setRange(range);
    event.setPosition(position);
    event.setMessage("committing " + position + " of " + range);
    queue.add(event);
    notifyObservers();
}
Also used : TransferEventCommittingStatus(org.alfresco.service.cmr.transfer.TransferEventCommittingStatus)

Aggregations

TransferEventCommittingStatus (org.alfresco.service.cmr.transfer.TransferEventCommittingStatus)4 TransferDefinition (org.alfresco.service.cmr.transfer.TransferDefinition)3 TransferEvent (org.alfresco.service.cmr.transfer.TransferEvent)3 TransferEventBegin (org.alfresco.service.cmr.transfer.TransferEventBegin)3 ArrayList (java.util.ArrayList)2 TransferEventEndState (org.alfresco.service.cmr.transfer.TransferEventEndState)2 TransferEventEnterState (org.alfresco.service.cmr.transfer.TransferEventEnterState)2 TransferEventReport (org.alfresco.service.cmr.transfer.TransferEventReport)2 TransferEventSendingContent (org.alfresco.service.cmr.transfer.TransferEventSendingContent)2 TransferEventSendingSnapshot (org.alfresco.service.cmr.transfer.TransferEventSendingSnapshot)2 TransferProgress (org.alfresco.service.cmr.transfer.TransferProgress)2 List (java.util.List)1 RetryingTransactionHelper (org.alfresco.repo.transaction.RetryingTransactionHelper)1 NodeRef (org.alfresco.service.cmr.repository.NodeRef)1 NodeCrawler (org.alfresco.service.cmr.transfer.NodeCrawler)1 TransferCallback (org.alfresco.service.cmr.transfer.TransferCallback)1 TransferEventError (org.alfresco.service.cmr.transfer.TransferEventError)1 TransferEventSuccess (org.alfresco.service.cmr.transfer.TransferEventSuccess)1 TransferException (org.alfresco.service.cmr.transfer.TransferException)1 TransferFailureException (org.alfresco.service.cmr.transfer.TransferFailureException)1