SMILA 1.0 API documentation

org.eclipse.smila.bulkbuilder.httphandler
Class BulkbuilderBurstHandler

java.lang.Object
  extended by org.eclipse.smila.http.server.util.ARequestHandler
      extended by org.eclipse.smila.http.server.json.JsonBulkRequestHandler
          extended by org.eclipse.smila.bulkbuilder.httphandler.BulkbuilderBurstHandler
All Implemented Interfaces:
HttpHandler, RequestHandler

public class BulkbuilderBurstHandler
extends JsonBulkRequestHandler

Implements the processing of HTTP requests for the bulk processing.


Field Summary
protected  java.util.Map<java.lang.String,java.lang.Boolean> _microBulkHasData
          mark if records where actually pushed for a bulk.
protected  java.lang.ThreadLocal<java.lang.String> _microBulkId
          The micro bulk id.
protected  BulkbuilderService _service
          Reference to the BulkBuilder.
protected  java.lang.ThreadLocal<java.util.Collection<WorkflowRunInfo>> _workflowRunDataToReturn
          The collected workflow run data data to return when calling finish.
static java.lang.String KEY_WORKFLOW_RUNS
          The key for the workflows in the result.
 
Fields inherited from class org.eclipse.smila.http.server.json.JsonBulkRequestHandler
FACTORY, HTTP_UTILS
 
Constructor Summary
BulkbuilderBurstHandler()
           
 
Method Summary
protected  void appendIntermediateWorkflowRunInfo(WorkflowRunInfo workflowRunInfo)
          appends the workflow run info to the list if the workflow run id has not already been set.
protected  java.lang.Object createResultObject(java.util.Collection<WorkflowRunInfo> workflowInfos)
          convert collected WorkflowRunInfos to Any.
 void end(java.lang.String method, java.lang.String requestUri, HttpExchange exchange)
          Called after processing and finishing is done.
 java.lang.Object finish(java.lang.String method, java.lang.String requestUri, HttpExchange exchange)
          Called after the complete input bulk has been processed successfully.
protected  int getErrorStatus(java.lang.String method, java.lang.String requestUri, java.lang.Throwable ex)
          Gets the HTTP error status code depending on the method, request URI and throwable.
protected  java.lang.String getJobName(java.lang.String requestUri)
          Extracts the job name from the requestURI.
 void process(java.lang.String method, java.lang.String requestUri, Record inputRecord, HttpExchange exchange)
          process input record and return result record.
 void setBulkbuilderService(BulkbuilderService service)
          Sets the bulk builder.
 void start(java.lang.String method, java.lang.String requestUri, HttpExchange exchange)
          Called before processing.
 void unsetBulkbuilderService(BulkbuilderService service)
          Unset the bulk builder.
 
Methods inherited from class org.eclipse.smila.http.server.json.JsonBulkRequestHandler
getRequestHost, getSuccessStatus, handle, isValidMethod, writeErrorResult, writeResultObject, writeSuccessResult
 
Methods inherited from class org.eclipse.smila.http.server.util.ARequestHandler
activate, getDynamicUriParts, getRootContextPath, getStaticUriParts, getUriPattern, matches, urlDecode
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

KEY_WORKFLOW_RUNS

public static final java.lang.String KEY_WORKFLOW_RUNS
The key for the workflows in the result.

See Also:
Constant Field Values

_workflowRunDataToReturn

protected final java.lang.ThreadLocal<java.util.Collection<WorkflowRunInfo>> _workflowRunDataToReturn
The collected workflow run data data to return when calling finish.


_microBulkId

protected final java.lang.ThreadLocal<java.lang.String> _microBulkId
The micro bulk id.


_microBulkHasData

protected final java.util.Map<java.lang.String,java.lang.Boolean> _microBulkHasData
mark if records where actually pushed for a bulk. If not, call commitJob instead of finishMicroBulk in finish


_service

protected BulkbuilderService _service
Reference to the BulkBuilder.

Constructor Detail

BulkbuilderBurstHandler

public BulkbuilderBurstHandler()
Method Detail

start

public void start(java.lang.String method,
                  java.lang.String requestUri,
                  HttpExchange exchange)
           throws java.lang.Exception
Called before processing.

Specified by:
start in class JsonBulkRequestHandler
Parameters:
method - the request method.
requestUri - the request URI.
exchange - http exchange object, contains e.g. the http header fields
Throws:
java.lang.Exception - any failure during processing.

process

public void process(java.lang.String method,
                    java.lang.String requestUri,
                    Record inputRecord,
                    HttpExchange exchange)
             throws java.lang.Exception
process input record and return result record.

Specified by:
process in class JsonBulkRequestHandler
Parameters:
method - the HTTP method of this request.
requestUri - the request URI
inputRecord - input Record, may be null
exchange - http exchange object, contains e.g. the http header fields
Throws:
java.lang.Exception - any failure during processing.

finish

public java.lang.Object finish(java.lang.String method,
                               java.lang.String requestUri,
                               HttpExchange exchange)
                        throws java.lang.Exception
Called after the complete input bulk has been processed successfully.

Specified by:
finish in class JsonBulkRequestHandler
Parameters:
method - the request method.
requestUri - the request URI.
exchange - http exchange object, contains e.g. the http header fields
Returns:
result object, may be null.
Throws:
java.lang.Exception - any failure during finishing.

createResultObject

protected java.lang.Object createResultObject(java.util.Collection<WorkflowRunInfo> workflowInfos)
                                       throws java.net.MalformedURLException
convert collected WorkflowRunInfos to Any.

Throws:
java.net.MalformedURLException

end

public void end(java.lang.String method,
                java.lang.String requestUri,
                HttpExchange exchange)
         throws java.lang.Exception
Called after processing and finishing is done. This method can be used to clean up resources.

Specified by:
end in class JsonBulkRequestHandler
Parameters:
method - the request method.
requestUri - the request URI.
exchange - http exchange object, contains e.g. the http header fields
Throws:
java.lang.Exception

appendIntermediateWorkflowRunInfo

protected void appendIntermediateWorkflowRunInfo(WorkflowRunInfo workflowRunInfo)
appends the workflow run info to the list if the workflow run id has not already been set.

Parameters:
workflowRunInfo -

getJobName

protected java.lang.String getJobName(java.lang.String requestUri)
Extracts the job name from the requestURI.

Parameters:
requestUri - the request URI
Returns:
the index name

getErrorStatus

protected int getErrorStatus(java.lang.String method,
                             java.lang.String requestUri,
                             java.lang.Throwable ex)
Gets the HTTP error status code depending on the method, request URI and throwable.

Overrides:
getErrorStatus in class JsonBulkRequestHandler
Returns:
HTTP error code matching the exception type.
See Also:
HTTP_UTILS#getErrorStatus(Throwable)

setBulkbuilderService

public void setBulkbuilderService(BulkbuilderService service)
Sets the bulk builder.

Parameters:
service - the new BulkBuilder

unsetBulkbuilderService

public void unsetBulkbuilderService(BulkbuilderService service)
Unset the bulk builder.

Parameters:
service - the BulkBuilder to unset

SMILA 1.0 API documentation