backtype.storm.utils
Class Utils

java.lang.Object
  extended by backtype.storm.utils.Utils

public class Utils
extends Object


Nested Class Summary
static class Utils.BoundedExponentialBackoffRetry
           
 
Field Summary
static String DEFAULT_STREAM_ID
           
 
Constructor Summary
Utils()
           
 
Method Summary
static Object deserialize(byte[] serialized)
           
static void downloadFromMaster(Map conf, String file, String localFile)
           
static boolean exceptionCauseIsInstanceOf(Class klass, Throwable throwable)
           
static Map findAndReadConfigFile(String name)
           
static Map findAndReadConfigFile(String name, boolean mustExist)
           
static List<URL> findResources(String name)
           
static
<S,T> T
get(Map<S,T> m, S key, T def)
           
static boolean getBoolean(Object o, boolean defaultValue)
           
static ComponentCommon getComponentCommon(StormTopology topology, String id)
           
static Integer getInt(Object o)
           
static Integer getInt(Object o, Integer defaultValue)
           
static Object getSetComponentObject(ComponentObject obj)
           
static TreeMap<Integer,Integer> integerDivided(int sum, int numPieces)
          (defn integer-divided [sum num-pieces] (let [base (int (/ sum num-pieces)) num-inc (mod sum num-pieces) num-bases (- num-pieces num-inc)] (if (= num-inc 0) {base num-bases} {base num-bases (inc base) num-inc} )))
static boolean isSystemId(String id)
           
static boolean isValidConf(Map<String,Object> stormConf)
           
static
<T> String
join(Iterable<T> coll, String sep)
           
static clojure.lang.IFn loadClojureFn(String namespace, String name)
           
static org.apache.curator.framework.CuratorFramework newCurator(Map conf, List<String> servers, Object port)
           
static org.apache.curator.framework.CuratorFramework newCurator(Map conf, List<String> servers, Object port, String root)
           
static org.apache.curator.framework.CuratorFramework newCurator(Map conf, List<String> servers, Object port, String root, ZookeeperAuthInfo auth)
           
static org.apache.curator.framework.CuratorFramework newCuratorStarted(Map conf, List<String> servers, Object port)
           
static org.apache.curator.framework.CuratorFramework newCuratorStarted(Map conf, List<String> servers, Object port, String root)
           
static Object newInstance(String klass)
           
static Map readCommandLineOpts()
           
static Map readDefaultConfig()
           
static Map readStormConfig()
           
static
<K,V> Map<V,K>
reverseMap(Map<K,V> map)
           
static long secureRandomLong()
           
static byte[] serialize(Object obj)
           
static void sleep(long millis)
           
static byte[] toByteArray(ByteBuffer buffer)
           
static List<Object> tuple(Object... values)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_STREAM_ID

public static final String DEFAULT_STREAM_ID
See Also:
Constant Field Values
Constructor Detail

Utils

public Utils()
Method Detail

newInstance

public static Object newInstance(String klass)

serialize

public static byte[] serialize(Object obj)

deserialize

public static Object deserialize(byte[] serialized)

join

public static <T> String join(Iterable<T> coll,
                              String sep)

sleep

public static void sleep(long millis)

findResources

public static List<URL> findResources(String name)

findAndReadConfigFile

public static Map findAndReadConfigFile(String name,
                                        boolean mustExist)

findAndReadConfigFile

public static Map findAndReadConfigFile(String name)

readDefaultConfig

public static Map readDefaultConfig()

readCommandLineOpts

public static Map readCommandLineOpts()

readStormConfig

public static Map readStormConfig()

isValidConf

public static boolean isValidConf(Map<String,Object> stormConf)

getSetComponentObject

public static Object getSetComponentObject(ComponentObject obj)

get

public static <S,T> T get(Map<S,T> m,
                          S key,
                          T def)

tuple

public static List<Object> tuple(Object... values)

downloadFromMaster

public static void downloadFromMaster(Map conf,
                                      String file,
                                      String localFile)
                               throws IOException,
                                      org.apache.thrift.TException
Throws:
IOException
org.apache.thrift.TException

loadClojureFn

public static clojure.lang.IFn loadClojureFn(String namespace,
                                             String name)

isSystemId

public static boolean isSystemId(String id)

reverseMap

public static <K,V> Map<V,K> reverseMap(Map<K,V> map)

getComponentCommon

public static ComponentCommon getComponentCommon(StormTopology topology,
                                                 String id)

getInt

public static Integer getInt(Object o)

getInt

public static Integer getInt(Object o,
                             Integer defaultValue)

getBoolean

public static boolean getBoolean(Object o,
                                 boolean defaultValue)

secureRandomLong

public static long secureRandomLong()

newCurator

public static org.apache.curator.framework.CuratorFramework newCurator(Map conf,
                                                                       List<String> servers,
                                                                       Object port,
                                                                       String root)

newCurator

public static org.apache.curator.framework.CuratorFramework newCurator(Map conf,
                                                                       List<String> servers,
                                                                       Object port,
                                                                       String root,
                                                                       ZookeeperAuthInfo auth)

newCurator

public static org.apache.curator.framework.CuratorFramework newCurator(Map conf,
                                                                       List<String> servers,
                                                                       Object port)

newCuratorStarted

public static org.apache.curator.framework.CuratorFramework newCuratorStarted(Map conf,
                                                                              List<String> servers,
                                                                              Object port,
                                                                              String root)

newCuratorStarted

public static org.apache.curator.framework.CuratorFramework newCuratorStarted(Map conf,
                                                                              List<String> servers,
                                                                              Object port)

integerDivided

public static TreeMap<Integer,Integer> integerDivided(int sum,
                                                      int numPieces)
(defn integer-divided [sum num-pieces] (let [base (int (/ sum num-pieces)) num-inc (mod sum num-pieces) num-bases (- num-pieces num-inc)] (if (= num-inc 0) {base num-bases} {base num-bases (inc base) num-inc} )))

Parameters:
sum -
numPieces -
Returns:

toByteArray

public static byte[] toByteArray(ByteBuffer buffer)

exceptionCauseIsInstanceOf

public static boolean exceptionCauseIsInstanceOf(Class klass,
                                                 Throwable throwable)


Copyright © 2014 The Apache Software Foundation. All Rights Reserved.