Package org.apache.solr.packagemanager
Class PackageUtils
- java.lang.Object
-
- org.apache.solr.packagemanager.PackageUtils
-
public class PackageUtils extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static String
BLACK
static String
BLUE
static String
CLUSTER_PLUGINS_PATH
static String
CLUSTERPROPS_PATH
static String
CYAN
static String
GREEN
static String
LATEST
Represents a version which denotes the latest version available at the moment.static String
PACKAGE_PATH
static String
PURPLE
static String
RED
static String
REPOSITORIES_ZK_PATH
static String
WHITE
static String
YELLOW
-
Constructor Summary
Constructors Constructor Description PackageUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
compareVersions(String v1, String v2)
Compares two versions v1 and v2.static SolrPackage.Manifest
fetchManifest(HttpSolrClient solrClient, String solrBaseUrl, String manifestFilePath, String expectedSHA512)
Fetches a manifest file from the File Store / Package Store.static String
getCollectionParamsPath(String collection)
static String
getFileFromJarsAsString(List<Path> jars, String filename)
Search through the list of jar files for a given file.static <T> T
getJson(org.apache.http.client.HttpClient client, String url, Class<T> klass)
Download JSON from the url and deserialize into klass.static String
getJsonStringFromUrl(org.apache.http.client.HttpClient client, String url)
Returns JSON string from a given URLstatic com.fasterxml.jackson.databind.ObjectMapper
getMapper()
static com.jayway.jsonpath.Configuration
jsonPathConfiguration()
static void
postFile(SolrClient client, ByteBuffer buffer, String name, String sig)
Uploads a file to the package store / file store of Solr.static void
print(Object message)
static void
print(String color, Object message)
static void
printGreen(Object message)
Console print using green colorstatic void
printRed(Object message)
Console print using red colorstatic String
resolve(String str, Map<String,String> defaults, Map<String,String> overrides, Map<String,String> systemParams)
Replace a templatized string with parameter substituted string.static void
uploadKey(byte[] bytes, String path, Path home, HttpSolrClient client)
static String[]
validateCollections(String[] collections)
-
-
-
Field Detail
-
LATEST
public static String LATEST
Represents a version which denotes the latest version available at the moment.
-
PACKAGE_PATH
public static String PACKAGE_PATH
-
CLUSTER_PLUGINS_PATH
public static String CLUSTER_PLUGINS_PATH
-
REPOSITORIES_ZK_PATH
public static String REPOSITORIES_ZK_PATH
-
CLUSTERPROPS_PATH
public static String CLUSTERPROPS_PATH
-
BLACK
public static String BLACK
-
RED
public static String RED
-
GREEN
public static String GREEN
-
YELLOW
public static String YELLOW
-
BLUE
public static String BLUE
-
PURPLE
public static String PURPLE
-
CYAN
public static String CYAN
-
WHITE
public static String WHITE
-
-
Method Detail
-
jsonPathConfiguration
public static com.jayway.jsonpath.Configuration jsonPathConfiguration()
-
getMapper
public static com.fasterxml.jackson.databind.ObjectMapper getMapper()
-
postFile
public static void postFile(SolrClient client, ByteBuffer buffer, String name, String sig) throws SolrServerException, IOException
Uploads a file to the package store / file store of Solr.- Parameters:
client
- A Solr clientbuffer
- File contentsname
- Name of the file as it will appear in the file store (can be hierarchical)sig
- Signature digest (public key should be separately uploaded to ZK)- Throws:
SolrServerException
IOException
-
getJson
public static <T> T getJson(org.apache.http.client.HttpClient client, String url, Class<T> klass)
Download JSON from the url and deserialize into klass.
-
getFileFromJarsAsString
public static String getFileFromJarsAsString(List<Path> jars, String filename)
Search through the list of jar files for a given file. Returns string of the file contents or null if file wasn't found. This is suitable for looking for manifest or property files within pre-downloaded jar files. Please note that the first instance of the file found is returned.
-
getJsonStringFromUrl
public static String getJsonStringFromUrl(org.apache.http.client.HttpClient client, String url)
Returns JSON string from a given URL
-
fetchManifest
public static SolrPackage.Manifest fetchManifest(HttpSolrClient solrClient, String solrBaseUrl, String manifestFilePath, String expectedSHA512) throws MalformedURLException, IOException
Fetches a manifest file from the File Store / Package Store. A SHA512 check is enforced after fetching.- Throws:
MalformedURLException
IOException
-
resolve
public static String resolve(String str, Map<String,String> defaults, Map<String,String> overrides, Map<String,String> systemParams)
Replace a templatized string with parameter substituted string. First applies the overrides, then defaults and then systemParams.
-
compareVersions
public static int compareVersions(String v1, String v2)
Compares two versions v1 and v2. Returns negative if v1 isLessThan v2, positive if v1 isGreaterThan v2 and 0 if equal.
-
printGreen
public static void printGreen(Object message)
Console print using green color
-
printRed
public static void printRed(Object message)
Console print using red color
-
print
public static void print(Object message)
-
uploadKey
public static void uploadKey(byte[] bytes, String path, Path home, HttpSolrClient client) throws IOException
- Throws:
IOException
-
-