Hyperic HQ Plugin API v. 4.4.0.2

org.hyperic.hq.autoinventory.server.session
Class AutoinventoryManagerEJBImpl

java.lang.Object
  extended by org.hyperic.hq.autoinventory.server.session.AutoinventoryManagerEJBImpl
All Implemented Interfaces:
java.io.Serializable, javax.ejb.EnterpriseBean, javax.ejb.SessionBean

public class AutoinventoryManagerEJBImpl
extends java.lang.Object
implements javax.ejb.SessionBean

This class is responsible for managing Autoinventory objects in autoinventory and their relationships

See Also:
Serialized Form

Field Summary
protected  java.lang.String DATASOURCE_NAME
           
 
Constructor Summary
AutoinventoryManagerEJBImpl()
           
 
Method Summary
 void _reportAIRuntimeReport(java.lang.String agentToken, CompositeRuntimeResourceReport crrr)
          Should only be called from RuntimePlatformAndServerMerger
 AIHistory createAIHistory(AppdefEntityID id, java.lang.Integer groupId, java.lang.Integer batchId, java.lang.String subjectName, ScanConfigurationCore config, java.lang.String scanName, java.lang.String scanDesc, java.lang.Boolean scheduled, long startTime, long stopTime, long scheduleTime, java.lang.String status, java.lang.String errorMessage)
          create AIHistory
 void ejbActivate()
           
 void ejbCreate()
          Create an autoinventory manager session bean.
 void ejbPassivate()
           
 void ejbRemove()
           
 java.util.List findAgentsRequiringRuntimeScan()
          Returns a list of Agents which still need to send in a runtime scan (their last runtime scan was unsuccessfully processed)
protected  org.hyperic.hq.appdef.shared.AIQueueManagerLocal getAIQueueManagerLocal()
          If we ever have more than this single session EJB, this method ought to be placed in a superclass, kinda like appdef has the AppdefSessionEJB as a base class for all other appdef session EJBs.
protected  AIHistoryDAO getHistoryDAO()
           
static org.hyperic.hq.autoinventory.shared.AutoinventoryManagerLocal getOne()
           
 ScanStateCore getScanStatus(AuthzSubject subject, AppdefEntityID aid)
          Get status for an autoinventory scan.
 ScanStateCore getScanStatusByAgentToken(AuthzSubject subject, java.lang.String agentToken)
          Get status for an autoinventory scan, given the agentToken
 java.util.Map getServerSignatures(AuthzSubject subject, java.util.List serverTypes)
          Get server signatures for a set of servertypes.
 void handleResourceEvents(java.util.List events)
          Handle ResourceZEvents for enabling runtime autodiscovery.
 boolean isRuntimeDiscoverySupported(AuthzSubject subject, AppdefEntityID id)
          Check if a given Appdef entity supports runtime auto-discovery.
 void markServiceClean(Agent agent, boolean serviceClean)
           
 void markServiceClean(java.lang.String agentToken)
           
 java.util.List mergePlatformsAndServers(java.lang.String agentToken, CompositeRuntimeResourceReport crrr)
          Merge platforms and servers from the runtime report.
 void mergeServices(java.util.List mergeInfos)
          Merge a list of RuntimeReportProcessor.ServiceMergeInfos in HQ's appdef model
 void notifyAgentsNeedingRuntimeScan()
           
 void removeHistory(AIHistory history)
          remove AIHistory
 void reportAIData(java.lang.String agentToken, ScanStateCore stateCore)
          Called by agents to report platforms, servers, and services detected via autoinventory scans.
 void reportAIRuntimeReport(java.lang.String agentToken, CompositeRuntimeResourceReport crrr)
          Called by agents to report resources detected at runtime via monitoring-based autoinventory scans.
 void setSessionContext(javax.ejb.SessionContext ctx)
           
 void startScan(AuthzSubject subject, AppdefEntityID aid, ScanConfigurationCore scanConfig, java.lang.String scanName, java.lang.String scanDesc, ScheduleValue schedule)
          Start an autoinventory scan.
 void startScan(AuthzSubject subject, java.lang.String agentToken, ScanConfigurationCore scanConfig)
          Start an autoinventory scan by agentToken
 void startup()
           
 void stopScan(AuthzSubject subject, AppdefEntityID aid)
          Stop an autoinventory scan.
 void toggleRuntimeScan(AuthzSubject subject, AppdefEntityID id, boolean enable)
          Toggle Runtime-AI config for the given server.
 void turnOffRuntimeDiscovery(AuthzSubject subject, AppdefEntityID id)
          Turn off runtime-autodiscovery for a server that no longer exists.
 void turnOffRuntimeDiscovery(AuthzSubject subject, AppdefEntityID id, java.lang.String agentToken)
          Turn off runtime-autodiscovery for a server that no longer exists.
 void updateAIHistory(java.lang.Integer jobId, long endTime, java.lang.String status, java.lang.String message)
          update AIHistory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DATASOURCE_NAME

