public class MongoDBKnowledgeBase extends KnowledgeBase
Modifier and Type | Class and Description |
---|---|
static class |
MongoDBKnowledgeBase.MongoDBKnowledgeBaseDescriptor
Descriptor for
MongoDBKnowledgeBase . |
KnowledgeBase.KnowledgeBaseDescriptor
Modifier and Type | Field and Description |
---|---|
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 and Description |
---|
MongoDBKnowledgeBase(String host,
int port,
String dbName,
String userName,
hudson.util.Secret password,
boolean enableStatistics,
boolean successfulLogging)
Standard constructor.
|
Modifier and Type | Method and Description |
---|---|
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. |
Date |
getCreationDateForCause(String id)
Find out when the FailureCause identified by id was first created.
|
String |
getDbName()
Getter for the database name value.
|
hudson.model.Descriptor<KnowledgeBase> |
getDescriptor() |
String |
getHost()
Getter for the host value.
|
Date |
getLatestFailureForCause(String id)
Find the time at which the latest Failure occurred which matches the provided FailureCause.
|
hudson.util.Secret |
getPassword()
Getter for the MongoDB password.
|
int |
getPort()
Getter for the port value.
|
protected List<FailureCause> |
getRemovedCauses()
Gets all causes flagged as removed in a "raw" JSON format.
|
Collection<FailureCause> |
getShallowCauses()
Get a shallow list of the
FailureCause s. |
String |
getUserName()
Getter for the MongoDB user name.
|
int |
hashCode() |
boolean |
isEnableStatistics()
If Statistics logging is enabled on this knowledge base or not.
|
boolean |
isSuccessfulLogging()
If all builds should be added to statistics logging, not just unsuccessful builds.
|
boolean |
isTls()
Whether to use TLS when connecting to the mongo server.
|
void |
removeBuildfailurecause(hudson.model.Run 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 |
setTls(boolean tls)
Set whether or not to use TLS when connecting to the mongo server.
|
void |
start()
Called when the KnowledgeBase should be up and running.
|
void |
stop()
Called when it is time to clean up after the KnowledgeBase.
|
void |
updateLastSeen(List<String> ids,
Date seen)
Set the time at which FailureCauses identified by ids last occurred.
|
convertFromAbstract, removeBuildfailurecause
public static final String COLLECTION_NAME
public static final String STATISTICS_COLLECTION_NAME
@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 DBpublic String getUserName()
public hudson.util.Secret getPassword()
public String getHost()
public int getPort()
public String getDbName()
public boolean isTls()
@DataBoundSetter public void setTls(boolean tls)
tls
- the tls optionpublic void start()
KnowledgeBase
start
in class KnowledgeBase
public void stop()
KnowledgeBase
stop
in class KnowledgeBase
public Collection<FailureCause> getCauses()
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
Can throw MongoException if unknown fields exist in the database.
public Collection<FailureCause> getCauseNames()
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
Can throw MongoException if unknown fields exist in the database.
public Collection<FailureCause> getShallowCauses()
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,
comment, lastOccurred and categories are preferred as well.getShallowCauses
in class KnowledgeBase
KnowledgeBase.getCauseNames()
public FailureCause getCause(String id)
KnowledgeBase
getCause
in class KnowledgeBase
id
- the id of the cause.public FailureCause addCause(FailureCause cause)
KnowledgeBase
addCause
in class KnowledgeBase
cause
- the cause to add.public FailureCause removeCause(String id)
KnowledgeBase
removeCause
in class KnowledgeBase
id
- the id of the cause to remove.public FailureCause addCause(FailureCause cause, boolean doUpdate)
cause
- the FailureCause to add.doUpdate
- true if a cache update should be made, false if not.addCause(FailureCause)
public FailureCause saveCause(FailureCause cause)
KnowledgeBase
KnowledgeBase
implementation with a preexisting id that is being converted via KnowledgeBase.convertFrom(KnowledgeBase)
.saveCause
in class KnowledgeBase
cause
- the cause to add.public FailureCause saveCause(FailureCause cause, boolean doUpdate)
cause
- the FailureCause to save.doUpdate
- true if a cache update should be made, false if not.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()
KnowledgeBase
getCategories
in class KnowledgeBase
protected void convertRemoved(MongoDBKnowledgeBase oldKnowledgeBase) throws Exception
oldKnowledgeBase
- the old database.Exception
- if something goes wrong.protected List<FailureCause> getRemovedCauses() throws Exception
Exception
- if so.public boolean equals(KnowledgeBase oldKnowledgeBase)
KnowledgeBase
equals
in class KnowledgeBase
oldKnowledgeBase
- the previous config.public static boolean equals(Object firstObject, Object secondObject)
firstObject
- the firstObject.secondObject
- the secondObject.public boolean isEnableStatistics()
KnowledgeBase
isEnableStatistics
in class KnowledgeBase
public boolean isSuccessfulLogging()
KnowledgeBase
KnowledgeBase.isEnableStatistics()
is true.isSuccessfulLogging
in class KnowledgeBase
public void saveStatistics(Statistics stat)
KnowledgeBase
saveStatistics
in class KnowledgeBase
stat
- the Statistics.public Date getLatestFailureForCause(String id)
KnowledgeBase
getLatestFailureForCause
in class KnowledgeBase
id
- the FailureCause to match.public Date getCreationDateForCause(String id)
KnowledgeBase
getCreationDateForCause
in class KnowledgeBase
id
- the id of the FailureCause which info to retrieve.public void updateLastSeen(List<String> ids, Date seen)
KnowledgeBase
updateLastSeen
in class KnowledgeBase
ids
- the ids of FailureCauses which occurred.seen
- the time at which the FailureCauses occurred.public void removeBuildfailurecause(hudson.model.Run build)
KnowledgeBase
removeBuildfailurecause
in class KnowledgeBase
build
- the build.public hudson.model.Descriptor<KnowledgeBase> getDescriptor()
Copyright © 2016–2020. All rights reserved.