Skip to content

Commit

Permalink
Merge branch 'feature/dockerization' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Jazmine committed Mar 16, 2018
2 parents 8bb97ac + 0c42162 commit 952ac8b
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 43 deletions.
15 changes: 15 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.metadata

**/.settings
**/.gitignore
**/*.RELEASE
**/lib/
**/classes/

## Project specific files:
IntegratedAlarmSystemRoot

#### For exceptions stop ignoring using '!<file_to_stop_ignoring>'. E.g:
#### !Cdb/extTools/antlr-2.7.7.jar

Dockerfile
60 changes: 30 additions & 30 deletions Converter/src/java/org/eso/ias/converter/ConverterKafkaStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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
Expand All @@ -113,7 +113,7 @@ public ConverterKafkaStream(
public ConverterKafkaStream(
String converterID,
String servers,
String pluginTopicName,
String pluginTopicName,
String iasCoreTopicName) {
super(converterID);
Objects.requireNonNull(servers);
Expand All @@ -127,10 +127,10 @@ public ConverterKafkaStream(
pluginsInputKTopicName,
iasCoreOutputKTopicName);
}

/**
* Initialize the stream
*
*
*/
public void init() {
logger.debug("Initializing...");
Expand All @@ -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() {
Expand All @@ -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
Expand All @@ -172,7 +172,7 @@ protected void startStreaming() throws ConverterStreamException {

/**
* Stop streaming data
*
*
* @see org.eso.ias.converter.ConverterStream#stop()
*/
@Override
Expand Down
29 changes: 29 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
24 changes: 12 additions & 12 deletions KafkaUtils/src/java/org/eso/ias/kafkautils/KafkaHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 5 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

source Tools/config/ias-bash-profile.sh
"${@}"
sleep infinity

0 comments on commit 952ac8b

Please sign in to comment.