protected final java.lang.String DATASOURCE_NAME
See Also:
Constant Field Values
Constructor Detail

AutoinventoryManagerEJBImpl

public AutoinventoryManagerEJBImpl()
Method Detail

getServerSignatures

public java.util.Map getServerSignatures(AuthzSubject subject,
                                         java.util.List serverTypes)
                                  throws javax.ejb.FinderException,
                                         AutoinventoryException
Get server signatures for a set of servertypes.

Parameters:
serverTypes - A List of ServerTypeValue objects representing the server types to get signatures for. If this is null, all server signatures are returned.
Returns:
A Map, where the keys are the names of the ServerTypeValues, and the values are the ServerSignature objects.
Throws:
javax.ejb.FinderException
AutoinventoryException

isRuntimeDiscoverySupported

public boolean isRuntimeDiscoverySupported(AuthzSubject subject,
                                           AppdefEntityID id)
Check if a given Appdef entity supports runtime auto-discovery.

Parameters:
id - The entity id to check.
Returns:
true if the given resource supports runtime auto-discovery.

turnOffRuntimeDiscovery

public void turnOffRuntimeDiscovery(AuthzSubject subject,
                                    AppdefEntityID id)
                             throws PermissionException
Turn off runtime-autodiscovery for a server that no longer exists. Use this method when you know the appdefentity identified by "id" exists, so that we'll be able to successfully find out which agent we should create our AICommandsClient from.

Parameters:
id - The AppdefEntityID of the resource to turn off runtime config for.
Throws:
PermissionException

turnOffRuntimeDiscovery

public void turnOffRuntimeDiscovery(AuthzSubject subject,
                                    AppdefEntityID id,
                                    java.lang.String agentToken)
                             throws PermissionException
Turn off runtime-autodiscovery for a server that no longer exists. We need this as a separate method call because when the server no longer exists, we have to manually specify the agent connection to use.

Parameters:
id - The AppdefEntityID of the resource to turn off runtime config for.
agentToken - Which agent controls the runtime AI scans for this resource.
Throws:
PermissionException

toggleRuntimeScan

public void toggleRuntimeScan(AuthzSubject subject,
                              AppdefEntityID id,
                              boolean enable)
                       throws PermissionException,
                              AutoinventoryException,
                              ResourceDeletedException
Toggle Runtime-AI config for the given server.

Throws:
PermissionException
AutoinventoryException
ResourceDeletedException

startScan

public void startScan(AuthzSubject subject,
                      AppdefEntityID aid,
                      ScanConfigurationCore scanConfig,
                      java.lang.String scanName,
                      java.lang.String scanDesc,
                      ScheduleValue schedule)
               throws AgentConnectionException,
                      AgentNotFoundException,
                      AutoinventoryException,
                      DuplicateAIScanNameException,
                      ScheduleWillNeverFireException,
                      PermissionException
