Package com.odiago.flumebase.exec

Examples of com.odiago.flumebase.exec.FlowId


   */
  @Override
  public QuerySubmitResponse submitQuery(String query, Map<String, String> options)
      throws InterruptedException {
    StringBuilder msgBuilder = new StringBuilder();
    FlowId flowId = null;

    // Build a configuration out of our conf and the user's options.
    Configuration planConf = new Configuration(mConf);
    for (Map.Entry<String, String> entry : options.entrySet()) {
      planConf.set(entry.getKey(), entry.getValue());
View Full Code Here


  @Override
  public FlowId addFlow(FlowSpecification spec) throws InterruptedException {
    if (null != spec) {
      // Turn the specification into a physical plan and run it.
      FlowId flowId = new FlowId(mNextFlowId++);
      UserSession userSession = getSessionForConf(spec.getConf());
      LocalFlowBuilder flowBuilder = new LocalFlowBuilder(flowId, mRootSymbolTable,
          mFlumeConfig, mMemoryOutputMap, userSession);
      try {
        spec.reverseBfs(flowBuilder);
View Full Code Here

   * Request that the execution environment stop the flow with the specified flowIdStr.
   */
  private void tryCancelFlow(String flowIdStr, boolean wait) {
    try {
      long idNum = Long.valueOf(flowIdStr);
      FlowId id = new FlowId(idNum);
      mExecEnv.cancelFlow(id);

      if (wait) {
        mExecEnv.joinFlow(id);
      }
View Full Code Here

   * Watch the output of the specified flow.
   */
  private void watch(String flowIdStr) {
    try {
      long idNum = Long.valueOf(flowIdStr);
      FlowId flowId = new FlowId(idNum);
      mExecEnv.watchFlow(mSessionId, flowId);

    } catch (Exception e) {
      LOG.error("Exception subscribing to flow: " + StringUtils.stringifyException(e));
    }
View Full Code Here

   * Stop watching the output of the specified flow.
   */
  private void unwatch(String flowIdStr) {
    try {
      long idNum = Long.valueOf(flowIdStr);
      FlowId flowId = new FlowId(idNum);
      mExecEnv.unwatchFlow(mSessionId, flowId);

    } catch (Exception e) {
      LOG.error("Exception unsubscribing from flow: " + StringUtils.stringifyException(e));
    }
View Full Code Here

   * Set the stream name associated with a flow Id.
   */
  private void setFlowName(String flowIdStr, String streamName) {
    try {
      long idNum = Long.valueOf(flowIdStr);
      FlowId flowId = new FlowId(idNum);
      mExecEnv.setFlowName(flowId, streamName);
      if (null == streamName) {
        System.out.println("Removed stream name from flow " + flowIdStr);
      } else {
        System.out.println("Created stream '" + streamName + "' on flow " + flowIdStr);
View Full Code Here

  }

  private void getFlowName(String flowIdStr) {
    try {
      long idNum = Long.valueOf(flowIdStr);
      FlowId flowId = new FlowId(idNum);

      Map<FlowId, FlowInfo> infoMap = mExecEnv.listFlows();
      FlowInfo info = infoMap.get(flowId);
      if (null == info) {
        System.out.println("No such flow: " + flowIdStr);
View Full Code Here

      String msg = response.getMessage();
      if (null != msg) {
        System.out.println(msg);
      }

      FlowId flowId = response.getFlowId();
      if (null != flowId) {
        System.out.println("Started flow: " + flowId);
      }
    }
  }
View Full Code Here

     */
    private void listFlows(Map<FlowId, FlowInfo> outMap) {
      assert outMap != null;
      synchronized (outMap) {
        for (Map.Entry<FlowId, ActiveFlowData> entry : mActiveFlows.entrySet()) {
          FlowId id = entry.getKey();
          ActiveFlowData activeData = entry.getValue();
          outMap.put(id, new FlowInfo(id, activeData.getFlow().getQuery(),
              activeData.getStreamName()));
        }

View Full Code Here

                  newFlow.notify();
                }
              }
              break;
            case CancelFlow:
              FlowId cancelId = (FlowId) nextOp.getDatum();
              cancelFlow(cancelId);
              break;
            case CancelAll:
              cancelAllFlows();
              break;
            case ShutdownThread:
              isFinished = true;
              break;
            case WatchFlow:
              WatchRequest watchReq = (WatchRequest) nextOp.getDatum();
              watch(watchReq);
              break;
            case UnwatchFlow:
              WatchRequest unwatchReq = (WatchRequest) nextOp.getDatum();
              watch(unwatchReq); // the request has the isWatch flag set false.
              break;
            case GetWatchList:
              Pair<SessionId, List<FlowId>> getReq =
                  (Pair<SessionId, List<FlowId>>) nextOp.getDatum();
              getWatchList(getReq.getLeft(), getReq.getRight());
              break;
            case SetFlowName:
              Pair<FlowId, String> flowNameData =
                  (Pair<FlowId, String>) nextOp.getDatum();
              setFlowName(flowNameData.getLeft(), flowNameData.getRight());
            case Noop:
              // Don't do any control operation; skip ahead to event processing.
              break;
            case ElementComplete:
              // Remove a specific FlowElement from service; it's done.
              LocalCompletionEvent completionEvent = (LocalCompletionEvent) nextOp.getDatum();
              try {
                LocalContext context = completionEvent.getContext();

                List<SelectableQueue<Object>> downstreamQueues =
                    context.getDownstreamQueues();
                List<FlowElement> downstreamElements = context.getDownstream();
                if (null == downstreamElements || downstreamElements.size() == 0) {
                  // We have received close() notification from the last element in a flow.
                  // Remove the entire flow from service.
                  // TODO(aaron): Are multiple SinkFlowElemContexts possible per flow?
                  // If so, we need to wait for the last of these...
                  SinkFlowElemContext sinkContext = (SinkFlowElemContext) context;
                  FlowId id = sinkContext.getFlowId();
                  LOG.info("Processing complete for flow: " + id);
                  if (isActive(id)) {
                    // If the flow is closing naturally, cancel it. If it's
                    // already canceled (inactive), don't do this twice.
                    cancelFlow(id);
                  }
                } else if (null == downstreamQueues || downstreamQueues.size() == 0) {
                  // Has elements, but no queues. Notify the downstream
                  // FlowElement(s) to close too.
                  for (FlowElement downstream : downstreamElements) {
                    downstream.closeUpstream();
                  }
                } else {
                  // May have downstream queues. For each downstream element, close it
                  // immediately if it has no queue, or an empty queue. Otherwise,
                  // watch these queues for emptiness.
                  assert downstreamQueues.size() == downstreamElements.size();
                  for (int i = 0; i < downstreamElements.size(); i++) {
                    SelectableQueue<Object> downstreamQueue = downstreamQueues.get(i);
                    FlowElement downstreamElement = downstreamElements.get(i);
                    if (downstreamQueue == null) {
                      // Close directly.
                      downstreamElement.closeUpstream();
                    } else if (downstreamQueue.size() == 0) {
                      // Queue's dry, close it down.
                      closeQueue(downstreamQueue, downstreamElement);
                    } else {
                      // Watch this queue for completion.
                      mCloseQueues.add(downstreamQueue);
                    }

                  }
                }
              } catch (IOException ioe) {
                LOG.error("IOException closing flow element: " + ioe);
              } catch (InterruptedException ie) {
                LOG.error("Interruption closing downstream element: " + ie);
              }
              break;
            case Join:
              FlowJoinRequest joinReq = (FlowJoinRequest) nextOp.getDatum();
              FlowId id = joinReq.getFlowId();
              Ref<Boolean> waitObj = joinReq.getJoinObj();
              ActiveFlowData flowData = mActiveFlows.get(id);
              if (null == flowData) {
                // This flow id is already canceled. Return immediately.
                synchronized (waitObj) {
View Full Code Here

TOP

Related Classes of com.odiago.flumebase.exec.FlowId

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.