Tabnine Logo
Task
Code IndexAdd Tabnine to your IDE (free)

How to use
Task
in
org.elasticsearch.tasks

Best Java code snippets using org.elasticsearch.tasks.Task (Showing top 20 results out of 315)

origin: org.elasticsearch/elasticsearch

@Override
public void onResponse(Task task, Response response) {
  logger.info("{} finished with response {}", task.getId(), response);
}
origin: org.elasticsearch/elasticsearch

  public boolean match(Task task) {
    if (getActions() != null && getActions().length > 0 && Regex.simpleMatch(getActions(), task.getAction()) == false) {
      return false;
    }
    if (getTaskId().isSet()) {
      if(getTaskId().getId() != task.getId()) {
        return false;
      }
    }
    if (parentTaskId.isSet()) {
      if (parentTaskId.equals(task.getParentTaskId()) == false) {
        return false;
      }
    }
    return true;
  }
}
origin: org.elasticsearch/elasticsearch

/**
 * Build a version of the task status you can throw over the wire and back
 * to the user.
 *
 * @param localNodeId
 *            the id of the node this task is running on
 * @param detailed
 *            should the information include detailed, potentially slow to
 *            generate data?
 */
public final TaskInfo taskInfo(String localNodeId, boolean detailed) {
  String description = null;
  Task.Status status = null;
  if (detailed) {
    description = getDescription();
    status = getStatus();
  }
  return taskInfo(localNodeId, description, status);
}
origin: org.elasticsearch/elasticsearch

/**
 * Build a proper {@link TaskInfo} for this task.
 */
protected final TaskInfo taskInfo(String localNodeId, String description, Status status) {
  return new TaskInfo(new TaskId(localNodeId, getId()), getType(), getAction(), description, status, startTime,
      System.nanoTime() - startTimeNanos, this instanceof CancellableTask, parentTask, headers);
}
origin: org.elasticsearch/elasticsearch

private void registerCancellableTask(Task task) {
  CancellableTask cancellableTask = (CancellableTask) task;
  CancellableTaskHolder holder = new CancellableTaskHolder(cancellableTask);
  CancellableTaskHolder oldHolder = cancellableTasks.put(task.getId(), holder);
  assert oldHolder == null;
  // Check if this task was banned before we start it
  if (task.getParentTaskId().isSet() && banedParents.isEmpty() == false) {
    String reason = banedParents.get(task.getParentTaskId());
    if (reason != null) {
      try {
        holder.cancel(reason);
        throw new IllegalStateException("Task cancelled before it started: " + reason);
      } finally {
        // let's clean up the registration
        unregister(task);
      }
    }
  }
}
origin: org.elasticsearch/elasticsearch

  return null;
assert task.getParentTaskId().equals(request.getParentTask()) : "Request [ " + request + "] didn't preserve it parentTaskId";
if (logger.isTraceEnabled()) {
  logger.trace("register {} [{}] [{}] [{}]", task.getId(), type, action, task.getDescription());
  registerCancellableTask(task);
} else {
  Task previousTask = tasks.put(task.getId(), task);
  assert previousTask == null;
origin: harbby/presto-connectors

/**
 * Build a version of the task status you can throw over the wire and back
 * to the user.
 *
 * @param node
 *            the node this task is running on
 * @param detailed
 *            should the information include detailed, potentially slow to
 *            generate data?
 */
public TaskInfo taskInfo(DiscoveryNode node, boolean detailed) {
  String description = null;
  Task.Status status = null;
  if (detailed) {
    description = getDescription();
    status = getStatus();
  }
  return new TaskInfo(node, getId(), getType(), getAction(), description, status, startTime, System.nanoTime() - startTimeNanos,
    parentTask);
}
origin: org.elasticsearch/elasticsearch

  public TaskResult result(DiscoveryNode node, ActionResponse response) throws IOException {
    if (response instanceof ToXContent) {
      return new TaskResult(taskInfo(node.getId(), true), (ToXContent) response);
    } else {
      throw new IllegalStateException("response has to implement ToXContent to be able to store the results");
    }
  }
}
origin: harbby/presto-connectors

  @Override
  public void accept(Task t) {
    operation.accept(t);
    while (System.nanoTime() - timeoutTime < 0) {
      Task task = taskManager.getTask(t.getId());
      if (task == null) {
        return;
      }
      if (task.getAction().startsWith(ListTasksAction.NAME)) {
        // It doesn't make sense to wait for List Tasks and it can cause an infinite loop of the task waiting
        // for itself of one of its child tasks
        return;
      }
      try {
        Thread.sleep(WAIT_FOR_COMPLETION_POLL.millis());
      } catch (InterruptedException e) {
        throw new ElasticsearchException("Interrupted waiting for completion of [{}]", e, t);
      }
    }
    throw new ElasticsearchTimeoutException("Timed out waiting for completion of [{}]", t);
  }
});
origin: floragunncom/search-guard

