/** * Classes derived from {@link AbstractCustomAction} can override this method to initialize the {@link CustomAction}. * @throws Exception if there is any error in initializing the custom action */ @TransactionPolicy(TransactionControl.IMPLICIT) protected void initialize() throws Exception { // No-op by default }
/** * Classes derived from {@link AbstractSpark} can override this method to initialize the {@link Spark}. * {@link SparkClientContext} will be available in this method using {@link AbstractSpark#getContext}. * @throws Exception if there is any error in initializing the Spark */ @TransactionPolicy(TransactionControl.IMPLICIT) protected void initialize() throws Exception { // do nothing by default }
@Override @TransactionPolicy(TransactionControl.IMPLICIT) public void destroy() { // do nothing by default }
@Override @TransactionPolicy(TransactionControl.IMPLICIT) public void destroy() { // Do nothing }
/** * Destroy is the last thing that gets called before the program is * shutdown. So, if there are any cleanups then they can be specified here. */ @TransactionPolicy(TransactionControl.IMPLICIT) void destroy(); }
/** * Classes derived from {@link AbstractCondition} can override this method to destroy the {@link Condition}. */ @Override @TransactionPolicy(TransactionControl.IMPLICIT) public void destroy() { }
@Override @TransactionPolicy(TransactionControl.EXPLICIT) public void initialize(WorkerContext context) throws Exception { this.context = context; }
/** * This method is called when the http service is about to shutdown. * Cleanup job can be done in this method. */ @TransactionPolicy(TransactionControl.EXPLICIT) @Override void destroy(); }
/** * This method will get invoked after the last chunk of data is sent. It is always * executed inside a single transaction unless annotated with {@link TransactionPolicy(TransactionControl}. * * @throws Exception if there is any error */ @TransactionPolicy(TransactionControl.IMPLICIT) public abstract void onFinish() throws Exception;
@Override @TransactionPolicy(TransactionControl.EXPLICIT) public void onFinish() throws Exception { input.close(); }
@Override @TransactionPolicy(TransactionControl.EXPLICIT) public void onFinish() throws Exception { input.close(); }
@Override @TransactionPolicy(TransactionControl.EXPLICIT) public void onError(Throwable failureCause) { Closeables.closeQuietly(input); LOG.warn("Failure in producing http content from location {}", location, failureCause); } }
@Override @TransactionPolicy(TransactionControl.IMPLICIT) public final void initialize(SparkClientContext context) throws Exception { this.context = context; initialize(); }
@TransactionPolicy(TransactionControl.EXPLICIT) @Path("/exceptionNoTx") @GET public void exceptionNoTx(HttpServiceRequest request, HttpServiceResponder responder) throws Exception { throw new Exception("exceptionNoTx"); } }
@Override @TransactionPolicy(TransactionControl.IMPLICIT) public void initialize(WorkerContext context) throws Exception { super.initialize(context); recordTransaction(getContext(), WORKER_TX, INITIALIZE); attemptNestedTransaction(getContext(), WORKER_TX, INITIALIZE_NEST); }
@Override @TransactionPolicy(TransactionControl.EXPLICIT) protected void initialize() throws Exception { recordTransaction(getContext(), ACTION_NOTX, INITIALIZE); executeRecordTransaction(getContext(), ACTION_NOTX, INITIALIZE_TX, TIMEOUT_ACTION_INITIALIZE); executeAttemptNestedTransaction(getContext(), ACTION_NOTX, INITIALIZE_NEST); }
@Override @TransactionPolicy(TransactionControl.EXPLICIT) public void destroy() { recordTransaction(getContext(), ACTION_NOTX, DESTROY); executeRecordTransaction(getContext(), ACTION_NOTX, DESTROY_TX, TIMEOUT_ACTION_DESTROY); executeAttemptNestedTransaction(getContext(), ACTION_NOTX, DESTROY_NEST); }
@Override @TransactionPolicy(TransactionControl.EXPLICIT) protected void initialize() throws Exception { // this job will fail because we don't configure the inputs etc. That is fine because destroy() still gets called recordTransaction(getContext(), MAPREDUCE_NOTX, INITIALIZE); executeRecordTransaction(getContext(), MAPREDUCE_NOTX, INITIALIZE_TX, TIMEOUT_MAPREDUCE_INITIALIZE); executeAttemptNestedTransaction(getContext(), MAPREDUCE_NOTX, INITIALIZE_NEST); }
@Override @TransactionPolicy(TransactionControl.EXPLICIT) public void initialize(HttpServiceContext context) throws Exception { super.initialize(context); recordTransaction(getContext(), HANDLER_NOTX, INITIALIZE); executeRecordTransaction(getContext(), HANDLER_NOTX, INITIALIZE_TX, TIMEOUT_HANDLER_INITIALIZE); executeAttemptNestedTransaction(getContext(), HANDLER_NOTX, INITIALIZE_NEST); }
@Override @TransactionPolicy(TransactionControl.EXPLICIT) public void destroy() { recordTransaction(getContext(), HANDLER_NOTX, DESTROY); executeRecordTransaction(getContext(), HANDLER_NOTX, DESTROY_TX, TIMEOUT_HANDLER_DESTROY); executeAttemptNestedTransaction(getContext(), HANDLER_NOTX, DESTROY_NEST); super.destroy(); }