try {
report.message = HttpClient.getBody(response, String.class);
} catch (Exception e) {
- logger.warn("{}: cannot get body from http-client {}", this, client, e);
+ logger.info("{}: cannot get body from http-client {}", this, client, e);
}
} catch (Exception e) {
+ logger.warn("{}: cannot contact http-client {}", this, client, e);
+
report.healthy = false;
reports.healthy = false;
}
}
}
} catch (Exception e) {
+ logger.warn("{}: cannot start {}", this, e);
return false;
}
if (uebSource != null)
sources.add(uebSource);
} catch (Exception e) {
- logger.info("No UEB source for topic: {}", topic);
+ logger.info("No UEB source for topic: {}", topic, e);
}
try {
if (dmaapSource != null)
sources.add(dmaapSource);
} catch (Exception e) {
- logger.info("No DMAAP source for topic: {}", topic);
+ logger.info("No DMAAP source for topic: {}", topic, e);
}
}
return sources;
if (uebSink != null)
sinks.add(uebSink);
} catch (Exception e) {
- logger.info("No UEB sink for topic: {}", topic);
+ logger.info("No UEB sink for topic: {}", topic, e);
}
try {
if (dmaapSink != null)
sinks.add(dmaapSink);
} catch (Exception e) {
- logger.info("No DMAAP sink for topic: {}", topic);
+ logger.info("No DMAAP sink for topic: {}", topic, e);
}
}
return sinks;
try {
sinks.add(this.getUebTopicSink(topicName));
} catch (Exception e) {
- ;
+ logger.debug("No sink for topic: {}", topicName, e);
}
try {
sinks.add(this.getDmaapTopicSink(topicName));
} catch (Exception e) {
- ;
+ logger.debug("No sink for topic: {}", topicName, e);
}
return sinks;
package org.onap.policy.drools.event.comm.bus.internal;
+import java.io.IOException;
import java.net.MalformedURLException;
import java.security.GeneralSecurityException;
import java.util.ArrayList;
* @return list of messages
* @throws Exception when error encountered by underlying libraries
*/
- public Iterable<String> fetch() throws Exception;
+ public Iterable<String> fetch() throws InterruptedException, IOException;
/**
* close underlying library consumer
/**
* {@inheritDoc}
*/
- public Iterable<String> fetch() throws Exception {
+ public Iterable<String> fetch() throws IOException {
return this.consumer.fetch();
}
/**
* {@inheritDoc}
*/
- public Iterable<String> fetch() throws Exception {
+ @Override
+ public Iterable<String> fetch() throws InterruptedException, IOException {
MRConsumerResponse response = this.consumer.fetchWithReturnConsumerResponse();
if (response == null) {
logger.warn("{}: DMaaP NULL response received", this);
/**
* {@inheritDoc}
*/
+ @Override
public void close() {
synchronized (closeCondition) {
closeCondition.notifyAll();
package org.onap.policy.drools.event.comm.bus.internal;
+import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
* Initialize the Bus client
*/
- public abstract void init() throws Exception;
+ public abstract void init() throws MalformedURLException;
@Override
public void register(TopicListener topicListener)
package org.onap.policy.drools.event.comm.bus.internal;
+import java.net.MalformedURLException;
import java.util.List;
import java.util.Map;
* Initialize the Cambria or MR Client
*/
@Override
- public void init() throws Exception {
+ public void init() throws MalformedURLException {
if (this.userName == null || this.userName.isEmpty() ||
this.password == null || this.password.isEmpty()) {
this.consumer =
*/
package org.onap.policy.drools.http.client;
+import java.security.KeyManagementException;
+import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * Http Client Factory
+ */
public interface HttpClientFactory {
+ /**
+ * build and http client with the following parameters
+ */
public HttpClient build(String name, boolean https,
boolean selfSignedCerts,
String hostname, int port,
String baseUrl, String userName,
String password, boolean managed)
- throws Exception;
+ throws KeyManagementException, NoSuchAlgorithmException;
- public ArrayList<HttpClient> build(Properties properties) throws Exception;
+ /**
+ * build http client from properties
+ */
+ public ArrayList<HttpClient> build(Properties properties)
+ throws KeyManagementException, NoSuchAlgorithmException;
+ /**
+ * get http client
+ * @param name the name
+ * @return the http client
+ */
public HttpClient get(String name);
+ /**
+ * list of http clients
+ * @return http clients
+ */
public List<HttpClient> inventory();
+ /**
+ * destroy by name
+ * @param name name
+ */
public void destroy(String name);
public void destroy();
}
+/**
+ * http client factory implementation indexed by name
+ */
class IndexedHttpClientFactory implements HttpClientFactory {
/**
String hostname, int port,
String baseUrl, String userName, String password,
boolean managed)
- throws Exception {
+ throws KeyManagementException, NoSuchAlgorithmException {
if (clients.containsKey(name))
return clients.get(name);
}
@Override
- public synchronized ArrayList<HttpClient> build(Properties properties) throws Exception {
+ public synchronized ArrayList<HttpClient> build(Properties properties)
+ throws KeyManagementException, NoSuchAlgorithmException {
ArrayList<HttpClient> clientList = new ArrayList<HttpClient>();
String clientNames = properties.getProperty(PolicyProperties.PROPERTY_HTTP_CLIENT_SERVICES);
package org.onap.policy.drools.http.client.internal;
+import java.security.KeyManagementException;
+import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
String hostname, int port,
String basePath, String userName,
String password)
- throws Exception {
+ throws KeyManagementException, NoSuchAlgorithmException {
super();
public void updateToVersion(String newGroupId, String newArtifactId, String newVersion,
List<TopicCoderFilterConfiguration> decoderConfigurations,
List<TopicCoderFilterConfiguration> encoderConfigurations)
- throws IllegalArgumentException, LinkageError, Exception;
+ throws IllegalArgumentException, LinkageError;
/**
* gets the classnames of facts as well as the current count
* @return the instantiated Drools Controller
* @throws IllegalArgumentException with invalid parameters
* @throws LinkageError Failure to link rules and models in Drools Libraries
- * @throws Exception Exception from Drools Libraries
*/
public DroolsController build(Properties properties,
List<? extends TopicSource> eventSources,
List<? extends TopicSink> eventSinks)
- throws IllegalArgumentException, LinkageError, Exception;
+ throws IllegalArgumentException, LinkageError;
/**
* Explicit construction of a Drools Controller
* @return the instantiated Drools Controller
* @throws IllegalArgumentException with invalid parameters
* @throws LinkageError Failure to link rules and models in Drools Libraries
- * @throws Exception Exception from Drools Libraries
*/
public DroolsController build(String groupId,
String artifactId,
String version,
List<TopicCoderFilterConfiguration> decoderConfigurations,
List<TopicCoderFilterConfiguration> encoderConfigurations)
- throws IllegalArgumentException, LinkageError, Exception;
+ throws IllegalArgumentException, LinkageError;
/**
* Releases the Drools Controller from operation
public DroolsController build(Properties properties,
List<? extends TopicSource> eventSources,
List<? extends TopicSink> eventSinks)
- throws IllegalArgumentException, LinkageError, Exception {
+ throws IllegalArgumentException, LinkageError {
String groupId = properties.getProperty(PolicyProperties.RULES_GROUPID);
if (groupId == null || groupId.isEmpty())
String newVersion,
List<TopicCoderFilterConfiguration> decoderConfigurations,
List<TopicCoderFilterConfiguration> encoderConfigurations)
- throws IllegalArgumentException, LinkageError, Exception {
+ throws IllegalArgumentException, LinkageError {
if (newGroupId == null || newArtifactId == null || newVersion == null ||
newGroupId.isEmpty() || newArtifactId.isEmpty() || newVersion.isEmpty()) {
public void updateToVersion(String newGroupId, String newArtifactId, String newVersion,
List<TopicCoderFilterConfiguration> decoderConfigurations,
List<TopicCoderFilterConfiguration> encoderConfigurations)
- throws IllegalArgumentException, LinkageError, Exception {
+ throws IllegalArgumentException, LinkageError {
if (logger.isInfoEnabled())
logger.info("UPDATE-TO-VERSION: " + this + " -> {" + newGroupId + ":" + newArtifactId + ":" + newVersion + "}");
List<PolicySession> sessions = this.getSessions();
for (PolicySession session : sessions) {
- if (sessionName.equals(session.getName()) || sessionName.equals(session.getName()))
+ if (sessionName.equals(session.getName()) || sessionName.equals(session.getFullName()))
return session;
}
else
classNames.put(className, 1);
} catch (Exception e) {
- if (logger.isInfoEnabled())
- logger.info("Object cannot be retrieved from fact: " + fact);
+ logger.warn("Object cannot be retrieved from fact {}", fact, e);
}
}
if (delete)
kieSession.delete(factHandle);
} catch (Exception e) {
- if (logger.isInfoEnabled())
- logger.info("Object cannot be retrieved from fact: " + factHandle);
+ logger.warn("Object cannot be retrieved from fact {}", factHandle, e);
}
}
if (delete)
kieSession.delete(row.getFactHandle(queriedEntity));
} catch (Exception e) {
- if (logger.isInfoEnabled())
- logger.info("Object cannot be retrieved from fact: " + row);
+ logger.warn("Object cannot be retrieved from row: {}", row, e);
}
}
public void updateToVersion(String newGroupId, String newArtifactId, String newVersion,
List<TopicCoderFilterConfiguration> decoderConfigurations,
List<TopicCoderFilterConfiguration> encoderConfigurations)
- throws IllegalArgumentException, LinkageError, Exception {
+ throws IllegalArgumentException, LinkageError {
throw new IllegalArgumentException(this.getClass().getCanonicalName() + " invoked");
}