Merge from BRANCHES/DEV/CLOUD1_SPRINT1 to HEAD:

40238: CLOUD-37 - Initial Commit to test
        Merged BRANCHES/DEV/AMILLER/CLOUD1_SPRINT1 to BRANCHES/DEV/CLOUD1_SPRINT1:
           40077: CLOUD-37: Initial commit.
           40101: CLOUD-37: Fix build error.
           40114: CLOUD-37: Fix path names and missing files.
           40122: CLOUD-37: Initial drop of UI code for investigation of progress issues
           40124: CLOUD-37: A couple of minor UI tweaks (set icon and hide panel before archive download)
           40125: CLOUD-37: Download files and folders as zip
           40134: CLOUD-37: Updates to UI (javascript doc, CSS tweaks, intervals for requests, labels, etc).
           40143: CLOUD-37: Error messages for failures, more JavaScript doc, archive naming, code tidy   40157: CLOUD-37 - Download files and folders as zip
           40202: CLOUD-37: UI tweaks following UX review
           40217: CLOUD-37: Add file count to status reports.
           40222: CLOUD-37: Added information to download dialog to report on the number of files added to the zip 
   40240: CLOUD-37: Remove extraneous file, breaking build
   40513: CLOUD-37: Add Action Service Metrics
        Merged BRANCHES/DEV/AMILLER/CLOUD1_SPRINT1 to BRANCHES/DEV/CLOUD1_SPRINT1:
           40260: CLOUD-37: Add action service metrics
           40309: CLOUD-37: Fix JMX configuration, pointing at renamed class.
   40514: CLOUD-37: Enable the execution of the zip creation process on a remote transformation node
        Merged BRANCHES/DEV/AMILLER/CLOUD1_SPRINT1 to BRANCHES/DEV/CLOUD1_SPRINT1:
           40369: CLOUD-37: Enable the execution of the zip creation process on a remote transformation node   
   40516: CLOUD-37: Implement clean up job.
        Merged BRANCHES/DEV/AMILLER/CLOUD1_SPRINT1 to BRANCHES/DEV/CLOUD1_SPRINT1:
           40462: CLOUD-37: Implement clean up job.
   40517: CLOUD-505: Add entries for folders.
        Merged BRANCHES/DEV/AMILLER/CLOUD1_SPRINT1 to BRANCHES/DEV/CLOUD1_SPRINT1:
           40493: CLOUD-505: Add entries for folders.
   40547: CLOUD-37: Fix broken test
   40595: CLOUD-518: Add working copy/locked file filtering
   40642: CLOUD-508: Prevent problems occurring when cancelling and restarting the same download
   40643: CLOUD-507: When a single item is selected for download it the item name gets used for the archive name
   41442: CLOUD-590: Limit the total size of the content which can be downloaded. This can be set via the property, download.maxContentSize. The default is 2GB.
   41472: CLOUD-589: Added cancelled flag to download type and added checks in Zip creation action to act upon the setting of this flag. Also added webscript for canceling the download.
   41692: Adds support to Alfresco.util.formatFileSize for file sizes with commas (as needed by zip download)
   41693: Zip Download enhancements:
       CLOUD-590: Notifies the user when they've exceeded the maximum file size limit.
       CLOUD-626: Better handling when there are errors during zipping. (WIP)
   41713: Zip Download Updates:
        CLOUD-589: A cancel download UI action now triggers a delete of the archive on the server.
        CLOUD-626: The UI now triggers a full download cancel (with node delete) in event of an error.
   41737: Updates Alfresco.util.formatFileSize to support an optional decimal places param. (For CLOUD-685)
   41739: CLOUD-685: Display total file size of files for download to two decimal places when there is an error.
   41832: Fixes: CLOUD-704: new CANCELLED status is now handled correctly.
   41887: CLOUD-686: Updated maximum download content size to 2152852358 bytes (2.005GB)
   41965: CLOUD-703: Upload content now runs as system user, and Quota Service returns unlimited quota for system user.
   42025: CLOUD-703: Fix test failures and ensure S3 content store works in the clustered and non-clustered environments

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@42146 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
David Draper
2012-09-28 13:26:36 +00:00
parent ed48e2c4c9
commit 642d332d24
43 changed files with 3561 additions and 6 deletions

View File

