TaskInfoFactory { public Protos.TaskInfo createTask(Configuration configuration, FrameworkState frameworkState, Protos.Offer offer, Clock clock) { long elasticSearchNodeId = configuration.getExternalVolumeDriver() != null && configuration.getExternalVolumeDriver().length() > 0 ? clusterState.getElasticNodeId() : ExecutorEnvironmentalVariables.EXTERNAL_VOLUME_NOT_CONFIGURED; LOGGER.debug("Elastic Search Node Id: " + elasticSearchNodeId); if (configuration.isFrameworkUseDocker()) { LOGGER.debug("Building Docker task"); Protos.TaskInfo taskInfo = buildDockerTask(offer, configuration, clock, elasticSearchNodeId); LOGGER.debug(taskInfo.toString()); return taskInfo; } else { LOGGER.debug("Building native task"); Protos.TaskInfo taskInfo = buildNativeTask(offer, configuration, clock, elasticSearchNodeId); LOGGER.debug(taskInfo.toString()); return taskInfo; } } TaskInfoFactory(ClusterState clusterState); Protos.TaskInfo createTask(Configuration configuration, FrameworkState frameworkState, Protos.Offer offer, Clock clock); ByteString toData(String hostname, String ipAddress, ZonedDateTime zonedDateTime); static Task parse(Protos.TaskInfo taskInfo, Protos.TaskStatus taskStatus, Clock clock); static final String TASK_DATE_FORMAT; }
@Test public void shouldAllowUserRequestForFixedHttpAndRandomTransportPort() { when(configuration.getElasticsearchPorts()).thenReturn(Arrays.asList(123, 0)); TaskInfoFactory factory = new TaskInfoFactory(clusterState); Protos.TaskInfo taskInfo = factory.createTask(configuration, frameworkState, getOffer(frameworkState.getFrameworkID()), new Clock()); assertTrue(taskInfo.isInitialized()); assertTrue(taskInfo.toString().contains("123")); assertTrue(taskInfo.toString().contains("9200")); }
@Test public void shouldAllowUserRequestForRandomHttpAndFixedTransportPort() { when(configuration.getElasticsearchPorts()).thenReturn(Arrays.asList(0, 456)); TaskInfoFactory factory = new TaskInfoFactory(clusterState); Protos.TaskInfo taskInfo = factory.createTask(configuration, frameworkState, getOffer(frameworkState.getFrameworkID()), new Clock()); assertTrue(taskInfo.isInitialized()); assertTrue(taskInfo.toString().contains("9200")); assertTrue(taskInfo.toString().contains("456")); }
@Test public void shouldAllowUserSpecifiedPorts() { when(configuration.getElasticsearchPorts()).thenReturn(Arrays.asList(123, 456)); TaskInfoFactory factory = new TaskInfoFactory(clusterState); Protos.TaskInfo taskInfo = factory.createTask(configuration, frameworkState, getOffer(frameworkState.getFrameworkID()), new Clock()); assertTrue(taskInfo.isInitialized()); assertTrue(taskInfo.toString().contains("123")); assertTrue(taskInfo.toString().contains("456")); }
@Test public void shouldAllowUserRequestForRandomHttpAndTransportPorts() { when(configuration.getElasticsearchPorts()).thenReturn(Arrays.asList(0, 0)); TaskInfoFactory factory = new TaskInfoFactory(clusterState); Protos.TaskInfo taskInfo = factory.createTask(configuration, frameworkState, getOffer(frameworkState.getFrameworkID()), new Clock()); assertTrue(taskInfo.isInitialized()); assertTrue(taskInfo.toString().contains("9200")); assertTrue(taskInfo.toString().contains("9300")); }