Package org.apache.uima.resource

Examples of org.apache.uima.resource.ResourceConfigurationException


        URL descriptorUrl = aCasProcessorConfiguration.getDescriptorUrl();
        String descriptorPath;
        try {
          descriptorPath = UriUtils.quote(descriptorUrl).getPath();
        } catch (URISyntaxException e) {
          throw new ResourceConfigurationException(e);
        }
        cmdArgs.add("\"" + descriptorPath + "\"");
      } else {
        cmdArgs.add(arg);
      }
View Full Code Here


          argList.add(args[i]);
        }

      }
    } catch (Exception e) {
      throw new ResourceConfigurationException(e);
    }
  }
View Full Code Here

              UIMAFramework.getLogger(this.getClass()).logrb(Level.SEVERE,
                      this.getClass().getName(), "initialize", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                      "UIMA_CPM_cp_no_name__SEVERE",
                      new Object[] { Thread.currentThread().getName() });
            }
            throw new ResourceConfigurationException(
                    InvalidXMLException.REQUIRED_ATTRIBUTE_MISSING, new Object[] { "name",
                        "casProcessor" }, new Exception(CpmLocalizedMessage.getLocalizedMessage(
                            CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                            "UIMA_CPM_EXP_missing_attribute_from_xml_element__WARNING",
                            new Object[] { Thread.currentThread().getName(), "n/a", "name",
                                "casProcessor" })));
          }
        } else {
          // Assumption is that the container already exists and it contains CasProcessor
          // configuration
          casProcessorConfig = processingContainer.getCasProcessorConfiguration();
          if (casProcessorConfig == null) {
            throw new ResourceConfigurationException(InvalidXMLException.ELEMENT_NOT_FOUND,
                    new Object[] { "<casProcessor>", "<casProcessors>" }, new Exception(
                            CpmLocalizedMessage.getLocalizedMessage(
                                    CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                                    "UIMA_CPM_EXP_bad_cpe_descriptor_no_cp__WARNING",
                                    new Object[] { Thread.currentThread().getName() })));
          }
        }
        // Add CasProcess to the instance pool
        casProcessorPool.addCasProcessor(casProcessor);

        if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
          UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(),
                  "initialize", CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_deploying_cp__FINEST",
                  new Object[] { Thread.currentThread().getName(), name });
        }
      }

    } catch (ResourceConfigurationException e) {
      e.printStackTrace();
      throw e;
    } catch (Exception e) {
      e.printStackTrace();
      throw new ResourceConfigurationException(ResourceServiceException.RESOURCE_UNAVAILABLE,
              new Object[] {}, e);
    }
    return processingContainer;
  }
View Full Code Here

    } catch (ResourceConfigurationException e) {
      e.printStackTrace();
      throw e;
    } catch (Exception e) {
      e.printStackTrace();
      throw new ResourceConfigurationException(ResourceServiceException.RESOURCE_UNAVAILABLE,
              new Object[] {}, e);
    }
  }
View Full Code Here

          }
        }

        // Check if CasProcesser has been instantiated
        if (casProcessor == null) {
          throw new ResourceConfigurationException(ResourceServiceException.RESOURCE_UNAVAILABLE,
                  new Object[] {}, new Exception(CpmLocalizedMessage.getLocalizedMessage(
                          CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                          "UIMA_CPM_EXP_instantiation_exception__WARNING", new Object[] {
                              Thread.currentThread().getName(), "Integrated Cas Processor" })));
        }
      }
    } catch (ResourceConfigurationException e) {
      throw e;
    } catch (Exception e) {
      e.printStackTrace();
      throw new ResourceConfigurationException(ResourceServiceException.RESOURCE_UNAVAILABLE,
              new Object[] {}, new Exception(CpmLocalizedMessage.getLocalizedMessage(
                      CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                      "UIMA_CPM_EXP_instantiation_exception__WARNING", new Object[] {
                          Thread.currentThread().getName(), "Integrated Cas Processor" })));
    }
