Package org.apache.uima.collection.metadata

Examples of org.apache.uima.collection.metadata.CpeCasProcessors


   */
  private CpeDescription createEmptyCpeDescription() {
    CpeDescription cpeDesc = CpeDescriptorFactory.produceDescriptor();
    // We use CAS pool size default of 3
    try {
      CpeCasProcessors cpeCasProcs = CpeDescriptorFactory.produceCasProcessors();
      cpeDesc.setCpeCasProcessors(cpeCasProcs);
      cpeCasProcs.setPoolSize(3);
    } catch (CpeDescriptorException e) {
      e.printStackTrace(); // this should never happen
    }
    return cpeDesc;
  }
View Full Code Here


        } else {
          isConfigTheSame(refCpeConfig, aGeneratedDescriptor.getCpeConfiguration());

        }
      }
      CpeCasProcessors refCasProcessors = referenceDesc.getCpeCasProcessors();
      if (refCasProcessors != null) {
        if (aGeneratedDescriptor.getCpeCasProcessors() == null) {
          fail("<casProcessors> element not found in generated CPE Descriptor");
        } else {
          compareCasProcessors(referenceDesc.getCpeCasProcessors(), aGeneratedDescriptor
View Full Code Here

                new Object[] { "<casProcessors>", "<cpeDescriptor>" }, new Exception(
                        CpmLocalizedMessage.getLocalizedMessage(CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                                "UIMA_CPM_EXP_bad_cpe_descriptor__WARNING", new Object[] { Thread
                                        .currentThread().getName() })));
      }
      CpeCasProcessors ct = getCpeDescriptor().getCpeCasProcessors();

      CpeCasProcessor[] casProcessorList = ct.getAllCpeCasProcessors();
      Vector v = new Vector();
      if (casProcessorList == null || casProcessorList.length == 0) {
        throw new ResourceConfigurationException(InvalidXMLException.ELEMENT_NOT_FOUND,
                new Object[] { "<casProcessor>", "<casProcessors>" }, new Exception(
                        CpmLocalizedMessage.getLocalizedMessage(CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
View Full Code Here

      int procIndex = 2;
      // First check if casProcessors have been previously been added. If not, add them
      // to a descriptor.
      boolean create = false;
      int numProcessors = 0;
      CpeCasProcessors processorList = getCpeDescriptor().getCpeCasProcessors();
      // Check if added casProcessors using addCasProcessor API. If not create needed
      // casProcessors and add descriptor paths
      if (processorCount == 0) {
        create = true;
        // the list contains two other entires besides casProcessors. Namely collection iterator
        // and cas Initializer. So to get # of casProcessors in the list subtract 2 non-casProcessor
        // entries.
        numProcessors = aList.size() - procIndex;
      } else {
        numProcessors = processorList.getAllCpeCasProcessors().length;
      }
      CpeCasProcessor newProcessor = null;

      // Now add each casProcessor to a descriptor
      for (int i = 0; i < numProcessors; i++) {
        String[] casProcInfo = (String[]) aList.get(procIndex + i);
        if (create) {
          if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
            UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(),
                    "initialize", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                    "UIMA_CPM_create_new_cp_from_list__FINEST",
                    new Object[] { Thread.currentThread().getName(), casProcInfo[0] });
          }
          // The list suppose to contain an array of Strings of size 2.
          // Where the the first element is the name of the CasProcessor
          // and the second is the descriptor path
          if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
            UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(),
                    "initialize", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                    "UIMA_CPM_add_cp_from_list__FINEST",
                    new Object[] { Thread.currentThread().getName(), casProcInfo[0] });
          }
          newProcessor = addCasProcessor(casProcInfo[0]);
        } else {
          newProcessor = processorList.getCpeCasProcessor(i);
        }
        if (newProcessor != null) {
          newProcessor.setDescriptor(casProcInfo[1]);
        }
      }
View Full Code Here

      }
      CpeCollectionReader[] readers = descriptor.getAllCollectionCollectionReaders();
      if (readers != null && readers.length > 0 && readers[0] != null) {
        addCollectionReader(readers[0]);
      }
      CpeCasProcessors cps = descriptor.getCpeCasProcessors();
      if (cps != null) {
        CpeCasProcessor[] casProcessors = cps.getAllCpeCasProcessors();
        for (int i = 0; casProcessors != null && i < casProcessors.length; i++) {
          addCasProcessor(casProcessors[i]);
        }
        if (getCpeCasProcessors() != null) {
          if (cps.getConcurrentPUCount() > 0) {
            getCpeCasProcessors().setConcurrentPUCount(cps.getConcurrentPUCount());
          }
          if (cps.getCasPoolSize() > 0) {
            getCpeCasProcessors().setPoolSize(cps.getCasPoolSize());
          }
          if (cps.getInputQueueSize() > 0) {
            getCpeCasProcessors().setInputQueueSize(cps.getInputQueueSize());
          }
          if (cps.getOutputQueueSize() > 0) {
            getCpeCasProcessors().setOutputQueueSize(cps.getOutputQueueSize());
          }
        }
      }
    } catch (Exception e) {
      throw new InvalidXMLException(e);
View Full Code Here

            cpe);
    // Crate CasInitializer and associate it with the CollectionReader
    CpeDescriptorFactory.produceCollectionReaderCasInitializer(confLocation
            + "casinitializers/WFReaderInitializer.xml", cpe);
    // Create CasProcessors
    CpeCasProcessors processors = CpeDescriptorFactory.produceCasProcessors(2, 4, 3, cpe);
    // Create Detag CasProcessor

    CpeRemoteCasProcessor remoteProcessor = CpeDescriptorFactory
            .produceRemoteCasProcessor("Detag Miner");
    // CpeComponentDescriptor detagDesc =
    // CpeDescriptorFactory.produceComponentDescriptor("c://cpm/annotators/wfminers/detag/service.xml");
    remoteProcessor.setDescriptor("c://cpm/annotators/wfminers/detag/service.xml"); // detagDesc);
    remoteProcessor.addDeployParam("vnsPort", "9003");
    remoteProcessor.addDeployParam("vnsHost", "localhost");
    remoteProcessor.setCasProcessorFilter("where Detag:DetagContent");
    remoteProcessor.setBatchSize(3);
    remoteProcessor.setMaxErrorCount(50);
    remoteProcessor.setMaxErrorSampleSize(500);
    remoteProcessor.setActionOnMaxError("continue");
    remoteProcessor.setMaxRestartCount(3);
    remoteProcessor.setActionOnMaxRestart("continue");
    remoteProcessor.setTimeout(5000);
    remoteProcessor.setCasProcessorFilter("where Detag:DetagContent");
    processors.addCpeCasProcessor(remoteProcessor);

    // Create Detag CasProcessor
    CpeLocalCasProcessor localProcessor = CpeDescriptorFactory.produceLocalCasProcessor(
            "DupShingle Miner", "Detag:DetagContent");
    localProcessor.setDescriptor("c://cpm/annotators/wfminers/detag/descriptor.xml");
    localProcessor
            .setExecutable("/home/cwiklik/cpm/wfcp/annotators/wfminers/detagger/bin/runDetagger.sh");
    localProcessor.addDeployParam("Parm1", "Value1");
    localProcessor.addDeployParam("vnsHost", "Host1");
    localProcessor.addExecArg("-DVNS_HOST=127.0.0.1");
    localProcessor.addExecArg("-DVNS_PORT=9904");
    localProcessor.setCasProcessorFilter("where Detag:DetagContent");
    localProcessor.setBatchSize(3);
    localProcessor.setMaxErrorCount(50);
    localProcessor.setMaxErrorSampleSize(500);
    localProcessor.setActionOnMaxError("continue");
    localProcessor.setMaxRestartCount(3);
    localProcessor.setActionOnMaxRestart("continue");
    localProcessor.setTimeout(5000);
    processors.addCpeCasProcessor(localProcessor);

    CpeIntegratedCasProcessor integratedProcessor = CpeDescriptorFactory
            .produceCasProcessor("WF Writer");
    integratedProcessor.setDescriptor(confLocation + "consumers/wf/store/descriptor.xml");
    integratedProcessor.setBatchSize(100);
    processors.addCpeCasProcessor(integratedProcessor);

    CpeConfiguration config = CpeDescriptorFactory.produceCpeConfiguration(cpe);
    CpeCheckpoint checkpoint = CpeDescriptorFactory.produceCpeCheckpoint();
    checkpoint.setBatchSize(10);
    checkpoint.setFilePath("c://cpm/data/checkpoint.dat");
