Examples of Discoverable


Examples of com.esri.gpt.catalog.discovery.Discoverable

    // TODO what if this is a Geometry property, also need to validate literals
   
    // initialize
    LOGGER.finer("Parsing property clause for "+parent.getNodeName());
    String sErr = parent.getNodeName();
    Discoverable discoverable = this.parsePropertyName(parent,xpath);
    propertyClause.setTarget(discoverable);
   
    // anytext queries are only supported for PropertyIsLike
    if (discoverable.getMeaning().getMeaningType().equals(PropertyMeaningType.ANYTEXT)) {
      if (!(propertyClause instanceof PropertyClause.PropertyIsLike)) {
        String sPropName = "AnyText";
        Node ndPropName = (Node)xpath.evaluate("ogc:PropertyName",parent,XPathConstants.NODE);
        if (ndPropName != null) {
          sPropName = Val.chkStr(ndPropName.getTextContent());
        }
        String msg = sErr+" - PropertyIsLike is the only supported operand for PropertyName: "+sPropName;
        throw new OwsException(OwsException.OWSCODE_InvalidParameterValue,"PropertyName",msg);
      }
    }

    // between comparison - set lower and upper boundaries
    if (propertyClause instanceof PropertyClause.PropertyIsBetween) {
      PropertyClause.PropertyIsBetween between;
      between = (PropertyClause.PropertyIsBetween)propertyClause;
      Node ndLower = (Node)xpath.evaluate("ogc:LowerBoundary",parent,XPathConstants.NODE);
      Node ndUpper = (Node)xpath.evaluate("ogc:UpperBoundary",parent,XPathConstants.NODE);
      String sLower = "";
      String sUpper = "";
      if ((ndLower == null) && (ndUpper == null)) {
        String msg = sErr+" - a LowerBoundary or UpperBoundary was not found.";
        throw new OwsException(OwsException.OWSCODE_MissingParameterValue,"PropertyIsBetween",msg);
      }
      if (ndLower != null) {
        sLower = ndLower.getTextContent();
        between.setLowerBoundary(sLower);
        // TODO validate content
      }
      if (ndUpper != null) {
        sUpper = ndUpper.getTextContent();
        between.setUpperBoundary(sUpper);
        // TODO validate content
      }
      if ((sLower == null) || (sLower.length() == 0)) {
        if ((sUpper == null) || (sUpper.length() == 0)) {
          String msg = sErr+" - the LowerBoundary and UpperBoundary are empty.";
          throw new OwsException(OwsException.OWSCODE_InvalidParameterValue,"PropertyIsBetween",msg);
        }
      }

      // null check - no literal required
    } else if (propertyClause instanceof PropertyClause.PropertyIsNull) {

      // non-range clauses
    } else {
      Node ndLiteral = (Node)xpath.evaluate("ogc:Literal", parent,XPathConstants.NODE);
      if (ndLiteral == null) {
        String msg = sErr+" - an ogc:Literal was not found.";
        throw new OwsException(OwsException.OWSCODE_MissingParameterValue,"Literal",msg);
      }
      String sLiteral = ndLiteral.getTextContent();
      propertyClause.setLiteral(sLiteral);
      // TODO validate content
      if ((sLiteral == null) || (sLiteral.length() == 0)) {
        String msg = sErr+".ogc:Literal - the supplied literal was empty.";
        throw new OwsException(OwsException.OWSCODE_InvalidParameterValue,"Literal",msg);
      }

      // set like comparison attributes
      if (propertyClause instanceof PropertyClause.PropertyIsLike) {
        PropertyClause.PropertyIsLike like;
        like = (PropertyClause.PropertyIsLike) propertyClause;
        like.setEscapeChar(xpath.evaluate("@escapeChar", parent));
        like.setSingleChar(xpath.evaluate("@singleChar", parent));
        like.setWildCard(xpath.evaluate("@wildCard", parent));
      }
     
      // initialize the language code, (INSPIRE requirement but generally applicable)
      // INSPIRE requirement, specify the language for exceptions in this manner
      // doesn't seem to be a good approach
      if ((this.opContext != null) && (propertyClause instanceof PropertyClause.PropertyIsEqualTo)) {
        if (discoverable.getMeaning().getName().equals("apiso.Language")) {
          if ((sLiteral != null) && (sLiteral.length() > 0)) {
            CapabilityOptions cOptions = this.opContext.getRequestOptions().getCapabilityOptions();
            if (cOptions.getLanguageCode() == null) {
              cOptions.setLanguageCode(sLiteral);
            }
View Full Code Here

Examples of org.apache.twill.discovery.Discoverable

    return new InetSocketAddress(address, port);
  }

  @Override
  protected void run() throws Exception {
    serviceCancellable = discoveryService.register(new Discoverable() {
      @Override
      public String getName() {
        return Constants.Service.EXTERNAL_AUTHENTICATION;
      }
View Full Code Here

Examples of org.apache.twill.discovery.Discoverable

    LOG.info("Starting {}...", ExploreExecutorService.class.getSimpleName());

    exploreService.startAndWait();

    httpService.startAndWait();
    cancellable = discoveryService.register(new Discoverable() {
      @Override
      public String getName() {
        return Constants.Service.EXPLORE_HTTP_USER_SERVICE;
      }
View Full Code Here

Examples of org.apache.twill.discovery.Discoverable

    this.picker = new RandomEndpointStrategy(discoverables);
  }

  @Override
  public Discoverable pick() {
    Discoverable lastPick = this.lastPick;
    if (lastPick == null || !isValid(lastPick)) {
      this.lastPick = lastPick = picker.pick();
    }
    return lastPick;
  }
View Full Code Here

Examples of org.apache.twill.discovery.Discoverable

  }

  @Override
  public Discoverable pick() {
    // Reservoir sampling
    Discoverable result = null;
    Iterator<Discoverable> itor = endpoints.iterator();
    Random random = new Random();
    int count = 0;
    while (itor.hasNext()) {
      Discoverable next = itor.next();
      if (random.nextInt(++count) == 0) {
        result = next;
      }
    }
    return result;
View Full Code Here

Examples of org.apache.twill.discovery.Discoverable

    this.timeoutUnit = timeoutUnit;
  }

  @Override
  public Discoverable pick() {
    Discoverable pick = delegate.pick();
    try {
      long count = 0;
      while (pick == null && count++ < timeout) {
        timeoutUnit.sleep(1);
        pick = delegate.pick();
View Full Code Here

Examples of org.apache.twill.discovery.Discoverable

      JsonArray entryJson = element.getAsJsonArray();
      if (entryJson.size() != 2) {
        throw new JsonParseException("Expect json array of size = 2, got " + entryJson.size());
      }
      Discoverable key = context.deserialize(entryJson.get(0), Discoverable.class);
      PartitionReplica value = context.deserialize(entryJson.get(1), PartitionReplica.class);
      assignments.put(key, value);
    }

    return new ResourceAssignment(name, assignments);
View Full Code Here

Examples of org.apache.twill.discovery.Discoverable

    final String service = jsonObj.get("service").getAsString();
    String hostname = jsonObj.get("hostname").getAsString();
    int port = jsonObj.get("port").getAsInt();
    final InetSocketAddress address = new InetSocketAddress(hostname, port);

    return new Discoverable() {
      @Override
      public String getName() {
        return service;
      }
View Full Code Here

Examples of org.apache.twill.discovery.Discoverable

      this.discoveryService = discoveryService;
    }

    @Override
    public Cancellable announce(final String serviceName, final int port) {
      return discoveryService.register(new Discoverable() {
        @Override
        public String getName() {
          return serviceName;
        }
View Full Code Here

Examples of org.apache.twill.discovery.Discoverable

      public void running() {
        final InetSocketAddress socketAddress = httpService.getBindAddress();
        LOG.info("AppFabric HTTP Service started at {}", socketAddress);

        // When it is running, register it with service discovery
        cancellable = discoveryService.register(new Discoverable() {

          @Override
          public String getName() {
            return Constants.Service.APP_FABRIC_HTTP;
          }
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.