public void registerFeedIntakeJob(FeedId feedId, JobId jobId, JobSpecification jobSpec)
      throws HyracksDataException {
    if (jobInfos.get(jobId) != null) {
      throw new IllegalStateException("Feed job already registered");
    }

    List<IFeedJoint> joints = feedPipeline.get(feedId);
    IFeedJoint intakeJoint = null;
    for (IFeedJoint joint : joints) {
      if (joint.getType().equals(IFeedJoint.FeedJointType.INTAKE)) {
        intakeJoint = joint;
        break;
      }
    }

    if (intakeJoint != null) {
      FeedIntakeInfo intakeJobInfo =
          new FeedIntakeInfo(
              jobId,
              FeedJobState.CREATED,
              FeedJobInfo.JobType.INTAKE,
              feedId,
              intakeJoint,
              jobSpec);
      intakeJobInfos.put(feedId, intakeJobInfo);
      jobInfos.put(jobId, intakeJobInfo);

      if (LOGGER.isLoggable(Level.INFO)) {
        LOGGER.info("Registered feed intake [" + jobId + "]" + " for feed " + feedId);
      }
    } else {
      throw new HyracksDataException(
          "Could not register feed intake job [" + jobId + "]" + " for feed  " + feedId);
    }
  }
 public IFeedJoint getFeedPoint(FeedId sourceFeedId, IFeedJoint.FeedJointType type) {
   List<IFeedJoint> joints = feedPipeline.get(sourceFeedId);
   for (IFeedJoint joint : joints) {
     if (joint.getType().equals(type)) {
       return joint;
     }
   }
   return null;
 }
  public synchronized void submitFeedConnectionRequest(
      IFeedJoint feedJoint, final FeedConnectionRequest request) throws Exception {
    List<String> locations = null;
    switch (feedJoint.getType()) {
      case INTAKE:
        FeedIntakeInfo intakeInfo = intakeJobInfos.get(feedJoint.getOwnerFeedId());
        locations = intakeInfo.getIntakeLocation();
        break;
      case COMPUTE:
        FeedConnectionId connectionId = feedJoint.getProvider();
        FeedConnectJobInfo cInfo = connectJobInfos.get(connectionId);
        locations = cInfo.getComputeLocations();
        break;
    }

    SubscribeFeedWork work = new SubscribeFeedWork(locations.toArray(new String[] {}), request);
    FeedWorkManager.INSTANCE.submitWork(
        work, new SubscribeFeedWork.FeedSubscribeWorkEventListener());
  }
  private void handleCollectJobStartMessage(FeedConnectJobInfo cInfo)
      throws RemoteException, ACIDException {
    // set locations of feed sub-operations (intake, compute, store)
    setLocations(cInfo);

    // activate joints
    List<IFeedJoint> joints = feedPipeline.get(cInfo.getConnectionId().getFeedId());
    for (IFeedJoint joint : joints) {
      if (joint.getProvider().equals(cInfo.getConnectionId())) {
        joint.setState(State.ACTIVE);
        if (joint.getType().equals(IFeedJoint.FeedJointType.COMPUTE)) {
          cInfo.setComputeFeedJoint(joint);
        }
      }
    }
    cInfo.setState(FeedJobState.ACTIVE);

    // register activity in metadata
    registerFeedActivity(cInfo);
    // notify event listeners
    notifyFeedEventSubscribers(cInfo, FeedLifecycleEvent.FEED_COLLECT_STARTED);
  }