no more crc32 checksum stuff
This commit is contained in:
parent
2af58b8d9b
commit
a174b18e6a
13 changed files with 23 additions and 106 deletions
|
@ -1,5 +1,5 @@
|
|||
group = org.xbib
|
||||
name = metrics
|
||||
version = 2.1.0
|
||||
version = 2.2.0
|
||||
|
||||
gradle.wrapper.version = 6.4.1
|
||||
gradle.wrapper.version = 6.6.1
|
||||
|
|
|
@ -28,6 +28,7 @@ task sourcesJar(type: Jar, dependsOn: classes) {
|
|||
|
||||
task javadocJar(type: Jar, dependsOn: javadoc) {
|
||||
classifier 'javadoc'
|
||||
from javadoc.destinationDir
|
||||
}
|
||||
|
||||
artifacts {
|
||||
|
|
|
@ -53,12 +53,14 @@ if (project.hasProperty("signing.keyId")) {
|
|||
}
|
||||
}
|
||||
|
||||
nexusPublishing {
|
||||
repositories {
|
||||
sonatype {
|
||||
username = project.property('ossrhUsername')
|
||||
password = project.property('ossrhPassword')
|
||||
packageGroup = "org.xbib"
|
||||
if (project.hasProperty("ossrhUsername")) {
|
||||
nexusPublishing {
|
||||
repositories {
|
||||
sonatype {
|
||||
username = project.property('ossrhUsername')
|
||||
password = project.property('ossrhPassword')
|
||||
packageGroup = "org.xbib"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
4
gradle/repositories/maven.gradle
Normal file
4
gradle/repositories/maven.gradle
Normal file
|
@ -0,0 +1,4 @@
|
|||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
def junitVersion = project.hasProperty('junit.version')?project.property('junit.version'):'5.6.2'
|
||||
def junitVersion = project.hasProperty('junit.version')?project.property('junit.version'):'5.7.2'
|
||||
def hamcrestVersion = project.hasProperty('hamcrest.version')?project.property('hamcrest.version'):'2.2'
|
||||
|
||||
dependencies {
|
||||
|
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,5 +1,5 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.4.1-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-all.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
|
2
gradlew
vendored
2
gradlew
vendored
|
@ -130,7 +130,7 @@ fi
|
|||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
|
||||
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
|
|
21
gradlew.bat
vendored
21
gradlew.bat
vendored
|
@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
|||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
if "%ERRORLEVEL%" == "0" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
@ -54,7 +54,7 @@ goto fail
|
|||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
|
@ -64,21 +64,6 @@ echo location of your Java installation.
|
|||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
|
@ -86,7 +71,7 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
|||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
|
|
|
@ -9,22 +9,14 @@ public interface Count {
|
|||
|
||||
void inc(long n);
|
||||
|
||||
void inc(String index, String type, String id);
|
||||
|
||||
void dec();
|
||||
|
||||
void dec(long n);
|
||||
|
||||
void dec(String index, String type, String id);
|
||||
|
||||
/**
|
||||
* Returns the current count.
|
||||
*
|
||||
* @return the current count
|
||||
*/
|
||||
long getCount();
|
||||
|
||||
String getIncChecksum(String index, String type);
|
||||
|
||||
String getDecChecksum(String index, String type);
|
||||
}
|
||||
|
|
|
@ -3,11 +3,7 @@ package org.xbib.metrics.common;
|
|||
import org.xbib.metrics.api.Count;
|
||||
import org.xbib.metrics.api.Metric;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.LongAdder;
|
||||
import java.util.zip.CRC32;
|
||||
|
||||
/**
|
||||
* An incrementing and decrementing counter metric.
|
||||
|
@ -16,14 +12,8 @@ public class CountMetric implements Metric, Count {
|
|||
|
||||
private final LongAdder count;
|
||||
|
||||
private final Map<String, CRC32> checksumIn;
|
||||
|
||||
private final Map<String, CRC32> checksumOut;
|
||||
|
||||
public CountMetric() {
|
||||
this.count = new LongAdder();
|
||||
this.checksumIn = new HashMap<>();
|
||||
this.checksumOut = new HashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -44,19 +34,6 @@ public class CountMetric implements Metric, Count {
|
|||
count.add(n);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inc(String index, String type, String id) {
|
||||
CRC32 crc32 = checksumIn.get(index + "/" + type);
|
||||
if (crc32 == null) {
|
||||
crc32 = new CRC32();
|
||||
checksumIn.put(index + "/" + type, crc32);
|
||||
}
|
||||
if (id != null) {
|
||||
byte[] b = id.getBytes(StandardCharsets.UTF_8);
|
||||
crc32.update(b, 0, b.length);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrement the counter by one.
|
||||
*/
|
||||
|
@ -75,19 +52,6 @@ public class CountMetric implements Metric, Count {
|
|||
count.add(-n);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dec(String index, String type, String id) {
|
||||
CRC32 crc32 = checksumOut.get(index + "/" + type);
|
||||
if (crc32 == null) {
|
||||
crc32 = new CRC32();
|
||||
checksumOut.put(index + "/" + type, crc32);
|
||||
}
|
||||
if (id != null) {
|
||||
byte[] b = id.getBytes(StandardCharsets.UTF_8);
|
||||
crc32.update(b, 0, b.length);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the counter's current value.
|
||||
*
|
||||
|
@ -98,15 +62,4 @@ public class CountMetric implements Metric, Count {
|
|||
return count.sum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIncChecksum(String index, String type) {
|
||||
return Long.toHexString(checksumIn.containsKey(index + "/" + type) ?
|
||||
checksumIn.get(index + "/" + type).getValue() : 0L);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDecChecksum(String index, String type) {
|
||||
return Long.toHexString(checksumOut.containsKey(index + "/" + type) ?
|
||||
checksumOut.get(index + "/" + type).getValue() : 0L);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,11 +46,6 @@ public class Histogram implements Metric, Sampling, Count {
|
|||
reservoir.update(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inc(String index, String type, String id) {
|
||||
// not used
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dec() {
|
||||
dec(1);
|
||||
|
@ -61,11 +56,6 @@ public class Histogram implements Metric, Sampling, Count {
|
|||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dec(String index, String type, String id) {
|
||||
// not used
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of values recorded.
|
||||
*
|
||||
|
@ -76,16 +66,6 @@ public class Histogram implements Metric, Sampling, Count {
|
|||
return count.sum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIncChecksum(String index, String type) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDecChecksum(String index, String type) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Snapshot getSnapshot() {
|
||||
return reservoir.getSnapshot();
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.util.concurrent.Executors;
|
|||
*/
|
||||
public class MetricRegistry implements MetricSet {
|
||||
|
||||
private final ConcurrentMap<MetricName, Metric> metrics;
|
||||
private final Map<MetricName, Metric> metrics;
|
||||
|
||||
private final List<Listener> listeners;
|
||||
|
||||
|
|
Loading…
Reference in a new issue