Package org.jgroups.util
Class CompareMetrics
- java.lang.Object
-
- org.jgroups.util.CompareMetrics
-
public class CompareMetrics extends java.lang.ObjectTools to (1) dump all protocols and the names of their attributes (ManagedAttribute) and properties (Property) to file, (2) read from that file (old) and compare whether old is a proper subset of new, ie. if all protocols and attributes/properties still have the same names in new.
To be run before releasing a new version (mainly minor and micro).- Since:
- 5.4.4
- Author:
- Bela Ban
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.String[]PACKAGESprotected static java.lang.StringROOT_PACKAGE
-
Constructor Summary
Constructors Constructor Description CompareMetrics()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description protected static booleancompareAttributes(java.util.Collection<java.lang.String> new_attrs, java.util.Collection<java.lang.String> old_attrs)protected static voidcompareMetrics(java.util.Map<java.lang.String,java.util.Collection<java.lang.String>> new_metrics, java.util.Map<java.lang.String,java.util.Collection<java.lang.String>> old_metrics)Compares the new to the old metrics by removing 'old' from 'new' (if present in both 'new' and 'old').
If protocols/attributes remain, then either new protocols or attributes were added in new, or attributes / protocols changed.static intcopy(java.io.Reader input, java.io.Writer output)protected static java.util.Collection<java.lang.String>getAttributes(java.lang.Class<?> clazz, java.lang.String prefix)protected static java.util.Set<java.lang.Class<?>>getProtocols()static voidmain(java.lang.String[] args)protected static java.lang.Stringprint(java.util.Map<java.lang.String,java.util.Collection<java.lang.String>> map)protected static java.util.Map<java.lang.String,java.util.Collection<java.lang.String>>readCurrentMetrics()protected static java.util.Map<java.lang.String,java.util.Collection<java.lang.String>>readOldMetrics(java.lang.String from_file)protected static java.lang.StringreadUntilBracket(java.io.InputStream in)Reads until the next bracket '}' and returns the string excluding the bracket, or throws an exception if no bracket has been foundprotected static voidreplaceVariables(java.io.InputStream in, java.io.OutputStream out, java.util.Properties p)Reads from the input stream and replaces occurrences of ${PROT} with p.get("PROT") and writes this to the output stream.protected static voidwriteMetricsToFile(java.util.Map<java.lang.String,java.util.Collection<java.lang.String>> metrics, java.lang.String to_file)protected static voidwriteVarToStream(java.lang.String var, java.util.Properties p, java.io.OutputStream out)
-
-
-
Field Detail
-
ROOT_PACKAGE
protected static final java.lang.String ROOT_PACKAGE
- See Also:
- Constant Field Values
-
PACKAGES
protected static final java.lang.String[] PACKAGES
-
-
Method Detail
-
main
public static void main(java.lang.String[] args) throws java.io.IOException, java.lang.ClassNotFoundException- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundException
-
readOldMetrics
protected static java.util.Map<java.lang.String,java.util.Collection<java.lang.String>> readOldMetrics(java.lang.String from_file) throws java.io.IOException- Throws:
java.io.IOException
-
readCurrentMetrics
protected static java.util.Map<java.lang.String,java.util.Collection<java.lang.String>> readCurrentMetrics() throws java.io.IOException, java.lang.ClassNotFoundException- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundException
-
getProtocols
protected static java.util.Set<java.lang.Class<?>> getProtocols() throws java.io.IOException, java.lang.ClassNotFoundException- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundException
-
writeMetricsToFile
protected static void writeMetricsToFile(java.util.Map<java.lang.String,java.util.Collection<java.lang.String>> metrics, java.lang.String to_file) throws java.io.IOException- Throws:
java.io.IOException
-
compareMetrics
protected static void compareMetrics(java.util.Map<java.lang.String,java.util.Collection<java.lang.String>> new_metrics, java.util.Map<java.lang.String,java.util.Collection<java.lang.String>> old_metrics)Compares the new to the old metrics by removing 'old' from 'new' (if present in both 'new' and 'old').
If protocols/attributes remain, then either new protocols or attributes were added in new, or attributes / protocols changed. E.g. an attribute changes from "number_of_messages" -> "num_msgs", then "number_of_attributes" will remain in 'old' and "num_msgs" in 'new'.
The goal is that all attributes of 'old' also need to be in 'new', or else we have an incompatible change in that an attribute was renamed or removed. If an attribute or protocol is only in 'new', that's acceptable and means that it was added in 'new.
-
compareAttributes
protected static boolean compareAttributes(java.util.Collection<java.lang.String> new_attrs, java.util.Collection<java.lang.String> old_attrs)
-
print
protected static java.lang.String print(java.util.Map<java.lang.String,java.util.Collection<java.lang.String>> map)
-
getAttributes
protected static java.util.Collection<java.lang.String> getAttributes(java.lang.Class<?> clazz, java.lang.String prefix) throws java.io.IOException, java.lang.ClassNotFoundException- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundException
-
replaceVariables
protected static void replaceVariables(java.io.InputStream in, java.io.OutputStream out, java.util.Properties p)Reads from the input stream and replaces occurrences of ${PROT} with p.get("PROT") and writes this to the output stream. If no value is found, then the ${PROT} will simple be omitted from the output. Escaped values of the form \${PROT} are not looked up and the value without the backslash will be written to the output stream.
-
writeVarToStream
protected static void writeVarToStream(java.lang.String var, java.util.Properties p, java.io.OutputStream out) throws java.io.IOException- Throws:
java.io.IOException
-
readUntilBracket
protected static java.lang.String readUntilBracket(java.io.InputStream in) throws java.io.IOExceptionReads until the next bracket '}' and returns the string excluding the bracket, or throws an exception if no bracket has been found- Throws:
java.io.IOException
-
copy
public static int copy(java.io.Reader input, java.io.Writer output) throws java.io.IOException- Throws:
java.io.IOException
-
-