congrats Icon
New! Announcing our next generation AI code completions
Read here
Tabnine Logo
ServiceRegistry.setCurrentJob
Code IndexAdd Tabnine to your IDE (free)

How to use
setCurrentJob
method
in
org.opencastproject.serviceregistry.api.ServiceRegistry

Best Java code snippets using org.opencastproject.serviceregistry.api.ServiceRegistry.setCurrentJob (Showing top 3 results out of 315)

origin: opencast/opencast

/**
 * {@inheritDoc}
 *
 * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse,
 *      javax.servlet.FilterChain)
 */
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,
    ServletException {
 HttpServletRequest httpRequest = (HttpServletRequest) request;
 HttpServletResponse httpResponse = (HttpServletResponse) response;
 try {
  setCurrentJob(httpRequest, httpResponse);
  chain.doFilter(httpRequest, httpResponse);
 } finally {
  serviceRegistry.setCurrentJob(null);
 }
}
origin: opencast/opencast

/**
 * Sets the current job on the new thread
 *
 * @param httpRequest
 *          the HTTP request
 * @param httpResponse
 *          the HTTP response
 * @throws IOException
 *           if the error response was not able to be sent
 */
private void setCurrentJob(HttpServletRequest httpRequest, HttpServletResponse httpResponse) throws IOException {
 String currentJobId = httpRequest.getHeader(CURRENT_JOB_HEADER);
 try {
  if (StringUtils.isNotBlank(currentJobId)) {
   Job currentJob = serviceRegistry.getJob(Long.parseLong(currentJobId));
   serviceRegistry.setCurrentJob(currentJob);
  }
 } catch (Exception e) {
  logger.error("Unable to set the current job {}: {}", currentJobId, e);
  httpResponse.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
      "Was not able to set the current job id {} to the service registry" + currentJobId);
 }
}
origin: opencast/opencast

@Override
public Void call() throws Exception {
 final SecurityService securityService = getSecurityService();
 final ServiceRegistry serviceRegistry = getServiceRegistry();
 final Job jobBeforeProcessing = serviceRegistry.getJob(jobId);
 if (currentJobId.isSome())
  serviceRegistry.setCurrentJob(serviceRegistry.getJob(currentJobId.get()));
 final Organization organization = getOrganizationDirectoryService()
     .getOrganization(jobBeforeProcessing.getOrganization());
 securityService.setOrganization(organization);
 final User user = getUserDirectoryService().loadUser(jobBeforeProcessing.getCreator());
 securityService.setUser(user);
 try {
  final String payload = process(jobBeforeProcessing);
  handleSuccessfulProcessing(payload);
 } catch (Throwable t) {
  handleFailedProcessing(t);
 } finally {
  serviceRegistry.setCurrentJob(null);
  securityService.setUser(null);
  securityService.setOrganization(null);
 }
 return null;
}
org.opencastproject.serviceregistry.apiServiceRegistrysetCurrentJob

Javadoc

Sets the current running job

Popular methods of ServiceRegistry

  • createJob
    Create and store a new job. If enqueueImmediately is true, the job will be in the Status#QUEUED stat
  • getCurrentJob
    Gets the current running job
  • getJob
    Gets a receipt by its ID, or null if not found
  • count
    Count the number of jobs that match the specified parameters.
  • getHostRegistrations
    Finds all host registrations, including offline hosts and those in maintenance mode.
  • getMaxLoadOnNode
    Returns the maximum load that can be handled by a given node. Note that this load is *not* 1-to-1 eq
  • getOwnLoad
    Gets the load value for the current host (ie, the host this service registry lives on
  • getServiceRegistrationsByLoad
    Finds the service registrations for this kind of job, ordered by load (lightest to heaviest).
  • incident
    Return a facility to record job incidents.
  • updateJob
    Update the job in the database
  • countByHost
    Count the number of jobs in this Status on this host
  • countByOperation
    Count the number of jobs running the given operation in this Status.
  • countByHost,
  • countByOperation,
  • countOfAbnormalServices,
  • disableHost,
  • enableHost,
  • getActiveJobs,
  • getChildJobs,
  • getCurrentHostLoads,
  • getJobs

Popular in Java

  • Reactive rest calls using spring rest template
  • getSystemService (Context)
  • compareTo (BigDecimal)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • Selector (java.nio.channels)
    A controller for the selection of SelectableChannel objects. Selectable channels can be registered w
  • Deque (java.util)
    A linear collection that supports element insertion and removal at both ends. The name deque is shor
  • SortedSet (java.util)
    SortedSet is a Set which iterates over its elements in a sorted order. The order is determined eithe
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • Manifest (java.util.jar)
    The Manifest class is used to obtain attribute information for a JarFile and its entries.
  • Top 17 PhpStorm Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now