diff options
author | 2020-02-24 14:39:34 +0000 | |
---|---|---|
committer | 2020-02-24 14:39:34 +0000 | |
commit | aacc7442f046d44359934ea3d93f425a809e7616 (patch) | |
tree | a764f4168d0ef918e7af2b31b30dc7dc5c13f711 /plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main | |
parent | 0c200b611ee7d56753915281f9a168f7f6e00e7e (diff) | |
parent | ed3c65efa81f5eb1c9271ab05a340ea9f8ee34e7 (diff) |
Merge "remove code duplication in plugins"
Diffstat (limited to 'plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main')
-rw-r--r-- | plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorConsumer.java | 55 |
1 files changed, 3 insertions, 52 deletions
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorConsumer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorConsumer.java index e382c0269..57560d2ef 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorConsumer.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorConsumer.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019-2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,6 @@ package org.onap.policy.apex.plugins.event.carrier.restrequestor; import java.net.URL; import java.util.ArrayList; import java.util.Arrays; -import java.util.EnumMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -45,13 +44,11 @@ import javax.ws.rs.client.Invocation.Builder; import javax.ws.rs.core.Response; import org.apache.commons.lang3.StringUtils; -import org.onap.policy.apex.core.infrastructure.threading.ApplicationThreadFactory; import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities; -import org.onap.policy.apex.service.engine.event.ApexEventConsumer; import org.onap.policy.apex.service.engine.event.ApexEventException; import org.onap.policy.apex.service.engine.event.ApexEventReceiver; import org.onap.policy.apex.service.engine.event.ApexEventRuntimeException; -import org.onap.policy.apex.service.engine.event.PeeredReference; +import org.onap.policy.apex.service.engine.event.ApexPluginsEventConsumer; import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters; import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode; import org.slf4j.Logger; @@ -63,7 +60,7 @@ import org.slf4j.LoggerFactory; * * @author Liam Fallon (liam.fallon@ericsson.com) */ -public class ApexRestRequestorConsumer implements ApexEventConsumer, Runnable { +public class ApexRestRequestorConsumer extends ApexPluginsEventConsumer { // Get a reference to the logger private static final Logger LOGGER = LoggerFactory.getLogger(ApexRestRequestorConsumer.class); @@ -86,16 +83,6 @@ public class ApexRestRequestorConsumer implements ApexEventConsumer, Runnable { // The HTTP client that makes a REST call to get an input event for Apex private Client client; - // The name for this consumer - private String name = null; - - // The peer references for this event handler - private Map<EventHandlerPeeredMode, PeeredReference> peerReferenceMap = new EnumMap<>(EventHandlerPeeredMode.class); - - // The consumer thread and stopping flag - private Thread consumerThread; - private boolean stopOrderedFlag = false; - // Temporary request holder for incoming REST requests private final BlockingQueue<ApexRestRequest> incomingRestRequestQueue = new LinkedBlockingQueue<>(); @@ -197,26 +184,6 @@ public class ApexRestRequestorConsumer implements ApexEventConsumer, Runnable { } /** - * {@inheritDoc}. - */ - @Override - public void start() { - // Configure and start the event reception thread - final String threadName = this.getClass().getName() + ":" + this.name; - consumerThread = new ApplicationThreadFactory(threadName).newThread(this); - consumerThread.setDaemon(true); - consumerThread.start(); - } - - /** - * {@inheritDoc}. - */ - @Override - public String getName() { - return name; - } - - /** * Get the number of events received to date. * * @return the number of events received @@ -229,22 +196,6 @@ public class ApexRestRequestorConsumer implements ApexEventConsumer, Runnable { * {@inheritDoc}. */ @Override - public PeeredReference getPeeredReference(final EventHandlerPeeredMode peeredMode) { - return peerReferenceMap.get(peeredMode); - } - - /** - * {@inheritDoc}. - */ - @Override - public void setPeeredReference(final EventHandlerPeeredMode peeredMode, final PeeredReference peeredReference) { - peerReferenceMap.put(peeredMode, peeredReference); - } - - /** - * {@inheritDoc}. - */ - @Override public void run() { // The endless loop that receives events using REST calls while (consumerThread.isAlive() && !stopOrderedFlag) { |