Package org.apache.drill.exec.work.fragment

Examples of org.apache.drill.exec.work.fragment.FragmentManager


      l.statusUpdate(status);
    }
  }

  public void setRootFragmentManager(RootFragmentManager fragmentManager) {
    FragmentManager old = managers.putIfAbsent(fragmentManager.getHandle(), fragmentManager);
    if (old != null)
      throw new IllegalStateException(
          "Tried to set fragment manager when has already been set for the provided fragment handle.");
  }
View Full Code Here


  public FragmentManager getOrCreateFragmentManager(FragmentHandle handle) throws FragmentSetupException{
    if (cancelledFragments.asMap().containsKey(handle)) {
      logger.debug("Fragment: {} was cancelled. Ignoring fragment handle", handle);
      return null;
    }
    FragmentManager manager = managers.get(handle);
    if (manager != null) return manager;
    DistributedMap<FragmentHandle, PlanFragment> planCache = bee.getContext().getCache().getMap(Foreman.FRAGMENT_CACHE);
    for(Map.Entry<FragmentHandle, PlanFragment> e : planCache.getLocalEntries()){
//      logger.debug("Key: {}", e.getKey());
//      logger.debug("Value: {}", e.getValue());
    }
    PlanFragment fragment = bee.getContext().getCache().getMap(Foreman.FRAGMENT_CACHE).get(handle);

    if (fragment == null) {
      throw new FragmentSetupException("Received batch where fragment was not in cache.");
    }

    FragmentManager newManager = new NonRootFragmentManager(fragment, bee);

    // since their could be a race condition on the check, we'll use putIfAbsent so we don't have two competing
    // handlers.
    manager = managers.putIfAbsent(fragment.getHandle(), newManager);
View Full Code Here

    FragmentRecordBatch fragmentBatch = get(pBody, FragmentRecordBatch.PARSER);
    FragmentHandle handle = fragmentBatch.getHandle();

    try {
      FragmentManager manager = workBus.getOrCreateFragmentManager(fragmentBatch.getHandle());
      if (manager == null) {
        if (body != null) {
          body.release();
        }
      }
      BufferAllocator allocator = manager.getFragmentContext().getAllocator();
      if(body != null){
        if(!allocator.takeOwnership((AccountingByteBuf) body.unwrap())){
          dataHandler.handle(connection, manager, OOM_FRAGMENT, null, null);
        }
      }
View Full Code Here

  /* (non-Javadoc)
   * @see org.apache.drill.exec.work.batch.BitComHandler#cancelFragment(org.apache.drill.exec.proto.ExecProtos.FragmentHandle)
   */
  @Override
  public Ack cancelFragment(FragmentHandle handle){
    FragmentManager manager = bee.getContext().getWorkBus().getFragmentManager(handle);

    if(manager != null){
      // try remote fragment cancel.
      manager.cancel();
    }else{
      // then try local cancel.
      FragmentExecutor runner = bee.getFragmentRunner(handle);
      if(runner != null) runner.cancel();
    }
View Full Code Here

    return Acks.OK;
  }

  public Ack receivingFragmentFinished(FinishedReceiver finishedReceiver) {
    FragmentManager manager = bee.getContext().getWorkBus().getFragmentManager(finishedReceiver.getSender());

    FragmentExecutor executor;
    if(manager != null) {
      executor = manager.getRunnable();
    } else {
      // then try local cancel.
      executor = bee.getFragmentRunner(finishedReceiver.getSender());
    }
View Full Code Here

  public void setFragmentManager(FragmentManager fragmentManager) {
    logger.debug("Manager created: {}", QueryIdHelper.getQueryIdentifier(fragmentManager.getHandle()));

    synchronized (managers) {
      FragmentManager old = managers.putIfAbsent(fragmentManager.getHandle(), fragmentManager);
      managers.notifyAll();
      if (old != null) {
        throw new IllegalStateException(
            "Tried to set fragment manager when has already been set for the provided fragment handle.");
      }
View Full Code Here

      logger.debug("Fragment: {} was cancelled. Ignoring fragment handle", handle);
      return null;
    }

    // chm manages concurrency better then everyone fighting for the same lock so we'll do a double check.
    FragmentManager m = managers.get(handle);
    if(m != null){
      return m;
    }

    logger.debug("Fragment was requested but no manager exists.  Waiting for manager for fragment: {}", QueryIdHelper.getQueryIdentifier(handle));
View Full Code Here

    FragmentRecordBatch fragmentBatch = get(pBody, FragmentRecordBatch.PARSER);
    FragmentHandle handle = fragmentBatch.getHandle();

    try {
      FragmentManager manager = workBus.getFragmentManager(fragmentBatch.getHandle());
      if (manager == null) {
        if (body != null) {
          body.release();
        }
      }
      BufferAllocator allocator = manager.getFragmentContext().getAllocator();
      if (body != null) {
        if (!allocator.takeOwnership((DrillBuf) body.unwrap())) {
          dataHandler.handle(connection, manager, OOM_FRAGMENT, null, null);
        }
      }
View Full Code Here

  /* (non-Javadoc)
   * @see org.apache.drill.exec.work.batch.BitComHandler#cancelFragment(org.apache.drill.exec.proto.ExecProtos.FragmentHandle)
   */
  @Override
  public Ack cancelFragment(FragmentHandle handle) {
    FragmentManager manager = bee.getContext().getWorkBus().getFragmentManagerIfExists(handle);
    if (manager != null) {
      // try remote fragment cancel.
      manager.cancel();
    } else {
      // then try local cancel.
      FragmentExecutor runner = bee.getFragmentRunner(handle);
      if (runner != null) {
        runner.cancel();
View Full Code Here

    return Acks.OK;
  }

  public Ack receivingFragmentFinished(FinishedReceiver finishedReceiver) {
    FragmentManager manager = bee.getContext().getWorkBus().getFragmentManagerIfExists(finishedReceiver.getSender());

    FragmentExecutor executor;
    if (manager != null) {
      executor = manager.getRunnable();
    } else {
      // then try local cancel.
      executor = bee.getFragmentRunner(finishedReceiver.getSender());
    }
View Full Code Here

TOP

Related Classes of org.apache.drill.exec.work.fragment.FragmentManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.