public ServiceEndpoint build() { return new ServiceEndpoint(name, protocol); } }
"bar", PortMapping.of(5000, externalPort)); final Map<ServiceEndpoint, ServicePorts> registration = ImmutableMap.of( ServiceEndpoint.of("foo-service", "tcp"), ServicePorts.of("foo"), ServiceEndpoint.of("bar-service", "http"), ServicePorts.of("bar")); final Map<String, String> env = ImmutableMap.of("BAD", "f00d");
builder.endpoint(registration.getName(), registration.getProtocol(), externalPort, fullyQualifiedRegistrationDomain(), host, portParameters.getTags(), endpointHealthCheck(portName));
if (servicePorts == null || servicePorts.getPorts() == null) { errors.add(format("registration for '%s' is malformed: does not have a port mapping", registration.getName())); continue; registration, portName)); if (!REGISTRATION_NAME_PATTERN.matcher(registration.getName()).matches()) { errors.add(format("Invalid service registration name: %s", registration.getName()));
builder.endpoint(registration.getName(), registration.getProtocol(), externalPort, fullyQualifiedRegistrationDomain(), host, portParameters.getTags(), endpointHealthCheck(portName));
"bar", PortMapping.of(5000, externalPort)); final Map<ServiceEndpoint, ServicePorts> registration = ImmutableMap.of( ServiceEndpoint.of("foo-service", "tcp"), ServicePorts.of("foo"), ServiceEndpoint.of("bar-service", "http"), ServicePorts.of("bar")); final Map<String, String> env = ImmutableMap.of(redundantEnvKey, "f00d"); final Map<String, String> volumes = Maps.newHashMap();
public static ServiceEndpoint of(final String service, final String proto) { return new ServiceEndpoint(service, proto); }
"bar", PortMapping.of(5000, externalPort)); final Map<ServiceEndpoint, ServicePorts> registration = ImmutableMap.of( ServiceEndpoint.of("foo-service", "tcp"), ServicePorts.of("foo"), ServiceEndpoint.of("bar-service", "http"), ServicePorts.of("bar")); final String registrationDomain = "my-domain"; final Map<String, String> env = ImmutableMap.of("BAD", "f00d");
explicitRegistration.put(ServiceEndpoint.of(service, proto), ServicePorts.of(port));
/** * Starts a container that listens on a poke port, and once poked listens on the healthcheck * port. */ private Job pokeJob(final HealthCheck healthCheck) { return Job.newBuilder() .setName(testJobName) .setVersion(testJobVersion) .setImage(ALPINE) .setCommand(asList("sh", "-c", "nc -l -p 4711 && nc -lk -p 4712 -e hostname")) .addPort("poke", PortMapping.of(4711)) .addPort("health", PortMapping.of(4712)) .addRegistration(ServiceEndpoint.of("foo_service", "foo_proto"), ServicePorts.of("health")) .setHealthCheck(healthCheck) .build(); }
"bar", PortMapping.of(5000, externalPort)); final Map<ServiceEndpoint, ServicePorts> registration = ImmutableMap.of( ServiceEndpoint.of("foo-service", "tcp"), ServicePorts.of("foo"), ServiceEndpoint.of("bar-service", "http"), ServicePorts.of("bar")); final Map<String, String> env = ImmutableMap.of("BAD", "f00d"); final Job job = statuses.get(jobId).getJob(); assertEquals(ServicePorts.of("foo"), job.getRegistration().get(ServiceEndpoint.of("foo-service", "tcp"))); assertEquals(ServicePorts.of("bar"), job.getRegistration().get(ServiceEndpoint.of("bar-service", "http"))); assertEquals(4711, job.getPorts().get("foo").getInternalPort()); assertEquals(PortMapping.of(5000, externalPort), job.getPorts().get("bar"));
.setCommand(asList("sh", "-c", "nc -l -p 4711")) .addPort(portName, PortMapping.of(4711)) .addRegistration(ServiceEndpoint.of(serviceName, serviceProtocol), ServicePorts.of(portName)) .setHealthCheck(healthCheck)
@Test public void testHttp() throws Exception { startDefaultMaster(); final HeliosClient client = defaultClient(); startDefaultAgent(testHost(), "--service-registry=" + registryAddress); awaitHostStatus(client, testHost(), UP, LONG_WAIT_SECONDS, SECONDS); final HealthCheck healthCheck = HttpHealthCheck.of("http", "/"); // start a container that listens on a poke port, and once poked runs a web server final Job job = Job.newBuilder() .setName(testJobName) .setVersion(testJobVersion) .setImage(NGINX) .setCommand(asList("sh", "-c", "nc -l -p 4711 && nginx -g 'daemon off;'")) .addPort("poke", PortMapping.of(4711)) .addPort("http", PortMapping.of(80)) .addRegistration(ServiceEndpoint.of("foo_service", "foo_proto"), ServicePorts.of("http")) .setHealthCheck(healthCheck) .build(); assertContainerRegistersAfterPoke(client, job); }
public TemporaryJobBuilder registration(final String service, final String protocol, final String... ports) { return registration(ServiceEndpoint.of(service, protocol), ServicePorts.of(ports)); }
explicitRegistration.put(ServiceEndpoint.of(service, proto), ServicePorts.of(port));