Examples of AFrame


Examples of org.apache.vinci.transport.document.AFrame

   * @see org.apache.uima.collection.impl.service.CasObjectProcessorServiceStub#callIsReadOnly()
   */
  public boolean callIsReadOnly() throws ResourceServiceException {
    try {
      // create Vinci Frame ( Data Cargo)
      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;
View Full Code Here

Examples of org.apache.vinci.transport.document.AFrame

   * @see org.apache.uima.collection.impl.service.CasObjectProcessorServiceStub#callIsStateless()
   */
  public boolean callIsStateless() throws ResourceServiceException {
    try {
      // create Vinci Frame ( Data Cargo)
      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;
View Full Code Here

Examples of org.apache.vinci.transport.document.AFrame

    // Serialize CasData to XCAS
    // Would be nice to serialize straight to parent frame frame, but we have
    // to change the tag name to KEYS to satisfy the TAE interface
    // spec - sigh.
    AFrame xcasHolder = new AFrame();
    SaxVinciFrameBuilder vinciFrameBuilder = new SaxVinciFrameBuilder();
    vinciFrameBuilder.setParentFrame(xcasHolder);
    CasDataToXCas xcasGenerator = new CasDataToXCas();
    xcasGenerator.setDocumentTextTypeName(mCasDataDocTextType);
    xcasGenerator.setDocumentTextFeatureName(mCasDataDocTextFeature);
    xcasGenerator.setXCasDocumentTextTagName(mXCasDocTextTag);
    xcasGenerator.setIncludeAnnotationSpannedText(mIncludeAnnotationSpannedText);

    xcasGenerator.setContentHandler(vinciFrameBuilder);
    xcasGenerator.generateXCas(aCasData, ueid);
    AFrame xcasFrame = xcasHolder.fgetAFrame("CAS");
    aParentFrame.aadd(Constants.KEYS, xcasFrame);
  }
View Full Code Here

Examples of org.apache.vinci.transport.document.AFrame

   * Returns a new VinciFrame
   *
   * @return {@link org.apache.vinci.transport.VinciFrame} instance
   */
  private AFrame getAFrame() {
    return new AFrame();
  }
View Full Code Here

Examples of org.apache.vinci.transport.document.AFrame

   *          error message to place in the error frame
   *
   * @return {@link org.apache.vinci.transport.VinciFrame} instance containing error
   */
  public VinciFrame replyWithError(String errorMsg) {
    AFrame aFrame = getAFrame();
    aFrame.fadd("Error", errorMsg);
    return aFrame;
  }
View Full Code Here

Examples of org.apache.vinci.transport.document.AFrame

    AFFactory af = new AFFactory();
    return (AFrame) conn.sendAndReceive(requestFrame, af);
  }

  public static AFrame produceAFrame(String cmd, String content) {
    AFrame query = new AFrame();
    query.fadd(Constants.VINCI_COMMAND, Constants.ANNOTATE);

    AFrame keys = new AFrame();
    keys.fadd(Constants.VINCI_DETAG, content);

    AFrame data = new AFrame();
    data.fadd(Constants.KEYS, keys);
    query.fadd(Constants.DATA, data);

    return query;
  }
View Full Code Here

Examples of org.apache.vinci.transport.document.AFrame

  public static final String VNS_PORT = "VNS_PORT";

  public static class AFFactory implements TransportableFactory {
    public Transportable makeTransportable() {
      return new AFrame();
    }
View Full Code Here

Examples of org.apache.vinci.transport.document.AFrame

   * @throws ServiceException - passthru, wraps Exception
   * @throws ServiceConnectionException passthru
   */
  public CasData analyze(CasData aCas, ProcessTrace aPT, String aResourceName)
          throws ServiceException, ServiceConnectionException {
    AFrame query = new AFrame();

    try {

      aPT.startEvent(aResourceName, "CAS to Vinci Request Frame", "");
      query.fadd(Constants.VINCI_COMMAND, Constants.ANNOTATE);

      AFrame dataFrame = new AFrame();

      vinciCasDataConverter.casDataToVinciFrame(aCas, dataFrame);
      query.fadd(Constants.DATA, dataFrame);
      aPT.endEvent(aResourceName, "CAS to Vinci Request Frame", "");
      // Time the amount of time the annalysis takes, including the comms.
      aPT.startEvent(aResourceName, "Vinci Call", "");
      // start = System.currentTimeMillis();
      AFrame responseFrame = sendAndReceive(query);
      aPT.endEvent(aResourceName, "Vinci Call", "");

      aPT.startEvent(aResourceName, "Vinci Response Frame to CAS", "");
      CasData newCasData = new CasDataImpl();
      FeatureStructure casDataFs = this.getDocTextFeatureStructure(aCas);
      if (casDataFs != null) {
        newCasData.addFeatureStructure(casDataFs);
      }
      vinciCasDataConverter.appendVinciFrameToCasData(responseFrame.fgetAFrame("DATA").fgetAFrame(
              "KEYS"), newCasData);
      aCas = newCasData;

      aPT.endEvent(aResourceName, "Vinci Response Frame to CAS", "");
      // Get the times reported by service and add to process trace
      int frameToCasTime = responseFrame.fgetVinciFrame("DATA")
              .fgetInt(Constants.FRAME_TO_CAS_TIME);
      if (frameToCasTime > 0) {
        totalFrameToCasTime += frameToCasTime;
        aPT.addEvent(aResourceName, Constants.FRAME_TO_CAS_TIME, "", frameToCasTime, "success");
      }
      int annotationTime = responseFrame.fgetVinciFrame("DATA").fgetInt(Constants.ANNOTATION_TIME);
      if (annotationTime > 0) {
        totalAnnotationTime += annotationTime;
        aPT.addEvent(aResourceName, ProcessTraceEvent.ANALYSIS, "", annotationTime, "success");
      }
      int casToFrameTime = responseFrame.fgetVinciFrame("DATA")
              .fgetInt(Constants.CAS_TO_FRAME_TIME);
      if (casToFrameTime > 0) {
        totalCasToFrameTime += casToFrameTime;
        aPT.addEvent(aResourceName, Constants.CAS_TO_FRAME_TIME, "", casToFrameTime, "success");
      }
View Full Code Here

Examples of org.apache.vinci.transport.document.AFrame

    if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
      UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(),
              "process", CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_analyze_bundle__FINEST",
              new Object[] { Thread.currentThread().getName(), String.valueOf(aCasList.length) });
    }
    AFrame query = new AFrame();

    try {
      aPT.startEvent(aResourceName, "Vinci Call", "");
      query.fadd(Constants.VINCI_COMMAND, Constants.ANNOTATE);
      // Handle each Cas individually. For each Cas create a seperate DATA frame.
      for (int i = 0; i < aCasList.length && aCasList[i] != null; i++) {
        // String content = Vinci.getContentFromDATACas(aCas);
        // Create a request frame, and populate it with document text
        AFrame dataFrame = new AFrame();
        // Produces KEY Frames and ads them to a given dataFrame
        // produceXCASRequestFrame(aCasList[i], dataFrame);
        if (System.getProperty("SHOWKEYS") != null) {
          Iterator it = aCasList[i].getFeatureStructures();
          while (it.hasNext()) {
            FeatureStructure fs = (FeatureStructure) it.next();
            if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
              UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST,
                      this.getClass().getName(), "process", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                      "UIMA_CPM_dump_casdata__FINEST",
                      new Object[] { Thread.currentThread().getName(), fs.getType() });
            }
          }
        }
        if (DATACasUtils.isCasEmpty(aCasList[i])) {
          if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
            UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(),
                    "process", CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_no_cas__FINEST",
                    new Object[] { Thread.currentThread().getName() });
          }
          continue;
        }
        long sTime = uimaTimer.getTimeInMillis();
        // Different serializer object is used for WF. It seems to perform better
        if (System.getProperty("WF_SERIALIZER") != null) {
          produceXCASRequestFrame(aCasList[i], dataFrame, keys2Drop);
        } else {
          vinciCasDataConverter.casDataToVinciFrame(aCasList[i], dataFrame);
          dropNamedTypes(dataFrame.fgetAFrame("KEYS"), keys2Drop);
        }
        totalSerializeTime += (uimaTimer.getTimeInMillis() - sTime);

        query.fadd(Constants.DATA, dataFrame);
      }

      if (serviceName != null && System.getProperty("SHOW_NAME") != null)
        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_casdata_to_service__FINEST",
                  new Object[] { Thread.currentThread().getName(), serviceName });
        }
      if (System.getProperty("SHOW_REQFRAME") != null) {
        UIMAFramework.getLogger(this.getClass()).log(Level.INFO, " queryFrame-" + query.toXML());
      }

      long t = uimaTimer.getTimeInMillis();
      AFrame responseFrame = sendAndReceive(query);
      // no longer need the query object
      query = null;
      totalRoundTripTime += (uimaTimer.getTimeInMillis() - t);
      if ((responseFrame != null) && (responseFrame.fgetString("Error") != null)) {
        throw new ServiceException(responseFrame.fgetString("Error"));
      }

      if (System.getProperty("SHOW_RAW_RESPFRAME") != null) {
        UIMAFramework.getLogger(this.getClass()).log(Level.INFO,
                " responseFrame from service::" + serviceName + "\n" + responseFrame.toXML());
      }

      if (responseFrame != null && responseFrame.fgetAFrame("DATA") == null) {
        // No annotations found in reply so just leave
        return aCasList;
      }
      ArrayList d = new ArrayList();
      if ( responseFrame != null ) {
        d = responseFrame.fget("DATA");
      }
      int instanceCount = 0;
      // Process response, DATA frame at a time. Each DATA frame corresponds to an instance of
      // CasData
      AFrame dataFrame = null;
      while (!(d.isEmpty())) {
        dataFrame = (AFrame) d.remove(0);
        try {
          if (System.getProperty("SHOW_RESPFRAME") != null) {
            UIMAFramework.getLogger(this.getClass()).log(Level.INFO,
                    " Converting XCAS in responseFrame to CasData.XCAS=" + dataFrame.toXML());
          }
          long eTime = uimaTimer.getTimeInMillis();
          // When configured use WF serializer which is faster than the alternative SAX based one
          if (System.getProperty("WF_SERIALIZER") != null) {
            addKeysToDataCas(aCasList[instanceCount], dataFrame);
          } else {
            // We will call vinciCasDataConverter to convert response frame to a new
            // CasData. BUT, we also need to preserve the document text from the request,
            // since it may not be echoed by the service.
            CasData newCasData = new CasDataImpl();
            FeatureStructure casDataFs = this.getDocTextFeatureStructure(aCasList[instanceCount]);
            if (casDataFs != null) {
              newCasData.addFeatureStructure(casDataFs);
            }
            vinciCasDataConverter.appendVinciFrameToCasData(dataFrame.fgetAFrame("KEYS"),
                    newCasData);
            aCasList[instanceCount] = newCasData;
          }
          totalDeSerializeTime += (uimaTimer.getTimeInMillis() - eTime);

          if (System.getProperty("SHOWFRAME") != null) {
            UIMAFramework.getLogger(this.getClass()).log(Level.INFO, " dumping CasData-\n");
            dumpFeatures(aCasList[instanceCount]);
          }

          if (dataFrame != null) {
            FeatureStructure vfs = new FeatureStructureImpl();
            vfs.setType(org.apache.uima.collection.impl.cpm.Constants.STAT_FEATURE);

            String frame2CasTime = dataFrame.fgetString(Constants.FRAME_TO_CAS_TIME);
            if (frame2CasTime != null) {
              PrimitiveValue pv = new PrimitiveValueImpl(frame2CasTime);
              vfs.setFeatureValue(Constants.FRAME_TO_CAS_TIME, pv);
            }
            String annotationTime = dataFrame.fgetString(Constants.ANNOTATION_TIME);
            if (annotationTime != null) {
              PrimitiveValue pv = new PrimitiveValueImpl(annotationTime);
              vfs.setFeatureValue(Constants.ANNOTATION_TIME, pv);
            }
            String cas2FrameTime = dataFrame.fgetString(Constants.CAS_TO_FRAME_TIME);
            if (cas2FrameTime != null) {
              PrimitiveValue pv = new PrimitiveValueImpl(cas2FrameTime);
              vfs.setFeatureValue(Constants.CAS_TO_FRAME_TIME, pv);
            }
            aCasList[instanceCount].addFeatureStructure(vfs);
          }
          instanceCount++;
        } catch (Exception e) {
          if (UIMAFramework.getLogger().isLoggable(Level.FINER)) {
            UIMAFramework.getLogger(this.getClass()).logrb(
                    Level.FINER,
                    this.getClass().getName(),
                    "process",
                    CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                    "UIMA_CPM_exception__FINER",
                    new Object[] { Thread.currentThread().getName(), e.getMessage(),
                        dataFrame.toXML() });
            e.printStackTrace();
          }
          dataFrame.toXML();
        }
      }
      aPT.endEvent(aResourceName, "Vinci Call", "");
      if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
        UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(),
