public static TaskFactory getTaskFactory(ApplicationDescriptorImpl<? extends ApplicationDescriptor> appDesc) {
    if (appDesc instanceof TaskApplicationDescriptorImpl) {
      return ((TaskApplicationDescriptorImpl) appDesc).getTaskFactory();
    } else if (appDesc instanceof StreamApplicationDescriptorImpl) {
      return (AsyncStreamTaskFactory) () -> new StreamOperatorTask(
          ((StreamApplicationDescriptorImpl) appDesc).getOperatorSpecGraph());
    }
    throw new IllegalArgumentException(String.format("ApplicationDescriptorImpl has to be either TaskApplicationDescriptorImpl or "
        + "StreamApplicationDescriptorImpl. class %s is not supported", appDesc.getClass().getName()));
  }
Creates a {@link TaskFactory} based on {@link ApplicationDescriptorImpl}

@param appDesc {@link ApplicationDescriptorImpl} for this application
@return {@link TaskFactory} object defined by {@code appDesc}
samza-core/src/main/java/org/apache/samza/task/TaskFactoryUtil.java