From c6ff44f1dc8d9c84e24735722caeaa6d5d916fcd Mon Sep 17 00:00:00 2001 From: Brian Hawkins Date: Tue, 19 Mar 2019 10:10:12 -0600 Subject: [PATCH] Fixed build file name, fixed disk usage setting --- build.groovy | 21 ++++++++----------- pom.xml | 2 +- .../plugin/remote/RemoteListener.java | 3 ++- src/main/resources/kairos-remote.properties | 2 +- .../plugin/remote/RemoteListenerTest.java | 3 ++- 5 files changed, 15 insertions(+), 16 deletions(-) diff --git a/build.groovy b/build.groovy index 0f0c399..3884bd6 100644 --- a/build.groovy +++ b/build.groovy @@ -26,16 +26,13 @@ println("===============================================") saw.setProperty(Tablesaw.PROP_MULTI_THREAD_OUTPUT, Tablesaw.PROP_VALUE_ON) -programName = "kairos-kafka-monitor" +programName = "kairos-remote" //Do not use '-' in version string, it breaks rpm uninstall. -version = "1.3.0" -release = saw.getProperty("KAIROS_RELEASE_NUMBER", "0.1beta") //package release number -summary = "KairosDB" +version = "1.0" +release = saw.getProperty("KAIROS_RELEASE_NUMBER", "1") //package release number +summary = "KairosDB Remote" description = """\ -KairosDB is a time series database that stores numeric values along -with key/value tags to a nosql data store. Currently supported -backends are Cassandra and H2. An H2 implementation is provided -for development work. +Remote plugin for KairosDB to send metrics to a remote KairosDB instance. """ @@ -133,12 +130,12 @@ def doRPM(Rule rule) rpmBuilder.addDependencyMore("kairosdb", "1.2.0") - addFileSetToRPM(rpmBuilder, "$rpmBaseInstallDir/lib/kafka-monitor", new RegExFileSet("target", ".*\\.jar")) - addFileSetToRPM(rpmBuilder, "$rpmBaseInstallDir/lib/kafka-monitor", new RegExFileSet("target/dependency", ".*\\.jar")) + addFileSetToRPM(rpmBuilder, "$rpmBaseInstallDir/lib/kairos-remote", new RegExFileSet("target", ".*\\.jar")) + addFileSetToRPM(rpmBuilder, "$rpmBaseInstallDir/lib/kairos-remote", new RegExFileSet("target/dependency", ".*\\.jar")) - rpmBuilder.addFile("$rpmBaseInstallDir/conf/kafka-monitor.properties", - new File("src/main/resources/kafka-monitor.properties"), 0644, new Directive(Directive.RPMFILE_CONFIG | Directive.RPMFILE_NOREPLACE)) + rpmBuilder.addFile("$rpmBaseInstallDir/conf/kairos-remote.properties", + new File("src/main/resources/kairos-remote.properties"), 0644, new Directive(Directive.RPMFILE_CONFIG | Directive.RPMFILE_NOREPLACE)) println("Building RPM "+rule.getTarget()) diff --git a/pom.xml b/pom.xml index 7994810..49ea09b 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.kairosdb kairos-remote - 1.0-SNAPSHOT + 1.0 jar kairos-remote diff --git a/src/main/java/org/kairosdb/plugin/remote/RemoteListener.java b/src/main/java/org/kairosdb/plugin/remote/RemoteListener.java index 928b745..ed5f4e1 100644 --- a/src/main/java/org/kairosdb/plugin/remote/RemoteListener.java +++ b/src/main/java/org/kairosdb/plugin/remote/RemoteListener.java @@ -396,7 +396,8 @@ private void cleanDiskSpace() private boolean hasSpace() { - return m_dropPercent >= 100 || m_diskUtils.percentAvailable(m_dataDirectory) < m_dropPercent; + long usedSpace = 100 - m_diskUtils.percentAvailable(m_dataDirectory); + return m_dropPercent >= 100 || usedSpace < m_dropPercent; } //Rolls to a new file and zips up the current one diff --git a/src/main/resources/kairos-remote.properties b/src/main/resources/kairos-remote.properties index 48e52d9..cdebd4b 100644 --- a/src/main/resources/kairos-remote.properties +++ b/src/main/resources/kairos-remote.properties @@ -23,7 +23,7 @@ kairosdb.remote.random_delay=0 # values in this comma-separated list are forwarded on. #kairosdb.remote.prefix_filter="" -# Drops the oldest zipped files waiting to be sent if the available disk space percent is +# Drops the oldest zipped files waiting to be sent if the used disk space percent is # greater than the specified value. This is to prevent filling up the disk space # if the receiving node is inaccessible. If set to 100, no files are deleted. # The percent must be greater than 0. diff --git a/src/test/java/org/kairosdb/plugin/remote/RemoteListenerTest.java b/src/test/java/org/kairosdb/plugin/remote/RemoteListenerTest.java index 0fb489b..71ebf6f 100644 --- a/src/test/java/org/kairosdb/plugin/remote/RemoteListenerTest.java +++ b/src/test/java/org/kairosdb/plugin/remote/RemoteListenerTest.java @@ -52,7 +52,7 @@ public void tearDown() throws IOException @Test public void test_cleanup() throws IOException, DatastoreException { - when(mockDiskUtils.percentAvailable(any())).thenReturn(96L).thenReturn(96L).thenReturn(80L); + when(mockDiskUtils.percentAvailable(any())).thenReturn(4L).thenReturn(4L).thenReturn(20L); RemoteListener remoteListener = new RemoteListener(tempDir.getAbsolutePath(), "95", 2000,"localhost", mockRemoteHost, mockEventBus, mockDiskUtils); @@ -74,6 +74,7 @@ public void test_cleanup() throws IOException, DatastoreException @Test public void test_sendData() throws IOException, DatastoreException { + when(mockDiskUtils.percentAvailable(any())).thenReturn(20L); RemoteListener remoteListener = new RemoteListener(tempDir.getAbsolutePath(), "95", 2000,"localhost", mockRemoteHost, mockEventBus, mockDiskUtils);