Package org.apache.vinci.transport

Examples of org.apache.vinci.transport.VinciFrame


    if (System.getProperty("FILTER_BATCH") != null) {
      return;
    }
    try {
      if (conn != null && conn.isOpen()) {
        VinciFrame query = new VinciFrame();
        query.fadd("vinci:COMMAND", Constants.BATCH_PROCESS_COMPLETE);
        if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
          UIMAFramework.getLogger(this.getClass()).logrb(
                  Level.FINEST,
                  this.getClass().getName(),
                  "process",
                  CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                  "UIMA_CPM_send_batch_complete__FINEST",
                  new Object[] { Thread.currentThread().getName(), conn.getHost(),
                      String.valueOf(conn.getPort()), query.toXML() });
        }
        // Send notification to service
        conn.send(query);
      }
    } catch (Exception e) {
View Full Code Here


   * @throws ResourceServiceException wraps Exception
   */
  public void collectionProcessComplete() throws ResourceServiceException {
    try {
      if (conn != null && conn.isOpen()) {
        VinciFrame query = new VinciFrame();
        query.fadd("vinci:COMMAND", Constants.COLLECTION_PROCESS_COMPLETE);
        if (UIMAFramework.getLogger().isLoggable(Level.INFO)) {
          UIMAFramework.getLogger(this.getClass()).logrb(
                  Level.FINEST,
                  this.getClass().getName(),
                  "process",
                  CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                  "UIMA_CPM_send_collection_complete__FINEST",
                  new Object[] { Thread.currentThread().getName(), conn.getHost(),
                      String.valueOf(conn.getPort()), query.toXML() });

          UIMAFramework.getLogger(this.getClass()).log(Level.INFO,
                  " Sending COLLECTION PROCESS COMPLETE TO Service\n" + query.toXML());
        }
        // Send notification to service
        conn.sendAndReceive(query);
      }
    } catch (Exception e) {
View Full Code Here

          collectionProcessComplete();
        }
        // If necessary send shutdown command
        if (shutdownService) {
          try {
            VinciFrame query = new VinciFrame();
            query.fadd("vinci:COMMAND", Constants.SHUTDOWN);
            if (UIMAFramework.getLogger().isLoggable(Level.INFO)) {
              UIMAFramework.getLogger(this.getClass()).logrb(
                      Level.INFO,
                      this.getClass().getName(),
                      "process",
                      CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                      "UIMA_CPM_stopping_service__INFO",
                      new Object[] { Thread.currentThread().getName(), conn.getHost(),
                          String.valueOf(conn.getPort()), query.toXML() });
            }
            // Send shutdown request to the TAE service
            conn.send(query);
          } finally {
            synchronized (conn) {
View Full Code Here

        throw new ServiceException("ResourceProcessException: " + e);
      }
    } else if (Constants.COLLECTION_PROCESS_COMPLETE.equals(op)) {
      try {
        mAE.collectionProcessComplete(new ProcessTrace_impl());
        return new VinciFrame(); // no return value - return empty
        // frame
      } catch (IOException e) {
        throw new ServiceException("IOException: " + e);
      } catch (ResourceProcessException e) {
        throw new ServiceException("ResourceProcessException: " + e);
      }
    } else if (Constants.IS_STATELESS.equals(op)) {
      return new AFrame().fadd("Result", mAE.isStateless());
    } else if (Constants.IS_READONLY.equals(op)) {
      return new AFrame().fadd("Result", mAE.isReadOnly());
    } else if (Constants.SHUTDOWN.equals(op)) {
      stop();
      System.exit(1);
    }
    return new VinciFrame().fadd("Error", "Invalid Operation:" + op);
  }
View Full Code Here

     */
    public void endElement(String uri, String name, String qName) {
      // Debug.p("End element: " + qName);
      if (top.sub_entries.size() == 0) {
        // Debug.p("Empty element.");
        top.component = new VinciFrame();
      } else {
        StackEntry child = (StackEntry) top.sub_entries.get(0);
        // Debug.p("Frameleaf.");
        if (top.sub_entries.size() == 1 && child.sub_entries == null) {
          // This is a frameleaf
          top.component = new FrameLeaf(child.ename_or_pcdata);
        } else {
          VinciFrame c = new VinciFrame();
          top.component = c;
          for (int i = 0; i < top.sub_entries.size(); i++) {
            child = (StackEntry) top.sub_entries.get(i);
            if (child.component != null) {
              c.add(child.ename_or_pcdata, child.component);
            } else {
              c.fadd(TransportConstants.PCDATA_KEY, child.ename_or_pcdata);
            }
            child.sub_entries = null;
          }
        }
      }
View Full Code Here

   * @see org.apache.uima.resource.service.ResourceServiceStub#callGetMetaData()
   */
  public ResourceMetaData callGetMetaData() throws ResourceServiceException {
    try {
      // create Vinci Frame
      VinciFrame queryFrame = new VinciFrame();
      // Add Vinci Command, so that the receiving service knows what to do
      queryFrame.fadd("vinci:COMMAND", "GetMeta");
      // Send the request to the service and wait for response

      if (debug) {
        System.out.println("Calling GetMeta");
      }

      VinciFrame resultFrame = mVinciClient.rpc(queryFrame, mGetMetaDataTimeout);

      if (debug) {
        System.out.println("Success");
      }

      // Extract the data from Vinci Response frame
      // System.out.println(resultFrame.toXML()); //DEBUG

      // Remove things from the result frame that are not the MetaData objects we expect.
      // In the future other things may go in here.
      int i = 0;
      while (i < resultFrame.getKeyValuePairCount()) {
        String key = resultFrame.getKeyValuePair(i).getKey();
        if (key.length() < 8 || !key.substring(key.length() - 8).equalsIgnoreCase("metadata")) {
          resultFrame.fdrop(key);
        } else {
          i++;
        }
      }

View Full Code Here

      AFrame queryFrame = new AFrame();
      // Add Vinci Command, so that the receiving service knows what to do
      queryFrame.fadd("vinci:COMMAND", Constants.IS_READONLY);

      // make RPC call
      VinciFrame resultFrame = mVinciClient.rpc(queryFrame);
      boolean result = resultFrame.fgetBoolean("Result");
      return result;
    } catch (Exception e) {
      throw new ResourceServiceException(e);
    }
  }
View Full Code Here

      AFrame queryFrame = new AFrame();
      // Add Vinci Command, so that the receiving service knows what to do
      queryFrame.fadd("vinci:COMMAND", Constants.IS_STATELESS);

      // make RPC call
      VinciFrame resultFrame = mVinciClient.rpc(queryFrame);
      boolean result = resultFrame.fgetBoolean("Result");
      return result;
    } catch (Exception e) {
      throw new ResourceServiceException(e);
    }
  }
View Full Code Here

      AFrame queryFrame = new AFrame();
      // Add Vinci Command, so that the receiving service knows what to do
      queryFrame.fadd("vinci:COMMAND", Constants.GET_SUPPORTED_XCAS_VERSIONS);

      // make RPC call
      VinciFrame resultFrame = mVinciClient.rpc(queryFrame);
      String result = resultFrame.fgetString("Result");
      if (result != null) {
        String[] versions = result.split("\\s+");
        return Collections.unmodifiableList(Arrays.asList(versions));
      }
      else {
View Full Code Here

   * @see org.apache.uima.resource.service.ResourceServiceStb#callGetMetaData()
   */
  public ResourceMetaData callGetMetaData() throws ResourceServiceException {
    try {
      // create Vinci Frame
      VinciFrame queryFrame = new VinciFrame();
      // Add Vinci Command, so that the receiving service knows what to do
      queryFrame.fadd("vinci:COMMAND", "GetMeta");
      // Send the request to the service and wait for response

      if (debug) {
        System.out.println("Calling GetMeta");
      }

      mVinciClient.setTransportableFactory(AFrame.getAFrameFactory());
      VinciFrame resultFrame = mVinciClient.rpc(queryFrame, mGetMetaDataTimeout);

      if (debug) {
        System.out.println("Success");
      }

      // Extract the data from Vinci Response frame
      // System.out.println(resultFrame.toXML()); //DEBUG

      // Remove things from the result frame that are not the MetaData objects we expect.
      // In the future other things may go in here.
      int i = 0;
      while (i < resultFrame.getKeyValuePairCount()) {
        String key = resultFrame.getKeyValuePair(i).getKey();
        if (key.length() < 8 || !key.substring(key.length() - 8).equalsIgnoreCase("metadata")) {
          resultFrame.fdrop(key);
        } else {
          i++;
        }
      }

View Full Code Here

TOP

Related Classes of org.apache.vinci.transport.VinciFrame

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.