improvements to tx client logging functionality and terminology performance tracking
This commit is contained in:
parent
f22855e82a
commit
2250b01fdd
|
@ -57,11 +57,11 @@ public class HTMLClientLogger extends BaseLogger implements ToolingClientLogger
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void logRequest(String method, String url, List<String> headers, byte[] body) {
|
public void logRequest(String method, String url, List<String> headers, byte[] body) {
|
||||||
|
if (DEBUG) {
|
||||||
|
System.out.println(" txlog req: " +method+" "+url+" "+present(body));
|
||||||
|
}
|
||||||
if (file == null)
|
if (file == null)
|
||||||
return;
|
return;
|
||||||
if (DEBUG) {
|
|
||||||
System.out.println("tx: " +method+" "+url+" "+present(body));
|
|
||||||
}
|
|
||||||
String id = nextId();
|
String id = nextId();
|
||||||
file.println("<hr/><a name=\"l"+id+"\"> </a>");
|
file.println("<hr/><a name=\"l"+id+"\"> </a>");
|
||||||
file.println("<p>#"+id+"</p>");
|
file.println("<p>#"+id+"</p>");
|
||||||
|
@ -81,11 +81,11 @@ public class HTMLClientLogger extends BaseLogger implements ToolingClientLogger
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void logResponse(String outcome, List<String> headers, byte[] body) {
|
public void logResponse(String outcome, List<String> headers, byte[] body) {
|
||||||
|
if (DEBUG) {
|
||||||
|
System.out.println(" txlog resp: " +outcome+" "+present(body));
|
||||||
|
}
|
||||||
if (file == null)
|
if (file == null)
|
||||||
return;
|
return;
|
||||||
if (DEBUG) {
|
|
||||||
System.out.println("tx: " +outcome+" "+present(body));
|
|
||||||
}
|
|
||||||
file.println("<pre>");
|
file.println("<pre>");
|
||||||
file.println(outcome);
|
file.println(outcome);
|
||||||
for (String s : headers)
|
for (String s : headers)
|
||||||
|
@ -106,8 +106,8 @@ public class HTMLClientLogger extends BaseLogger implements ToolingClientLogger
|
||||||
}
|
}
|
||||||
String cnt = new String(body);
|
String cnt = new String(body);
|
||||||
cnt = cnt.replace("\n", " ").replace("\r", "");
|
cnt = cnt.replace("\n", " ").replace("\r", "");
|
||||||
if (cnt.length() > 400) {
|
if (cnt.length() > 800) {
|
||||||
return cnt.substring(0, 398)+"...";
|
return cnt.substring(0, 798)+"...";
|
||||||
} else {
|
} else {
|
||||||
return cnt;
|
return cnt;
|
||||||
}
|
}
|
||||||
|
|
|
@ -285,6 +285,9 @@ public class TerminologyCache {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ValidationResult getValidation(CacheToken cacheToken) {
|
public ValidationResult getValidation(CacheToken cacheToken) {
|
||||||
|
if (cacheToken.key == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
synchronized (lock) {
|
synchronized (lock) {
|
||||||
NamedCache nc = getNamedCache(cacheToken);
|
NamedCache nc = getNamedCache(cacheToken);
|
||||||
CacheEntry e = nc.map.get(cacheToken.key);
|
CacheEntry e = nc.map.get(cacheToken.key);
|
||||||
|
@ -296,14 +299,16 @@ public class TerminologyCache {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cacheValidation(CacheToken cacheToken, ValidationResult res, boolean persistent) {
|
public void cacheValidation(CacheToken cacheToken, ValidationResult res, boolean persistent) {
|
||||||
synchronized (lock) {
|
if (cacheToken.key != null) {
|
||||||
NamedCache nc = getNamedCache(cacheToken);
|
synchronized (lock) {
|
||||||
CacheEntry e = new CacheEntry();
|
NamedCache nc = getNamedCache(cacheToken);
|
||||||
e.request = cacheToken.request;
|
CacheEntry e = new CacheEntry();
|
||||||
e.persistent = persistent;
|
e.request = cacheToken.request;
|
||||||
e.v = res;
|
e.persistent = persistent;
|
||||||
store(cacheToken, persistent, nc, e);
|
e.v = res;
|
||||||
}
|
store(cacheToken, persistent, nc, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -266,11 +266,15 @@ public class FHIRToolingClient {
|
||||||
if (p.getValue() instanceof PrimitiveType)
|
if (p.getValue() instanceof PrimitiveType)
|
||||||
ps += p.getName() + "=" + Utilities.encodeUri(((PrimitiveType) p.getValue()).asStringValue()) + "&";
|
ps += p.getName() + "=" + Utilities.encodeUri(((PrimitiveType) p.getValue()).asStringValue()) + "&";
|
||||||
ResourceRequest<T> result;
|
ResourceRequest<T> result;
|
||||||
|
URI url = resourceAddress.resolveOperationURLFromClass(resourceClass, name, ps);
|
||||||
if (complex) {
|
if (complex) {
|
||||||
result = client.issuePostRequest(resourceAddress.resolveOperationURLFromClass(resourceClass, name, ps), ByteUtils.resourceToByteArray(params, false, isJson(getPreferredResourceFormat())), getPreferredResourceFormat(),
|
byte[] body = ByteUtils.resourceToByteArray(params, false, isJson(getPreferredResourceFormat()));
|
||||||
|
client.getLogger().logRequest("POST", url.toString(), null, body);
|
||||||
|
result = client.issuePostRequest(url, body, getPreferredResourceFormat(),
|
||||||
"POST " + resourceClass.getName() + "/$" + name, TIMEOUT_OPERATION_LONG);
|
"POST " + resourceClass.getName() + "/$" + name, TIMEOUT_OPERATION_LONG);
|
||||||
} else {
|
} else {
|
||||||
result = client.issueGetResourceRequest(resourceAddress.resolveOperationURLFromClass(resourceClass, name, ps), getPreferredResourceFormat(), "GET " + resourceClass.getName() + "/$" + name, TIMEOUT_OPERATION_LONG);
|
client.getLogger().logRequest("GET", url.toString(), null, null);
|
||||||
|
result = client.issueGetResourceRequest(url, getPreferredResourceFormat(), "GET " + resourceClass.getName() + "/$" + name, TIMEOUT_OPERATION_LONG);
|
||||||
}
|
}
|
||||||
if (result.isUnsuccessfulRequest()) {
|
if (result.isUnsuccessfulRequest()) {
|
||||||
throw new EFhirClientException("Server returned error code " + result.getHttpStatus(), (OperationOutcome) result.getPayload());
|
throw new EFhirClientException("Server returned error code " + result.getHttpStatus(), (OperationOutcome) result.getPayload());
|
||||||
|
|
|
@ -734,7 +734,7 @@ public class BaseValidator {
|
||||||
fr = ValueSetUtilities.generateImplicitValueSet(reference);
|
fr = ValueSetUtilities.generateImplicitValueSet(reference);
|
||||||
}
|
}
|
||||||
|
|
||||||
timeTracker.tx(t);
|
timeTracker.tx(t, "vs "+uri);
|
||||||
return fr;
|
return fr;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
|
|
|
@ -31,7 +31,9 @@ public class TimeTracker {
|
||||||
overall = overall + (System.nanoTime() - start);
|
overall = overall + (System.nanoTime() - start);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void tx(long start) {
|
public void tx(long start, String s) {
|
||||||
|
long ms = (System.nanoTime() - start) / 1000000;
|
||||||
|
// System.out.println("tx: "+ms+" "+s);
|
||||||
txTime = txTime + (System.nanoTime() - start);
|
txTime = txTime + (System.nanoTime() - start);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -524,7 +524,7 @@ public class QuestionnaireValidator extends BaseValidator {
|
||||||
|
|
||||||
long t = System.nanoTime();
|
long t = System.nanoTime();
|
||||||
ValidationResult res = context.validateCode(new ValidationOptions(stack.getWorkingLang()), c, vs);
|
ValidationResult res = context.validateCode(new ValidationOptions(stack.getWorkingLang()), c, vs);
|
||||||
timeTracker.tx(t);
|
timeTracker.tx(t, "vc "+c.getSystem()+"#"+c.getCode()+" '"+c.getDisplay()+"'");
|
||||||
if (!res.isOk()) {
|
if (!res.isOk()) {
|
||||||
txRule(errors, res.getTxLink(), IssueType.CODEINVALID, value.line(), value.col(), stack.getLiteralPath(), false, I18nConstants.QUESTIONNAIRE_QR_ITEM_BADOPTION, c.getSystem(), c.getCode());
|
txRule(errors, res.getTxLink(), IssueType.CODEINVALID, value.line(), value.col(), stack.getLiteralPath(), false, I18nConstants.QUESTIONNAIRE_QR_ITEM_BADOPTION, c.getSystem(), c.getCode());
|
||||||
} else if (res.getSeverity() != null) {
|
} else if (res.getSeverity() != null) {
|
||||||
|
|
Loading…
Reference in New Issue