View Full Code Here

    if (Constants.DEPLOYMENT_LOCAL.equals(deployMode)) {
      return new VinciCasProcessorDeployer(aCpeFactory);
    } else if (Constants.DEPLOYMENT_REMOTE.equals(deployMode)) {
      String protocol = getProtocol(aCasProcessorConfig, aCpeFactory.getResourceManager());
      if (protocol == null || protocol.trim().length() == 0) {
        throw new ResourceConfigurationException(CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                "UIMA_CPM_invalid_service_descriptor__SEVERE", new Object[] {
                    Thread.currentThread().getName(), "<uriSpecifier>", "<protocol>" },
                new Exception(CpmLocalizedMessage.getLocalizedMessage(
                        CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                        "UIMA_CPM_EXP_invalid_service_descriptor__WARNING", new Object[] {
                            Thread.currentThread().getName(), aCasProcessorConfig.getName() })));
      } else if (Constants.SOCKET_PROTOCOL.equalsIgnoreCase(protocol)) {
        if (aPca == null) {
          throw new ResourceConfigurationException(
                  ResourceInitializationException.CONFIG_SETTING_ABSENT,
                  new Object[] { "ProcessControllerAdapter" });
        }
        return new SocketCasProcessorDeployer(aPca, aCpeFactory);
      } else {
        // Default is still Vinci
        return new VinciCasProcessorDeployer(aCpeFactory);
      }
    } else if (Constants.DEPLOYMENT_INTEGRATED.equals(deployMode)) {
      return new CPEDeployerDefaultImpl(aCpeFactory);
    }
    throw new ResourceConfigurationException(InvalidXMLException.REQUIRED_ATTRIBUTE_MISSING,
            new Object[] { "deployment", "casProcessor" }, new Exception(CpmLocalizedMessage
                    .getLocalizedMessage(CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                            "UIMA_CPM_Exception_invalid_deployment__WARNING", new Object[] {
                                Thread.currentThread().getName(), aCasProcessorConfig.getName(),
                                deployMode })));
View Full Code Here

              new XMLInputSource(clientServiceDescriptor));
      if (resourceSpecifier instanceof URISpecifier) {
        return ((URISpecifier) resourceSpecifier).getProtocol();
      }
    } catch (Exception e) {
      throw new ResourceConfigurationException(e);
    }
    return null;
  }
View Full Code Here

      UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(),
              "initialize", CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_deploy_services__FINEST",
              Thread.currentThread().getName());
    }
    if (controller == null) {
      throw new ResourceConfigurationException(
              ResourceInitializationException.CONFIG_SETTING_ABSENT,
              new Object[] { "ProcessControllerAdapter" });
    }
    try {
      // Launch one instance of fenced CasProcessor per pipeline -Adam
      serviceUrls = controller.deploy(name, aCasProcessorList.size());

      ServiceProxyPool casProcessorPool = new ServiceProxyPool();
      // Deploy one Cas Processor at a time in sequential order
      for (int i = 0; i < aCasProcessorList.size(); i++) {
        cProcessor = (CasProcessor) aCasProcessorList.get(i);
        // Container may have already been instantiated. This will be the case if the CPM is
        // configured for concurrent
        // processing ( more than one processing pipeline). There is only one container per
        // CasProcessor type.
        // So each instance of the same CasProcessor will be associated with a single container.
        // Inside the
        // container instances are pooled. When deploying the very first CasProcessor of each type,
        // the
        // container will be created and initialized. Any subsequent deployments of this
        // CasProcessor will
        // simply use it, and will be added to this container's instance pool.
        if (processingContainer == null) {
          ProcessingResourceMetaData metaData = cProcessor.getProcessingResourceMetaData();
          CpeCasProcessor casProcessorType = (CpeCasProcessor) cpeFactory.casProcessorConfigMap
                  .get(metaData.getName());
          // Create a pool to hold instances of CasProcessors. Instances are managed by a container
          // through
          // getCasProcessor() and releaseProcessor() methods.
          // Create CasProcess Configuration holding info defined in the CPE descriptor
          casProcessorConfig = new CasProcessorConfigurationJAXBImpl(casProcessorType, cpeFactory.getResourceManager());

          // Associate CasProcessor configuration from CPE descriptor with this container
          processingContainer = new ProcessingContainer_Impl(casProcessorConfig, metaData,
                  casProcessorPool);
          processingContainer.setCasProcessorDeployer(this);
          processingContainer.setSingleFencedService(true);
          // Instantiate an object that encapsulates CasProcessor configuration
          // Determine deployment model for this CasProcessor
          // Each CasProcessor must have a name
          name = casProcessorConfig.getName();
          if (name == null) {
            if (UIMAFramework.getLogger().isLoggable(Level.SEVERE)) {
              UIMAFramework.getLogger(this.getClass()).logrb(Level.SEVERE,
                      this.getClass().getName(), "initialize", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                      "UIMA_CPM_unable_to_read_meta__SEVERE", Thread.currentThread().getName());
            }
            throw new ResourceConfigurationException(CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                    "UIMA_CPM_casprocessor_no_name_found__SEVERE", new Object[] { Thread
                            .currentThread().getName() });
          }
        }
        if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
          UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(),
                  "initialize", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                  "UIMA_CPM_deploying_service__FINEST",
                  new Object[] { Thread.currentThread().getName(), name });
        }
        // Launch one instance of the fenced CasProcessor
        // URL[] urls = controller.deploy(name, 1); //Commented out by Adam -- deployment is now
        // done outside of loop
        if (cProcessor instanceof CasObjectNetworkCasProcessorImpl) {
          ((CasObjectNetworkCasProcessorImpl) cProcessor).connect(serviceUrls[i]);
          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_deployed__FINEST",
                    new Object[] { Thread.currentThread().getName(), name });
          }
        }
        // Add CasProcess to the instance pool
        casProcessorPool.addCasProcessor(cProcessor);
      }

      // There is one instance of ProcessingContainer for set of CasProcessors
      if (processingContainer == null) {
        throw new ResourceConfigurationException(CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                "UIMA_CPM_invalid_container__SEVERE", new Object[] { Thread.currentThread()
                        .getName() });
      }
      // Assumption is that the container already exists and it contains CasProcessor configuration
      casProcessorConfig = processingContainer.getCasProcessorConfiguration();
      if (casProcessorConfig == null) {
        throw new ResourceConfigurationException(CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                "UIMA_CPM_container_configuration_not_found__SEVERE", new Object[] { Thread
                        .currentThread().getName() });
      }
    } catch (ResourceConfigurationException e) {
      if (UIMAFramework.getLogger().isLoggable(Level.SEVERE)) {
        UIMAFramework.getLogger(this.getClass()).log(Level.SEVERE, e.getMessage(), e);
      }
      throw e;
    } catch (Exception e) {
      if (UIMAFramework.getLogger().isLoggable(Level.SEVERE)) {
        UIMAFramework.getLogger(this.getClass()).log(Level.SEVERE, e.getMessage(), e);
      }
      throw new ResourceConfigurationException(e);
    }
    return processingContainer;
  }
