io.fabric8.openshift.api.model.Route类的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(9.3k)|赞(0)|评价(0)|浏览(165)

本文整理了Java中io.fabric8.openshift.api.model.Route类的一些代码示例,展示了Route类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Route类的具体详情如下:
包路径:io.fabric8.openshift.api.model.Route
类名称:Route

Route介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

import spark.Request;
import spark.Response;
import spark.Route;
import spark.Spark;

public class HelloWorldSparkStyle {
  public static void main(String[] args){

    Spark.get("/", new Route() {
        public Object handle(final Request request, final Response response){
        return "Hello World from Spark";
      }
    });
  }
}

代码示例来源:origin: stackoverflow.com

final Route route = new Route();
    route.setName(leg.getString("start_address") + " to " + leg.getString("end_address"));
    route.setCopyright(jsonRoute.getString("copyrights"));
    route.setLength(leg.getJSONObject("distance").getInt("value"));
        route.setWarning(jsonRoute.getJSONArray("warnings").getString(0));
        route.addPoints(decodePolyLine(step.getJSONObject("polyline").getString("points")));
        route.addSegment(segment.copy());

代码示例来源:origin: org.domeos/kubernetes-model

public RouteBuilder(Route instance,Boolean validationEnabled){
    this.fluent = this; 
    this.withApiVersion(instance.getApiVersion()); 
    this.withKind(instance.getKind()); 
    this.withMetadata(instance.getMetadata()); 
    this.withSpec(instance.getSpec()); 
    this.withStatus(instance.getStatus()); 
    this.validationEnabled = validationEnabled; 
}

代码示例来源:origin: fabric8io/kubernetes-client

@Override
public String getURL(Service service, String portName, String namespace, KubernetesClient client) {
 String serviceName = service.getMetadata().getName();
 ServicePort port = URLFromServiceUtil.getServicePortByName(service, portName);
 if(port != null && port.getName() != null && isOpenShift(client)) {
  try {
   String serviceProtocol = port.getProtocol();
   OpenShiftClient openShiftClient = client.adapt(OpenShiftClient.class);
   Route route = openShiftClient.routes().inNamespace(namespace).withName(service.getMetadata().getName()).get();
   if (route != null) {
    return (serviceProtocol + "://" + route.getSpec().getHost()).toLowerCase();
   }
  } catch (KubernetesClientException e) {
   if(e.getCode() == HttpURLConnection.HTTP_FORBIDDEN) {
    logger.warn("Could not lookup route:" + serviceName + " in namespace:"+ namespace +", due to: " + e.getMessage());
   }
  }
 }
 return null;
}

代码示例来源:origin: org.eclipse.che.infrastructure/infrastructure-openshift

private void validateRoutesMatchServices(OpenShiftEnvironment env) throws ValidationException {
  Set<String> recipeServices =
    env.getServices()
      .values()
      .stream()
      .map(s -> s.getMetadata().getName())
      .collect(Collectors.toSet());
  for (Route route : env.getRoutes().values()) {
   if (route.getSpec() == null
     || route.getSpec().getTo() == null
     || !route.getSpec().getTo().getKind().equals(SERVICE_KIND)) {
    continue;
   }
   String serviceName = route.getSpec().getTo().getName();
   if (!recipeServices.contains(serviceName)) {
    throw new ValidationException(
      String.format(
        "Route '%s' refers to Service '%s'. Routes must refer to Services included in recipe",
        route.getMetadata().getName(), serviceName));
   }
  }
 }
}

代码示例来源:origin: stackoverflow.com

Route route = new Route();
Scanner scanner = new Scanner(System.in);
route.setName(name);
route.setStartLocation(startDest);
route.setEndLocation(endDest);
  route.setStopList(new ArrayList<String>());
