Commit 1e232b2a authored by Waleed Akbar's avatar Waleed Akbar
Browse files

Changes in Analytics and KpiValueAPI:

- Changed `StartAnalyzer` return type to `AnalyzerId`.
- Added `APScheduler` to requirements.
- Updated `AnalyticsBackend` Dockerfile to set `JAVA_HOME`.
- Added `Alarms` topic in the Kafka class.
parent ad695f99
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -53,6 +53,15 @@ RUN python3 -m grpc_tools.protoc -I=. --python_out=. --grpc_python_out=. *.proto
RUN rm *.proto
RUN find . -type f -exec sed -i -E 's/(import\ .*)_pb2/from . \1_pb2/g' {} \;

# Install Java (required for PySpark)
RUN apt-get update && \
    apt-get install -y default-jdk && \
    apt-get clean

# Set JAVA_HOME environment variable
ENV JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
ENV PATH=$JAVA_HOME/bin:$PATH

# Create component sub-folders, get specific Python packages
RUN mkdir -p /var/teraflow/analytics/backend
WORKDIR /var/teraflow/analytics/backend
+1 −1
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ class AnalyticsFrontendServiceServicerImpl(AnalyticsFrontendServiceServicer):
    @safe_and_metered_rpc_method(METRICS_POOL, LOGGER)
    def StartAnalyzer(self, 
                       request : Analyzer, grpc_context: grpc.ServicerContext # type: ignore
                      ) -> AnalyzerAlarms: # type: ignore
                      ) -> AnalyzerId: # type: ignore
        LOGGER.info ("At Service gRPC message: {:}".format(request))
        response = AnalyzerId()

+3 −2
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ class KafkaTopic(Enum):
    RAW                = 'topic_raw' 
    LABELED            = 'topic_labeled'
    VALUE              = 'topic_value'
    ALARMS             = 'topic_alarms'
    ANALYTICS_REQUEST  = 'topic_request_analytics'
    ANALYTICS_RESPONSE = 'topic_response_analytics'

@@ -77,8 +78,8 @@ class KafkaTopic(Enum):
                # LOGGER.debug("Existing topic list: {:}".format(topic_metadata.topics))
                if topic not in topic_metadata.topics:
                    # If the topic does not exist, create a new topic
                    print("Topic {:} does not exist. Creating...".format(topic))
                    LOGGER.debug("Topic {:} does not exist. Creating...".format(topic))
                    # print("Topic {:} does not exist. Creating...".format(topic))
                    # LOGGER.debug("Topic {:} does not exist. Creating...".format(topic))
                    new_topic = NewTopic(topic, num_partitions=1, replication_factor=1)
                    KafkaConfig.get_admin_client().create_topics([new_topic])
                else:
+2 −1
Original line number Diff line number Diff line
@@ -15,3 +15,4 @@
confluent-kafka==2.3.*
requests==2.27.*
prometheus-api-client==0.5.3
apscheduler==3.10.4