@Test public void should_not_create_and_upload_file_when_no_invocations_exist() throws Exception { Set<String> invocations = new HashSet<>(); publisher.setCodeBaseFingerprint(CodeBaseFingerprint.builder(config).build()); publisher.doPublishInvocationData(System.currentTimeMillis(), invocations); assertThat(uploadedFile, nullValue()); assertThat(uploadedPublicationSize, is(0)); }
@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); } }
HttpInvocationDataPublisherImpl extends AbstractInvocationDataPublisher { @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); } } }
HttpInvocationDataPublisherImpl extends AbstractInvocationDataPublisher { @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); } } HttpInvocationDataPublisherImpl(AgentConfig config); }
HttpInvocationDataPublisherImpl extends AbstractInvocationDataPublisher { @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); } } HttpInvocationDataPublisherImpl(AgentConfig config); @Override String getName(); }
HttpInvocationDataPublisherImpl extends AbstractInvocationDataPublisher { @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); } } HttpInvocationDataPublisherImpl(AgentConfig config); @Override String getName();  }