for(int i = 1; i<=numberOfStops; i++){
  route.getStopList().add(scanner.next());

代码示例来源:origin: fabric8io/fabric8-maven-plugin

private Route createRouteForService(String routeDomainPostfix, String namespace, Service service) {
  Route route = null;
  String id = KubernetesHelper.getName(service);
  if (StringUtils.isNotBlank(id) && hasExactlyOneService(service, id)) {
    route = new Route();
    ObjectMeta routeMeta = KubernetesHelper.getOrCreateMetadata(route);
    routeMeta.setName(id);
    routeMeta.setNamespace(namespace);
    RouteSpec routeSpec = new RouteSpec();
    RouteTargetReference objectRef = new RouteTargetReferenceBuilder().withName(id).build();
    //objectRef.setNamespace(namespace);
    routeSpec.setTo(objectRef);
    if (StringUtils.isNotBlank(routeDomainPostfix)) {
      routeSpec.setHost(prepareHostForRoute(routeDomainPostfix, id));
    } else {
      routeSpec.setHost("");
    }
    route.setSpec(routeSpec);
    String json;
    try {
      json = ResourceUtil.toJson(route);
    } catch (JsonProcessingException e) {
      json = e.getMessage() + ". object: " + route;
    }
    log.debug("Created route: " + json);
  }
  return route;
}

代码示例来源:origin: stackoverflow.com

Route route = new Route();
     route.setCna( "cnavalue" );

代码示例来源:origin: stackoverflow.com

Route route = new Route(); double distance = route.getDistance();

代码示例来源:origin: stackoverflow.com

Stop s=new Stop(po,nLiters);
   Route r=new Route(1);
   r.addStop(s);

代码示例来源:origin: stackoverflow.com

ArrayList<LatLng> allatlng = new ArrayList<LatLng>();
         LatLng latlng = new LatLng(Double.parseDouble(strDestlat), Double.parseDouble(strDestlng));
         allatlng.add(latlng);
         LatLng latlng1 = new LatLng(Double.parseDouble(strCurrentLat), Double.parseDouble(strCurrentLong));
         allatlng.add(latlng1);
         Route route = new Route();
         route.drawRoute(googleMap, Home.this, allatlng, true, Route.LANGUAGE_ENGLISH, true);

代码示例来源:origin: org.eclipse.che.infrastructure/infrastructure-openshift

public OpenShiftServerResolver(List<Service> services, List<Route> routes) {
 super(services, Collections.emptyList());
 this.routes = ArrayListMultimap.create();
 for (Route route : routes) {
  String machineName =
    Annotations.newDeserializer(route.getMetadata().getAnnotations()).machineName();
  this.routes.put(machineName, route);
 }
}

代码示例来源:origin: stackoverflow.com

public class Navigator
{
  private GPS gps;
  private UserInterface ui;

  public Navigator(UserInterface ui, GPS gps) {
    this.ui = ui;
    this.gps = gps;
  }

  public void display() {
    String destination = ui.getDestEntry().getText();
    Route theRoute = new Route(gps.getLocation(), destination);
    theRoute.calculateRoute();
    MapView theMap = new MapView();
    theMap.plot(theRoute);
  }
}

public class GPS {
  public String getLocation() { ... }
}

代码示例来源:origin: strimzi/strimzi-kafka-operator

/**
   * Checks if the Route already has an assigned address.
   *
   * @param namespace The namespace.
   * @param name The route name.
   */
  public boolean isAddressReady(String namespace, String name) {
    Resource<Route, DoneableRoute> resourceOp = operation().inNamespace(namespace).withName(name);
    Route resource = resourceOp.get();

    if (resource != null && resource.getStatus() != null && resource.getStatus().getIngress() != null && resource.getStatus().getIngress().size() > 0) {
      if (resource.getStatus().getIngress().get(0).getHost() != null) {
        return true;
      }
    }

    return false;
  }
}

代码示例来源:origin: org.apache.stratos/kubernetes-model

public RouteBuilder( RouteFluent<?> fluent , Route instance ){
  this.fluent = fluent; fluent.withApiVersion(instance.getApiVersion()); fluent.withKind(instance.getKind()); fluent.withMetadata(instance.getMetadata()); fluent.withSpec(instance.getSpec()); fluent.withStatus(instance.getStatus()); 
}
public RouteBuilder( Route instance ){

代码示例来源:origin: io.fabric8.pipeline/kubernetes-pipeline-devops-steps

private String serviceNameFromRoute(Route route) {
  if(route.getSpec() != null && route.getSpec().getTo() != null && route.getSpec().getTo().getKind().equals("Service")) {
    return route.getSpec().getTo().getName();
  } else {
    return null;
  }
}

代码示例来源:origin: org.eclipse.che.infrastructure/infrastructure-openshift

private void fillRouteServers(Route route, Map<String, ServerImpl> servers) {
  Annotations.newDeserializer(route.getMetadata().getAnnotations())
    .servers()
    .forEach(
      (name, config) ->
        servers.put(
          name,
          newServer(
            config.getProtocol(),
            route.getSpec().getHost(),
            null,
            config.getPath(),
            config.getAttributes())));
 }
}

代码示例来源:origin: stackoverflow.com

final Route route = new Route();
    route.setName(leg.getString("start_address") + " to " + leg.getString("end_address"));
    route.setCopyright(jsonRoute.getString("copyrights"));
    route.setLength(leg.getJSONObject("distance").getInt("value"));
        route.setWarning(jsonRoute.getJSONArray("warnings").getString(0));
        route.addPoints(decodePolyLine(step.getJSONObject("polyline").getString("points")));
        route.addSegment(segment.copy());

代码示例来源:origin: io.fabric8/fabric8-arquillian

public static Route createRouteForService(String routeDomainPostfix, String namespace, Service service, Logger log) {
  Route route = null;
  String id = KubernetesHelper.getName(service);
  if (Strings.isNotBlank(id) && shouldCreateRouteForService(log, service, id)) {
    route = new Route();
    String routeId = id;
    KubernetesHelper.setName(route, namespace, routeId);
    RouteSpec routeSpec = new RouteSpec();
    RouteTargetReference objectRef = new RouteTargetReferenceBuilder().withName(id).build();
    //objectRef.setNamespace(namespace);
    routeSpec.setTo(objectRef);
    if (Strings.isNotBlank(routeDomainPostfix)) {
      // Let Openshift determine the route host when the domain is not set
      String host = Strings.stripSuffix(Strings.stripSuffix(id, "-service"), ".");
      String namespaceSuffix = "-" + namespace;
      routeSpec.setHost(host + namespaceSuffix + "." + Strings.stripPrefix(routeDomainPostfix, "."));
    }
    route.setSpec(routeSpec);
    String json = null;
    try {
      json = KubernetesHelper.toJson(route);
    } catch (JsonProcessingException e) {
      json = e.getMessage() + ". object: " + route;
    }
  }
  return route;
}

代码示例来源:origin: stackoverflow.com

void marshal() throws Exception {
  Route route = new Route();
  route.setCna( "cnavalue" );
  JAXBContext jc = JAXBContext.newInstance( Route.class );
  Marshaller m = jc.createMarshaller();
  m.setProperty( "jaxb.fragment", true );
  StringWriter sw = new StringWriter();
  m.marshal( route, sw );
  System.out.println( sw.toString() );
}

相关文章