Skip to content
Snippets Groups Projects
Commit c441d20b authored by sveseli's avatar sveseli
Browse files

added commands for retrieving async op status

parent f75bbfc8
No related branches found
No related tags found
No related merge requests found
#!/bin/sh
# Run command
if [ -z $DM_ROOT_DIR ]; then
cd `dirname $0` && myDir=`pwd`
setupFile=$myDir/../setup.sh
if [ ! -f $setupFile ]; then
echo "Cannot find setup file: $setupFile"
exit 1
fi
source $setupFile > /dev/null
fi
$DM_ROOT_DIR/src/python/dm/cat_web_service/cli/getAsyncUpdateStatusCli.py $@
#!/usr/bin/env python
from catWebServiceSessionCli import CatWebServiceSessionCli
from dm.cat_web_service.api.fileCatApi import FileCatApi
from dm.common.exceptions.invalidRequest import InvalidRequest
class GetAsyncUpdateStatusCli(CatWebServiceSessionCli):
def __init__(self):
CatWebServiceSessionCli.__init__(self, validArgCount=0)
self.addOption('', '--id', dest='id', help='Async operation id.')
def checkArgs(self):
if self.options.id is None:
raise InvalidRequest('Async operation id must be provided.')
def getId(self):
return self.options.id
def runCommand(self):
self.parseArgs(usage="""
dm-get-async-update-status --id=ID
Description:
Retrieves detailed information for the given asynchronous file update operation.
""")
self.checkArgs()
api = FileCatApi(self.getLoginUsername(), self.getLoginPassword(), self.getServiceHost(), self.getServicePort(), self.getServiceProtocol())
asyncOperation = api.getAsyncUpdateStatus(self.getId())
print asyncOperation.getDisplayString(self.getDisplayKeys(), self.getDisplayFormat())
#######################################################################
# Run command.
if __name__ == '__main__':
cli = GetAsyncUpdateStatusCli()
cli.run()
......@@ -12,6 +12,7 @@ from dm.common.objects.dmObjectManager import DmObjectManager
from dm.common.mongodb.api.fileMongoDbApi import FileMongoDbApi
from dm.common.objects.asynchronousOperation import AsynchronousOperation
from dm.common.utility.asynchronousOperationTracker import AsynchronousOperationTracker
from dm.common.exceptions.objectNotFound import ObjectNotFound
class FileSessionControllerImpl(DmObjectManager):
""" File controller implementation class. """
......@@ -42,16 +43,18 @@ class FileSessionControllerImpl(DmObjectManager):
asyncOp['type'] = 'updateExperimentFiles'
asyncOp['experimentName'] = experimentName
asyncOp['updateDict'] = updateDict
asyncOp['message'] = 'Scheduled update for experiment %s files.' % experimentName
asyncOp['status'] = dmProcessingStatus.DM_PROCESSING_STATUS_PENDING
timer = threading.Timer(self.UPDATE_TIMER_DELAY_IN_SECONDS, self.updateExperimentFiles, args=[experimentName, updateDict])
timer = threading.Timer(self.UPDATE_TIMER_DELAY_IN_SECONDS, self.updateExperimentFiles, args=[experimentName, updateDict, asyncOp])
self.asyncOpTracker.put(opId, asyncOp)
timer.start()
self.logger.debug('Scheduled files update for experiment %s with: %s' % (experimentName, updateDict))
return asyncOp
def getAsyncUpdateStatus(self, id):
return self.asyncOpTracker.get(id)
asyncOp = self.asyncOpTracker.get(id)
if not asyncOp:
raise ObjectNotFound('Asynchronous update operation id %s not found.' % id)
return asyncOp
def getExperimentFiles(self, experimentName, queryDict):
return self.fileMongoDbApi.getExperimentFiles(experimentName, queryDict=queryDict)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment