public class Utils extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
Utils.InputStreamConsumer<T> |
Modifier and Type | Field and Description |
---|---|
static Pattern |
ARRAY_ELEMENT_INDEX |
static Utils.InputStreamConsumer<?> |
JAVABINCONSUMER |
static Utils.InputStreamConsumer<?> |
JSONCONSUMER |
static Function<JSONParser,ObjectBuilder> |
MAPOBJBUILDER |
static Function<JSONParser,ObjectBuilder> |
MAPWRITEROBJBUILDER |
static Function<Object,String> |
OBJECT_TO_STRING
|
static Function<JSONParser,ObjectBuilder> |
STANDARDOBJBUILDER |
Constructor and Description |
---|
Utils() |
Modifier and Type | Method and Description |
---|---|
static void |
consumeFully(org.apache.http.HttpEntity entity)
If the passed entity has content, make sure it is fully
read and closed.
|
static <T> T |
executeGET(org.apache.http.client.HttpClient client,
String url,
Utils.InputStreamConsumer<T> consumer) |
static <T> T |
executeHttpMethod(org.apache.http.client.HttpClient client,
String url,
Utils.InputStreamConsumer<T> consumer,
org.apache.http.client.methods.HttpRequestBase httpMethod) |
static void |
forEachMapEntry(Object o,
BiConsumer fun) |
static void |
forEachMapEntry(Object o,
List<String> path,
BiConsumer fun) |
static void |
forEachMapEntry(Object o,
String path,
BiConsumer fun) |
static Object |
fromJavabin(byte[] bytes) |
static Object |
fromJSON(byte[] utf8) |
static Object |
fromJSON(byte[] utf8,
int offset,
int length) |
static Object |
fromJSON(InputStream is) |
static Object |
fromJSON(InputStream is,
Function<JSONParser,ObjectBuilder> objBuilderProvider) |
static Object |
fromJSON(Reader is) |
static Object |
fromJSONResource(String resourceName) |
static Object |
fromJSONString(String json) |
static String |
getBaseUrlForNodeName(String nodeName,
String urlScheme) |
static String |
getBaseUrlForNodeName(String nodeName,
String urlScheme,
boolean isV2) |
static Collection |
getDeepCopy(Collection c,
int maxDepth,
boolean mutable) |
static Collection |
getDeepCopy(Collection c,
int maxDepth,
boolean mutable,
boolean sorted) |
static Map |
getDeepCopy(Map map,
int maxDepth) |
static Map |
getDeepCopy(Map map,
int maxDepth,
boolean mutable) |
static Map |
getDeepCopy(Map map,
int maxDepth,
boolean mutable,
boolean sorted) |
static Map<String,Object> |
getJson(DistribStateManager distribStateManager,
String path) |
static Map<String,Object> |
getJson(SolrZkClient zkClient,
String path,
boolean retryOnConnLoss)
Assumes data in ZooKeeper is a JSON string, deserializes it and returns as a Map
|
static JSONParser |
getJSONParser(Reader reader) |
static String |
getMDCNode() |
static Object |
getObjectByPath(Object root,
boolean onlyPrimitive,
List<String> hierarchy) |
static Object |
getObjectByPath(Object root,
boolean onlyPrimitive,
String hierarchy) |
static SpecProvider |
getSpec(String name) |
static <T> T |
handleExp(org.slf4j.Logger logger,
T def,
Callable<T> c) |
static Map<String,Object> |
makeMap(boolean skipNulls,
Object... keyVals) |
static Map<String,Object> |
makeMap(Object... keyVals) |
static boolean |
mergeJson(Map<String,Object> sink,
Map<String,Object> input)
Applies one json over other.
|
static Utils.InputStreamConsumer<ByteBuffer> |
newBytesConsumer(int maxSize) |
static String |
parseMetricsReplicaName(String collectionName,
String coreName) |
static void |
reflectWrite(MapWriter.EntryWriter ew,
Object o) |
static boolean |
setObjectByPath(Object root,
List<String> hierarchy,
Object value) |
static boolean |
setObjectByPath(Object root,
String hierarchy,
Object value) |
static long |
time(TimeSource timeSource,
TimeUnit unit) |
static long |
timeElapsed(TimeSource timeSource,
long start,
TimeUnit unit) |
static InputStream |
toJavabin(Object o) |
static byte[] |
toJSON(Object o) |
static String |
toJSONString(Object o) |
static byte[] |
toUTF8(CharArr out) |
static void |
writeJson(Object o,
OutputStream os,
boolean indent) |
static Writer |
writeJson(Object o,
Writer writer,
boolean indent) |
public static final Function<JSONParser,ObjectBuilder> STANDARDOBJBUILDER
public static final Function<JSONParser,ObjectBuilder> MAPWRITEROBJBUILDER
public static final Function<JSONParser,ObjectBuilder> MAPOBJBUILDER
public static final Pattern ARRAY_ELEMENT_INDEX
public static final Utils.InputStreamConsumer<?> JAVABINCONSUMER
public static final Utils.InputStreamConsumer<?> JSONCONSUMER
public static void forEachMapEntry(Object o, String path, BiConsumer fun)
public static void forEachMapEntry(Object o, List<String> path, BiConsumer fun)
public static void forEachMapEntry(Object o, BiConsumer fun)
public static InputStream toJavabin(Object o) throws IOException
IOException
public static Object fromJavabin(byte[] bytes) throws IOException
IOException
public static Collection getDeepCopy(Collection c, int maxDepth, boolean mutable)
public static Collection getDeepCopy(Collection c, int maxDepth, boolean mutable, boolean sorted)
public static void writeJson(Object o, OutputStream os, boolean indent) throws IOException
IOException
public static Writer writeJson(Object o, Writer writer, boolean indent) throws IOException
IOException
public static byte[] toJSON(Object o)
public static byte[] toUTF8(CharArr out)
public static Object fromJSON(byte[] utf8)
public static Object fromJSON(byte[] utf8, int offset, int length)
public static Object fromJSON(InputStream is)
public static Object fromJSON(InputStream is, Function<JSONParser,ObjectBuilder> objBuilderProvider)
public static JSONParser getJSONParser(Reader reader)
public static Object getObjectByPath(Object root, boolean onlyPrimitive, String hierarchy)
public static boolean setObjectByPath(Object root, List<String> hierarchy, Object value)
public static Object getObjectByPath(Object root, boolean onlyPrimitive, List<String> hierarchy)
public static void consumeFully(org.apache.http.HttpEntity entity)
entity
- to consume or nullpublic static Map<String,Object> getJson(DistribStateManager distribStateManager, String path) throws InterruptedException, IOException, org.apache.zookeeper.KeeperException
InterruptedException
IOException
org.apache.zookeeper.KeeperException
public static Map<String,Object> getJson(SolrZkClient zkClient, String path, boolean retryOnConnLoss) throws org.apache.zookeeper.KeeperException, InterruptedException
zkClient
- the zookeeper clientpath
- the path to the znode being readretryOnConnLoss
- whether to retry the operation automatically on connection loss, see ZkCmdExecutor.retryOperation(ZkOperation)
org.apache.zookeeper.KeeperException
InterruptedException
public static SpecProvider getSpec(String name)
public static String parseMetricsReplicaName(String collectionName, String coreName)
public static boolean mergeJson(Map<String,Object> sink, Map<String,Object> input)
sink
- the original json object to start with. Ensure that this Map is mutableinput
- the json with new valuespublic static String getBaseUrlForNodeName(String nodeName, String urlScheme, boolean isV2)
public static long time(TimeSource timeSource, TimeUnit unit)
public static long timeElapsed(TimeSource timeSource, long start, TimeUnit unit)
public static String getMDCNode()
public static <T> T handleExp(org.slf4j.Logger logger, T def, Callable<T> c)
public static Utils.InputStreamConsumer<ByteBuffer> newBytesConsumer(int maxSize)
public static <T> T executeGET(org.apache.http.client.HttpClient client, String url, Utils.InputStreamConsumer<T> consumer) throws SolrException
SolrException
public static <T> T executeHttpMethod(org.apache.http.client.HttpClient client, String url, Utils.InputStreamConsumer<T> consumer, org.apache.http.client.methods.HttpRequestBase httpMethod)
public static void reflectWrite(MapWriter.EntryWriter ew, Object o) throws IOException
IOException
Copyright © 2000-2020 Apache Software Foundation. All Rights Reserved.