David
David
Does it also support the case of having no output files? My service
performs offline housekeeping tasks for my S3-hosted files - e.g.
deleting unneeded objects - which requires no input (besides the
filename passed as a param) and produces no output.
Actually, I'm thinking that it might be more correct to send a status
report "file" as text/plain output, a few lines indicating the
success/failure of the operation.
Still, it may be a valid use case to have a service that produces no output.
.. Shlomo
-- Chris
I also just realized that the params in the request are persisted
across from this service to the subsequent services in the workflow --
including modifications made by this service. That's great, and using
this I can chain together a few zero-input services based solely on
the params. This is really cool.
David
When I return a null List<MetaFile> from executeService I get a
NullPointerException, caused by the following code in
AbstractBaseService:
List<MetaFile> results = executeService(inputFile, request);
inputFile.delete();
logger.debug("service produced "+results.size()+" results");
An obvious workaround is to return an empty List, but I think it's
"cleaner" to support a null return value as well.
Can this be changed as well?
logger.debug("service produced "+((results==null)?0:results.size())+"
results");
I'll be running this more today.. I got hung-up trying to test
yesterday.. not much progress.
David
-----
public void ingest(List<Properties> properties) {
/* main body of this method is the same as in
IngestorBase.ingest(List<File>) method, up until the for loop over the
Files */
for (Properties props : properties) {
long startTime = System.currentTimeMillis();
wr.setInput(null);
// set the WorkRequest params
for (ParamType param : wr.getParams()) {
String paramKey = param.getName();
boolean hasPropertySet = props.containsKey(paramKey);
if (hasPropertySet) {
param.setValue(props.getProperty(paramKey));
}
}
/* and the rest of the method is also the same */
/* actually, we need to remove references to File variables, but
those are obvious */
-----
The idea is that each Properties contains the params as they should be
set for one specific request.
For example, a DeleteFileService requires no input files, only two
params: the S3 bucket name and the object key. The PropertiesIngestor
can be used as follows:
-----
PropertiesIngestor ingestor = new PropertiesIngestor(/* whatever */);
Properties deleteFileRequestProperties = new Properties();
deleteFileRequestProperties.setProperty("delFile.bucket", "mybucket");
deleteFileRequestProperties.setProperty("delFile.objectKey",
"objectWaitingForDeletion");
List<Properties> propsList = new LinkedList<Properties>();
propsList.add(deleteFileRequestProperties);
ingestor.ingestProperties(propsList);
-----
Then, the DeleteFileService is informed of which file to delete by
getting these params' values in the standard way.
What do you think of this idea?
[BTW, In the current code base it is somewhat inconvenient to subclass
IngestorBase and provide a new ingesting method because all
IngestorBase's members are private.]
.. Shlomo
David
/**
* This method takes a list of properties submits work requests for
each. This is designed
* for workflows that don't require an initial input file, rather
some properties unique to
* each request define the inputs.
*
* @param properties the list of properties to use
*/
public void ingest(List<Properties> properties) {
}
/**
* This method takes a list of keys of objects in S3 and submits work
requests for each.
*
* @param files the list of files to ingest
*/
public void ingest(List<String> keys) {
}
/**
* This method takes a list of files, moves the files to S3 and
submits work requests for each.
*
* @param files the list of files to ingest
*/
public void ingest(List<File> files) {
}
I'm re-factoring the code so there is as much re-use as possible
between these methods.
David
On Thu, Aug 14, 2008 at 7:34 AM, <shlomo....@gmail.com> wrote:
>