View Full Code Here

                            CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                            "UIMA_CPM_no_service_proxy__SEVERE",
                            new Object[] { Thread.currentThread().getName(),
                                aProcessingContainer.getName() });
          }
          throw new ResourceConfigurationException(CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                  "UIMA_CPM_no_service_proxy__SEVERE", new Object[] {
                      Thread.currentThread().getName(), aProcessingContainer.getName() });

        }
        int totalPoolSize = pool.getAllInstanceCount();
        while (totalPoolSize != pool.getSize()) {
          try {
            if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
              UIMAFramework.getLogger(this.getClass()).logrb(
                      Level.SEVERE,
                      this.getClass().getName(),
                      "initialize",
                      CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                      "UIMA_CPM_wait_for_service_proxy_pool__FINEST",
                      new Object[] { Thread.currentThread().getName(),
                          aProcessingContainer.getName() });
            }
            pool.wait()// pool has notifyall when it changes the pool.getSize() result
          } catch (Exception e) {
          }
        }
        CasProcessor cProcessor = pool.checkOut();
        if (cProcessor != null && cProcessor instanceof CasObjectNetworkCasProcessorImpl) {

          URL undeployUrl = ((CasObjectNetworkCasProcessorImpl) cProcessor).getEndpoint();
          undeploy(undeployUrl);
          pool.checkIn(cProcessor);
          cProcessor = null;
          if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
            UIMAFramework.getLogger(this.getClass())
                    .logrb(
                            Level.SEVERE,
                            this.getClass().getName(),
                            "initialize",
                            CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                            "UIMA_CPM_deploying_service__FINEST",
                            new Object[] { Thread.currentThread().getName(),
                                aProcessingContainer.getName() });

          }
          // Launch fenced CasProcessor instances (the same number as totalPoolSize)
          serviceUrls = controller.deploy(aProcessingContainer.getName(), totalPoolSize);
          LinkedList casProcessors = new LinkedList();
          // Checkout ALL CasProcessors from the Pool and reconnect them with the fenced service
          try {
            for (int i = 0; i < totalPoolSize; i++) {
              cProcessor = pool.checkOut();
              ((CasObjectNetworkCasProcessorImpl) cProcessor).connect(serviceUrls[i]);
              casProcessors.add(cProcessor);
            }
          } catch (Exception e) {
            if (UIMAFramework.getLogger().isLoggable(Level.SEVERE)) {
              UIMAFramework.getLogger(this.getClass()).log(Level.SEVERE, e.getMessage(), e);
            }
            throw e;
          } finally {
            // Now check ALL CasProcessor back into the pool
            while (casProcessors.size() > 0) {
              cProcessor = (CasProcessor) casProcessors.remove(0);
              pool.checkIn(cProcessor);
            }
          }
        }
      }
    } catch (Exception e) {
      if (UIMAFramework.getLogger().isLoggable(Level.SEVERE)) {
        UIMAFramework.getLogger(this.getClass()).log(Level.SEVERE, e.getMessage(), e);
      }
      throw new ResourceConfigurationException(e);
    }
  }
View Full Code Here

   *
   * @throws ConfigurationException -
   */
  private void checkForErrors() throws ResourceConfigurationException {
    if (cpeDescriptor == null) {
      throw new ResourceConfigurationException(new Exception(CpmLocalizedMessage
              .getLocalizedMessage(CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                      "UIMA_CPM_EXP_no_cpe_descriptor__WARNING", new Object[] { Thread
                              .currentThread().getName() })));
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.uima.resource.ResourceConfigurationException

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.