View Full Code Here

   * test the config of a remote CasProcessor with all possible values set
   *
   * @throws Exception
   */
  public void testAddRemoteCasProcessor() throws Exception {
    CpeCasProcessors processors = cpe.getCpeCasProcessors();

    CpeRemoteCasProcessor remoteProcessor = CpeDescriptorFactory
            .produceRemoteCasProcessor("Detag Miner _2_");
    remoteProcessor.setDescriptor("c://cpm/annotators/dummy.xml");
    remoteProcessor.addDeployParam("vnsPort", "9999");
    remoteProcessor.addDeployParam("vnsHost", "localhost");
    remoteProcessor.setCasProcessorFilter("where Detag:DetagContent_2");
    remoteProcessor.setBatchSize(5);
    remoteProcessor.setMaxErrorCount(51);
    remoteProcessor.setMaxErrorSampleSize(505);
    remoteProcessor.setActionOnMaxError("continue");
    remoteProcessor.setMaxRestartCount(2);
    remoteProcessor.setActionOnMaxRestart("continue");
    remoteProcessor.setTimeout(5002);
    processors.addCpeCasProcessor(remoteProcessor);

    assertEquals("Name", "Detag Miner _2_", remoteProcessor.getName());
    assertEquals("Descriptor()", "c://cpm/annotators/dummy.xml", remoteProcessor.getDescriptor());
    assertEquals("DeploymentParam", "9999",
            ((remoteProcessor.getDeploymentParams()).get("vnsPort")).getParameterValue());
View Full Code Here

   * test the config of a local CasProcessor with all possible values set
   *
   * @throws Exception
   */
  public void testAddLocalCasProcessor() throws Exception {
    CpeCasProcessors processors = cpe.getCpeCasProcessors();

    // Create Detag CasProcessor
    CpeLocalCasProcessor localProcessor = CpeDescriptorFactory.produceLocalCasProcessor(
            "DupShingle Miner", "Detag:DetagContent");
    localProcessor.setDescriptor("c://cpm/annotators/example.xml");
    localProcessor.setExecutable("/some/path/executable.sh");
    localProcessor.addDeployParam("Parm1", "Value1x");
    localProcessor.addDeployParam("vnsHost", "Host1x");
    localProcessor.addExecArg("-DVNS_HOST=localhost");
    localProcessor.addExecArg("-DVNS_PORT=9905");
    localProcessor.setCasProcessorFilter("where Detag:DetagContent");
    localProcessor.setBatchSize(4);
    localProcessor.setMaxErrorCount(52);
    localProcessor.setMaxErrorSampleSize(503);
    localProcessor.setActionOnMaxError("continue");
    localProcessor.setMaxRestartCount(2);
    localProcessor.setActionOnMaxRestart("continue");
    localProcessor.setTimeout(5001);
    processors.addCpeCasProcessor(localProcessor);

    assertEquals("Name", "DupShingle Miner", localProcessor.getName());
    assertEquals("Descriptor()", "c://cpm/annotators/example.xml", localProcessor.getDescriptor());
    assertEquals("DeploymentParam", "Value1x",
            ((localProcessor.getDeploymentParams()).get("Parm1")).getParameterValue());
View Full Code Here

   * test the config of a integrated CasProcessor with all possible values set
   *
   * @throws Exception
   */
  public void testAddIntegratedCasProcessor() throws Exception {
    CpeCasProcessors processors = cpe.getCpeCasProcessors();

    CpeIntegratedCasProcessor integratedProcessor = CpeDescriptorFactory
            .produceCasProcessor("WF Writer_X");
    assertEquals("name", "WF Writer_X", integratedProcessor.getName());
    integratedProcessor.setDescriptor(confLocation + "consumers/bla.xml");
    integratedProcessor.setBatchSize(99);
    assertEquals("BatchSize", 99, integratedProcessor.getBatchSize());
    integratedProcessor.addDeployParam("testversion", "V1.0");
    integratedProcessor.setActionOnMaxError("terminate");
    integratedProcessor.setActionOnMaxRestart("continue");
    integratedProcessor.setBatchSize(25);
    integratedProcessor.setCasProcessorFilter("some filter");
    integratedProcessor.setMaxErrorCount(300);
    integratedProcessor.setMaxErrorSampleSize(100);
    integratedProcessor.setMaxRestartCount(5);
    integratedProcessor.setTimeout(6000);
    integratedProcessor.setName("special name");
    processors.addCpeCasProcessor(integratedProcessor);

    assertEquals("name", "special name", integratedProcessor.getName());
    assertEquals("Descriptor()", confLocation + "consumers/bla.xml", integratedProcessor
            .getDescriptor());
    assertEquals("DeploymentParam", "V1.0", ((integratedProcessor.getDeploymentParams())
View Full Code Here

  public static CpeCasProcessors produceCasProcessors(CpeDescription aDescriptor)
          throws CpeDescriptorException {
    if (aDescriptor == null) {
      aDescriptor = produceDescriptor();
    }
    CpeCasProcessors processors = new CpeCasProcessorsImpl();
    aDescriptor.setCpeCasProcessors(processors);
    return processors;
  }
View Full Code Here

TOP

Related Classes of org.apache.uima.collection.metadata.CpeCasProcessors

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.