Tabnine Logo
StorageSizeWithTimeLimitLogUploadStrategy
Code IndexAdd Tabnine to your IDE (free)

How to use
StorageSizeWithTimeLimitLogUploadStrategy
in
org.kaaproject.kaa.client.logging.strategies

Best Java code snippets using org.kaaproject.kaa.client.logging.strategies.StorageSizeWithTimeLimitLogUploadStrategy (Showing top 5 results out of 315)

origin: kaaproject/kaa

public StorageSizeWithTimeLimitLogUploadStrategy(int volumeThreshold, long timeLimit,
                         TimeUnit timeUnit) {
 setUploadCheckPeriod((int) timeUnit.toSeconds(timeLimit));
 setVolumeThreshold(volumeThreshold);
}
origin: kaaproject/kaa

@Test
public void testEqualToRecordThresholdCount() {
 int thresholdVolume = 5;
 int uploadCheckPeriod = 2000; // 2 Sec
 LogStorageStatus logStorageStatus = Mockito.mock(LogStorageStatus.class);
 Mockito.when(logStorageStatus.getConsumedVolume()).thenReturn((long) thresholdVolume);
 StorageSizeWithTimeLimitLogUploadStrategy strategy =
   new StorageSizeWithTimeLimitLogUploadStrategy(thresholdVolume, uploadCheckPeriod, TimeUnit.MILLISECONDS);
 Assert.assertEquals(strategy.checkUploadNeeded(logStorageStatus), LogUploadStrategyDecision.UPLOAD);
}
origin: kaaproject/kaa

@Test
public void testLessThanRecordThresholdCount() {
 int thresholdVolume = 5;
 int uploadCheckPeriod = 2000; // 2 Sec
 LogStorageStatus logStorageStatus = Mockito.mock(LogStorageStatus.class);
 Mockito.when(logStorageStatus.getConsumedVolume()).thenReturn((long) (thresholdVolume - 1));
 StorageSizeWithTimeLimitLogUploadStrategy strategy =
   new StorageSizeWithTimeLimitLogUploadStrategy(thresholdVolume, uploadCheckPeriod, TimeUnit.MILLISECONDS);
 Assert.assertEquals(strategy.checkUploadNeeded(logStorageStatus), LogUploadStrategyDecision.NOOP);
}
origin: kaaproject/kaa

@Test
public void testGreaterThanRecordThresholdCount() {
 int thresholdVolume = 5;
 int uploadCheckPeriod = 2000; // 2 Sec
 LogStorageStatus logStorageStatus = Mockito.mock(LogStorageStatus.class);
 Mockito.when(logStorageStatus.getConsumedVolume()).thenReturn((long) (thresholdVolume + 1));
 StorageSizeWithTimeLimitLogUploadStrategy strategy =
   new StorageSizeWithTimeLimitLogUploadStrategy(thresholdVolume, uploadCheckPeriod, TimeUnit.MILLISECONDS);
 Assert.assertEquals(strategy.checkUploadNeeded(logStorageStatus), LogUploadStrategyDecision.UPLOAD);
}
origin: kaaproject/kaa

@Test
public void testUploadAfterSomeTime() throws InterruptedException {
 int thresholdVolume = 5;
 int uploadCheckPeriod = 2000; // 2 Sec
 LogStorageStatus logStorageStatus = Mockito.mock(LogStorageStatus.class);
 Mockito.when(logStorageStatus.getConsumedVolume()).thenReturn((long) 0);
 StorageSizeWithTimeLimitLogUploadStrategy strategy =
   new StorageSizeWithTimeLimitLogUploadStrategy(thresholdVolume, uploadCheckPeriod, TimeUnit.MILLISECONDS);
 Assert.assertEquals(strategy.checkUploadNeeded(logStorageStatus), LogUploadStrategyDecision.NOOP);
 Thread.sleep(uploadCheckPeriod / 2);
 Assert.assertEquals(strategy.checkUploadNeeded(logStorageStatus), LogUploadStrategyDecision.NOOP);
 Thread.sleep(uploadCheckPeriod / 2);
 Assert.assertEquals(strategy.checkUploadNeeded(logStorageStatus), LogUploadStrategyDecision.UPLOAD);
 Thread.sleep(uploadCheckPeriod / 2);
 Assert.assertEquals(strategy.checkUploadNeeded(logStorageStatus), LogUploadStrategyDecision.NOOP);
 Thread.sleep(uploadCheckPeriod / 2);
 Assert.assertEquals(strategy.checkUploadNeeded(logStorageStatus), LogUploadStrategyDecision.UPLOAD);
}
org.kaaproject.kaa.client.logging.strategiesStorageSizeWithTimeLimitLogUploadStrategy

Javadoc

Reference implementation for LogUploadStrategy. Start log upload when there storage size is equals or greater than volumeThreshold bytes or records are stored for more then timeLimit TimeUnit units.

Most used methods

  • <init>
  • checkUploadNeeded
  • setUploadCheckPeriod
  • setVolumeThreshold

Popular in Java

  • Updating database using SQL prepared statement
  • getApplicationContext (Context)
  • compareTo (BigDecimal)
  • setContentView (Activity)
  • FileInputStream (java.io)
    An input stream that reads bytes from a file. File file = ...finally if (in != null) in.clos
  • InputStreamReader (java.io)
    A class for turning a byte stream into a character stream. Data read from the source input stream is
  • ResultSet (java.sql)
    An interface for an object which represents a database table entry, returned as the result of the qu
  • JTable (javax.swing)
  • JTextField (javax.swing)
  • Table (org.hibernate.mapping)
    A relational table
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now