use of io.codekvast.javaagent.publishing.CodekvastPublishingException in project codekvast by crispab.
the class HttpInvocationDataPublisherImpl method doPublishInvocationData.
@Override
void doPublishInvocationData(long recordingIntervalStartedAtMillis, Set<String> invocations) throws CodekvastPublishingException {
if (invocations.isEmpty()) {
logger.fine("Codekvast detected no invocations to publish");
return;
}
String url = getConfig().getInvocationDataUploadEndpoint();
File file = null;
try {
InvocationDataPublication2 publication = createPublication(getCustomerId(), recordingIntervalStartedAtMillis, invocations);
file = FileUtils.serializeToFile(publication, getConfig().getFilenamePrefix("invocations-"), ".ser");
doPost(file, url, getCodeBaseFingerprint().toString(), publication.getInvocations().size());
logger.fine(String.format("Codekvast uploaded %d invocations (%s) to %s", publication.getInvocations().size(), LogUtil.humanReadableByteCount(file.length()), url));
} catch (Exception e) {
throw new CodekvastPublishingException("Cannot upload invocation data to " + url, e);
} finally {
FileUtils.safeDelete(file);
}
}
use of io.codekvast.javaagent.publishing.CodekvastPublishingException in project codekvast by crispab.
the class InvocationRegistryTest method doExtremelyConcurrentRegistrationOf.
private boolean doExtremelyConcurrentRegistrationOf(final Signature... signatures) throws InterruptedException {
val numThreads = 25;
val numRegistrations = 10_000;
val finishLine = new CountDownLatch(numThreads * numRegistrations);
val random = new Random();
val startingGun = new CountDownLatch(1);
for (int i = 0; i < numThreads; i++) {
Thread t = new Thread(() -> {
try {
int max = signatures.length;
startingGun.await();
for (int j = 0; j < numRegistrations; j++) {
InvocationRegistry.registerMethodInvocation(signatures[random.nextInt(max)]);
finishLine.countDown();
}
} catch (InterruptedException ignore) {
Thread.currentThread().interrupt();
}
});
t.start();
}
Thread publisher = new Thread(() -> {
NullInvocationDataPublisher publisher1 = new NullInvocationDataPublisher();
try {
startingGun.await();
while (true) {
InvocationRegistry.publishInvocationData(publisher1);
}
} catch (InterruptedException | CodekvastPublishingException ignore) {
Thread.currentThread().interrupt();
}
});
publisher.start();
startingGun.countDown();
finishLine.await();
publisher.interrupt();
InvocationRegistry.initialize(null);
return true;
}
use of io.codekvast.javaagent.publishing.CodekvastPublishingException in project codekvast by crispab.
the class HttpCodeBasePublisherImpl method doPublishCodeBase.
@Override
public void doPublishCodeBase(CodeBase codeBase) throws CodekvastPublishingException {
String url = getConfig().getCodeBaseUploadEndpoint();
File file = null;
try {
CodeBasePublication3 publication = codeBase.getCodeBasePublication(getCustomerId(), this.getSequenceNumber());
file = FileUtils.serializeToFile(publication, getConfig().getFilenamePrefix("codebase-"), ".ser");
doPost(file, url, codeBase.getFingerprint().toString(), publication.getEntries().size());
logger.fine(String.format("Codekvast uploaded %d methods (%s) to %s", publication.getEntries().size(), LogUtil.humanReadableByteCount(file.length()), url));
} catch (IOException e) {
throw new CodekvastPublishingException("Cannot upload code base to " + url, e);
} finally {
FileUtils.safeDelete(file);
}
}
Aggregations