Examples of AFrame


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

    // first, check to see whether we have a frame for which this temporary info
    // was stored from the previous call to startElement.
    if (mCurrentFrameName != null) {
      // create a non-leaf frame
      AFrame frame = new AFrame();

      // add this frame to its parent frame
      // (the one on top of stack)
      AFrame parent = (AFrame) mOpenFrames.peek();
      org.apache.vinci.transport.Attributes vinciAttrs = parent.aadd(mCurrentFrameName, frame);

      // set attributes
      if (mCurrentFrameAttrs != null) {
        for (int i = 0; i < mCurrentFrameAttrs.getLength(); i++) {
          String attrName = getName(mCurrentFrameAttrs.getLocalName(i), mCurrentFrameAttrs
View Full Code Here

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

      // mCharContentBuffer, but exists so subclasses can override for
      // specialized behavior (such as supressing certain content).
      String leafContent = getLeafContent(mCurrentFrameName, mCurrentFrameAttrs, mCharContentBuffer);

      // add leaf to parent frame
      AFrame parent = (AFrame) mOpenFrames.peek();
      org.apache.vinci.transport.Attributes vinciAttrs = parent
              .aadd(mCurrentFrameName, leafContent);

      // set attributes
      if (mCurrentFrameAttrs != null) {
        for (int i = 0; i < mCurrentFrameAttrs.getLength(); i++) {
View Full Code Here

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

          getAnalysisEngineMetaData();
          try {
            VinciFrame query = new VinciFrame();
            query.fadd("vinci:COMMAND", "GetPid");
            // Send shutdown request to the TAE service
            AFrame resp = (AFrame) conn.sendAndReceive(query);
            if (resp.fgetString("vinci:STATUS") != null
                    && resp.fgetString("vinci:STATUS").equals("OK")) {
              fencedProcessPID = resp.fgetString("PID");
              if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
                UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST,
                        this.getClass().getName(), "initialize", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                        "UIMA_CPM_service_pid__FINEST",
                        new Object[] { Thread.currentThread().getName(), fencedProcessPID });
View Full Code Here

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

              "UIMA_CPM_sending_process_req__FINEST",
              new Object[] { Thread.currentThread().getName(), serviceHost, servicePort,
                  String.valueOf(currentTimeout) });
    }
    try {
      AFrame responseFrame = null;

      // Dont test the connection, just try to send a message. If the send fails, go through the
      // error handler
      if (System.getProperty("TEST_BEFORE_SEND") != null) {
        testAndReconnect();
View Full Code Here

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

   * @throws Exception
   */
  private void produceXCASRequestFrame(CasData aCasData, AFrame dataFrame, String[] aDropKeyList)
          throws Exception {

    AFrame keysFrame = new AFrame();
    dataFrame.fadd("KEYS", keysFrame);
    String ueid = DATACasUtils.getFeatureValueByType(aCasData,
            org.apache.uima.collection.impl.cpm.Constants.METADATA_KEY,
            org.apache.uima.collection.impl.cpm.Constants.DOC_ID);
    keysFrame.fadd("UEID", ueid);

    AFrame keyFrame = null;
    try {
      Iterator it = aCasData.getFeatureStructures();
      while (it.hasNext()) {
        FeatureStructure fs = (FeatureStructure) it.next();
        boolean skipTheFeature = false;
        if (aDropKeyList != null) {
          for (int i = 0; i < aDropKeyList.length; i++) {
            if (aDropKeyList[i].equalsIgnoreCase(fs.getType())) {
              skipTheFeature = true;
              break;
            }
          }
          if (skipTheFeature) {
            continue;
          }
        }
        keyFrame = new AFrame();

        FeatureValue value = null;
        String[] keys = fs.getFeatureNames();
        for (int i = 0; i < keys.length; i++) {
          value = fs.getFeatureValue(keys[i]);
          if (value instanceof PrimitiveValueImpl || value instanceof PrimitiveValue) {
            keyFrame.add("", new FrameLeaf(value.toString()));
          }
        }
        // Convert the type to make
        String type = fs.getType();
        if (type.indexOf(org.apache.uima.collection.impl.cpm.Constants.LONG_COLON_TERM) > -1) {
View Full Code Here

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

   * @throws ServiceException -
   * @throws ServiceConnectionException
   */
  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

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

   * @see org.apache.uima.collection.impl.service.CasObjectProcessorServiceStub#callBatchProcessComplete()
   */
  public void callBatchProcessComplete() 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.BATCH_PROCESS_COMPLETE);

      mVinciClient.send(queryFrame); // oneway call
    } catch (Exception e) {
      throw new ResourceServiceException(e);
    }
View Full Code Here

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

   * @see org.apache.uima.collection.impl.service.CasObjectProcessorServiceStub#callCollectionProcessComplete()
   */
  public void callCollectionProcessComplete() 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.COLLECTION_PROCESS_COMPLETE);

      // make RPC call (no return val)
      mVinciClient.rpc(queryFrame, mTimeout);
    } catch (Exception e) {
      throw new ResourceServiceException(e);
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.