• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Route类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中io.fabric8.openshift.api.model.Route的典型用法代码示例。如果您正苦于以下问题:Java Route类的具体用法?Java Route怎么用?Java Route使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Route类属于io.fabric8.openshift.api.model包,在下文中一共展示了Route类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: setup

import io.fabric8.openshift.api.model.Route; //导入依赖的package包/类
@BeforeClass
public static void setup() throws IOException {
    OpenShiftClient oc = new DefaultOpenShiftClient();
    List<Route> routes = oc.routes().inNamespace(oc.getNamespace()).list().getItems();

    String ssoAuthUrl = routes.stream()
            .filter(r -> "secure-sso".equals(r.getMetadata().getName()))
            .findFirst()
            .map(r -> "https://" + r.getSpec().getHost())
            .orElseThrow(() -> new IllegalStateException("Couldn't find secure-sso route"));

    InputStream configStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("keycloak.json");
    if (configStream == null) {
        throw new IllegalStateException("Could not find any keycloak.json file in classpath.");
    }
    System.setProperty("sso.auth.server.url", ssoAuthUrl);
    Configuration config = JsonSerialization.readValue(configStream, Configuration.class, true);
    authzClient = AuthzClient.create(config);

    applicationUrls = routes.stream()
            .filter(r -> r.getMetadata().getName().contains("secured"))
            .map(r -> "http://" + r.getSpec().getHost())
            .collect(toList());

}
 
开发者ID:obsidian-toaster-quickstarts,项目名称:redhat-sso,代码行数:26,代码来源:SsoIT.java


示例2: getUrl

import io.fabric8.openshift.api.model.Route; //导入依赖的package包/类
public String getUrl(final OpenShiftClient client, final String namespace) throws RouteNotFoundException {
    Route route = getRouteByName(client, namespace, cheRoute);
    if (route == null) {
        LOG.warn("Route '" + cheRoute + "' not found. Trying to get '" + cheHostRoute + "' route");
        route = getRouteByName(client, namespace, cheHostRoute);
    }
    if (route != null) {
        String host = route.getSpec().getHost();
        String protocol = getProtocol(route);
        LOG.info("Host '{}' has been found", host);
        LOG.info("Route protocol '{}'", protocol);
        return protocol + "://" + host;
    }
    throw new RouteNotFoundException(
            "Routes '" + cheRoute + "'/'" + cheHostRoute + "' not found in '" + namespace + "' namespace");
}
 
开发者ID:redhat-developer,项目名称:che-starter,代码行数:17,代码来源:CheServerRoute.java


示例3: createRestRoute

import io.fabric8.openshift.api.model.Route; //导入依赖的package包/类
public Route createRestRoute() {

		final Route route = new RouteBuilder()
					.withNewMetadata()
						.withName("syndesis-rest")
					.endMetadata()
					.withNewSpec()
						.withPath("/api").withHost("rest-" + TestConfiguration.openShiftNamespace() + "." + TestConfiguration.syndesisUrlSuffix())
						.withWildcardPolicy("None")
						.withNewTls()
							.withTermination("edge")
						.endTls()
						.withNewTo()
							.withKind("Service").withName("syndesis-rest")
						.endTo()
					.endSpec()
				.build();

		return withDefaultUser(client -> client.resource(route).createOrReplace());
	}
 
开发者ID:syndesisio,项目名称:syndesis-qe,代码行数:21,代码来源:OpenShiftUtils.java


示例4: checkRepositoryAvailability

import io.fabric8.openshift.api.model.Route; //导入依赖的package包/类
/**
 * Check if a maven artifact repository is running in Openshift.
 * Repository is searched for under a route with name 'maven'.
 *
 * @return true if http GET on route's host URL returns 200, false otherwise
 */
public static boolean checkRepositoryAvailability() {
	Optional<Route> routeOptional = OpenshiftUtil.getInstance().withAdminUser(x -> x.routes().inNamespace("test-infra").list().getItems()).stream()
			.filter(r -> r.getSpec().getHost().startsWith("maven"))
			.findAny();

	if(routeOptional.isPresent()) {
		try {
			HttpUtil.httpGet("http://"+routeOptional.get().getSpec().getHost());
		} catch(Exception e) {
			return false;
		}
	} else {
		return false;
	}
	return true;
}
 
