KKcorps commented on a change in pull request #7026: URL: https://github.com/apache/incubator-pinot/pull/7026#discussion_r648614370
########## File path: pinot-plugins/pinot-stream-ingestion/pinot-pulsar/src/test/java/org/apache/pinot/plugin/stream/pulsar/PulsarStandaloneCluster.java ########## @@ -0,0 +1,115 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.pinot.plugin.stream.pulsar; + +import java.io.File; +import org.apache.commons.io.FileUtils; + + +public class PulsarStandaloneCluster { + public static final Integer DEFAULT_BROKER_PORT = 6650; + public static final Integer DEFAULT_ADMIN_PORT = 8080; + public static final String DEFAULT_DATA_MOUNT_DIRECTORY = "pulsar-data"; + public static final String DEFAULT_CONF_MOUNT_DIRECTORY = "pulsar-conf"; + public static final String DOCKER_CONTAINER_NAME = "pulsar_standalone_pinot"; + + private Integer _brokerPort; + private Integer _adminPort; + private String _dataMountDirectory; + private String _confMountDirectory; + + private Process _pulsarCluster; + + public static final String DOCKER_COMMAND = + "docker run --name " + DOCKER_CONTAINER_NAME + " -p %d:%d -p %d:%d " + " --mount source=pulsardata,target=%s" + + " --mount source=pulsarconf,target=%s " + " apachepulsar/pulsar:2.7.2 bin/pulsar standalone"; + + public static final String DOCKER_STOP_COMMAND = "docker stop " + DOCKER_CONTAINER_NAME; + public static final String DOCKER_REMOVE_COMMAND = "docker rm " + DOCKER_CONTAINER_NAME; + + public PulsarStandaloneCluster() { + + } + + public void setBrokerPort(Integer brokerPort) { + _brokerPort = brokerPort; + } + + public void setAdminPort(Integer adminPort) { + _adminPort = adminPort; + } + + public Integer getBrokerPort() { + Integer brokerPort = _brokerPort == null ? DEFAULT_BROKER_PORT : _brokerPort; + return brokerPort; + } + + public Integer getAdminPort() { + Integer adminPort = _adminPort == null ? DEFAULT_ADMIN_PORT : _adminPort; + return adminPort; + } + + public void setDataMountDirectory(String dataMountDirectory) { + _dataMountDirectory = dataMountDirectory; + } + + public void setConfMountDirectory(String confMountDirectory) { + _confMountDirectory = confMountDirectory; + } + + public void start() + throws Exception { + Integer brokerPort = _brokerPort == null ? DEFAULT_BROKER_PORT : _brokerPort; + Integer adminPort = _adminPort == null ? DEFAULT_ADMIN_PORT : _adminPort; + String dataMountDirectory = _dataMountDirectory == null ? DEFAULT_DATA_MOUNT_DIRECTORY : _dataMountDirectory; + String confMountDirectory = _confMountDirectory == null ? DEFAULT_CONF_MOUNT_DIRECTORY : _confMountDirectory; + + File tempDir = FileUtils.getTempDirectory(); + File dataDir = new File(tempDir, dataMountDirectory); + File confDir = new File(tempDir, confMountDirectory); + dataDir.mkdirs(); + confDir.mkdirs(); + + String formattedCommand = String + .format(DOCKER_COMMAND, brokerPort, brokerPort, adminPort, adminPort, dataDir.getAbsolutePath(), + confDir.getAbsolutePath()); + + _pulsarCluster = Runtime.getRuntime().exec(formattedCommand); + + Thread.sleep(30000); + } + + public void stop() + throws Exception { Review comment: done ########## File path: pinot-plugins/pinot-stream-ingestion/pinot-pulsar/src/test/java/org/apache/pinot/plugin/stream/pulsar/PulsarStandaloneCluster.java ########## @@ -0,0 +1,115 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.pinot.plugin.stream.pulsar; + +import java.io.File; +import org.apache.commons.io.FileUtils; + + +public class PulsarStandaloneCluster { + public static final Integer DEFAULT_BROKER_PORT = 6650; + public static final Integer DEFAULT_ADMIN_PORT = 8080; + public static final String DEFAULT_DATA_MOUNT_DIRECTORY = "pulsar-data"; + public static final String DEFAULT_CONF_MOUNT_DIRECTORY = "pulsar-conf"; + public static final String DOCKER_CONTAINER_NAME = "pulsar_standalone_pinot"; + + private Integer _brokerPort; + private Integer _adminPort; + private String _dataMountDirectory; + private String _confMountDirectory; + + private Process _pulsarCluster; + + public static final String DOCKER_COMMAND = + "docker run --name " + DOCKER_CONTAINER_NAME + " -p %d:%d -p %d:%d " + " --mount source=pulsardata,target=%s" + + " --mount source=pulsarconf,target=%s " + " apachepulsar/pulsar:2.7.2 bin/pulsar standalone"; + + public static final String DOCKER_STOP_COMMAND = "docker stop " + DOCKER_CONTAINER_NAME; + public static final String DOCKER_REMOVE_COMMAND = "docker rm " + DOCKER_CONTAINER_NAME; + + public PulsarStandaloneCluster() { + + } + + public void setBrokerPort(Integer brokerPort) { + _brokerPort = brokerPort; + } + + public void setAdminPort(Integer adminPort) { + _adminPort = adminPort; + } + + public Integer getBrokerPort() { + Integer brokerPort = _brokerPort == null ? DEFAULT_BROKER_PORT : _brokerPort; + return brokerPort; + } + + public Integer getAdminPort() { + Integer adminPort = _adminPort == null ? DEFAULT_ADMIN_PORT : _adminPort; + return adminPort; + } + + public void setDataMountDirectory(String dataMountDirectory) { + _dataMountDirectory = dataMountDirectory; + } + + public void setConfMountDirectory(String confMountDirectory) { + _confMountDirectory = confMountDirectory; + } + + public void start() + throws Exception { + Integer brokerPort = _brokerPort == null ? DEFAULT_BROKER_PORT : _brokerPort; + Integer adminPort = _adminPort == null ? DEFAULT_ADMIN_PORT : _adminPort; + String dataMountDirectory = _dataMountDirectory == null ? DEFAULT_DATA_MOUNT_DIRECTORY : _dataMountDirectory; + String confMountDirectory = _confMountDirectory == null ? DEFAULT_CONF_MOUNT_DIRECTORY : _confMountDirectory; + + File tempDir = FileUtils.getTempDirectory(); + File dataDir = new File(tempDir, dataMountDirectory); + File confDir = new File(tempDir, confMountDirectory); + dataDir.mkdirs(); + confDir.mkdirs(); + + String formattedCommand = String + .format(DOCKER_COMMAND, brokerPort, brokerPort, adminPort, adminPort, dataDir.getAbsolutePath(), + confDir.getAbsolutePath()); + + _pulsarCluster = Runtime.getRuntime().exec(formattedCommand); + + Thread.sleep(30000); Review comment: not required now. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org