Permalink
Browse files

format cleanup

  • Loading branch information...
1 parent f4f2cdd commit a22cb5d17d85c7da3035fca835d46114e88aed51 @anfeng anfeng committed Feb 20, 2013
@@ -28,7 +28,7 @@
/**
* Constructor based on a JAAS configuration
*
- * For digest, you should have a pair of user name and password defined in this figgure.
+ * For digest, you should have a pair of user name and password defined.
*
* @param configuration
* @throws IOException
@@ -43,6 +43,7 @@ public ClientCallbackHandler(Configuration configuration) throws IOException {
throw new IOException(errorMessage);
}
+ _password = "";
for(AppConfigurationEntry entry: configurationEntries) {
if (entry.getOptions().get(USERNAME) != null) {
_username = (String)entry.getOptions().get(USERNAME);
@@ -68,22 +69,7 @@ public void handle(Callback[] callbacks) throws IOException, UnsupportedCallback
PasswordCallback pc = (PasswordCallback)c;
if (_password != null) {
pc.setPassword(_password.toCharArray());
- } else {
- LOG.warn("Could not login: the client is being asked for a password, but the " +
- " client code does not currently support obtaining a password from the user." +
- " Make sure that the client is configured to use a ticket cache (using" +
- " the JAAS configuration setting 'useTicketCache=true)' and restart the client. If" +
- " you still get this message after that, the TGT in the ticket cache has expired and must" +
- " be manually refreshed. To do so, first determine if you are using a password or a" +
- " keytab. If the former, run kinit in a Unix shell in the environment of the user who" +
- " is running this client using the command" +
- " 'kinit <princ>' (where <princ> is the name of the client's Kerberos principal)." +
- " If the latter, do" +
- " 'kinit -k -t <keytab> <princ>' (where <princ> is the name of the Kerberos principal, and" +
- " <keytab> is the location of the keytab file). After manually refreshing your cache," +
- " restart this client. If you continue to see this message after manually refreshing" +
- " your cache, ensure that your KDC host's clock is in sync with this host's clock.");
- }
+ }
} else if (c instanceof AuthorizeCallback) {
LOG.debug("authorization callback");
AuthorizeCallback ac = (AuthorizeCallback) c;
@@ -44,7 +44,7 @@ public static Object newInstance(String klass) {
throw new RuntimeException(e);
}
}
-
+
public static byte[] serialize(Object obj) {
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
@@ -90,7 +90,7 @@ public static void sleep(long millis) {
throw new RuntimeException(e);
}
}
-
+
public static List<URL> findResources(String name) {
try {
Enumeration<URL> resources = Thread.currentThread().getContextClassLoader().getResources(name);
@@ -112,29 +112,30 @@ public static Map findAndReadConfigFile(String name, boolean mustExist) {
else return new HashMap();
}
if(resources.size() > 1) {
- throw new RuntimeException("Found multiple " + name + " resources. You're probably bundling the Storm jars with your topology jar.");
+ throw new RuntimeException("Found multiple " + name + " resources. You're probably bundling the Storm jars with your topology jar. "
+ + resources);
}
URL resource = resources.get(0);
Yaml yaml = new Yaml();
Map ret = (Map) yaml.load(new InputStreamReader(resource.openStream()));
if(ret==null) ret = new HashMap();
-
+
return new HashMap(ret);
-
+
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public static Map findAndReadConfigFile(String name) {
- return findAndReadConfigFile(name, true);
+ return findAndReadConfigFile(name, true);
}
public static Map readDefaultConfig() {
return findAndReadConfigFile("defaults.yaml", true);
}
-
+
public static Map readCommandLineOpts() {
Map ret = new HashMap();
String commandOptions = System.getProperty("storm.options");
@@ -164,7 +165,7 @@ public static Map readStormConfig() {
ret.putAll(readCommandLineOpts());
return ret;
}
-
+
private static Object normalizeConf(Object conf) {
if(conf==null) return new HashMap();
if(conf instanceof Map) {
@@ -189,7 +190,7 @@ private static Object normalizeConf(Object conf) {
return conf;
}
}
-
+
public static boolean isValidConf(Map<String, Object> stormConf) {
return normalizeConf(stormConf).equals(normalizeConf((Map) JSONValue.parse(JSONValue.toJSONString(stormConf))));
}
@@ -211,7 +212,7 @@ public static Object getSetComponentObject(ComponentObject obj) {
}
return ret;
}
-
+
public static List<Object> tuple(Object... values) {
List<Object> ret = new ArrayList<Object>();
for(Object v: values) {
@@ -231,28 +232,28 @@ public static void downloadFromMaster(Map conf, String file, String localFile) t
}
out.close();
}
-
+
public static IFn loadClojureFn(String namespace, String name) {
try {
- clojure.lang.Compiler.eval(RT.readString("(require '" + namespace + ")"));
+ clojure.lang.Compiler.eval(RT.readString("(require '" + namespace + ")"));
} catch (Exception e) {
- //if playing from the repl and defining functions, file won't exist
+ //if playing from the repl and defining functions, file won't exist
}
return (IFn) RT.var(namespace, name).deref();
}
-
+
public static boolean isSystemId(String id) {
return id.startsWith("__");
}
-
+
public static <K, V> Map<V, K> reverseMap(Map<K, V> map) {
Map<V, K> ret = new HashMap<V, K>();
for(K key: map.keySet()) {
ret.put(map.get(key), key);
}
return ret;
}
-
+
public static ComponentCommon getComponentCommon(StormTopology topology, String id) {
if(topology.get_spouts().containsKey(id)) {
return topology.get_spouts().get(id).get_common();
@@ -265,7 +266,7 @@ public static ComponentCommon getComponentCommon(StormTopology topology, String
}
throw new IllegalArgumentException("Could not find component with id " + id);
}
-
+
public static Integer getInt(Object o) {
if(o instanceof Long) {
return ((Long) o ).intValue();
@@ -277,34 +278,35 @@ public static Integer getInt(Object o) {
throw new IllegalArgumentException("Don't know how to convert " + o + " + to int");
}
}
-
+
public static long secureRandomLong() {
return UUID.randomUUID().getLeastSignificantBits();
}
-
-
+
+
public static CuratorFramework newCurator(Map conf, List<String> servers, Object port, String root) {
return newCurator(conf, servers, port, root, null);
}
-
+
public static CuratorFramework newCurator(Map conf, List<String> servers, Object port, String root, ZookeeperAuthInfo auth) {
List<String> serverPorts = new ArrayList<String>();
for(String zkServer: (List<String>) servers) {
serverPorts.add(zkServer + ":" + Utils.getInt(port));
}
String zkStr = StringUtils.join(serverPorts, ",") + root;
try {
+
CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder()
.connectString(zkStr)
.connectionTimeoutMs(Utils.getInt(conf.get(Config.STORM_ZOOKEEPER_CONNECTION_TIMEOUT)))
.sessionTimeoutMs(Utils.getInt(conf.get(Config.STORM_ZOOKEEPER_SESSION_TIMEOUT)))
.retryPolicy(new RetryNTimes(Utils.getInt(conf.get(Config.STORM_ZOOKEEPER_RETRY_TIMES)), Utils.getInt(conf.get(Config.STORM_ZOOKEEPER_RETRY_INTERVAL))));
if(auth!=null && auth.scheme!=null) {
builder = builder.authorization(auth.scheme, auth.payload);
- }
+ }
return builder.build();
} catch (IOException e) {
- throw new RuntimeException(e);
+ throw new RuntimeException(e);
}
}
@@ -323,7 +325,7 @@ public static CuratorFramework newCuratorStarted(Map conf, List<String> servers,
ret.start();
return ret;
}
-
+
/**
*
(defn integer-divided [sum num-pieces]
@@ -338,7 +340,7 @@ public static CuratorFramework newCuratorStarted(Map conf, List<String> servers,
* @param numPieces
* @return
*/
-
+
public static TreeMap<Integer, Integer> integerDivided(int sum, int numPieces) {
int base = sum / numPieces;
int numInc = sum % numPieces;

0 comments on commit a22cb5d

Please sign in to comment.