Start an autoinventory scan.

Parameters:
aid - The appdef entity whose agent we'll talk to.
scanConfig - The scan configuration to use when scanning.
scanName - The name of the scan - this is ignored (i.e. it can be null) for immediate, one-time scans.
scanDesc - The description of the scan - this is ignored (i.e. it can be null) for immediate, one-time scans.
schedule - Described when and how often the scan should run. If this is null, then the scan will be run as an immediate, one-time only scan.
Throws:
AgentConnectionException
AgentNotFoundException
AutoinventoryException
DuplicateAIScanNameException
ScheduleWillNeverFireException
PermissionException

startScan

public void startScan(AuthzSubject subject,
                      java.lang.String agentToken,
                      ScanConfigurationCore scanConfig)
               throws AgentConnectionException,
                      AgentNotFoundException,
                      AutoinventoryException,
                      PermissionException
Start an autoinventory scan by agentToken

Throws:
AgentConnectionException
AgentNotFoundException
AutoinventoryException
PermissionException

stopScan

public void stopScan(AuthzSubject subject,
                     AppdefEntityID aid)
              throws AutoinventoryException
Stop an autoinventory scan.

Parameters:
aid - The appdef entity whose agent we'll talk to.
Throws:
AutoinventoryException

getScanStatus

public ScanStateCore getScanStatus(AuthzSubject subject,
                                   AppdefEntityID aid)
                            throws AgentNotFoundException,
                                   AgentConnectionException,
                                   AgentRemoteException,
                                   AutoinventoryException
Get status for an autoinventory scan.

Parameters:
aid - The appdef entity whose agent we'll talk to.
Throws:
AgentNotFoundException
AgentConnectionException
AgentRemoteException
AutoinventoryException

createAIHistory

public AIHistory createAIHistory(AppdefEntityID id,
                                 java.lang.Integer groupId,
                                 java.lang.Integer batchId,
                                 java.lang.String subjectName,
                                 ScanConfigurationCore config,
                                 java.lang.String scanName,
                                 java.lang.String scanDesc,
                                 java.lang.Boolean scheduled,
                                 long startTime,
                                 long stopTime,
                                 long scheduleTime,
                                 java.lang.String status,
                                 java.lang.String errorMessage)
                          throws AutoinventoryException
create AIHistory

Throws:
AutoinventoryException

removeHistory

public void removeHistory(AIHistory history)
remove AIHistory


updateAIHistory

public void updateAIHistory(java.lang.Integer jobId,
                            long endTime,
                            java.lang.String status,
                            java.lang.String message)
update AIHistory


getHistoryDAO

protected AIHistoryDAO getHistoryDAO()

getScanStatusByAgentToken

public ScanStateCore getScanStatusByAgentToken(AuthzSubject subject,
                                               java.lang.String agentToken)
                                        throws AgentNotFoundException,
                                               AgentConnectionException,
                                               AgentRemoteException,
                                               AutoinventoryException
Get status for an autoinventory scan, given the agentToken

Throws:
AgentNotFoundException
AgentConnectionException
AgentRemoteException
AutoinventoryException

reportAIData

public void reportAIData(java.lang.String agentToken,
                         ScanStateCore stateCore)
                  throws AutoinventoryException
Called by agents to report platforms, servers, and services detected via autoinventory scans.

Parameters:
agentToken - The token identifying the agent that sent the report.
stateCore - The ScanState that was detected during the autoinventory scan.
Throws:
AutoinventoryException

reportAIRuntimeReport

public void reportAIRuntimeReport(java.lang.String agentToken,
                                  CompositeRuntimeResourceReport crrr)
                           throws AutoinventoryException,
                                  PermissionException,
                                  ValidationException,
                                  ApplicationException