@@ -108,6 +108,7 @@ public class ActionServiceImpl implements ActionService, RuntimeActionService, A
private AuthenticationContext authenticationContext;
private ActionTrackingService actionTrackingService;
private PolicyComponent policyComponent;
private ActionServiceMonitor monitor;
/**
* The asynchronous action execution queues map of name, queue
@@ -201,6 +202,14 @@ public class ActionServiceImpl implements ActionService, RuntimeActionService, A
{
this.policyComponent = policyComponent;
}
/**
* @param monitor used to monitor running actions and execution times
*/
public void setMonitor(ActionServiceMonitor monitor)
{
this.monitor = monitor;
}
/**
* Set the asynchronous action execution queues
@@ -706,8 +715,22 @@ public class ActionServiceImpl implements ActionService, RuntimeActionService, A
actionTrackingService.recordActionExecuting(action);
}
// Execute the action
directActionExecution(action, actionedUponNodeRef);
RunningAction runningAction = monitor.actionStarted(action);
try
{
// Execute the action
directActionExecution(action, actionedUponNodeRef);
}
catch (Throwable e)
{
runningAction.setException(e);
throw e;
}
finally
{
monitor.actionCompleted(runningAction);
}
if (getTrackStatus(action))
{

View File

@@ -0,0 +1,105 @@
/*
* Copyright (C) 2005-2011 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.action;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import org.alfresco.service.cmr.action.Action;
/**
* Responsible for monitoring running actions and accumulating statistics on actions that have been run.
*
* @author Alex Miller
*/
public class ActionServiceMonitor
{
private ConcurrentHashMap<UUID, RunningAction> runningActions = new ConcurrentHashMap<UUID, RunningAction>();
private ConcurrentHashMap<String, ActionStatistics> actionStatistics = new ConcurrentHashMap<String, ActionStatistics>();
/**
* Called by the {@link ActionServiceImpl} when an action is started.
*
* Adds the action to the list of currently running actions.
*
* @param action The action being started
* @return A {@link RunningAction} object used to track the status of the running action.
*/
public RunningAction actionStarted(Action action)
{
RunningAction runningAction = new RunningAction(action);
this.runningActions.put(runningAction.getId(), runningAction);
return runningAction;
}
/**
* Called by the {@link ActionServiceImpl} when sn action completes.
*
* Removes the actions from the list of currently running actions, and updated the accumulated statistics for that action.
*
* @param action The {@link RunningAction} object returned by actionStatred.
*/
public void actionCompleted(RunningAction action)
{
runningActions.remove(action.getId());
updateActionStatisitcis(action);
}
private void updateActionStatisitcis(RunningAction action)
{
String actionName = action.getActionName();
ActionStatistics actionStats = actionStatistics.get(actionName);
if (actionStats == null)
{
actionStatistics.putIfAbsent(actionName, new ActionStatistics(actionName));
actionStats = actionStatistics.get(actionName);
}
actionStats.addAction(action);
}
/**
* @return The list of currently running actions.
*/
public List<RunningAction> getRunningActions()
{
return Collections.unmodifiableList(new ArrayList<RunningAction>(runningActions.values()));
}
/**
* @return a count of the currently running actions
*/
public int getRunningActionCount()
{
return runningActions.size();
}
/**
* @return a list of the accumulated action statistics.
*/
public List<ActionStatistics> getActionStatisitcs()
{
return Collections.unmodifiableList(new ArrayList<ActionStatistics>(actionStatistics.values()));
}
}

View File

@@ -0,0 +1,87 @@
/*
* Copyright (C) 2005-2011 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.action;
/**
* Responsible for accumulating and providing statistics on the invocations of a particualr action.
*
* @author Alex Miller
*/
public class ActionStatistics
{
private String actionName;
long invocationCount = 0;
long errorCount = 0;
long totalTime = 0;
/**
* @param actionName The name of the action this object will provide statistics for.
*/
public ActionStatistics(String actionName)
{
this.actionName = actionName;
}
/**
* Accumulate statistics from action.
*/
public synchronized void addAction(RunningAction action)
{
invocationCount = invocationCount + 1;
if (action.hasError() == true)
{
errorCount = errorCount +1;
}
totalTime = totalTime + action.getElapsedTime();
}
/**
* @return The name of the actions this object has statistics for
*/
public String getActionName()
{
return actionName;
}
/**
* @return The number of times the action has been invoked
*/
public long getInvocationCount()
{
return invocationCount;
}
/**
* @return The number of time the invocation of this action has resulted in an exception
*/
public long getErrorCount()
{
return errorCount;
}
/**
* @return The average time for the invocation of this action
*/
public long getAverageTime()
{
return totalTime / invocationCount;
}
}

View File

@@ -0,0 +1,85 @@
package org.alfresco.repo.action;
import java.util.Date;
import java.util.UUID;
import org.alfresco.service.cmr.action.Action;
/**
* Responsible for tracking the invocation of an action.
*
* @author Alex Miller
*/
public class RunningAction
{
private UUID id = UUID.randomUUID();
private String name;
private Thread thread;
private Date started;
private boolean exceptionThrown = false;
/**
* @param action The action being run
*/
public RunningAction(Action action)
{
this.name = action.getActionDefinitionName();
this.started = new Date();
this.thread = Thread.currentThread();
}
/**
* @return The name of the action this object is tracking
*/
public String getActionName()
{
return name;
}
/**
* @return The name of thread the action is being run on
*/
public String getThread()
{
return thread.toString();
}
/**
* @return The generated id for the action invocation
*/
public UUID getId()
{
return id;
}
/**
* @return The time since the action was started
*/
public long getElapsedTime()
{
return System.currentTimeMillis() - started.getTime();
}
/**
* Called by the {@link ActionServiceImpl} if the action generates an exception during invocation.
*/
public void setException(Throwable e)
{
this.exceptionThrown = true;
}
/**
* @return true, if setException was called
*/
public boolean hasError()
{
return exceptionThrown;
}
}