Search in sources :

Example 1 with AlarmSourceImpl

use of alma.acs.alarmsystem.source.AlarmSourceImpl in project ACS by ACS-Community.

the class ManagerImpl method initialize.

/**
	 * Initializes Manager.
	 * @param	prevayler			implementation of prevayler system
	 * @param	context				remote directory implementation
	 */
public void initialize(Prevayler prevayler, CDBAccess cdbAccess, Context context, final Logger logger, ManagerContainerServices managerContainerServices) {
    this.prevayler = prevayler;
    this.remoteDirectory = context;
    this.logger = logger;
    // needs to be done here, since deserialization is used
    initializeDefaultConfiguration();
    if (cdbAccess != null)
        setCDBAccess(cdbAccess);
    readManagerConfiguration();
    componentsLock = (ProfilingReentrantLock.isProfilingEnabled ? new ProfilingReentrantLock("componentsLock") : new ReentrantLock());
    random = new Random();
    heartbeatTask = new Timer(true);
    delayedDeactivationTask = new Timer(true);
    containerLoggedInMonitor = new Object();
    activationSynchronization = new HashMap<String, ReferenceCountingLock>();
    activationPendingRWLock = new ReaderPreferenceReadWriteLock();
    shutdown = new AtomicBoolean(false);
    threadPool = new ThreadPoolExecutor(poolThreads, poolThreads, Long.MAX_VALUE, TimeUnit.NANOSECONDS, new LinkedBlockingQueue(), new DaemonThreadFactory("managerThreadPool"));
    managerCache = new HashMap<String, Manager>();
    pendingActivations = new HashMap<String, ComponentInfo>();
    pendingContainerShutdown = Collections.synchronizedSet(new HashSet<String>());
    pendingContainerAsyncRequests = new HashMap<String, Deque<ComponentInfoCompletionCallback>>();
    clientMessageQueue = new HashMap<Client, LinkedList<ClientMessageTask>>();
    groupedNotifyTaskMap = new HashMap<Object, GroupedNotifyTask>();
    threadsUsedPercentage = new AtomicInteger(0);
    // create threads
    threadPool.prestartAllCoreThreads();
    // read CDB startup
    try {
        String componentSpec = System.getProperty(NAME_CDB_COMPONENTSPEC);
        if (componentSpec != null) {
            cdbActivation = new ComponentSpec(componentSpec);
            logger.log(Level.INFO, "Using CDB component specification: '" + cdbActivation + "'.");
        }
    } catch (Throwable t) {
        logger.log(Level.WARNING, "Failed to parse '" + NAME_CDB_COMPONENTSPEC + "' variable, " + t.getMessage(), t);
    }
    // check load balancing strategy
    checkLoadBalancingStrategy();
    // establish connect to the alarm system
    try {
        alarmSource = new AlarmSourceImpl(managerContainerServices);
        alarmSource.start();
    } catch (Throwable ex) {
        logger.log(Level.SEVERE, "Failed to initialize Alarm System Interface " + ex.getMessage(), ex);
        alarmSource = null;
    }
    // register ping tasks
    initializePingTasks();
    // handle monitoring removal task
    final long timeInMs = enableHandleMonitoringDurationMins * 60L * 1000;
    if (enableHandleMonitoring && enableHandleMonitoringDurationMins > 0) {
        heartbeatTask.schedule(new TimerTask() {

            @Override
            public void run() {
                try {
                    logHandleCleanup(timeInMs);
                } catch (Throwable th) {
                    logger.log(Level.SEVERE, "Unexpected exception in handle log cleanup task.", th);
                }
            }
        }, 0, timeInMs);
    }
    // start topology sort manager
    topologySortManager = new ComponentInfoTopologicalSortManager(components, containers, activationPendingRWLock, pendingContainerShutdown, threadPool, logger);
    if (prevayler == null)
        statePersitenceFlag.set(false);
    String enDis = statePersitenceFlag.get() ? "enabled" : "disabled";
    logger.info("Manager initialized with state persistence " + enDis + ".");
}
Also used : DaemonThreadFactory(alma.acs.concurrent.DaemonThreadFactory) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue) Manager(com.cosylab.acs.maci.Manager) Random(java.util.Random) TimerTask(java.util.TimerTask) AlarmSourceImpl(alma.acs.alarmsystem.source.AlarmSourceImpl) Client(com.cosylab.acs.maci.Client) LinkedHashSet(java.util.LinkedHashSet) HashSet(java.util.HashSet) ReentrantLock(java.util.concurrent.locks.ReentrantLock) ComponentSpec(com.cosylab.acs.maci.ComponentSpec) ArrayDeque(java.util.ArrayDeque) Deque(java.util.Deque) LinkedList(java.util.LinkedList) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Timer(java.util.Timer) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) ComponentInfo(com.cosylab.acs.maci.ComponentInfo)

Example 2 with AlarmSourceImpl

use of alma.acs.alarmsystem.source.AlarmSourceImpl in project ACS by ACS-Community.

the class AlarmSourceTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    alarmSource = new AlarmSourceImpl(this.getContainerServices());
    assertNotNull(alarmSource);
    alarmSource.start();
}
Also used : AlarmSourceImpl(alma.acs.alarmsystem.source.AlarmSourceImpl)

Aggregations

AlarmSourceImpl (alma.acs.alarmsystem.source.AlarmSourceImpl)2 DaemonThreadFactory (alma.acs.concurrent.DaemonThreadFactory)1 Client (com.cosylab.acs.maci.Client)1 ComponentInfo (com.cosylab.acs.maci.ComponentInfo)1 ComponentSpec (com.cosylab.acs.maci.ComponentSpec)1 Manager (com.cosylab.acs.maci.Manager)1 ArrayDeque (java.util.ArrayDeque)1 Deque (java.util.Deque)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 LinkedList (java.util.LinkedList)1 Random (java.util.Random)1 Timer (java.util.Timer)1 TimerTask (java.util.TimerTask)1 LinkedBlockingQueue (java.util.concurrent.LinkedBlockingQueue)1 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 ReentrantLock (java.util.concurrent.locks.ReentrantLock)1