diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..cf85b171f --- /dev/null +++ b/.dockerignore @@ -0,0 +1,15 @@ +.metadata + +**/.settings +**/.gitignore +**/*.RELEASE +**/lib/ +**/classes/ + +## Project specific files: +IntegratedAlarmSystemRoot + +#### For exceptions stop ignoring using '!'. E.g: +#### !Cdb/extTools/antlr-2.7.7.jar + +Dockerfile diff --git a/Converter/src/java/org/eso/ias/converter/ConverterKafkaStream.java b/Converter/src/java/org/eso/ias/converter/ConverterKafkaStream.java index c13b464f9..90594a3ef 100644 --- a/Converter/src/java/org/eso/ias/converter/ConverterKafkaStream.java +++ b/Converter/src/java/org/eso/ias/converter/ConverterKafkaStream.java @@ -19,71 +19,71 @@ * The list of kafka servers to connect to and the names of * the input and output topics can be passed by means of * java properties ({@link #ConverterKafkaStream(String, Properties)}) - * or programmatically. - * - * + * or programmatically. + * + * * @author acaproni */ public class ConverterKafkaStream extends ConverterStream { - + /** * The logger */ private static final Logger logger = LoggerFactory.getLogger(ConverterKafkaStream.class); - + /** * The name of the topic where plugins pushes * monitor point values and alarms */ private final String pluginsInputKTopicName; - + /** - * The name of the java property to get the name of the + * The name of the java property to get the name of the * topic where plugins push values */ private static final String PLUGIN_TOPIC_NAME_PROP_NAME = "org.eso.ias.converter.kafka.inputstream"; - + /** * The name of the topic to send values to the core of the IAS */ private final String iasCoreOutputKTopicName; - + /** - * The name of the java property to get thename of the + * The name of the java property to get thename of the * topic where plugins push values */ private static final String IASCORE_TOPIC_NAME_PROP_NAME = "org.eso.ias.converter.kafka.outputstream"; - + /** * The name of the property to pass the kafka servers to connect to */ private static final String KAFKA_SERVERS_PROP_NAME = "org.eso.ias.converter.kafka.servers"; - + /** * Default list of kafka servers to connect to */ private static final String DEFAULTKAFKASERVERS = "localhost:9092"; - + /** * The list of kafka servers to connect to */ private final String kafkaServers; - + /** * Kafka stream builder */ private final StreamsBuilder builder = new StreamsBuilder(); - + /** * The kafka streams */ private KafkaStreams streams; - + /** * The empty constructor gets the kafka servers, and the topics * for the streaming from the passed properties or falls * back to the defaults. - * + * * @param converterID The ID of the converter. * @param props the properties to get kafka serves and topic anmes */ @@ -92,19 +92,19 @@ public ConverterKafkaStream( Properties props) { super(converterID); Objects.requireNonNull(props); - kafkaServers = props.getProperty(KAFKA_SERVERS_PROP_NAME,DEFAULTKAFKASERVERS); + kafkaServers = props.getProperty(KAFKA_SERVERS_PROP_NAME, DEFAULTKAFKASERVERS); pluginsInputKTopicName=props.getProperty(PLUGIN_TOPIC_NAME_PROP_NAME, KafkaHelper.PLUGINS_TOPIC_NAME); iasCoreOutputKTopicName=props.getProperty(IASCORE_TOPIC_NAME_PROP_NAME, KafkaHelper.IASIOs_TOPIC_NAME); - + logger.debug("Will connect to {} to send data from {} to {}", kafkaServers, pluginsInputKTopicName, iasCoreOutputKTopicName); } - + /** * Constructor - * + * * @param converterID The ID of the converter * @param servers The kafka servers to conncet to * @param pluginTopicName The name of the topic to get monitor points from plugins @@ -113,7 +113,7 @@ public ConverterKafkaStream( public ConverterKafkaStream( String converterID, String servers, - String pluginTopicName, + String pluginTopicName, String iasCoreTopicName) { super(converterID); Objects.requireNonNull(servers); @@ -127,10 +127,10 @@ public ConverterKafkaStream( pluginsInputKTopicName, iasCoreOutputKTopicName); } - + /** * Initialize the stream - * + * */ public void init() { logger.debug("Initializing..."); @@ -139,12 +139,12 @@ public void init() { streams = new KafkaStreams(builder.build(), setKafkaProps()); logger.debug("Initialized."); } - - - + + + /** * Set and return the properties for the kafka stream - * + * * @return the properties for the kafka stream */ private Properties setKafkaProps() { @@ -160,7 +160,7 @@ private Properties setKafkaProps() { /** * Start streaming data from the kafka input topic * to the kafka output topic - * + * * @see org.eso.ias.converter.ConverterStream#start() */ @Override @@ -172,7 +172,7 @@ protected void startStreaming() throws ConverterStreamException { /** * Stop streaming data - * + * * @see org.eso.ias.converter.ConverterStream#stop() */ @Override diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..3aae10ce7 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +FROM openjdk:8 + +# Install Apache Ant +RUN apt-get update && apt-get -y install ant ant-contrib + +# Install Scala +RUN wget http://scala-lang.org/files/archive/scala-2.12.1.deb && \ + dpkg -i scala-2.12.1.deb && \ + apt-get update && \ + apt-get -y install scala + +# Install Python 3 +RUN apt-get update && apt-get install python3 -y && \ + update-alternatives --install /usr/bin/python python /usr/bin/python3 1 + +RUN mkdir -p /usr/src/IntegratedAlarmSystemRoot +WORKDIR /usr/src/ias +COPY . /usr/src/ias + +ENV JRE_HOME $JAVA_HOME/jre +ENV SCALA_HOME /usr/share/scala +ENV IAS_ROOT /usr/src/IntegratedAlarmSystemRoot + +RUN bash -c "source Tools/config/ias-bash-profile.sh && ant build" + +ENV PATH $PATH:/usr/src/ias/Tools/bin + +COPY entrypoint.sh /usr/src/ias +ENTRYPOINT ["./entrypoint.sh"] diff --git a/KafkaUtils/src/java/org/eso/ias/kafkautils/KafkaHelper.java b/KafkaUtils/src/java/org/eso/ias/kafkautils/KafkaHelper.java index 06513bf92..d9205c384 100644 --- a/KafkaUtils/src/java/org/eso/ias/kafkautils/KafkaHelper.java +++ b/KafkaUtils/src/java/org/eso/ias/kafkautils/KafkaHelper.java @@ -5,47 +5,47 @@ /** * A helper class providing useful methods and constants for Kafka - * + * * @author acaproni * */ public class KafkaHelper { - + /** * Default list of servers */ public static final String DEFAULT_BOOTSTRAP_BROKERS="localhost:9092"; - + /** * The name of the property to get the list of kafka servers */ public static final String BROKERS_PROPNAME="org.eso.ias.kafka.brokers"; - + /** * The kafka group to which this consumer belongs */ public static final String DEFAULT_CONSUMER_GROUP = "ias.default.consumer.group"; - + /** * The name of the property to get the name of the consumer group */ public static final String CONSUMER_GROUP_PROPNAME="org.eso.ias.kafka.consumer.group"; - + /** * The topic used by plugins to send monitor point values - * and alarms to the converter + * and alarms to the converter */ public static final String PLUGINS_TOPIC_NAME = "PluginsKTopic"; - + /** * The name of the kafka topic where converters and DASUs * push the IASIOs */ public static final String IASIOs_TOPIC_NAME = "BsdbCoreKTopic"; - + /** * Get the value of a property from the system properties - * + * * @param propName the name of the property whose value must be get from the system properties * @param defaultValue the default value if the property is not defined * @return the value of the property @@ -62,12 +62,12 @@ public String getValue(String propName, String defaultValue) { String propValue= System.getProperties().getProperty(propName); return (propValue==null)?defaultValue:propValue; } - + /** * Get the value of a property from the passed properties or, if * not found from the System properties. If the value is not found in both * properties sets then the default is returned. - * + * * @param userProps the user defined properties * @param propName the name of the property to retrieve * @param defaultValue the default value if the property is not found diff --git a/WebServerSender/src/java/org/eso/ias/webserversender/WebServerSender.java b/WebServerSender/src/java/org/eso/ias/webserversender/WebServerSender.java index d4bb21d26..5b185c982 100644 --- a/WebServerSender/src/java/org/eso/ias/webserversender/WebServerSender.java +++ b/WebServerSender/src/java/org/eso/ias/webserversender/WebServerSender.java @@ -141,7 +141,8 @@ public WebServerSender(String senderID, Properties props, WebServerSenderListene kafkaServers = props.getProperty(KAFKA_SERVERS_PROP_NAME,KafkaHelper.DEFAULT_BOOTSTRAP_BROKERS); sendersInputKTopicName = props.getProperty(IASCORE_TOPIC_NAME_PROP_NAME, KafkaHelper.IASIOs_TOPIC_NAME); webserverUri = props.getProperty(WEBSERVER_URI_PROP_NAME, DEFAULT_WEBSERVER_URI); - + logger.info("Websocket connection URI: "+ webserverUri); + logger.info("Kafka server: "+ kafkaServers); senderListener = listener; kafkaConsumer = new KafkaIasiosConsumer(kafkaServers, sendersInputKTopicName, this.senderID); kafkaConsumer.setUp(); diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 000000000..d44e735dd --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +source Tools/config/ias-bash-profile.sh +"${@}" +sleep infinity