|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sonyericsson.jenkins.plugins.bfa.db.KnowledgeBase
com.sonyericsson.jenkins.plugins.bfa.db.MongoDBKnowledgeBase
public class MongoDBKnowledgeBase
Handling of the MongoDB way of saving the knowledge base.
Nested Class Summary | |
---|---|
static class |
MongoDBKnowledgeBase.MongoDBKnowledgeBaseDescriptor
Descriptor for LocalFileKnowledgeBase . |
Nested classes/interfaces inherited from class com.sonyericsson.jenkins.plugins.bfa.db.KnowledgeBase |
---|
KnowledgeBase.KnowledgeBaseDescriptor |
Field Summary | |
---|---|
static String |
COLLECTION_NAME
The name of the cause collection in the database. |
static String |
STATISTICS_COLLECTION_NAME
The name of the statistics collection in the database. |
Constructor Summary | |
---|---|
MongoDBKnowledgeBase(String host,
int port,
String dbName,
String userName,
hudson.util.Secret password,
boolean enableStatistics,
boolean successfulLogging)
Standard constructor. |
Method Summary | |
---|---|
FailureCause |
addCause(FailureCause cause)
Saves a new cause to the db and generates a new id for the cause. |
FailureCause |
addCause(FailureCause cause,
boolean doUpdate)
Does not update the cache, used when we know we will have a lot of save/add calls all at once, e.g. |
void |
convertFrom(KnowledgeBase oldKnowledgeBase)
Converts the existing old knowledge base into this one. |
protected void |
convertRemoved(MongoDBKnowledgeBase oldKnowledgeBase)
Copies all causes flagged as removed from the old database to this one. |
boolean |
equals(KnowledgeBase oldKnowledgeBase)
Called to see if the configuration has changed. |
boolean |
equals(Object other)
|
static boolean |
equals(Object firstObject,
Object secondObject)
Checks if two objects equal each other, both being null counts as being equal. |
List<String> |
getCategories()
Gets the unique categories of all FailureCauses. |
FailureCause |
getCause(String id)
Get the cause with the given id. |
Collection<FailureCause> |
getCauseNames()
Get the list of the FailureCause 's names and ids. |
Collection<FailureCause> |
getCauses()
Get the list of FailureCause s. |
String |
getDbName()
Getter for the database name value. |
hudson.model.Descriptor<KnowledgeBase> |
getDescriptor()
|
List<ObjectCountPair<String>> |
getFailureCauseNames(GraphFilterBuilder filter)
Gets a list of ObjectCountPair s where each pair contains a unique FailureCause -name as key
and the number of times that failure cause was triggered as count. |
Map<Integer,List<FailureCause>> |
getFailureCausesPerBuild(GraphFilterBuilder filter)
Gets a map where a lists of failure causes are mapped by the build number for which they were triggered. |
List<FailureCauseTimeInterval> |
getFailureCausesPerTime(int intervalSize,
GraphFilterBuilder filter,
boolean byCategories)
Fetches failure causes grouped in time intervals. |
String |
getHost()
Getter for the host value. |
List<ObjectCountPair<String>> |
getNbrOfFailureCategoriesPerName(GraphFilterBuilder filter,
int limit)
Gets a list of ObjectCountPair where each pair contains a unique failure category string as key
and the number of times that the failure cause category was triggered as count. |
List<ObjectCountPair<FailureCause>> |
getNbrOfFailureCauses(GraphFilterBuilder filter)
Gets a list of ObjectCountPair where each pair contains a unique FailureCause as key
and the number of times that failure cause was triggered as count. |
List<ObjectCountPair<String>> |
getNbrOfFailureCausesPerId(GraphFilterBuilder filter,
int maxNbr)
Gets a list of ObjectCountPair where each pair contains a unique FailureCause id as key
and a belonging count value for how many times that FailureCause was triggered. |
long |
getNbrOfNullFailureCauses(GraphFilterBuilder filter)
Counts how many statistics posts there are without FailureCause (null) for a given filter. |
hudson.util.Secret |
getPassword()
Getter for the MongoDB password. |
int |
getPort()
Getter for the port value. |
protected List<com.mongodb.DBObject> |
getRemovedCauses()
Gets all causes flagged as removed in a "raw" JSON format. |
Collection<FailureCause> |
getShallowCauses()
Get a shallow list of the FailureCause s. |
List<Statistics> |
getStatistics(GraphFilterBuilder filter,
int limit)
Gets Statistics data. |
Map<org.jfree.data.time.TimePeriod,Double> |
getUnknownFailureCauseQuotaPerTime(int intervalSize,
GraphFilterBuilder filter)
Gets the quota of unknown failure causes mapped by time periods. |
String |
getUserName()
Getter for the MongoDB user name. |
int |
hashCode()
|
boolean |
isStatisticsEnabled()
If Statistics logging is enabled on this knowledge base or not. |
boolean |
isSuccessfulLoggingEnabled()
If all builds should be added to statistics logging, not just unsuccessful builds. |
void |
removeBuildfailurecause(hudson.model.AbstractBuild build)
Removes the build failure cause of particular build. |
FailureCause |
removeCause(String id)
Removes the cause from the knowledge base. |
FailureCause |
saveCause(FailureCause cause)
Saves a cause to the db. |
FailureCause |
saveCause(FailureCause cause,
boolean doUpdate)
Does not update the cache, used when we know we will have a lot of save/add calls all at once, e.g. |
void |
saveStatistics(Statistics stat)
Saves the Statistics. |
void |
start()
Called when the KnowledgeBase should be up and running. |
void |
stop()
Called when it is time to clean up after the KnowledgeBase. |
Methods inherited from class com.sonyericsson.jenkins.plugins.bfa.db.KnowledgeBase |
---|
convertFromAbstract |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String COLLECTION_NAME
public static final String STATISTICS_COLLECTION_NAME
Constructor Detail |
---|
@DataBoundConstructor public MongoDBKnowledgeBase(String host, int port, String dbName, String userName, hudson.util.Secret password, boolean enableStatistics, boolean successfulLogging)
host
- the host to connect to.port
- the port to connect to.dbName
- the database name to connect to.userName
- the user name for the database.password
- the password for the database.enableStatistics
- if statistics logging should be enabled or not.successfulLogging
- if all builds should be logged to the statistics DBMethod Detail |
---|
public String getUserName()
public hudson.util.Secret getPassword()
public String getHost()
public int getPort()
public String getDbName()
public void start() throws UnknownHostException, AuthenticationException
KnowledgeBase
start
in class KnowledgeBase
UnknownHostException
AuthenticationException
public void stop()
KnowledgeBase
stop
in class KnowledgeBase
public Collection<FailureCause> getCauses() throws UnknownHostException, AuthenticationException
KnowledgeBase
FailureCause
s. It is intended to be used in the scanning phase hence it should be
returned as quickly as possible, so the list could be cached.
getCauses
in class KnowledgeBase
UnknownHostException
- if a connection to the host cannot be made.
AuthenticationException
- if we cannot authenticate towards the database.Can throw MongoException if unknown fields exist in the database.
public Collection<FailureCause> getCauseNames() throws UnknownHostException, AuthenticationException
KnowledgeBase
FailureCause
's names and ids. The list should be the latest possible from the DB as
they will be used for editing. The objects returned should contain at least the id and the name of the cause.
getCauseNames
in class KnowledgeBase
UnknownHostException
- if a connection to the host cannot be made.
AuthenticationException
- if we cannot authenticate towards the database.Can throw MongoException if unknown fields exist in the database.
public Collection<FailureCause> getShallowCauses() throws Exception
KnowledgeBase
FailureCause
s. The list should be the latest possible from the DB as
they will be used in the list of causes to edit.
shallow meaning no indications but information enough to show a nice list; at least id and name but description
and categories are preferred as well.
getShallowCauses
in class KnowledgeBase
Exception
- if something in the KnowledgeBase handling goes wrong.KnowledgeBase.getCauseNames()
public FailureCause getCause(String id) throws UnknownHostException, AuthenticationException
KnowledgeBase
getCause
in class KnowledgeBase
id
- the id of the cause.
UnknownHostException
AuthenticationException
public FailureCause addCause(FailureCause cause) throws UnknownHostException, AuthenticationException
KnowledgeBase
addCause
in class KnowledgeBase
cause
- the cause to add.
UnknownHostException
AuthenticationException
public FailureCause removeCause(String id) throws Exception
KnowledgeBase
removeCause
in class KnowledgeBase
id
- the id of the cause to remove.
Exception
- if so.public FailureCause addCause(FailureCause cause, boolean doUpdate) throws UnknownHostException, AuthenticationException
cause
- the FailureCause to add.doUpdate
- true if a cache update should be made, false if not.
UnknownHostException
- If a connection to the Mongo database cannot be made.
AuthenticationException
- if we cannot authenticate towards the database.addCause(FailureCause)
public FailureCause saveCause(FailureCause cause) throws UnknownHostException, AuthenticationException
KnowledgeBase
KnowledgeBase
implementation with a preexisting id that is being converted via KnowledgeBase.convertFrom(KnowledgeBase)
.
saveCause
in class KnowledgeBase
cause
- the cause to add.
UnknownHostException
AuthenticationException
public FailureCause saveCause(FailureCause cause, boolean doUpdate) throws UnknownHostException, AuthenticationException
cause
- the FailureCause to save.doUpdate
- true if a cache update should be made, false if not.
UnknownHostException
- If a connection to the Mongo database cannot be made.
AuthenticationException
- if we cannot authenticate towards the database.saveCause(FailureCause)
public void convertFrom(KnowledgeBase oldKnowledgeBase) throws Exception
KnowledgeBase
convertFrom
in class KnowledgeBase
oldKnowledgeBase
- the old one.
Exception
- if something in the KnowledgeBase handling goes wrong.public List<String> getCategories() throws UnknownHostException, AuthenticationException
KnowledgeBase
getCategories
in class KnowledgeBase
UnknownHostException
AuthenticationException
protected void convertRemoved(MongoDBKnowledgeBase oldKnowledgeBase) throws Exception
oldKnowledgeBase
- the old database.
Exception
- if something goes wrong.protected List<com.mongodb.DBObject> getRemovedCauses() throws Exception
Exception
- if so.public boolean equals(KnowledgeBase oldKnowledgeBase)
KnowledgeBase
equals
in class KnowledgeBase
oldKnowledgeBase
- the previous config.
public boolean equals(Object other)
equals
in class Object
public static boolean equals(Object firstObject, Object secondObject)
firstObject
- the firstObject.secondObject
- the secondObject.
public int hashCode()
hashCode
in class KnowledgeBase
public boolean isStatisticsEnabled()
KnowledgeBase
isStatisticsEnabled
in class KnowledgeBase
public boolean isSuccessfulLoggingEnabled()
KnowledgeBase
KnowledgeBase.isStatisticsEnabled()
is true.
isSuccessfulLoggingEnabled
in class KnowledgeBase
public void saveStatistics(Statistics stat) throws UnknownHostException, AuthenticationException
KnowledgeBase
saveStatistics
in class KnowledgeBase
stat
- the Statistics.
UnknownHostException
AuthenticationException
public List<Statistics> getStatistics(GraphFilterBuilder filter, int limit) throws UnknownHostException, AuthenticationException
KnowledgeBase
getStatistics
in class KnowledgeBase
filter
- the filter to use when fetching datalimit
- number of statistics items to fetch, set to nonpositive value to fetch all
UnknownHostException
AuthenticationException
public long getNbrOfNullFailureCauses(GraphFilterBuilder filter)
KnowledgeBase
getNbrOfNullFailureCauses
in class KnowledgeBase
filter
- the filter to use when fetching data
public Map<org.jfree.data.time.TimePeriod,Double> getUnknownFailureCauseQuotaPerTime(int intervalSize, GraphFilterBuilder filter)
KnowledgeBase
getUnknownFailureCauseQuotaPerTime
in class KnowledgeBase
intervalSize
- the interval sizes in which the data is grouped.
Should be set to Calendar.MONTH, Calendar.DATE or Calendar.HOUR_OF_DAY.filter
- The filter to use when fetching the data
public List<ObjectCountPair<String>> getNbrOfFailureCausesPerId(GraphFilterBuilder filter, int maxNbr)
KnowledgeBase
ObjectCountPair
where each pair contains a unique FailureCause id as key
and a belonging count value for how many times that FailureCause was triggered.
This method needs to be implemented in subclass for graph support.
getNbrOfFailureCausesPerId
in class KnowledgeBase
filter
- the filter to use when fetching datamaxNbr
- the number of items to fetch, set to nonpositive value to fetch all
public List<ObjectCountPair<FailureCause>> getNbrOfFailureCauses(GraphFilterBuilder filter)
KnowledgeBase
ObjectCountPair
where each pair contains a unique FailureCause
as key
and the number of times that failure cause was triggered as count.
The list is sorted by counts, meaning that the FailureCause that has been triggered the most comes first.
This method needs to be implemented in subclass for graph support.
getNbrOfFailureCauses
in class KnowledgeBase
filter
- the filter to use when fetching data
public List<ObjectCountPair<String>> getFailureCauseNames(GraphFilterBuilder filter)
KnowledgeBase
ObjectCountPair
s where each pair contains a unique FailureCause
-name as key
and the number of times that failure cause was triggered as count.
This list is sorted by counts, meaning that the FailureCause that has been triggered the most comes first.
This method needs to be implemented in subclass for graph support.
getFailureCauseNames
in class KnowledgeBase
filter
- The filter to use when fetching the data
public Map<Integer,List<FailureCause>> getFailureCausesPerBuild(GraphFilterBuilder filter)
KnowledgeBase
getFailureCausesPerBuild
in class KnowledgeBase
filter
- the filter to use when fetching data
public List<FailureCauseTimeInterval> getFailureCausesPerTime(int intervalSize, GraphFilterBuilder filter, boolean byCategories)
KnowledgeBase
getFailureCausesPerTime
in class KnowledgeBase
intervalSize
- the interval sizes in which the data is grouped.
Should be set to Calendar.MONTH, Calendar.DATE or Calendar.HOUR_OF_DAY.filter
- the filter to use when fetching databyCategories
- set to true in order to group failure causes by their categories
public List<ObjectCountPair<String>> getNbrOfFailureCategoriesPerName(GraphFilterBuilder filter, int limit)
KnowledgeBase
ObjectCountPair
where each pair contains a unique failure category string as key
and the number of times that the failure cause category was triggered as count.
The list is sorted by counts, meaning that the Category that has been triggered the most comes first.
This method needs to be implemented in subclass for graph support.
getNbrOfFailureCategoriesPerName
in class KnowledgeBase
filter
- the filter to use when fetching datalimit
- the number of categories to fetch, set to nonpositive value to fetch all
public void removeBuildfailurecause(hudson.model.AbstractBuild build) throws Exception
KnowledgeBase
removeBuildfailurecause
in class KnowledgeBase
build
- the AbstractBuild.
Exception
- if something in the KnowledgeBase handling goes wrong.public hudson.model.Descriptor<KnowledgeBase> getDescriptor()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |