Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add name and protocol to discovery info packet. #535

Merged
merged 1 commit into from
Mar 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public Protos.TaskInfo createTask(Configuration configuration, FrameworkState fr
private Protos.TaskInfo buildNativeTask(Protos.Offer offer, Configuration configuration, Clock clock, Long elasticSearchNodeId) {
final List<Integer> ports = getPorts(offer, configuration);
final List<Protos.Resource> resources = getResources(configuration, ports);
final Protos.DiscoveryInfo discovery = getDiscovery(ports);
final Protos.DiscoveryInfo discovery = getDiscovery(ports, configuration);

final String hostAddress = resolveHostAddress(offer, ports);

Expand All @@ -89,7 +89,7 @@ private Protos.TaskInfo buildNativeTask(Protos.Offer offer, Configuration config
private Protos.TaskInfo buildDockerTask(Protos.Offer offer, Configuration configuration, Clock clock, Long elasticSearchNodeId) {
final List<Integer> ports = getPorts(offer, configuration);
final List<Protos.Resource> resources = getResources(configuration, ports);
final Protos.DiscoveryInfo discovery = getDiscovery(ports);
final Protos.DiscoveryInfo discovery = getDiscovery(ports, configuration);

final String hostAddress = resolveHostAddress(offer, ports);

Expand Down Expand Up @@ -135,13 +135,14 @@ private List<Protos.Resource> getResources(Configuration configuration, List<Int
return acceptedResources;
}

private Protos.DiscoveryInfo getDiscovery(List<Integer> ports) {
private Protos.DiscoveryInfo getDiscovery(List<Integer> ports, Configuration configuration) {
Protos.DiscoveryInfo.Builder discovery = Protos.DiscoveryInfo.newBuilder();
Protos.Ports.Builder discoveryPorts = Protos.Ports.newBuilder();
discoveryPorts.addPorts(Discovery.CLIENT_PORT_INDEX, Protos.Port.newBuilder().setNumber(ports.get(0)).setName(Discovery.CLIENT_PORT_NAME));
discoveryPorts.addPorts(Discovery.TRANSPORT_PORT_INDEX, Protos.Port.newBuilder().setNumber(ports.get(1)).setName(Discovery.TRANSPORT_PORT_NAME));
discoveryPorts.addPorts(Discovery.CLIENT_PORT_INDEX, Protos.Port.newBuilder().setNumber(ports.get(0)).setName(Discovery.CLIENT_PORT_NAME).setProtocol("TCP"));
discoveryPorts.addPorts(Discovery.TRANSPORT_PORT_INDEX, Protos.Port.newBuilder().setNumber(ports.get(1)).setName(Discovery.TRANSPORT_PORT_NAME).setProtocol("TCP"));
discovery.setPorts(discoveryPorts);
discovery.setVisibility(Protos.DiscoveryInfo.Visibility.EXTERNAL);
discovery.setName(configuration.getTaskName());
return discovery.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class TaskInfoFactoryTest {
public void before() {
Protos.FrameworkID frameworkId = Protos.FrameworkID.newBuilder().setValue(UUID.randomUUID().toString()).build();
when(frameworkState.getFrameworkID()).thenReturn(frameworkId);
when(configuration.getTaskName()).thenReturn("esdemo");
when(configuration.getTaskName()).thenReturn(Configuration.EXECUTOR_NAME);
when(configuration.getMesosZKURL()).thenReturn("zk://zookeeper:2181/mesos");
when(configuration.getExecutorImage()).thenReturn(Configuration.DEFAULT_EXECUTOR_IMAGE);
when(configuration.getElasticsearchSettingsLocation()).thenReturn(Configuration.HOST_PATH_CONF);
Expand Down