log optimization

This commit is contained in:
gexce
2017-11-16 17:21:14 +01:00
parent 909f34d062
commit 9649cdb153
3 changed files with 16 additions and 18 deletions
@@ -2,4 +2,4 @@
logging.level.com.bayer=DEBUG logging.level.com.bayer=DEBUG
#logging.level.com.bayer.edam.migration.interceptors=INFO #logging.level.com.bayer.edam.migration.interceptors=INFO
logging.pattern.console=%d{yyyy-MM-dd HH:mm:ss} %-5level- %msg%n logging.pattern.console=%d{yyyy-MM-dd HH:mm:ss} %-5level- %msg%n
logging.file=application_2017-11-16_QA_2.log logging.file=application_2017-11-16_QA_3_3.log
@@ -49,7 +49,7 @@ public class Definitions {
users = new HashMap<String, String>(); users = new HashMap<String, String>();
// XXX QA values // XXX QA values
classifications.put("Migration.Test", new WriteClassification("c07e583879a2409a8536a82d00f0ef5c", 1)); classifications.put("Migration.Test", new WriteClassification("de8edf2ed8d2405b87dea82d01062d50", 1));
classifications.put("Migration", new WriteClassification("2bd24882-b7d8-4d30-8e6f-a7ef00eb33e7", 1)); classifications.put("Migration", new WriteClassification("2bd24882-b7d8-4d30-8e6f-a7ef00eb33e7", 1));
classifications.put("Migration.Logos", new WriteClassification("de96f8db1de44cc6841ba81c00b9db8e", 1)); classifications.put("Migration.Logos", new WriteClassification("de96f8db1de44cc6841ba81c00b9db8e", 1));
@@ -38,7 +38,6 @@ import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap; import org.springframework.util.MultiValueMap;
import org.springframework.web.client.HttpStatusCodeException; import org.springframework.web.client.HttpStatusCodeException;
import org.springframework.web.client.ResourceAccessException;
import org.springframework.web.client.RestClientException; import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
@@ -108,19 +107,23 @@ public class MamMigrationSelective implements CommandLineRunner {
List<Long> entrySelection; List<Long> entrySelection;
// XXX
// XXX ----------------------------------------------------------------
// Option 1: Process all available entries
// entrySelection = new ArrayList<Long>(entryMap.keySet()); // entrySelection = new ArrayList<Long>(entryMap.keySet());
// // XXX // Option 2: Process a fixed set of entry IDs
entrySelection = Arrays.asList(71725L, 71263L, 71048L, 70778L, 70746L, 70745L, 70440L, 70361L, 70340L, 70288L, 70161L, 70142L, entrySelection = Arrays.asList(71725L, 71263L, 71048L, 70778L, 70746L, 70745L, 70440L, 70361L, 70340L, 70288L, 70161L, 70142L,
63924L, 63201L, 57641L, 56942L); 63924L, 63201L, 57641L, 56942L);
// XXX // Option 3: Read entry IDs from file
// entrySelection = new ArrayList<Long>(); // entrySelection = new ArrayList<Long>();
// List<String> entryIDsList = FileUtils.readLines(new File("resources/lottery.txt"), Charset.forName("utf-8")); // List<String> entryIDsList = FileUtils.readLines(new File("resources/lottery.txt"), Charset.forName("utf-8"));
// for (String idString : entryIDsList) { // for (String idString : entryIDsList) {
// entrySelection.add(Long.parseLong(idString)); // entrySelection.add(Long.parseLong(idString));
// } // }
// --------------------------------------------------------------------
@@ -158,6 +161,8 @@ public class MamMigrationSelective implements CommandLineRunner {
// HttpEntity<String> entity = new HttpEntity<String>("", mamHeaders); // HttpEntity<String> entity = new HttpEntity<String>("", mamHeaders);
for (long id : entrySelection) { for (long id : entrySelection) {
// XXX // XXX
// // if needed start from a certain ID // // if needed start from a certain ID
// if (id > 44741) // if (id > 44741)
@@ -527,19 +532,13 @@ public class MamMigrationSelective implements CommandLineRunner {
URI location = restTemplate.postForLocation(Definitions.adamHost + "/records", httpEntity, UploadRecord.class); URI location = restTemplate.postForLocation(Definitions.adamHost + "/records", httpEntity, UploadRecord.class);
log.info("RESULT Entry " + entry.id + " migrated to record " + location); log.info("RESULT Entry " + entry.id + " migrated to record " + location);
// XXX
uploadFilesForEntry(entry, location); uploadFilesForEntry(entry, location);
log.info("FINAL " + entry.id + fieldSeparator + location.toString() + fieldSeparator + entryJson); log.info("FINAL " + entry.id + fieldSeparator + location.toString() + fieldSeparator + entryJson);
} }
catch (HttpStatusCodeException hsce) { catch (RestClientException rce) {
log.error("RESULT Skipping entry " + entry.id + ": Error while creating record " + hsce.getStatusCode().toString()); log.error("RESULT Could not create record for entry " + entry.id + ": " + rce.getMessage());
log.error(hsce.getResponseBodyAsString()); rce.printStackTrace();
hsce.printStackTrace();
}
catch (ResourceAccessException rae) {
log.error("RESULT Could not create record for entry " + entry.id + ": " + rae.getMessage());
rae.printStackTrace();
} }
} }
@@ -621,7 +620,7 @@ public class MamMigrationSelective implements CommandLineRunner {
new HttpEntity<MultiValueMap<String, Object>>(parameters, adamUploadHeaders), UploadResult.class).getBody(); new HttpEntity<MultiValueMap<String, Object>>(parameters, adamUploadHeaders), UploadResult.class).getBody();
if (result.token != null) { if (result.token != null) {
log.debug("Storing upload token " + result.token + "(" + isMaster + ") for " + recordLocation + " from entry " + entry.id); log.debug("Storing upload token " + result.token + " (" + isMaster + ") for " + recordLocation + " from entry " + entry.id);
UploadReference reference = new UploadReference(); UploadReference reference = new UploadReference();
reference.targetRecord = recordLocation; reference.targetRecord = recordLocation;
reference.isMaster = isMaster; reference.isMaster = isMaster;
@@ -679,14 +678,13 @@ public class MamMigrationSelective implements CommandLineRunner {
try { try {
ResponseEntity<Void> response = restTemplate.exchange(Definitions.adamHost + reference.targetRecord, HttpMethod.PUT, httpEntity, Void.class); ResponseEntity<Void> response = restTemplate.exchange(Definitions.adamHost + reference.targetRecord, HttpMethod.PUT, httpEntity, Void.class);
log.debug("Response: " + response.toString()); log.debug("ATTACH RESULT Attached " + reference.cachePath + " (" + reference.isMaster + ") to " + reference.targetRecord);
} }
catch (RestClientException rce) { catch (RestClientException rce) {
log.error("ATTACH RESULT Exception while attaching file " + reference.cachePath + " (" + reference.isMaster + ") for " + reference.targetRecord + ": " + rce.getMessage()); log.error("ATTACH RESULT Exception while attaching file " + reference.cachePath + " (" + reference.isMaster + ") for " + reference.targetRecord + ": " + rce.getMessage());
rce.printStackTrace(); rce.printStackTrace();
} }
log.debug("ATTACH RESULT Attached " + reference.cachePath + " (" + reference.isMaster + ") to " + reference.targetRecord);
processedReferences.add(reference); processedReferences.add(reference);
} }
else { else {