Configuration { public List<String> esArguments(ClusterState clusterState, Protos.DiscoveryInfo discoveryInfo, Protos.SlaveID slaveID) { List<String> args = new ArrayList<>(); List<Protos.TaskInfo> taskList = clusterState.getTaskList(); String hostAddress = ""; if (taskList.size() > 0) { Protos.TaskInfo taskInfo = taskList.get(0); String taskId = taskInfo.getTaskId().getValue(); InetSocketAddress transportAddress = clusterState.getGuiTaskList().get(taskId).getTransportAddress(); hostAddress = NetworkUtils.addressToString(transportAddress, getIsUseIpAddress()).replace("http: } addIfNotEmpty(args, "--default.discovery.zen.ping.unicast.hosts", hostAddress); args.add("--default.http.port=" + discoveryInfo.getPorts().getPorts(Discovery.CLIENT_PORT_INDEX).getNumber()); args.add("--default.transport.tcp.port=" + discoveryInfo.getPorts().getPorts(Discovery.TRANSPORT_PORT_INDEX).getNumber()); args.add("--default.cluster.name=" + getElasticsearchClusterName()); args.add("--default.node.master=true"); args.add("--default.node.data=true"); args.add("--default.node.local=false"); args.add("--default.index.number_of_replicas=0"); args.add("--default.index.auto_expand_replicas=0-all"); if (!isFrameworkUseDocker()) { String taskSpecificDataDir = taskSpecificHostDir(slaveID); args.add("--path.home=" + HOST_PATH_HOME); args.add("--default.path.data=" + taskSpecificDataDir); args.add("--path.conf=" + HOST_PATH_CONF); } else { args.add("--path.data=" + CONTAINER_PATH_DATA); } args.add("--default.bootstrap.mlockall=true"); args.add("--default.network.bind_host=0.0.0.0"); args.add("--default.network.publish_host=_non_loopback:ipv4_"); args.add("--default.gateway.recover_after_nodes=1"); args.add("--default.gateway.expected_nodes=1"); args.add("--default.indices.recovery.max_bytes_per_sec=100mb"); args.add("--default.discovery.type=zen"); args.add("--default.discovery.zen.fd.ping_timeout=30s"); args.add("--default.discovery.zen.fd.ping_interval=1s"); args.add("--default.discovery.zen.fd.ping_retries=30"); args.add("--default.discovery.zen.ping.multicast.enabled=false"); return args; } Configuration(String... args); double getCpus(); double getMem(); double getDisk(); int getElasticsearchNodes(); void setElasticsearchNodes(int numberOfNodes); String getElasticsearchSettingsLocation(); String getElasticsearchClusterName(); int getWebUiPort(); String getVersion(); String getFrameworkName(); String getTaskName(); Map<String, String> getTaskLabels(); String getDataDir(); double getFailoverTimeout(); String getFrameworkRole(); String getExecutorImage(); Boolean getExecutorForcePullImage(); Boolean getIsUseIpAddress(); String getElasticsearchBinary(); String getMesosStateZKURL(); String getMesosZKURL(); ZookeeperCLIParameter getZookeeperCLI(); ElasticsearchCLIParameter getElasticsearchCLI(); String getFrameworkSecretPath(); String getFrameworkPrincipal(); Boolean isFrameworkUseDocker(); String getFrameworkFileServerAddress(); String webUiAddress(); void setFrameworkFileServerAddress(InetSocketAddress addr); String getJavaHome(); List<Integer> getElasticsearchPorts(); String getExternalVolumeDriver(); String getExternalVolumeOption(); String nativeCommand(List<String> arguments); List<String> esArguments(ClusterState clusterState, Protos.DiscoveryInfo discoveryInfo, Protos.SlaveID slaveID); String taskSpecificHostDir(Protos.SlaveID slaveID); String dataVolumeName(Long nodeId); static final String ELASTICSEARCH_CPU; static final String ELASTICSEARCH_RAM; static final String ELASTICSEARCH_DISK; static final String WEB_UI_PORT; static final String FRAMEWORK_NAME; static final String EXECUTOR_NAME; static final String EXECUTOR_LABELS; static final String DATA_DIR; static final String DEFAULT_HOST_DATA_DIR; static final String FRAMEWORK_FAILOVER_TIMEOUT; static final String FRAMEWORK_ROLE; static final String EXECUTOR_IMAGE; static final String EXECUTOR_BINARY; static final String DEFAULT_EXECUTOR_IMAGE; static final String EXECUTOR_FORCE_PULL_IMAGE; static final String FRAMEWORK_PRINCIPAL; static final String FRAMEWORK_SECRET_PATH; static final String ES_TAR; static final String ES_BINARY; static final String FRAMEWORK_USE_DOCKER; static final String JAVA_HOME; static final String USE_IP_ADDRESS; static final String ELASTICSEARCH_PORTS; static final String CONTAINER_PATH_DATA; static final String CONTAINER_PATH_CONF; static final String CONTAINER_PATH_CONF_YML; static final String HOST_SANDBOX; static final String HOST_PATH_HOME; static final String HOST_PATH_CONF; static final String EXTERNAL_VOLUME_DRIVER; static final String EXTERNAL_VOLUME_OPTIONS; }
@Test public void shouldCreateArguments() { Configuration configuration = new Configuration(ZookeeperCLIParameter.ZOOKEEPER_MESOS_URL, "aa"); final ClusterState clusterState = Mockito.mock(ClusterState.class); final int port = 1234; final Protos.DiscoveryInfo discoveryInfo = Protos.DiscoveryInfo.newBuilder().setPorts(Protos.Ports.newBuilder() .addPorts(Protos.Port.newBuilder().setNumber(port)) .addPorts(Protos.Port.newBuilder().setNumber(port))) .setVisibility(Protos.DiscoveryInfo.Visibility.EXTERNAL) .build(); Protos.SlaveID slaveID = Protos.SlaveID.newBuilder().setValue("SLAVE").build(); final List<String> arguments = configuration.esArguments(clusterState, discoveryInfo, slaveID); String allArgs = arguments.toString(); assertTrue(allArgs.contains(Integer.toString(port))); }