Called by agents to report resources detected at runtime via monitoring-based autoinventory scans. There are some interesting situations that can occur related to synchronization between the server and agent. If runtime scans are turned off for a server, but the agent is never notified (for example if the agent is not running at the time), then the agent is going to eventually report a runtime scan that includes resources detected by that server's runtime scan. If this happens, we detect it and take the opportunity to tell the agent again that it should not perform runtime AI scans for that server. Any resources reported by that server will be ignored. A similar situation occurs when the appdef server has been deleted but the agent was never notified to turn off runtime AI. We handle this in the same way, by telling the agent to turn off runtime scans for that server, and ignoring anything in the report from that server. This method will process all platform and server merging, given by the report. Any services will be added to Zevent queue to be processed in their own transactions.

Parameters:
agentToken - The token identifying the agent that sent the report.
crrr - The CompositeRuntimeResourceReport that was generated during the runtime autoinventory scan.
Throws:
AutoinventoryException
PermissionException
ValidationException
ApplicationException

_reportAIRuntimeReport

public void _reportAIRuntimeReport(java.lang.String agentToken,
                                   CompositeRuntimeResourceReport crrr)
                            throws AutoinventoryException,
                                   PermissionException,
                                   ValidationException,
                                   ApplicationException
Should only be called from RuntimePlatformAndServerMerger

Throws:
AutoinventoryException
PermissionException
ValidationException
ApplicationException

mergePlatformsAndServers

public java.util.List mergePlatformsAndServers(java.lang.String agentToken,
                                               CompositeRuntimeResourceReport crrr)
                                        throws ApplicationException,
                                               AutoinventoryException
Merge platforms and servers from the runtime report.

Returns:
a List of RuntimeReportProcessor.ServiceMergeInfo -- information from the report about services still needing to be processed
Throws:
ApplicationException
AutoinventoryException

mergeServices

public void mergeServices(java.util.List mergeInfos)
                   throws PermissionException,
                          ApplicationException
Merge a list of RuntimeReportProcessor.ServiceMergeInfos in HQ's appdef model

Throws:
PermissionException
ApplicationException

findAgentsRequiringRuntimeScan

public java.util.List findAgentsRequiringRuntimeScan()
Returns a list of Agents which still need to send in a runtime scan (their last runtime scan was unsuccessfully processed)


notifyAgentsNeedingRuntimeScan

public void notifyAgentsNeedingRuntimeScan()

markServiceClean

public void markServiceClean(java.lang.String agentToken)

markServiceClean

public void markServiceClean(Agent agent,
                             boolean serviceClean)

startup

public void startup()

handleResourceEvents

public void handleResourceEvents(java.util.List events)
Handle ResourceZEvents for enabling runtime autodiscovery.

Parameters:
events - A list of ResourceZevents

setSessionContext

public void setSessionContext(javax.ejb.SessionContext ctx)
Specified by:
setSessionContext in interface javax.ejb.SessionBean

getOne

public static org.hyperic.hq.autoinventory.shared.AutoinventoryManagerLocal getOne()

ejbCreate

public void ejbCreate()
               throws javax.ejb.CreateException
Create an autoinventory manager session bean.

Throws:
javax.ejb.CreateException - If an error occurs creating the pager for the bean.

ejbRemove

public void ejbRemove()
Specified by:
ejbRemove in interface javax.ejb.SessionBean

ejbActivate

public void ejbActivate()
Specified by:
ejbActivate in interface javax.ejb.SessionBean

ejbPassivate

public void ejbPassivate()
Specified by:
ejbPassivate in interface javax.ejb.SessionBean

getAIQueueManagerLocal

protected org.hyperic.hq.appdef.shared.AIQueueManagerLocal getAIQueueManagerLocal()
If we ever have more than this single session EJB, this method ought to be placed in a superclass, kinda like appdef has the AppdefSessionEJB as a base class for all other appdef session EJBs.


Hyperic HQ Plugin API v. 4.4.0.2

Copyright © 2004-2006 Hyperic, Inc. support@hyperic.net, All Rights Reserved.