* @param properties
* @param integrityAuditPeriodSeconds
* @param integrityAudit
- * @throws Exception
+ * @throws IntegrityAuditException
*/
public AuditThread(String resourceName, String persistenceUnit,
Properties properties, int integrityAuditPeriodSeconds, IntegrityAudit integrityAudit)
- throws Exception {
+ throws IntegrityAuditException {
this(resourceName, persistenceUnit, properties, TimeUnit.SECONDS.toMillis(integrityAuditPeriodSeconds),
integrityAudit, null);
* @param integrityAuditMillis
* @param integrityAudit
* @param queue
- * @throws Exception
+ * @throws IntegrityAuditException
*/
public AuditThread(String resourceName, String persistenceUnit,
Properties properties, long integrityAuditMillis, IntegrityAudit integrityAudit,
BlockingQueue<CountDownLatch> queue)
- throws Exception {
+ throws IntegrityAuditException {
this.resourceName = resourceName;
this.persistenceUnit = persistenceUnit;
this.properties = properties;
return auditCompleted;
}
- private void runAudit(DbAudit dbAudit) throws Exception {
+ private void runAudit(DbAudit dbAudit) throws IntegrityAuditException {
if (logger.isDebugEnabled()) {
logger.debug("runAudit: Entering, dbAudit=" + dbAudit
* @param nodeType
* @throws Exception
*/
- public void dbAudit(String resourceName, String persistenceUnit, String nodeType) throws Exception {
+ public void dbAudit(String resourceName, String persistenceUnit, String nodeType) throws IntegrityAuditException {
if (logger.isDebugEnabled()) {
logger.debug("dbAudit: Entering, resourceName=" + resourceName
if (logger.isDebugEnabled()) {
logger.debug("dbAudit: Sleeping " + dbAuditSleepMillis + "ms");
}
- Thread.sleep(dbAuditSleepMillis);
+ sleep();
if (logger.isDebugEnabled()) {
logger.debug("dbAudit: Waking from sleep");
}
if (logger.isDebugEnabled()) {
logger.debug("dbAudit: Second comparison; sleeping " + dbAuditSleepMillis + "ms");
}
- Thread.sleep(dbAuditSleepMillis);
+ sleep();
if (logger.isDebugEnabled()) {
logger.debug("dbAudit: Second comparison; waking from sleep");
}
return; //all done
}
+ /**
+ * Sleeps a bit.
+ * @throws IntegrityAuditException
+ */
+ private void sleep() throws IntegrityAuditException {
+ try {
+ Thread.sleep(dbAuditSleepMillis);
+
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ throw new IntegrityAuditException(e);
+ }
+ }
+
/**
* dbAuditSimulate simulates the DB audit
* @param resourceName
* @param resourceName2
* @param entry1
* @param entry2
- * @throws ClassNotFoundException
+ * @throws IntegrityAuditException
*/
public void writeAuditDebugLog(String clazzName, String resourceName1,
- String resourceName2, Object entry1, Object entry2) throws ClassNotFoundException{
- Class<?> entityClass = Class.forName(clazzName);
- String tableName = entityClass.getAnnotation(Table.class).name();
- String msg = "\nDB Audit Error: "
- + "\n Table Name: " + tableName
- + "\n Entry 1 (short prefix style): " + resourceName1 + ": " + new ReflectionToStringBuilder(entry1,ToStringStyle.SHORT_PREFIX_STYLE).toString()
- + "\n Entry 2 (short prefix style): " + resourceName2 + ": " + new ReflectionToStringBuilder(entry2,ToStringStyle.SHORT_PREFIX_STYLE).toString()
- + "\n Entry 1 (recursive style): " + resourceName1 + ": " + new ReflectionToStringBuilder(entry1, new RecursiveToStringStyle()).toString()
- + "\n Entry 2 (recursive style): " + resourceName2 + ": " + new ReflectionToStringBuilder(entry2, new RecursiveToStringStyle()).toString();
- logger.debug(msg);
+ String resourceName2, Object entry1, Object entry2) throws IntegrityAuditException{
+ try {
+ Class<?> entityClass = Class.forName(clazzName);
+ String tableName = entityClass.getAnnotation(Table.class).name();
+ String msg = "\nDB Audit Error: "
+ + "\n Table Name: " + tableName
+ + "\n Entry 1 (short prefix style): " + resourceName1 + ": " + new ReflectionToStringBuilder(entry1,ToStringStyle.SHORT_PREFIX_STYLE).toString()
+ + "\n Entry 2 (short prefix style): " + resourceName2 + ": " + new ReflectionToStringBuilder(entry2,ToStringStyle.SHORT_PREFIX_STYLE).toString()
+ + "\n Entry 1 (recursive style): " + resourceName1 + ": " + new ReflectionToStringBuilder(entry1, new RecursiveToStringStyle()).toString()
+ + "\n Entry 2 (recursive style): " + resourceName2 + ": " + new ReflectionToStringBuilder(entry2, new RecursiveToStringStyle()).toString();
+ logger.debug(msg);
+
+ } catch (ClassNotFoundException e) {
+ throw new IntegrityAuditException(e);
+ }
}
* @param resourceName1
* @param resourceName2
* @param keys
- * @throws ClassNotFoundException
+ * @throws IntegrityAuditException
*/
public void writeAuditSummaryLog(String clazzName, String resourceName1,
- String resourceName2, String keys) throws ClassNotFoundException{
- Class<?> entityClass = Class.forName(clazzName);
- String tableName = entityClass.getAnnotation(Table.class).name();
- String msg = " DB Audit Error: Table Name: " + tableName
- + "; Mismatch between nodes: " + resourceName1 +" and " + resourceName2
- + "; Mismatched entries (keys): " + keys;
- logger.info(msg);
+ String resourceName2, String keys) throws IntegrityAuditException{
+ try {
+ Class<?> entityClass = Class.forName(clazzName);
+ String tableName = entityClass.getAnnotation(Table.class).name();
+ String msg = " DB Audit Error: Table Name: " + tableName
+ + "; Mismatch between nodes: " + resourceName1 +" and " + resourceName2
+ + "; Mismatched entries (keys): " + keys;
+ logger.info(msg);
+ } catch (ClassNotFoundException e) {
+ throw new IntegrityAuditException(e);
+ }
}
/**
* ============LICENSE_START=======================================================
* Integrity Audit
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.common.ia;
-public class DbAuditException extends Exception{
+public class DbAuditException extends IntegrityAuditException {
private static final long serialVersionUID = 1L;
public DbAuditException() {
super();
* ============LICENSE_START=======================================================
* Integrity Audit
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* @param resourceName
* @param persistenceUnit
* @param properties
- * @throws Exception
+ * @throws IntegrityAuditException
*/
- public DbDAO(String resourceName, String persistenceUnit, Properties properties) throws Exception {
+ public DbDAO(String resourceName, String persistenceUnit, Properties properties) throws IntegrityAuditException {
this(resourceName, persistenceUnit, properties, null);
}
* @param properties
* @param lastUpdateDate may be {@code null}
* @param altDbUrl may be {@code null}
- * @throws Exception
+ * @throws IntegrityAuditException
*/
protected DbDAO(String resourceName, String persistenceUnit, Properties properties, String altDbUrl)
- throws Exception {
+ throws IntegrityAuditException {
logger.debug("DbDAO contructor: enter");
validateProperties(resourceName, persistenceUnit, properties);
* ============LICENSE_START=======================================================
* Integrity Audit
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.common.ia;
-public class DbDaoTransactionException extends Exception{
+public class DbDaoTransactionException extends IntegrityAuditException {
private static final long serialVersionUID = 1L;
public DbDaoTransactionException() {
super();
* @param resourceName
* @param persistenceUnit
* @param properties
- * @throws Exception
+ * @throws IntegrityAuditException
*/
public IntegrityAudit(String resourceName, String persistenceUnit, Properties properties) throws IntegrityAuditException {
}
/**
* Starts the audit thread
- * @throws Exception
+ * @throws IntegrityAuditException
*/
- public void startAuditThread() throws Exception {
+ public void startAuditThread() throws IntegrityAuditException {
startAuditThread(null);
}
/**
* Starts the audit thread
* @param queue
* @return {@code true} if the thread was started, {@code false} otherwise
- * @throws Exception
+ * @throws IntegrityAuditException
*/
- protected boolean startAuditThread(BlockingQueue<CountDownLatch> queue) throws Exception {
+ protected boolean startAuditThread(BlockingQueue<CountDownLatch> queue) throws IntegrityAuditException {
logger.info("startAuditThread: Entering");
* ============LICENSE_START=======================================================
* Integrity Audit
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.common.ia;
-public class IntegrityAuditPropertiesException extends Exception{
+public class IntegrityAuditPropertiesException extends IntegrityAuditException {
private static final long serialVersionUID = 1L;
public IntegrityAuditPropertiesException() {
super();
* with the thread.
*/
@Override
- public final void startAuditThread() throws Exception {
+ public final void startAuditThread() throws IntegrityAuditException {
if (queue != null) {
// queue up a bogus latch, in case a thread is still running
queue.add(new CountDownLatch(1) {
// wait for the thread to start
CountDownLatch latch = new CountDownLatch(1);
queue.add(latch);
- waitLatch(latch);
+
+ try {
+ waitLatch(latch);
+
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ throw new IntegrityAuditException(e);
+ }
}
}
* ============LICENSE_START=======================================================
* Integrity Monitor
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.common.im;
-public class AdministrativeStateException extends Exception{
+public class AdministrativeStateException extends IntegrityMonitorException {
private static final long serialVersionUID = 1L;
public AdministrativeStateException() {
super();
* ============LICENSE_START=======================================================
* Integrity Monitor
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.common.im;
-public class AllSeemsWellException extends Exception {
+public class AllSeemsWellException extends IntegrityMonitorException {
/**
*
* ============LICENSE_START=======================================================
* Integrity Monitor
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.common.im;
-public class ForwardProgressException extends Exception{
+public class ForwardProgressException extends IntegrityMonitorException {
private static final long serialVersionUID = 1L;
public ForwardProgressException() {
super();
* The resource name of the resource
* @param properties
* a set of properties passed in from the resource
- * @throws Exception
+ * @throws IntegrityMonitorException
* if any errors are encountered in the constructor
*/
- protected IntegrityMonitor(String resourceName, Properties properties) throws Exception {
+ protected IntegrityMonitor(String resourceName, Properties properties) throws IntegrityMonitorException {
this(resourceName, properties, null);
}
* a set of properties passed in from the resource
* @param queue
* queue to use to control the FPManager thread, or {@code null}
- * @throws Exception
+ * @throws IntegrityMonitorException
* if any errors are encountered in the constructor
*/
protected IntegrityMonitor(String resourceName, Properties properties, BlockingQueue<CountDownLatch> queue)
- throws Exception {
+ throws IntegrityMonitorException {
// singleton check since this constructor can be called from a child or
// sub-class
throw e;
}
- // create instance of StateMangement class and pass emf to it
- stateManager = new StateManagement(emf, resourceName);
-
- /**
- * Initialize the state and status attributes. This will maintain any
- * Administrative state value but will set the operational state =
- * enabled, availability status = null, standby status = null. The
- * integrity monitor will set the operational state via the FPManager
- * and the owning application must set the standby status by calling
- * promote/demote on the StateManager.
- */
- stateManager.initializeState();
+ try {
+ // create instance of StateMangement class and pass emf to it
+ stateManager = new StateManagement(emf, resourceName);
+
+ /**
+ * Initialize the state and status attributes. This will maintain any
+ * Administrative state value but will set the operational state =
+ * enabled, availability status = null, standby status = null. The
+ * integrity monitor will set the operational state via the FPManager
+ * and the owning application must set the standby status by calling
+ * promote/demote on the StateManager.
+ */
+ stateManager.initializeState();
+
+ } catch(StateManagementException e) {
+ throw new IntegrityMonitorException(e);
+ }
// create management bean
try {
* @param properties
* a set of properties passed in from the resource
* @return The new instance of IntegrityMonitor
- * @throws Exception
+ * @throws IntegrityMonitorException
* if unable to create jmx url or the constructor returns an
* exception
*/
- public static IntegrityMonitor getInstance(String resourceName, Properties properties) throws Exception {
+ public static IntegrityMonitor getInstance(String resourceName, Properties properties) throws IntegrityMonitorException {
return getInstance(resourceName, properties, null);
}
* @param queue
* queue to use to control the FPManager thread, or {@code null}
* @return The new instance of IntegrityMonitor
- * @throws Exception
+ * @throws IntegrityMonitorException
* if unable to create jmx url or the constructor returns an
* exception
*/
protected static IntegrityMonitor getInstance(String resourceName, Properties properties,
- BlockingQueue<CountDownLatch> queue) throws Exception {
+ BlockingQueue<CountDownLatch> queue) throws IntegrityMonitorException {
synchronized (getInstanceLock) {
logger.debug("getInstance() called - resourceName= {}", resourceName);
}
}
- public static IntegrityMonitor getInstance() throws Exception {
+ public static IntegrityMonitor getInstance() throws IntegrityMonitorException {
logger.debug("getInstance() called");
if (instance == null) {
String msg = "No IntegrityMonitor instance exists."
* disabled, it will include the dependencyCheckErrorMsg which includes
* information about any dependency (node) which has failed.
*/
- public void evaluateSanity() throws Exception {
+ public void evaluateSanity() throws IntegrityMonitorException {
logger.debug("evaluateSanity called ....");
synchronized (evaluateSanityLock) {
* throws admin state exception if resource is locked
* @throws StandbyStatusException
*/
- public void startTransaction() throws AdministrativeStateException, StandbyStatusException {
+ public void startTransaction() throws IntegrityMonitorException {
synchronized (startTransactionLock) {
// check admin state and throw exception if locked
/**
* Read and validate properties
*
- * @throws Exception
+ * @throws IntegrityMonitorPropertiesException
*/
private static void validateProperties(Properties prop) throws IntegrityMonitorPropertiesException {
* ============LICENSE_START=======================================================
* Integrity Monitor
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
super(message, cause);
}
+ public IntegrityMonitorException(String message, Throwable cause,
+ boolean enableSuppression, boolean writableStackTrace)
+ {
+ super(message, cause, enableSuppression, writableStackTrace);
+ }
+
}
* ============LICENSE_START=======================================================
* Integrity Monitor
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.common.im;
-public class IntegrityMonitorPropertiesException extends Exception{
+public class IntegrityMonitorPropertiesException extends IntegrityMonitorException {
private static final long serialVersionUID = 1L;
public IntegrityMonitorPropertiesException() {
super();
* ============LICENSE_START=======================================================
* Integrity Monitor
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.common.im;
-public class StandbyStatusException extends Exception {
+public class StandbyStatusException extends IntegrityMonitorException {
/**
*
*/
* ============LICENSE_START=======================================================
* Integrity Monitor
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* StateManagement constructor
* @param entityManagerFactory
* @param resourceName
- * @throws Exception
+ * @throws StateManagementException
*/
public StateManagement(EntityManagerFactory entityManagerFactory, String resourceName) throws StateManagementException
{
/**
* lock() changes the administrative state to locked.
- * @throws Exception
+ * @throws StateManagementException
*/
public void lock() throws StateManagementException
{
/**
* unlock() changes the administrative state to unlocked.
- * @throws Exception
+ * @throws StateManagementException
*/
public void unlock() throws StateManagementException
{
/**
* enableNotFailed() removes the "failed" availability status and changes the operational
* state to enabled if no dependency is also failed.
- * @throws Exception
+ * @throws StateManagementException
*/
public void enableNotFailed() throws StateManagementException
{
/**
* disableFailed() changes the operational state to disabled and adds availability status of "failed"
- * @throws Exception
+ * @throws StateManagementException
*/
public void disableFailed() throws StateManagementException
{
/**
* This version of disableFailed is to be used to manipulate the state of a remote resource in the event
* that remote resource has failed but its state is still showing that it is viable.
- * @throws Exception
+ * @throws StateManagementException
*/
public void disableFailed(String otherResourceName) throws StateManagementException
{
/**
* disableDependency() changes operational state to disabled and adds availability status of "dependency"
- * @throws Exception
+ * @throws StateManagementException
*/
public void disableDependency() throws StateManagementException
{
/**
* enableNoDependency() removes the availability status of "dependency " and will change the
* operational state to enabled if not otherwise failed.
- * @throws Exception
+ * @throws StateManagementException
*/
public void enableNoDependency() throws StateManagementException
{
/**
* promote() changes the standby status to providingservice if not otherwise failed.
* @throws StandbyStatusException
- * @throws Exception
+ * @throws StateManagementException
*/
- public void promote() throws StandbyStatusException, StateManagementException
+ public void promote() throws IntegrityMonitorException
{
synchronized (SYNCLOCK){
if(logger.isDebugEnabled()){
/**
* demote() changes standbystatus to hotstandby or, if failed, coldstandby
- * @throws Exception
+ * @throws StateManagementException
*/
public void demote() throws StateManagementException
{
* this is observed by PDP-D DroolsPdpsElectionHandler when it is trying to determine which PDP-D should
* be designated as the lead.
* @param otherResourceName
- * @throws Exception
+ * @throws StateManagementException
*/
public void demote(String otherResourceName) throws StateManagementException
{
* ============LICENSE_START=======================================================
* Integrity Monitor
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.common.im;
-public class StateManagementException extends Exception{
+public class StateManagementException extends IntegrityMonitorException {
private static final long serialVersionUID = 1L;
public StateManagementException() {
super();
* ============LICENSE_START=======================================================
* Integrity Monitor
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
/**
* StateTransition constructor
- * @throws Exception
+ * @throws StateTransitionException
*/
public StateTransition() throws StateTransitionException
{
* @param standbyStatus
* @param actionName
* @return
- * @throws Exception
+ * @throws StateTransitionException
*/
public StateElement getEndingState(String adminState, String opState, String availStatus,
String standbyStatus, String actionName) throws StateTransitionException
* ============LICENSE_START=======================================================
* Integrity Monitor
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.common.im;
-public class StateTransitionException extends Exception{
+public class StateTransitionException extends IntegrityMonitorException {
private static final long serialVersionUID = 1L;
public StateTransitionException() {
super();
* ============LICENSE_START=======================================================
* Integrity Monitor
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.slf4j.LoggerFactory;
import org.onap.policy.common.im.IntegrityMonitor;
+import org.onap.policy.common.im.IntegrityMonitorException;
import org.onap.policy.common.im.StateManagement;
/**
}
@Override
- public void test() throws Exception {
+ public void test() throws IntegrityMonitorException {
// Call evaluateSanity on IntegrityMonitor to run the test
logger.debug("test() called...");
if (integrityMonitor != null) {
}
@Override
- public void lock() throws Exception {
+ public void lock() throws IntegrityMonitorException {
logger.debug("lock() called...");
if (stateManager != null) {
stateManager.lock();
}
@Override
- public void unlock() throws Exception {
+ public void unlock() throws IntegrityMonitorException {
logger.debug("unlock() called...");
if (stateManager != null) {
stateManager.unlock();
package org.onap.policy.common.im.jmx;
-public class ComponentAdminException extends Exception {
+import org.onap.policy.common.im.IntegrityMonitorException;
+
+public class ComponentAdminException extends IntegrityMonitorException {
private static final long serialVersionUID = 1L;
public ComponentAdminException() {
* ============LICENSE_START=======================================================
* Integrity Monitor
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.common.im.jmx;
+import org.onap.policy.common.im.IntegrityMonitorException;
+
/**
* Provides operations to test health, lock and unlock components.
*/
/**
* Test health of component.
*
- * @throws Exception
+ * @throws IntegrityMonitorException
* if the component fails the health check
*/
- void test() throws Exception;
+ void test() throws IntegrityMonitorException;
/**
* Administratively lock component.
*
- * @throws Exception
+ * @throws IntegrityMonitorException
* if the component lock fails
*/
- void lock() throws Exception;
+ void lock() throws IntegrityMonitorException;
/**
* Administratively unlock component.
*
- * @throws Exception
+ * @throws IntegrityMonitorException
* if the component unlock fails
*/
- void unlock() throws Exception;
+ void unlock() throws IntegrityMonitorException;
}
* ============LICENSE_START=======================================================
* Integrity Monitor
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
+import org.onap.policy.common.im.IntegrityMonitorException;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
/**
* Get a connection to the jmxAgent MBeanServer.
* @return the connection
- * @throws Exception on error
+ * @throws IntegrityMonitorException on error
*/
- public MBeanServerConnection getMBeanConnection() throws Exception {
- JMXServiceURL url;
- if (jmxUrl == null) {
- url = new JMXServiceURL(jmxAgentUrl(host, port));
- }
- else {
- url = new JMXServiceURL(jmxUrl);
- }
- Map<String, Object> env = new HashMap<>();
-
- connector = JMXConnectorFactory.newJMXConnector(url, env);
- connector.connect();
- connector.addConnectionNotificationListener(
- new NotificationListener() {
+ public MBeanServerConnection getMBeanConnection() throws IntegrityMonitorException {
- @Override
- public void handleNotification(
- Notification notification, Object handback) {
- if (notification.getType().equals(
- JMXConnectionNotification.FAILED)) {
- // handle disconnect
- disconnect();
- }
- }
- }, null, null);
+ try {
+ JMXServiceURL url;
+ if (jmxUrl == null) {
+ url = new JMXServiceURL(jmxAgentUrl(host, port));
+ }
+ else {
+ url = new JMXServiceURL(jmxUrl);
+ }
+ Map<String, Object> env = new HashMap<>();
+
+ connector = JMXConnectorFactory.newJMXConnector(url, env);
+ connector.connect();
+ connector.addConnectionNotificationListener(
+ new NotificationListener() {
- return connector.getMBeanServerConnection();
+ @Override
+ public void handleNotification(
+ Notification notification, Object handback) {
+ if (notification.getType().equals(
+ JMXConnectionNotification.FAILED)) {
+ // handle disconnect
+ disconnect();
+ }
+ }
+ }, null, null);
+
+ return connector.getMBeanServerConnection();
+
+ } catch (IOException e) {
+ throw new IntegrityMonitorException(e);
+ }
}
/**
@Test
public void testIntegrityMonitorException() throws Exception {
- assertEquals(4, test(IntegrityMonitorException.class));
+ assertEquals(5, test(IntegrityMonitorException.class));
}
@Test