http://jira.mfd.msk:8088/browse/BKI-3203 Do not save empty reports from monitoring service; Updated version to 1.11
This commit is contained in:
parent
7c6a5fef6b
commit
5ec5c407ab
3 changed files with 21 additions and 3 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
#commons
|
#commons
|
||||||
APP_VERSION=1.10
|
APP_VERSION=1.11
|
||||||
REGISTRY_URL=rh8-vm3.nbki.msk:5000
|
REGISTRY_URL=rh8-vm3.nbki.msk:5000
|
||||||
JMX_PORT=
|
JMX_PORT=
|
||||||
JMX_HOSTNAME=
|
JMX_HOSTNAME=
|
||||||
|
|
|
||||||
2
pom.xml
2
pom.xml
|
|
@ -10,7 +10,7 @@
|
||||||
</parent>
|
</parent>
|
||||||
<groupId>ru.nbch</groupId>
|
<groupId>ru.nbch</groupId>
|
||||||
<artifactId>credit-tracker</artifactId>
|
<artifactId>credit-tracker</artifactId>
|
||||||
<version>1.10</version>
|
<version>1.11</version>
|
||||||
<name>credit_tracker</name>
|
<name>credit_tracker</name>
|
||||||
<description>Credit Tracker Application</description>
|
<description>Credit Tracker Application</description>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ import java.util.UUID;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipOutputStream;
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
|
|
@ -126,7 +127,10 @@ public class MonitoringService {
|
||||||
}
|
}
|
||||||
|
|
||||||
String responsePath = generateResponse(userPackage, reportPath);
|
String responsePath = generateResponse(userPackage, reportPath);
|
||||||
String fileName = createResponseFile(userPackage, responsePath);
|
String fileName = null;
|
||||||
|
if (responsePath != null) {
|
||||||
|
fileName = createResponseFile(userPackage, responsePath);
|
||||||
|
}
|
||||||
if (fileName != null) {
|
if (fileName != null) {
|
||||||
log.info("New report fileName: {}", fileName);
|
log.info("New report fileName: {}", fileName);
|
||||||
updateSignalHits(userPackage, responsePath, fileName);
|
updateSignalHits(userPackage, responsePath, fileName);
|
||||||
|
|
@ -147,6 +151,8 @@ public class MonitoringService {
|
||||||
* @return Путь к временному рещультирующему файлу
|
* @return Путь к временному рещультирующему файлу
|
||||||
*/
|
*/
|
||||||
private String generateResponse(UserPackage userPackage, String reportPath) {
|
private String generateResponse(UserPackage userPackage, String reportPath) {
|
||||||
|
AtomicBoolean generateResponse = new AtomicBoolean(false); // Выставляется в true, если хотя бы один субъект с мониторинга подошел под условие срабатывания сигнала. В этом случае отчет сохраняется
|
||||||
|
|
||||||
String folderPath = config.getLoadDir() + File.separator + "tmp_folder" + File.separator + userPackage.getId() + File.separator;
|
String folderPath = config.getLoadDir() + File.separator + "tmp_folder" + File.separator + userPackage.getId() + File.separator;
|
||||||
String responsePath = folderPath + UUID.randomUUID() + "_response_output.xml";
|
String responsePath = folderPath + UUID.randomUUID() + "_response_output.xml";
|
||||||
|
|
||||||
|
|
@ -161,6 +167,9 @@ public class MonitoringService {
|
||||||
staxXmlProcessor.read(in, Persons.class,
|
staxXmlProcessor.read(in, Persons.class,
|
||||||
personsData -> { // как только считали пачку Persons сразу записали ее в результирующий файл
|
personsData -> { // как только считали пачку Persons сразу записали ее в результирующий файл
|
||||||
List<Subject> subjectsBatch = processPersons(personsData.getPersons());
|
List<Subject> subjectsBatch = processPersons(personsData.getPersons());
|
||||||
|
if (!subjectsBatch.isEmpty()) {
|
||||||
|
generateResponse.set(true);
|
||||||
|
}
|
||||||
writer.accept(subjectsBatch);
|
writer.accept(subjectsBatch);
|
||||||
personsData.getPersons().clear(); // чистим список для экономии памяти
|
personsData.getPersons().clear(); // чистим список для экономии памяти
|
||||||
},
|
},
|
||||||
|
|
@ -179,6 +188,15 @@ public class MonitoringService {
|
||||||
log.warn("File {} hasn't been deleted", reportPath);
|
log.warn("File {} hasn't been deleted", reportPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!generateResponse.get()) { // ни один субъект не подошел под условие, удаляем временный отчет
|
||||||
|
try {
|
||||||
|
Files.delete(Path.of(responsePath));
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.warn("File {} hasn't been deleted", responsePath);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return responsePath;
|
return responsePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue