Skip to content

Commit

Permalink
feat: writing the node type in to the CSV file
Browse files Browse the repository at this point in the history
  • Loading branch information
AllanCapistrano committed Mar 15, 2024
1 parent 6923f87 commit 5cdc97c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
20 changes: 11 additions & 9 deletions src/main/java/reputation/node/models/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public class Node implements NodeTypeService, ILedgerSubscriber {
private NodeCredibility nodeCredibility;
private CsvWriterService csvWriter;
private String credibilityHeader;
private String[] csvData = new String[8];
private String[] csvData = new String[9];
private long startedExperiment;
private boolean flagStartedExperiment = true;
private static final Logger logger = Logger.getLogger(Node.class.getName());
Expand Down Expand Up @@ -806,11 +806,13 @@ private float calculateCredibility(
currentServiceEvaluation
);

/* Salvando o ID, consistência, confiabilidade e credibilidade mais recente. */
/* Salvando o ID, tipo, consistência, confiabilidade e credibilidade mais
recente. */
this.csvData[0] = String.valueOf(this.nodeType.getNodeId());
this.csvData[1] = String.valueOf(consistency);
this.csvData[3] = String.valueOf(trustworthiness);
this.csvData[4] = String.valueOf(nodeCredibility);
this.csvData[1] = this.getNodeType().getType().toString();
this.csvData[2] = String.valueOf(consistency);
this.csvData[4] = String.valueOf(trustworthiness);
this.csvData[5] = String.valueOf(nodeCredibility);

logger.info("TRUSTWORTHINESS");
logger.info(String.valueOf(trustworthiness));
Expand Down Expand Up @@ -858,7 +860,7 @@ private float calculateCredibility(
}

/* Salvando a nova credibilidade. */
this.csvData[5] = String.valueOf(nodeCredibility);
this.csvData[6] = String.valueOf(nodeCredibility);

logger.info("NEW NODE CREDIBILITY");
logger.info(String.valueOf(nodeCredibility));
Expand All @@ -868,9 +870,9 @@ private float calculateCredibility(
startedExperiment = System.currentTimeMillis();
flagStartedExperiment = false;
}
this.csvData[6] = String.valueOf(startedExperiment);
this.csvData[7] = String.valueOf(startedExperiment);
/* Salvando o tempo em que calculou a nova credibilidade. */
this.csvData[7] = String.valueOf(System.currentTimeMillis());
this.csvData[8] = String.valueOf(System.currentTimeMillis());

/* Escrevendo na blockchain a credibilidade calculado do nó avaliador */
try {
Expand Down Expand Up @@ -986,7 +988,7 @@ private float calculateTrustworthiness(
}

/* Salvando R. */
this.csvData[2] = String.valueOf(R);
this.csvData[3] = String.valueOf(R);

logger.info("R VALUE");
logger.info(String.valueOf(R));
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/OSGI-INF/blueprint/blueprint.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
<cm:property name="useCredibility" value="true" />
<cm:property name="useLatestCredibility" value="true" />
<cm:property name="debugModeValue" value="true" />
<cm:property name="credibilityHeader" value="Node_ID,C(n),R,Tr(n),Cr_old(n),Cr_new(n),Started_experiment_time,wrote_file_time" />
<cm:property name="credibilityHeader" value="Node_ID,Type,C(n),R,Tr(n),Cr_old(n),Cr_new(n),Started_experiment_time,wrote_file_time" />
</cm:default-properties>
</cm:property-placeholder>
</blueprint>
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ useCredibility=true
useLatestCredibility=true
# Cabeçalho do experimento de credibilidades.
# Obs: Separe somente utilizando vírgula
credibilityHeader=Node_ID,C(n),R,Tr(n),Cr_old(n),Cr_new(n),Started_experiment_time,wrote_file_time
credibilityHeader=Node_ID,Type,C(n),R,Tr(n),Cr_old(n),Cr_new(n),Started_experiment_time,wrote_file_time

debugModeValue=true

0 comments on commit 5cdc97c

Please sign in to comment.