Package org.jgroups.util
Class CompareMetrics
java.lang.Object
org.jgroups.util.CompareMetrics
Tools 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
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static booleancompareAttributes(Collection<String> new_attrs, Collection<String> old_attrs) protected static voidcompareMetrics(Map<String, Collection<String>> new_metrics, Map<String, Collection<String>> old_metrics) Compares the new to the old metrics by removing 'old' from 'new' (if present in both 'new' and 'old').static intprivate static StringfileToString(File f) protected static Collection<String> getAttributes(Class<?> clazz, String prefix) static voidprotected static Stringprint(Map<String, Collection<String>> map) protected static Map<String, Collection<String>> protected static Map<String, Collection<String>> readOldMetrics(String from_file) protected static StringReads until the next bracket '}' and returns the string excluding the bracket, or throws an exception if no bracket has been foundprotected static voidreplaceVariables(InputStream in, OutputStream out, 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(Map<String, Collection<String>> metrics, String to_file) protected static voidwriteVarToStream(String var, Properties p, OutputStream out)
-
Field Details
-
ROOT_PACKAGE
- See Also:
-
PACKAGES
-
-
Constructor Details
-
CompareMetrics
public CompareMetrics()
-
-
Method Details
-
main
- Throws:
IOExceptionClassNotFoundException
-
readOldMetrics
- Throws:
IOException
-
readCurrentMetrics
protected static Map<String,Collection<String>> readCurrentMetrics() throws IOException, ClassNotFoundException- Throws:
IOExceptionClassNotFoundException
-
getProtocols
- Throws:
IOExceptionClassNotFoundException
-
writeMetricsToFile
protected static void writeMetricsToFile(Map<String, Collection<String>> metrics, String to_file) throws IOException- Throws:
IOException
-
compareMetrics
protected static void compareMetrics(Map<String, Collection<String>> new_metrics, Map<String, Collection<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(Collection<String> new_attrs, Collection<String> old_attrs) -
print
-
getAttributes
protected static Collection<String> getAttributes(Class<?> clazz, String prefix) throws IOException, ClassNotFoundException - Throws:
IOExceptionClassNotFoundException
-
replaceVariables
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(String var, Properties p, OutputStream out) throws IOException - Throws:
IOException
-
readUntilBracket
Reads until the next bracket '}' and returns the string excluding the bracket, or throws an exception if no bracket has been found- Throws:
IOException
-
fileToString
- Throws:
Exception
-
copy
- Throws:
IOException
-