@Override public String toString() { StringBuilder sb = new StringBuilder(); if (host != null) { sb.append(host).append(":"); } if (exposed.getExposed() != bound) { sb.append(bound).append("->"); } sb.append(exposed.getExposed()).append("/").append(exposed.getType()); return sb.toString(); } }
@Override public String toString() { StringBuilder sb = new StringBuilder(); if (host != null) { sb.append(host).append(":"); } if (exposed.getExposed() != bound) { sb.append(bound).append("->"); } sb.append(exposed.getExposed()).append("/").append(exposed.getType()); return sb.toString(); } }
bound = exposed.getExposed();
bound = exposed.getExposed();
@Override public void populateProxies() { Proxy proxy = proxyInst.get(); ToxiProxyScenario scenario = scenarioInst.get(); if (scenario == null) { throw new IllegalStateException("Scenario is not Initiated. Proxy not started before others."); } for (Relation rel : proxy.getRelations()) { String relName = rel.getFrom() + ":" + rel.getPort().getExposed(); String localExp = "0.0.0.0:" + rel.getPort().getExposed(); String remoteExp = rel.getTo() + ":" + rel.getPort().getExposed(); System.out.println("Registered proxy " + relName + " " + localExp + " -> " + remoteExp); scenario.register( relName, localExp, remoteExp); } }
private Set<ExposedPort> resolveExposedPorts(CubeContainer containerConfiguration, CreateContainerCmd createContainerCmd) { Set<ExposedPort> allExposedPorts = new HashSet<>(); if (containerConfiguration.getPortBindings() != null) { for (PortBinding binding : containerConfiguration.getPortBindings()) { allExposedPorts.add(new ExposedPort(binding.getExposedPort().getExposed(), InternetProtocol.parse(binding.getExposedPort().getType()))); } } if (containerConfiguration.getExposedPorts() != null) { for (org.arquillian.cube.docker.impl.client.config.ExposedPort port : containerConfiguration.getExposedPorts()) { allExposedPorts.add(new ExposedPort(port.getExposed(), InternetProtocol.parse(port.getType()))); } } return allExposedPorts; }
private Set<ExposedPort> resolveExposedPorts(CubeContainer containerConfiguration, CreateContainerCmd createContainerCmd) { Set<ExposedPort> allExposedPorts = new HashSet<>(); if (containerConfiguration.getPortBindings() != null) { for (PortBinding binding : containerConfiguration.getPortBindings()) { allExposedPorts.add(new ExposedPort(binding.getExposedPort().getExposed(), InternetProtocol.parse(binding.getExposedPort().getType()))); } } if (containerConfiguration.getExposedPorts() != null) { for (org.arquillian.cube.docker.impl.client.config.ExposedPort port : containerConfiguration.getExposedPorts()) { allExposedPorts.add(new ExposedPort(port.getExposed(), InternetProtocol.parse(port.getType()))); } } return allExposedPorts; }
if (portBindings != null) { for (PortBinding portBinding : portBindings) { if (portBinding.getExposedPort().getExposed() == exposedPort) { if (noPreviousBindPortFound(portBindInfo)) { int bindPort = portBinding.getBound(); portBindInfo = new PortBindInfo( portBinding.getExposedPort().getExposed(), bindPort, cubeContainerEntry.getKey()); } else {
if (portBindings != null) { for (PortBinding portBinding : portBindings) { if (portBinding.getExposedPort().getExposed() == exposedPort) { if (noPreviousBindPortFound(portBindInfo)) { int bindPort = portBinding.getBound(); portBindInfo = new PortBindInfo( portBinding.getExposedPort().getExposed(), bindPort, cubeContainerEntry.getKey()); } else {
.iterator().next(); int bindPort = portBinding.getBound(); int exposedPort = portBinding.getExposedPort().getExposed(); portBindInfo = new PortBindInfo(exposedPort, bindPort, cubeContainerEntry.getKey()); } else {
.iterator().next(); int bindPort = portBinding.getBound(); int exposedPort = portBinding.getExposedPort().getExposed(); portBindInfo = new PortBindInfo(exposedPort, bindPort, cubeContainerEntry.getKey()); } else {
public static Binding binding(CubeContainer cubeConfiguration, DockerClientExecutor executor) { Binding binding = new Binding(executor.getDockerServerIp()); if (cubeConfiguration.getPortBindings() != null) { for (PortBinding cubePortBinding : cubeConfiguration.getPortBindings()) { binding.addPortBinding(cubePortBinding.getExposedPort().getExposed(), cubePortBinding.getBound()); } } return binding; } }
public static Binding binding(CubeContainer cubeConfiguration, DockerClientExecutor executor) { Binding binding = new Binding(executor.getDockerServerIp()); if (cubeConfiguration.getPortBindings() != null) { for (PortBinding cubePortBinding : cubeConfiguration.getPortBindings()) { binding.addPortBinding(cubePortBinding.getExposedPort().getExposed(), cubePortBinding.getBound()); } } return binding; } }
private Ports toPortBindings(Collection<PortBinding> portBindings) { Ports ports = new Ports(); for (PortBinding portBinding : portBindings) { ports.bind( new ExposedPort( portBinding.getExposedPort().getExposed(), InternetProtocol.parse(portBinding.getExposedPort().getType())), new Binding(portBinding.getHost(), Integer.toString(portBinding.getBound()))); } return ports; }
@Override public boolean matches(Object item){ if (item instanceof PortBinding) { PortBinding portBinding = (PortBinding) item; return portBinding.getExposedPort().getExposed() == 4444 && portBinding.getBound() >= 49152 && portBinding.getBound() < 65535; } return false; } };
private Ports toPortBindings(Collection<PortBinding> portBindings) { Ports ports = new Ports(); for (PortBinding portBinding : portBindings) { ports.bind( new ExposedPort( portBinding.getExposedPort().getExposed(), InternetProtocol.parse(portBinding.getExposedPort().getType())), new Binding(portBinding.getHost(), Integer.toString(portBinding.getBound()))); } return ports; }
@Override public void proxyStarted(Cube<?> cube) { Proxy proxy = proxyInst.get(); if (!cube.hasMetadata(HasPortBindings.class)) { throw new IllegalStateException("Proxy Cube " + proxy.getName() + " has no PortBinding data."); } HasPortBindings bindings = cube.getMetadata(HasPortBindings.class); PortAddress communicationPort = bindings.getMappedAddress(proxy.getCommunicationPort().getExposed()); scenarioInst.set(new ToxiProxyScenario(ToxiProxyClient.Builder.create(communicationPort.getIP(), communicationPort.getPort()), injectorInstance.get())); }
final ExposedPort exposedPort = portBinding.getExposedPort(); if (exposedPort != null) { builder.containerExpose(link.getName(), exposedPort.getExposed(), exposedPort.getType()); if (exposedPorts != null) { for (ExposedPort exposedPort : exposedPorts) { builder.containerExpose(link.getName(), exposedPort.getExposed(), exposedPort.getType()); Collection<PortBinding> ports = data.getPortBindings(); for (PortBinding binding : ports) { builder.containerBinds(cubeName, binding.getBound(), binding.getExposedPort().getExposed(), binding.getExposedPort().getType()); removedBoundPorts.add(binding); Collection<ExposedPort> ports = data.getExposedPorts(); for (ExposedPort port : ports) { builder.containerExpose(cubeName, port.getExposed(), port.getType());
Assert.assertEquals(8089, exposedPort.getExposed()); Assert.assertEquals("tcp", exposedPort.getType()); PortBinding portBinding1 = portBindingIterator.next(); PortBinding portBinding2 = portBindingIterator.next(); Assert.assertEquals(1521, portBinding1.getExposedPort().getExposed()); Assert.assertEquals("tcp", portBinding1.getExposedPort().getType()); Assert.assertEquals(81, portBinding2.getExposedPort().getExposed()); Assert.assertEquals("tcp", portBinding2.getExposedPort().getType());