getThreadContext().putTransient(ConfigConstants.SG_ACTION_NAME, task.getAction());
    && !task.getAction().equals("internal:transport/handshake")
    && (task.getAction().startsWith("internal:") || task.getAction().contains("["))) {
  auditLog.logMissingPrivileges(task.getAction(), request, task);
  log.error("Internal or shard requests ("+task.getAction()+") not allowed from a non-server node for transport type "+transportChannel.getChannelType());
  transportChannel.sendResponse(new ElasticsearchSecurityException(
      "Internal or shard requests not allowed from a non-server node for transport type "+transportChannel.getChannelType()));
  Exception ex = new ElasticsearchSecurityException(
      "No SSL client certificates found for transport type "+transportChannel.getChannelType()+". Search Guard needs the Search Guard SSL plugin to be installed");
  auditLog.logSSLException(request, ex, task.getAction(), task);
  log.error("No SSL client certificates found for transport type "+transportChannel.getChannelType()+". Search Guard needs the Search Guard SSL plugin to be installed");
  transportChannel.sendResponse(ex);
      auditLog.logBadHeaders(request, task.getAction(), task);
      log.error(exception);
      transportChannel.sendResponse(exception);
      if((user = backendRegistry.authenticate(request, principal, task, task.getAction())) == null) {
        org.apache.logging.log4j.ThreadContext.remove("user");
        if(task.getAction().equals(WhoAmIAction.NAME)) {
          super.messageReceivedDecorate(request, handler, transportChannel, task);
          return;
        if(task.getAction().equals("cluster:monitor/nodes/liveness")
            || task.getAction().equals("internal:transport/handshake")) {
origin: org.elasticsearch/elasticsearch

/**
 * Returns the task object that should be used to keep track of the processing of the request.
 *
 * A request can override this method and return null to avoid being tracked by the task
 * manager.
 */
default Task createTask(long id, String type, String action, TaskId parentTaskId, Map<String, String> headers) {
  return new Task(id, type, action, getDescription(), parentTaskId, headers);
}
origin: org.elasticsearch/elasticsearch

  taskResult = task.result(localNode, response);
} catch (IOException ex) {
  logger.warn(() -> new ParameterizedMessage("couldn't store response {}", response), ex);
origin: com.strapdata.elasticsearch/elasticsearch

/**
 * Registers a task without parent task
 * <p>
 * Returns the task manager tracked task or null if the task doesn't support the task manager
 */
public Task register(String type, String action, TaskAwareRequest request) {
  Task task = request.createTask(taskIdGenerator.incrementAndGet(), type, action, request.getParentTask());
  if (task == null) {
    return null;
  }
  assert task.getParentTaskId().equals(request.getParentTask()) : "Request [ " + request + "] didn't preserve it parentTaskId";
  if (logger.isTraceEnabled()) {
    logger.trace("register {} [{}] [{}] [{}]", task.getId(), type, action, task.getDescription());
  }
  if (task instanceof CancellableTask) {
    registerCancellableTask(task);
  } else {
    Task previousTask = tasks.put(task.getId(), task);
    assert previousTask == null;
  }
  return task;
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.elasticsearch

/**
 * Build a proper {@link TaskInfo} for this task.
 */
protected final TaskInfo taskInfo(String localNodeId, String description, Status status) {
  return new TaskInfo(new TaskId(localNodeId, getId()), getType(), getAction(), description, status, startTime,
      System.nanoTime() - startTimeNanos, this instanceof CancellableTask, parentTask, headers);
}
origin: apache/servicemix-bundles

private void registerCancellableTask(Task task) {
  CancellableTask cancellableTask = (CancellableTask) task;
  CancellableTaskHolder holder = new CancellableTaskHolder(cancellableTask);
  CancellableTaskHolder oldHolder = cancellableTasks.put(task.getId(), holder);
  assert oldHolder == null;
  // Check if this task was banned before we start it
  if (task.getParentTaskId().isSet() && banedParents.isEmpty() == false) {
    String reason = banedParents.get(task.getParentTaskId());
    if (reason != null) {
      try {
        holder.cancel(reason);
        throw new IllegalStateException("Task cancelled before it started: " + reason);
      } finally {
        // let's clean up the registration
        unregister(task);
      }
    }
  }
}
origin: org.elasticsearch/elasticsearch

public TaskResult result(DiscoveryNode node, Exception error) throws IOException {
  return new TaskResult(taskInfo(node.getId(), true), error);
}
origin: org.elasticsearch/elasticsearch

@Override
protected void processTasks(ListTasksRequest request, Consumer<Task> operation) {
  if (request.getWaitForCompletion()) {
    long timeoutNanos = waitForCompletionTimeout(request.getTimeout());
    operation = operation.andThen(task -> {
      if (task.getAction().startsWith(ListTasksAction.NAME)) {
        // It doesn't make sense to wait for List Tasks and it can cause an infinite loop of the task waiting
        // for itself or one of its child tasks
        return;
      }
      taskManager.waitForTaskCompletion(task, timeoutNanos);
    });
  }
  super.processTasks(request, operation);
}
origin: apache/servicemix-bundles

/**
 * Returns the task object that should be used to keep track of the processing of the request.
 *
 * A request can override this method and return null to avoid being tracked by the task
 * manager.
 */
default Task createTask(long id, String type, String action, TaskId parentTaskId, Map<String, String> headers) {
  return new Task(id, type, action, getDescription(), parentTaskId, headers);
}
origin: org.elasticsearch/elasticsearch

/**
 * Stores the task failure
 */
public <Response extends ActionResponse> void storeResult(Task task, Exception error, ActionListener<Response> listener) {
  DiscoveryNode localNode = lastDiscoveryNodes.getLocalNode();
  if (localNode == null) {
    // too early to store anything, shouldn't really be here - just pass the error along
    listener.onFailure(error);
    return;
  }
  final TaskResult taskResult;
  try {
    taskResult = task.result(localNode, error);
  } catch (IOException ex) {
    logger.warn(() -> new ParameterizedMessage("couldn't store error {}", ExceptionsHelper.detailedMessage(error)), ex);
    listener.onFailure(ex);
    return;
  }
  taskResultsService.storeResult(taskResult, new ActionListener<Void>() {
    @Override
    public void onResponse(Void aVoid) {
      listener.onFailure(error);
    }
    @Override
    public void onFailure(Exception e) {
      logger.warn(() -> new ParameterizedMessage("couldn't store error {}", ExceptionsHelper.detailedMessage(error)), e);
      listener.onFailure(e);
    }
  });
}
origin: org.elasticsearch/elasticsearch

  @Override
  public void onFailure(Task task, Throwable e) {
    logger.warn(() -> new ParameterizedMessage("{} failed with exception", task.getId()), e);
  }
}
org.elasticsearch.tasksTask

Javadoc

Current task information

Most used methods

  • getId
    Returns task id
  • getAction
    Returns task action
  • taskInfo
    Build a version of the task status you can throw over the wire and back to the user.
  • <init>
  • getDescription
    Generates task description
  • getParentTaskId
    Returns id of the parent task or NO_PARENT_ID if the task doesn't have any parent tasks
  • getStatus
    Build a status for this task or null if this task doesn't have status. Since most tasks don't have s
  • getType
    Returns task channel type (netty, transport, direct)
  • result

Popular in Java

  • Parsing JSON documents to java classes using gson
  • startActivity (Activity)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • setScale (BigDecimal)
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • File (java.io)
    An "abstract" representation of a file system entity identified by a pathname. The pathname may be a
  • FileWriter (java.io)
    A specialized Writer that writes to a file in the file system. All write requests made by calling me
  • ArrayList (java.util)
    ArrayList is an implementation of List, backed by an array. All optional operations including adding
  • SSLHandshakeException (javax.net.ssl)
    The exception that is thrown when a handshake could not be completed successfully.
  • SAXParseException (org.xml.sax)
    Encapsulate an XML parse error or warning.> This module, both source code and documentation, is in t
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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