开发者ID:xtf-cz,项目名称:xtf,代码行数:23,代码来源:MavenUtil.java


示例5: provision

import io.fabric8.openshift.api.model.Route; //导入依赖的package包/类
@Override
public void provision(OpenShiftEnvironment osEnv, RuntimeIdentity identity)
    throws InfrastructureException {
  final String workspaceId = identity.getWorkspaceId();
  final Set<Pod> pods = new HashSet<>(osEnv.getPods().values());
  osEnv.getPods().clear();
  for (Pod pod : pods) {
    final ObjectMeta podMeta = pod.getMetadata();
    putLabel(pod, Constants.CHE_ORIGINAL_NAME_LABEL, podMeta.getName());
    final String podName = Names.uniquePodName(podMeta.getName(), workspaceId);
    podMeta.setName(podName);
    osEnv.getPods().put(podName, pod);
  }
  final Set<Route> routes = new HashSet<>(osEnv.getRoutes().values());
  osEnv.getRoutes().clear();
  for (Route route : routes) {
    final ObjectMeta routeMeta = route.getMetadata();
    putLabel(route, Constants.CHE_ORIGINAL_NAME_LABEL, routeMeta.getName());
    final String routeName = Names.uniqueRouteName();
    routeMeta.setName(routeName);
    osEnv.getRoutes().put(routeName, route);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:24,代码来源:UniqueNamesProvisioner.java


示例6: createPods

import io.fabric8.openshift.api.model.Route; //导入依赖的package包/类
/**
 * Creates OpenShift pods and resolves machine servers based on routes and services.
 *
 * @param services created OpenShift services
 * @param routes created OpenShift routes
 * @throws InfrastructureException when any error occurs while creating OpenShift pods
 */
@VisibleForTesting
void createPods(List<Service> services, List<Route> routes) throws InfrastructureException {
  final ServerResolver serverResolver = ServerResolver.of(services, routes);
  final OpenShiftEnvironment environment = getContext().getEnvironment();
  final Map<String, InternalMachineConfig> machineConfigs = environment.getMachines();
  for (Pod toCreate : environment.getPods().values()) {
    final Pod createdPod = project.pods().create(toCreate);
    final ObjectMeta podMetadata = createdPod.getMetadata();
    for (Container container : createdPod.getSpec().getContainers()) {
      String machineName = Names.machineName(toCreate, container);
      OpenShiftMachine machine =
          new OpenShiftMachine(
              machineName,
              podMetadata.getName(),
              container.getName(),
              serverResolver.resolve(machineName),
              project,
              MachineStatus.STARTING,
              machineConfigs.get(machineName).getAttributes());
      machines.put(machine.getName(), machine);
      sendStartingEvent(machine.getName());
    }
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:32,代码来源:OpenShiftInternalRuntime.java


示例7: build

import io.fabric8.openshift.api.model.Route; //导入依赖的package包/类
private Route build() {
  io.fabric8.openshift.api.model.RouteBuilder builder =
      new io.fabric8.openshift.api.model.RouteBuilder();

  return builder
      .withNewMetadata()
      .withName(name.replace("/", "-"))
      .withAnnotations(
          Annotations.newSerializer()
              .servers(serversConfigs)
              .machineName(machineName)
              .annotations())
      .endMetadata()
      .withNewSpec()
      .withNewTo()
      .withName(serviceName)
      .endTo()
      .withNewPort()
      .withTargetPort(targetPort)
      .endPort()
      .endSpec()
      .build();
}
 
开发者ID:eclipse,项目名称:che,代码行数:24,代码来源:ServerExposer.java


示例8: testResolvingServersWhenThereIsNoTheCorrespondingServiceAndRouteForTheSpecifiedMachine

import io.fabric8.openshift.api.model.Route; //导入依赖的package包/类
@Test
public void
    testResolvingServersWhenThereIsNoTheCorrespondingServiceAndRouteForTheSpecifiedMachine() {
  // given
  Service nonMatchedByPodService =
      createService("nonMatched", "foreignMachine", CONTAINER_PORT, null);
  Route route =
      createRoute(
          "nonMatched",
          "foreignMachine",
          ImmutableMap.of(
              "http-server", new ServerConfigImpl("3054", "http", "/api", ATTRIBUTES_MAP)));

  ServerResolver serverResolver =
      ServerResolver.of(singletonList(nonMatchedByPodService), singletonList(route));

  // when
  Map<String, ServerImpl> resolved = serverResolver.resolve("machine");

  // then
  assertTrue(resolved.isEmpty());
}
 
开发者ID:eclipse,项目名称:che,代码行数:23,代码来源:ServerResolverTest.java


示例9: testResolvingServersWhenThereIsMatchedRouteForTheSpecifiedMachine

import io.fabric8.openshift.api.model.Route; //导入依赖的package包/类
@Test
public void testResolvingServersWhenThereIsMatchedRouteForTheSpecifiedMachine() {
  Route route =
      createRoute(
          "matched",
          "machine",
          ImmutableMap.of(
              "http-server", new ServerConfigImpl("3054", "http", "/api", ATTRIBUTES_MAP)));

  ServerResolver serverResolver = ServerResolver.of(emptyList(), singletonList(route));

  Map<String, ServerImpl> resolved = serverResolver.resolve("machine");

  assertEquals(resolved.size(), 1);
  assertEquals(
      resolved.get("http-server"),
      new ServerImpl()
          .withUrl("http://localhost/api")
          .withStatus(UNKNOWN)
          .withAttributes(ATTRIBUTES_MAP));
}
 
开发者ID:eclipse,项目名称:che,代码行数:22,代码来源:ServerResolverTest.java


示例10: testResolvingServersWhenThereIsMatchedRouteForMachineAndServerPathIsNull

import io.fabric8.openshift.api.model.Route; //导入依赖的package包/类
@Test
public void testResolvingServersWhenThereIsMatchedRouteForMachineAndServerPathIsNull() {
  Route route =
      createRoute(
          "matched",
          "machine",
          singletonMap(
              "http-server", new ServerConfigImpl("3054", "http", null, ATTRIBUTES_MAP)));

  ServerResolver serverResolver = ServerResolver.of(emptyList(), singletonList(route));

  Map<String, ServerImpl> resolved = serverResolver.resolve("machine");

  assertEquals(resolved.size(), 1);
  assertEquals(
      resolved.get("http-server"),
      new ServerImpl()
          .withUrl("http://localhost")
          .withStatus(UNKNOWN)
          .withAttributes(ATTRIBUTES_MAP));
}
 
开发者ID:eclipse,项目名称:che,代码行数:22,代码来源:ServerResolverTest.java


示例11: testResolvingServersWhenThereIsMatchedRouteForMachineAndServerPathIsEmpty

import io.fabric8.openshift.api.model.Route; //导入依赖的package包/类
@Test
public void testResolvingServersWhenThereIsMatchedRouteForMachineAndServerPathIsEmpty() {
  Route route =
      createRoute(
          "matched",
          "machine",
          singletonMap("http-server", new ServerConfigImpl("3054", "http", "", ATTRIBUTES_MAP)));

  ServerResolver serverResolver = ServerResolver.of(emptyList(), singletonList(route));

  Map<String, ServerImpl> resolved = serverResolver.resolve("machine");

  assertEquals(resolved.size(), 1);
  assertEquals(
      resolved.get("http-server"),
      new ServerImpl()
          .withUrl("http://localhost")
          .withStatus(UNKNOWN)
          .withAttributes(ATTRIBUTES_MAP));
}
 
开发者ID:eclipse,项目名称:che,代码行数:21,代码来源:ServerResolverTest.java


示例12: testResolvingServersWhenThereIsMatchedRouteForMachineAndServerPathIsRelative

import io.fabric8.openshift.api.model.Route; //导入依赖的package包/类
@Test
public void testResolvingServersWhenThereIsMatchedRouteForMachineAndServerPathIsRelative() {
  Route route =
      createRoute(
          "matched",
          "machine",
          singletonMap(
              "http-server", new ServerConfigImpl("3054", "http", "api", ATTRIBUTES_MAP)));

  ServerResolver serverResolver = ServerResolver.of(emptyList(), singletonList(route));

  Map<String, ServerImpl> resolved = serverResolver.resolve("machine");

  assertEquals(resolved.size(), 1);
  assertEquals(
      resolved.get("http-server"),
      new ServerImpl()
          .withUrl("http://localhost/api")
          .withStatus(UNKNOWN)
          .withAttributes(ATTRIBUTES_MAP));
}
 
开发者ID:eclipse,项目名称:che,代码行数:22,代码来源:ServerResolverTest.java


示例13: testResolvingInternalServers

import io.fabric8.openshift.api.model.Route; //导入依赖的package包/类
@Test
public void testResolvingInternalServers() {
  Service service =
      createService(
          "service11",
          "machine",
          CONTAINER_PORT,
          singletonMap(
              "http-server", new ServerConfigImpl("3054", "http", "api", ATTRIBUTES_MAP)));
  Route route = createRoute("matched", "machine", null);

  ServerResolver serverResolver = ServerResolver.of(singletonList(service), singletonList(route));

  Map<String, ServerImpl> resolved = serverResolver.resolve("machine");

  assertEquals(resolved.size(), 1);
  assertEquals(
      resolved.get("http-server"),
      new ServerImpl()
          .withUrl("http://service11:3054/api")
          .withStatus(UNKNOWN)
          .withAttributes(ATTRIBUTES_MAP));
}
 
开发者ID:eclipse,项目名称:che,代码行数:24,代码来源:ServerResolverTest.java


示例14: testResolvingInternalServersWithPortWithTransportProtocol

import io.fabric8.openshift.api.model.Route; //导入依赖的package包/类
@Test
public void testResolvingInternalServersWithPortWithTransportProtocol() {
  Service service =
      createService(
          "service11",
          "machine",
          CONTAINER_PORT,
          singletonMap(
              "http-server", new ServerConfigImpl("3054/udp", "xxx", "api", ATTRIBUTES_MAP)));
  Route route = createRoute("matched", "machine", null);

  ServerResolver serverResolver = ServerResolver.of(singletonList(service), singletonList(route));

  Map<String, ServerImpl> resolved = serverResolver.resolve("machine");

  assertEquals(resolved.size(), 1);
  assertEquals(
      resolved.get("http-server"),
      new ServerImpl()
          .withUrl("xxx://service11:3054/api")
          .withStatus(UNKNOWN)
          .withAttributes(ATTRIBUTES_MAP));
}
 
开发者ID:eclipse,项目名称:che,代码行数:24,代码来源:ServerResolverTest.java


示例15: createRoute

import io.fabric8.openshift.api.model.Route; //导入依赖的package包/类
private Route createRoute(
    String name, String machineName, Map<String, ServerConfigImpl> servers) {
  Serializer serializer = Annotations.newSerializer();
  serializer.machineName(machineName);
  if (servers != null) {
    serializer.servers(servers);
  }
  return new RouteBuilder()
      .withNewMetadata()
      .withName(name)
      .withAnnotations(serializer.annotations())
      .endMetadata()
      .withNewSpec()
      .withHost(ROUTE_HOST)
      .withNewTo()
      .withName(name)
      .endTo()
      .endSpec()
      .build();
}
 
开发者ID:eclipse,项目名称:che,代码行数:21,代码来源:ServerResolverTest.java


示例16: getRuntimeEndpoint

import io.fabric8.openshift.api.model.Route; //导入依赖的package包/类
public OpenShiftRuntimeEndpoint getRuntimeEndpoint(String id) throws OpenShiftClientException {
    try {
        OpenShiftRuntimeId runtimeId = OpenShiftRuntimeId.fromString(id);
        String prjName = runtimeId.project();
        String svcName = runtimeId.service();
        OpenShiftRuntimeEndpoint endpoint = new OpenShiftRuntimeEndpoint();
        Route route = delegate.routes().inNamespace(prjName).withName(svcName).get();
        if (route != null) {
            RouteSpec routeSpec = route.getSpec();
            endpoint.setProtocol(routeSpec.getTls() != null ? "https" : "http");
            endpoint.setHost(routeSpec.getHost());
            RoutePort routePort = routeSpec.getPort();
            if (routePort != null) {
                IntOrString targetPort = routePort.getTargetPort();
                if (targetPort != null) {
                    endpoint.setPort(targetPort.getIntVal());
                }
            }
        }
        return endpoint;
    } catch (Throwable t) {
        throw new OpenShiftClientException(t.getMessage(), t);
    }
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:25,代码来源:OpenShiftClient.java


示例17: setRoutes

import io.fabric8.openshift.api.model.Route; //导入依赖的package包/类
public static void setRoutes(RouteList routeList, String routerHost) {
    InetAddress routerAddr;
    try {
        routerAddr = routerHost == null ? null : InetAddress.getByName(routerHost);
    } catch (UnknownHostException e) {
        throw new IllegalArgumentException("Invalid IP for router host", e);
    }
    if (routeList != null) {
        synchronized (ROUTING) {
            for (Route route : routeList.getItems()) {
                String host = route.getSpec().getHost();
                if (routerAddr != null) {
                    System.out.println(String.format("Adding route (router -> host): %s -> %s", routerHost, host));
                    ROUTING.put(host, routerAddr);
                } else {
                    ROUTING.remove(host);
                }
            }
        }
    }
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:22,代码来源:OpenShiftNameService.java


示例18: getRoute

import io.fabric8.openshift.api.model.Route; //导入依赖的package包/类
public Route getRoute(final String name) {
	List<Route> candidates = getRoutesNamedWithPrefix(name).collect(Collectors.toList());
	if (candidates.size() == 1) {
		return candidates.get(0);
	}
	throw new IllegalArgumentException("Cannot find unique route, there is " + candidates.size() + "candidate(s)");
}
 
开发者ID:xtf-cz,项目名称:xtf,代码行数:8,代码来源:OpenshiftUtil.java


示例19: build

import io.fabric8.openshift.api.model.Route; //导入依赖的package包/类
@Override
public Route build() {
	RouteSpecBuilder spec = new RouteSpecBuilder()
			.withHost(hostName)
			.withNewTo()
			.withKind("Service")
			.withName(serviceName)
			.endTo();

	if (targetPort != 0) {
		spec.withNewPort().withNewTargetPort(targetPort).endPort();
	}

	if (tlsType != TLSType.NONE) {
		TLSConfigBuilder tls = new TLSConfigBuilder()
				.withTermination(tlsType.toString().toLowerCase());

		if (StringUtils.isNotBlank(routeKey)) {
			tls.withKey(routeKey);
		}
		if (StringUtils.isNotBlank(routeCertificate)) {
			tls.withCertificate(routeCertificate);
		}
		if (StringUtils.isNotBlank(routeCA)) {
			tls.withCaCertificate(routeCA);
		}
		if (StringUtils.isNotBlank(serverCA)) {
			tls.withDestinationCACertificate(serverCA);
		}
		spec.withTls(tls.build());
	}

	return new io.fabric8.openshift.api.model.RouteBuilder()
			.withMetadata(metadataBuilder().build())
			.withSpec(spec.build())
			.build();
}
 
开发者ID:xtf-cz,项目名称:xtf,代码行数:38,代码来源:RouteBuilder.java


示例20: routeToEndpoint

import io.fabric8.openshift.api.model.Route; //导入依赖的package包/类
private Endpoint routeToEndpoint(Route route) {
    String secretName = route.getMetadata().getAnnotations().get(AnnotationKeys.CERT_SECRET_NAME);
    Endpoint.Builder builder = new Endpoint.Builder()
            .setName(route.getMetadata().getName())
            .setHost(route.getSpec().getHost())
            .setPort(443)
            .setService(route.getSpec().getTo().getName());

    if (secretName != null) {
        builder.setCertProvider(new SecretCertProvider(secretName));
    }

    return builder.build();
}
 
开发者ID:EnMasseProject,项目名称:enmasse,代码行数:15,代码来源:Controller.java



注:本文中的io.fabric8.openshift.api.model.Route类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FileWriteTask类代码示例发布时间:2022-05-22
下一篇:
Java DigitalChannel类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap