当前位置: 首页>>代码示例>>Java>>正文


Java Route类代码示例

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


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


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