Fixes to replication job status handling:

- success, error and cancelled states now correctly reported
- source and target reports now correctly provided for each of above

Changes:
- deprecated TransferService interface, replaced by TransferService2
  - introduces new sync transfer methods
  - new TransferServiceImpl2 class, old TransferServiceImpl delegates to new class
- sync transfer now returns TransferEndEvent
- sync transfer now raises TransferFailureException
- success, error and cancelled events are now end events (raised after report events)
- transfer client handling refactored to support cancel and errors appropriately
  - converted to event loop with polling of server status for all states
  - cancel request may now end with success or error (depending on when cancel requested)
  - extract transfer errors from server
  - only raise exception for errors (cancelled now returns)
  - source and destination reports written for all states
- Added TransferEndEvent interface for end events - reports attached to end event
- replication service fixed to record source and dest reports in error case
- action service fixed to record cancelled state

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@22390 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
David Caruana
2010-09-10 14:00:05 +00:00
parent 82955f3ae2
commit 35b2b7a122
25 changed files with 2176 additions and 1492 deletions

View File

@@ -25,16 +25,15 @@ import java.util.concurrent.LinkedBlockingQueue;
import org.alfresco.service.cmr.repository.ContentData;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.transfer.TransferCallback;
import org.alfresco.service.cmr.transfer.TransferEndEvent;
import org.alfresco.service.cmr.transfer.TransferEvent;
import org.alfresco.service.cmr.transfer.TransferEventBegin;
import org.alfresco.service.cmr.transfer.TransferEventCommittingStatus;
import org.alfresco.service.cmr.transfer.TransferEventEndState;
import org.alfresco.service.cmr.transfer.TransferEventEnterState;
import org.alfresco.service.cmr.transfer.TransferEventError;
import org.alfresco.service.cmr.transfer.TransferEventReport;
import org.alfresco.service.cmr.transfer.TransferEventSendingContent;
import org.alfresco.service.cmr.transfer.TransferEventSendingSnapshot;
import org.alfresco.service.cmr.transfer.TransferEventSuccess;
import org.alfresco.service.cmr.transfer.TransferEventReport;
/**
* Class to bring together all the transfer event stuff.
@@ -45,15 +44,15 @@ import org.alfresco.service.cmr.transfer.TransferEventReport;
*
* @author Mark Rogers
*/
public class TransferEventProcessor
{
public Set<TransferCallback> observers = new HashSet<TransferCallback>();
LinkedBlockingQueue<TransferEvent> queue = new LinkedBlockingQueue<TransferEvent>();
public TransferEventProcessor()
{
}
public void addObserver(TransferCallback observer)
{
@@ -65,14 +64,6 @@ public class TransferEventProcessor
observers.remove(observer);
}
/**
*
*/
public TransferEventProcessor()
{
}
public void begin(String transferId)
{
setState(TransferEvent.TransferState.START);
@@ -80,47 +71,23 @@ public class TransferEventProcessor
event.setTransferState(TransferEvent.TransferState.START);
event.setMessage("begin transferId:" + transferId);
queue.add(event);
event.setTransferId(transferId);
event.setTransferId(transferId);
notifyObservers();
}
public void start()
{
setState(TransferEvent.TransferState.START);
setState(TransferEvent.TransferState.START);
notifyObservers();
}
public void success()
public void end(TransferEndEvent endEvent)
{
setState(TransferEvent.TransferState.SUCCESS);
/**
* Write the success event
*/
TransferEventSuccess event = new TransferEventSuccess();
event.setTransferState(TransferEvent.TransferState.SUCCESS);
event.setLast(true);
event.setMessage("success lastEvent:true");
queue.add(event);
setState(endEvent.getTransferState());
queue.add(endEvent);
notifyObservers();
}
public void error(Exception exception)
{
setState(TransferEvent.TransferState.ERROR);
/**
* Write the error event
*/
TransferEventError event = new TransferEventError();
event.setTransferState(TransferEvent.TransferState.ERROR);
event.setLast(true);
event.setMessage("error lastEvent:true, " + exception.getMessage());
event.setException(exception);
queue.add(event);
notifyObservers();
}
/**
*
* @param data
@@ -175,6 +142,7 @@ public class TransferEventProcessor
public void writeReport(NodeRef nodeRef, TransferEventReport.ReportType reportType)
{
TransferEventReport event = new TransferEventReport();
event.setTransferState(currentState);
event.setNodeRef(nodeRef);
event.setReportType(reportType);
event.setMessage("report nodeRef:" + nodeRef + ", reportType :" + reportType );
@@ -198,13 +166,8 @@ public class TransferEventProcessor
event.setMessage("committing " + position + " of " + range);
queue.add(event);
notifyObservers();
}
public void abort()
{
}
private TransferEvent.TransferState currentState;
@@ -217,13 +180,13 @@ public class TransferEventProcessor
TransferEventImpl event = new TransferEventEndState();
event.setMessage("End State: " + currentState);
event.setTransferState(currentState);
queue.add(event);
queue.add(event);
}
TransferEventImpl event = new TransferEventEnterState();
event.setMessage("Enter State: " + state);
event.setTransferState(state);
queue.add(event);
queue.add(event);
currentState = state;
}
}