You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by ri...@apache.org on 2022/02/16 20:35:28 UTC

[incubator-streampipes] branch dev updated: [hotfix] Remove notification listener

This is an automated email from the ASF dual-hosted git repository.

riemer pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes.git


The following commit(s) were added to refs/heads/dev by this push:
     new 8900084  [hotfix] Remove notification listener
8900084 is described below

commit 8900084ff351498c325fc7d4a79719e55fa3171d
Author: Dominik Riemer <do...@gmail.com>
AuthorDate: Wed Feb 16 21:04:29 2022 +0100

    [hotfix] Remove notification listener
---
 .../backend/StreamPipesBackendApplication.java     | 16 -----
 .../AbstractNotificationSubscriber.java            | 76 ----------------------
 .../rest/notifications/NotificationListener.java   | 45 -------------
 .../StreamPipesNotificationSubscriber.java         | 35 ----------
 4 files changed, 172 deletions(-)

diff --git a/streampipes-backend/src/main/java/org/apache/streampipes/backend/StreamPipesBackendApplication.java b/streampipes-backend/src/main/java/org/apache/streampipes/backend/StreamPipesBackendApplication.java
index 79dc10b..1f7be83 100644
--- a/streampipes-backend/src/main/java/org/apache/streampipes/backend/StreamPipesBackendApplication.java
+++ b/streampipes-backend/src/main/java/org/apache/streampipes/backend/StreamPipesBackendApplication.java
@@ -23,7 +23,6 @@ import org.apache.streampipes.manager.operations.Operations;
 import org.apache.streampipes.manager.setup.AutoInstallation;
 import org.apache.streampipes.model.pipeline.Pipeline;
 import org.apache.streampipes.model.pipeline.PipelineOperationStatus;
-import org.apache.streampipes.rest.notifications.NotificationListener;
 import org.apache.streampipes.rest.security.SpPermissionEvaluator;
 import org.apache.streampipes.service.base.BaseNetworkingConfig;
 import org.apache.streampipes.service.base.StreamPipesServiceBase;
@@ -35,15 +34,12 @@ import org.apache.streampipes.svcdiscovery.api.model.SpServiceTag;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
-import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;
-import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.Import;
 
 import javax.annotation.PostConstruct;
 import javax.annotation.PreDestroy;
-import javax.servlet.ServletContextListener;
 import java.net.UnknownHostException;
 import java.util.Arrays;
 import java.util.HashMap;
@@ -104,7 +100,6 @@ public class StreamPipesBackendApplication extends StreamPipesServiceBase {
       doInitialSetup();
     }
 
