Skip to content
This repository has been archived by the owner on Mar 21, 2022. It is now read-only.

Issue/105 - Fix QA Warnings #128

Open
wants to merge 11 commits into
base: dev-1
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@

import net.explorviz.kiekeradapter.main.KiekerAdapter;

public class Main {
/**
* Main class for analysis-service.
*/
public final class Main {

private Main(){}

public static void main(final String[] args) {
KiekerAdapter.getInstance().startReader();
}



}
9 changes: 8 additions & 1 deletion conf/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@
<module name="ModifiedControlVariable" />
<module name="MultipleStringLiterals">
<property name="ignoreStringsRegexp" value='^.{0,5}$' />
<!-- <property name="allowedDuplicates" value="2"/> -->
</module>
<module name="SimplifyBooleanExpression" />
<module name="SimplifyBooleanReturn" />
Expand All @@ -313,7 +314,9 @@
<module name="SuppressWithNearbyCommentFilter">
<property name="commentFormat" value="NOCS" />
</module>


<module name="SuppressionCommentFilter"/>

<module name="SuppressionCommentFilter">
<property name="offCommentFormat"
value="CHECKSTYLE.OFF\: ([\w\|]+)" />
Expand All @@ -322,6 +325,10 @@
<property name="checkFormat" value="$1" />
</module>





<!-- TODO - we require a rule to enforce only fqn for @link (afterwards,
UnusedImports->processJavadoc can be removed) - we require a rule to enforce
declaring type arguments for generic types/methods -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* In-Memory repository for {@link Agent}s.
*/
public class AgentRepository {

private static final Logger LOGGER = LoggerFactory.getLogger(AgentRepository.class);
Expand All @@ -22,19 +25,34 @@ public class AgentRepository {

private final BroadcastService broadcastService;

/**
* Creates a new repository. Handled by DI.
* @param broadcastService the used
*/
@Inject
public AgentRepository(final BroadcastService broadcastService) {
this.broadcastService = broadcastService;
}

public String getUniqueIdString() {
private String getUniqueIdString() {
return String.valueOf(this.idGenerator.incrementAndGet());
}

/**
* Get all agents.
*
* @return list of all registered agents.
*/
public List<Agent> getAgents() {
return this.agents;
}

/**
* Find a specific agent.
*
* @param agent the agent to search for.
* @return the agent if it exists in this repository or {@code null} otherwise
*/
public Agent lookupAgent(final Agent agent) {
synchronized (this.agents) {
return this.agents.stream()
Expand All @@ -45,6 +63,13 @@ public Agent lookupAgent(final Agent agent) {
}
}

/**
* Register a new agent. If the agent to register already existed, it is re-registered with the
* same Id.
*
* @param agent the agent to register
* @return the registered agent
*/
public Agent registerAgent(final Agent agent) {
synchronized (this.agents) {
final Agent possibleOldAgent = this.lookupAgent(agent);
Expand All @@ -69,6 +94,12 @@ public Agent registerAgent(final Agent agent) {
return agent;
}

/**
* Generates and assigns a unique Id for each process in a list.
*
* @param procezzList the list of {@link Procezz} objects
* @return the same list of procezzes where each object has an Id now
*/
public List<Procezz> insertIdsInProcezzList(final List<Procezz> procezzList) {

for (final Procezz p : procezzList) {
Expand All @@ -79,6 +110,12 @@ public List<Procezz> insertIdsInProcezzList(final List<Procezz> procezzList) {

}

/**
* Find an agent by its Id.
*
* @param id the Id to look for
* @return An optional containing the agent with the given Id if found
*/
public Optional<Agent> lookupAgentById(final String id) {
synchronized (this.agents) {
for (final Agent agent : this.agents) {
Expand All @@ -91,6 +128,10 @@ public Optional<Agent> lookupAgentById(final String id) {
return Optional.empty();
}

/**
* Updates an existing agent. Fails silently if such agent does not exist.
* @param a the agent to update
*/
public void updateAgent(final Agent a) {
synchronized (this.agents) {
final Agent potentialAgent = this.lookupAgent(a);
Expand All @@ -106,6 +147,7 @@ public void updateAgent(final Agent a) {
}
}


public void exchangeProcezzInAgent(final Procezz proc, final Agent a) {

synchronized (this.agents) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
class Application extends ResourceConfig {

public Application() {

super();
GenericTypeFinder.getTypeMap().put("Agent", Agent.class);
GenericTypeFinder.getTypeMap().put("Procezz", Procezz.class);

Expand Down
Loading