View Full Code Here

Examples of org.apache.vinci.transport.document.AFrame

              "UIMA_CPM_request_metadata__FINEST",
              new Object[] { Thread.currentThread().getName(), serviceName, conn.getHost(),
                  String.valueOf(conn.getPort()) });
    }
    // Added to support WF Miners that have descriptors.
    AFrame resultFrame = null;
    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
      resultFrame = (AFrame) conn.sendAndReceive(queryFrame, AFrame.getAFrameFactory(), timeout);
      if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
        UIMAFramework.getLogger(this.getClass()).logrb(
                Level.FINEST,
                this.getClass().getName(),
                "process",
                CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                "UIMA_CPM_return_meta__FINEST",
                new Object[] { Thread.currentThread().getName(), serviceName, conn.getHost(),
                    String.valueOf(conn.getPort()) });
      }
      // Parse the XML into the ProcessingResourceMetaData object
      SaxDeserializer saxDeser = UIMAFramework.getXMLParser().newSaxDeserializer();

      VinciSaxParser vinciSaxParser = new VinciSaxParser();
      vinciSaxParser.setContentHandler(saxDeser);
      vinciSaxParser.parse(resultFrame);

      ProcessingResourceMetaData metadata = (ProcessingResourceMetaData) saxDeser.getObject();

      if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
        UIMAFramework.getLogger(this.getClass()).logrb(
                Level.FINEST,
                this.getClass().getName(),
                "process",
                CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                "UIMA_CPM_done_parsing_meta__FINEST",
                new Object[] { Thread.currentThread().getName(), serviceName, conn.getHost(),
                    String.valueOf(conn.getPort()) });
      }
      return metadata;
    } catch (ServiceException e) {
      if (UIMAFramework.getLogger().isLoggable(Level.SEVERE)) {
        UIMAFramework.getLogger(this.getClass()).logrb(Level.SEVERE, this.getClass().getName(),
                "process", CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_service_exception__SEVERE",
                new Object[] { Thread.currentThread().getName(), e.getMessage() });
      }
      if ("No Such Command supported.".equals(e.getMessage().trim())) {
        return null;
      }
      e.printStackTrace();
      throw new ResourceServiceException(e);
    } catch (Exception e) {
      if ("No Such Command supported".equals(e.getMessage())) {
        if (UIMAFramework.getLogger().isLoggable(Level.WARNING)) {
          UIMAFramework.getLogger(this.getClass())
                  .logrb(
                          Level.WARNING,
                          this.getClass().getName(),
                          "process",
                          CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                          "UIMA_CPM_service_rejected_requested__WARNING",
                          new Object[] { Thread.currentThread().getName(), serviceName,
                              resultFrame.toXML() });
        }
        return null;
      }
      if (UIMAFramework.getLogger().isLoggable(Level.SEVERE)) {
        UIMAFramework.getLogger(this.getClass()).logrb(Level.SEVERE, this.getClass().getName(),
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.