-    new NotificationListener().contextInitialized(null);
     executorService.schedule(this::startAllPreviouslyStoppedPipelines, 5, TimeUnit.SECONDS);
     LOG.info("Pipeline health check will run every {} seconds", HEALTH_CHECK_INTERVAL);
     healthCheckExecutorService.scheduleAtFixedRate(new PipelineHealthCheck(),
@@ -242,17 +237,6 @@ public class StreamPipesBackendApplication extends StreamPipesServiceBase {
             .getPipelineStorageAPI();
   }
 
-  @Bean
-  public ServletListenerRegistrationBean streamPipesNotificationListenerBean() {
-    return listener(new NotificationListener());
-  }
-
-  private ServletListenerRegistrationBean listener(ServletContextListener listener) {
-    ServletListenerRegistrationBean<ServletContextListener> bean =
-            new ServletListenerRegistrationBean<>();
-    bean.setListener(listener);
-    return bean;
-  }
 
   @Override
   protected List<SpServiceTag> getServiceTags() {
diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/notifications/AbstractNotificationSubscriber.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/notifications/AbstractNotificationSubscriber.java
deleted file mode 100644
index 66bae64..0000000
--- a/streampipes-rest/src/main/java/org/apache/streampipes/rest/notifications/AbstractNotificationSubscriber.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * 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.streampipes.rest.notifications;
-
-import com.google.gson.Gson;
-import org.apache.streampipes.commons.exceptions.SpRuntimeException;
-import org.apache.streampipes.config.backend.BackendConfig;
-import org.apache.streampipes.messaging.InternalEventProcessor;
-import org.apache.streampipes.messaging.jms.ActiveMQConsumer;
-import org.apache.streampipes.model.Notification;
-import org.apache.streampipes.model.grounding.JmsTransportProtocol;
-import org.apache.streampipes.model.grounding.SimpleTopicDefinition;
-import org.apache.streampipes.storage.management.StorageDispatcher;
-
-import java.text.SimpleDateFormat;
-
-public abstract class AbstractNotificationSubscriber implements InternalEventProcessor<byte[]>, Runnable {
-
-    protected String topic;
-    protected Gson gson;
-
-    public AbstractNotificationSubscriber(String topic) {
-        this.topic = topic;
-        this.gson = new Gson();
-    }
-
-    public void subscribe() throws SpRuntimeException {
-        ActiveMQConsumer consumer = new ActiveMQConsumer();
-        consumer.connect(getConsumerSettings(), this);
-    }
-
-    private JmsTransportProtocol getConsumerSettings() {
-        JmsTransportProtocol protocol = new JmsTransportProtocol();
-        protocol.setPort(BackendConfig.INSTANCE.getJmsPort());
-        protocol.setBrokerHostname(BackendConfig.INSTANCE.getJmsHost());
-        protocol.setTopicDefinition(new SimpleTopicDefinition(topic));
-
-        return protocol;
-    }
-
-    @Override
-    public void run() {
-        try {
-            subscribe();
-        } catch (SpRuntimeException e) {
-            e.printStackTrace();
-        }
-    }
-
-    protected void storeNotification(Notification message) {
-        StorageDispatcher.INSTANCE.getNoSqlStore()
-                .getNotificationStorageApi()
-                .addNotification(message);
-    }
-
-    protected String parseDate(long timestamp) {
-        return new SimpleDateFormat("MM/dd/yyyy HH:mm:ss").format(timestamp);
-    }
-
-}
diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/notifications/NotificationListener.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/notifications/NotificationListener.java
deleted file mode 100644
index d6248a8..0000000
--- a/streampipes-rest/src/main/java/org/apache/streampipes/rest/notifications/NotificationListener.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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.streampipes.rest.notifications;
-
-import org.apache.streampipes.config.backend.BackendConfig;
-
-import javax.servlet.ServletContextEvent;
-import javax.servlet.ServletContextListener;
-
-public class NotificationListener implements ServletContextListener {
-
-  private static final String internalNotificationTopic = "org.apache.streampipes.notifications.>";
-
-
-  @Override
-  public void contextDestroyed(ServletContextEvent arg0) {
-  }
-
-  @Override
-  public void contextInitialized(ServletContextEvent arg0) {
-    if (BackendConfig.INSTANCE.isConfigured()) {
-      try {
-        new Thread(new StreamPipesNotificationSubscriber(internalNotificationTopic)).start();
-      } catch (Exception e) {
-        e.printStackTrace();
-      }
-    }
-  }
-}
diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/notifications/StreamPipesNotificationSubscriber.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/notifications/StreamPipesNotificationSubscriber.java
deleted file mode 100644
index 8ac3315..0000000
--- a/streampipes-rest/src/main/java/org/apache/streampipes/rest/notifications/StreamPipesNotificationSubscriber.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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.streampipes.rest.notifications;
-
-import org.apache.streampipes.model.Notification;
-
-public class StreamPipesNotificationSubscriber extends AbstractNotificationSubscriber {
-
-  public StreamPipesNotificationSubscriber(String topic) {
-    super(topic);
-  }
-
-  @Override
-  public void onEvent(byte[] notificationMessage) {
-    Notification notification = gson.fromJson(new String(notificationMessage), Notification.class);
-    storeNotification(notification);
-
-  }
-}