本文整理汇总了Java中com.alibaba.jstorm.callback.Callback.execute方法的典型用法代码示例。如果您正苦于以下问题:Java Callback.execute方法的具体用法?Java Callback.execute怎么用?Java Callback.execute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.alibaba.jstorm.callback.Callback
的用法示例。
在下文中一共展示了Callback.execute方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import com.alibaba.jstorm.callback.Callback; //导入方法依赖的package包/类
@Override
public <T> Object execute(T... args) {
// TODO Auto-generated method stub
String topologyName = (String) args[0];
try {
if (isLocal) {
System.out.println("REACH: " + drpc.execute(topologyName, "aaa"));
System.out.println("REACH: " + drpc.execute(topologyName, "foo.com/blog/1"));
System.out.println("REACH: " + drpc.execute(topologyName, "engineering.twitter.com/blog/5"));
} else {
Callback callback = new JStormHelper.CheckAckedFail(conf);
callback.execute(args);
}
} catch (Exception e) {
e.printStackTrace();
Assert.fail("Failed to run drpc action");
}
return null;
}
示例2: runTopologyLocally
import com.alibaba.jstorm.callback.Callback; //导入方法依赖的package包/类
public static void runTopologyLocally(StormTopology topology, String topologyName, Config conf,
int runtimeInSeconds, Callback callback) throws Exception {
LocalCluster cluster = new LocalCluster();
cluster.submitTopology(topologyName, conf, topology);
if (runtimeInSeconds < 120) {
JStormUtils.sleepMs(120 * 1000);
} else {
JStormUtils.sleepMs(runtimeInSeconds * 1000);
}
if (callback != null) {
callback.execute(topologyName);
}
cluster.killTopology(topologyName);
cluster.shutdown();
}
示例3: runTopologyRemotely
import com.alibaba.jstorm.callback.Callback; //导入方法依赖的package包/类
public static void runTopologyRemotely(StormTopology topology, String topologyName, Config conf,
int runtimeInSeconds, Callback callback) throws Exception {
if (conf.get(Config.TOPOLOGY_WORKERS) == null) {
conf.setNumWorkers(3);
}
StormSubmitter.submitTopology(topologyName, conf, topology);
if (JStormUtils.parseBoolean(conf.get("RUN_LONG_TIME"), false)) {
LOG.info(topologyName + " will run long time");
return;
}
if (runtimeInSeconds < 120) {
JStormUtils.sleepMs(120 * 1000);
} else {
JStormUtils.sleepMs(runtimeInSeconds * 1000);
}
if (callback != null) {
callback.execute(topologyName);
}
killTopology(conf, topologyName);
}
示例4: handlerCallback
import com.alibaba.jstorm.callback.Callback; //导入方法依赖的package包/类
private void handlerCallback() {
if (_callbacks != null) {
synchronized (_callbackLock) {
if (_callbacks != null) {
Iterator<Callback> itr = _callbacks.iterator();
while (itr.hasNext()) {
Callback cb = itr.next();
if ((boolean) cb.execute(this)) {
itr.remove();
}
}
if (_callbacks.size() == 0) {
_callbacks = null;
}
}
}
}
}
示例5: execute
import com.alibaba.jstorm.callback.Callback; //导入方法依赖的package包/类
@Override
public <T> Object execute(T... args) {
// TODO Auto-generated method stub
String topologyName = (String) args[0];
try {
if (isLocal) {
for (int i = 0; i < 100; i++) {
System.out.println("DRPC RESULT: " + drpc.execute("words", "cat the dog jumped"));
Thread.sleep(1000);
}
} else {
Callback callback = new JStormHelper.CheckAckedFail(conf);
callback.execute(args);
// Map conf = Utils.readStormConfig();
// "foo.com/blog/1" "engineering.twitter.com/blog/5"
// DRPCClient client = new DRPCClient(conf, "localhost",
// 4772);
// String result = client.execute((String)args[0],
// "tech.backtype.com/blog/123");
}
} catch (Exception e) {
e.printStackTrace();
Assert.fail("Failed to run drpc action");
}
return null;
}
示例6: execute
import com.alibaba.jstorm.callback.Callback; //导入方法依赖的package包/类
@Override
public <T> Object execute(T... args) {
// TODO Auto-generated method stub
try {
if (isLocal) {
for (int i = 0; i < 100; i++) {
System.out.println("DRPC RESULT: " + drpc.execute("words", "CAT THE DOG JUMPED"));
Thread.sleep(1000);
}
} else {
Callback callback = new JStormHelper.CheckAckedFail(conf);
callback.execute(args);
// Map conf = Utils.readStormConfig();
// "foo.com/blog/1" "engineering.twitter.com/blog/5"
// DRPCClient client = new DRPCClient(conf, "localhost",
// 4772);
// String result = client.execute((String)args[0],
// "tech.backtype.com/blog/123");
}
} catch (Exception e) {
e.printStackTrace();
Assert.fail("Failed to run drpc action");
}
return null;
}
示例7: transitionLock
import com.alibaba.jstorm.callback.Callback; //导入方法依赖的package包/类
/**
* Changing status
*
* @param topologyId
* @param errorOnNTransition
* if it is true, failure will throw exception
* @param args
* -- will be used in the status changing callback
*
*/
public <T> void transitionLock(String topologyid,
boolean errorOnNoTransition, StatusType changeStatus, T... args)
throws Exception {
// get ZK's topology node's data, which is StormBase
StormBase stormbase = data.getStormClusterState().storm_base(
topologyid, null);
if (stormbase == null) {
LOG.error("Cannot apply event changing status "
+ changeStatus.getStatus() + " to " + topologyid
+ " because failed to get StormBase from ZK");
return;
}
StormStatus currentStatus = stormbase.getStatus();
if (currentStatus == null) {
LOG.error("Cannot apply event changing status "
+ changeStatus.getStatus() + " to " + topologyid
+ " because topologyStatus is null in ZK");
return;
}
// <currentStatus, Map<changingStatus, callback>>
Map<StatusType, Map<StatusType, Callback>> callbackMap = stateTransitions(
topologyid, currentStatus);
// get current changingCallbacks
Map<StatusType, Callback> changingCallbacks = callbackMap
.get(currentStatus.getStatusType());
if (changingCallbacks == null
|| changingCallbacks.containsKey(changeStatus) == false
|| changingCallbacks.get(changeStatus) == null) {
String msg = "No transition for event: changing status:"
+ changeStatus.getStatus() + ", current status: "
+ currentStatus.getStatusType() + " topology-id: "
+ topologyid;
LOG.info(msg);
if (errorOnNoTransition) {
throw new RuntimeException(msg);
}
return;
}
Callback callback = changingCallbacks.get(changeStatus);
Object obj = callback.execute(args);
if (obj != null && obj instanceof StormStatus) {
StormStatus newStatus = (StormStatus) obj;
// update status to ZK
data.getStormClusterState().update_storm(topologyid, newStatus);
LOG.info("Successfully updated " + topologyid + " as status "
+ newStatus);
}
LOG.info("Successfully apply event changing status "
+ changeStatus.getStatus() + " to " + topologyid);
return;
}
示例8: transitionLock
import com.alibaba.jstorm.callback.Callback; //导入方法依赖的package包/类
/**
* Changing status
*
* @param args -- will be used in the status changing callback
*/
public <T> void transitionLock(String topologyid, boolean errorOnNoTransition, StatusType changeStatus, T... args) throws Exception {
// get ZK's topology node's data, which is StormBase
StormBase stormbase = data.getStormClusterState().storm_base(topologyid, null);
if (stormbase == null) {
LOG.error("Cannot apply event changing status " + changeStatus.getStatus() + " to " + topologyid + " because failed to get StormBase from ZK");
return;
}
StormStatus currentStatus = stormbase.getStatus();
if (currentStatus == null) {
LOG.error("Cannot apply event changing status " + changeStatus.getStatus() + " to " + topologyid + " because topologyStatus is null in ZK");
return;
}
// <currentStatus, Map<changingStatus, callback>>
Map<StatusType, Map<StatusType, Callback>> callbackMap = stateTransitions(topologyid, currentStatus);
// get current changingCallbacks
Map<StatusType, Callback> changingCallbacks = callbackMap.get(currentStatus.getStatusType());
if (changingCallbacks == null || changingCallbacks.containsKey(changeStatus) == false || changingCallbacks.get(changeStatus) == null) {
String msg =
"No transition for event: changing status:" + changeStatus.getStatus() + ", current status: " + currentStatus.getStatusType()
+ " topology-id: " + topologyid;
LOG.info(msg);
if (errorOnNoTransition) {
throw new RuntimeException(msg);
}
return;
}
Callback callback = changingCallbacks.get(changeStatus);
Object obj = callback.execute(args);
if (obj != null && obj instanceof StormStatus) {
StormStatus newStatus = (StormStatus) obj;
// update status to ZK
data.getStormClusterState().update_storm(topologyid, newStatus);
LOG.info("Successfully updated " + topologyid + " as status " + newStatus);
}
LOG.info("Successfully apply event changing status " + changeStatus.getStatus() + " to " + topologyid);
return;
}
示例9: execute
import com.alibaba.jstorm.callback.Callback; //导入方法依赖的package包/类
@Override
public <T> Object execute(T... args) {
// TODO Auto-generated method stub
topologyName = (String) args[0];
if (isLocal == true) {
Callback callback = new JStormHelper.CheckAckedFail(conf);
callback.execute(args);
return null;
}
verifyAssignment();
verifyNumber();
return null;
}
示例10: transitionLock
import com.alibaba.jstorm.callback.Callback; //导入方法依赖的package包/类
/**
* Changing status
*
* @param args -- will be used in the status changing callback
*/
public <T> void transitionLock(String topologyId, boolean errorOnNoTransition, StatusType changeStatus, T... args)
throws Exception {
// get ZK's topology node's data, which is StormBase
StormBase stormbase = data.getStormClusterState().storm_base(topologyId, null);
if (stormbase == null) {
LOG.error("Cannot apply event: changing status " + topologyId + " -> " + changeStatus.getStatus() +
", cause: failed to get StormBase from ZK");
return;
}
StormStatus currentStatus = stormbase.getStatus();
if (currentStatus == null) {
LOG.error("Cannot apply event: changing status " + topologyId + " -> " + changeStatus.getStatus() +
", cause: topologyStatus is null in ZK");
return;
}
// <currentStatus, Map<changingStatus, callback>>
Map<StatusType, Map<StatusType, Callback>> callbackMap = stateTransitions(topologyId, currentStatus);
// get current changingCallbacks
Map<StatusType, Callback> changingCallbacks = callbackMap.get(currentStatus.getStatusType());
if (changingCallbacks == null || !changingCallbacks.containsKey(changeStatus) ||
changingCallbacks.get(changeStatus) == null) {
String msg = "No transition for event: changing status:" + changeStatus.getStatus() +
", current status: " + currentStatus.getStatusType() + ", topology-id: " + topologyId;
LOG.info(msg);
if (errorOnNoTransition) {
throw new RuntimeException(msg);
}
return;
}
Callback callback = changingCallbacks.get(changeStatus);
Object obj = callback.execute(args);
if (obj != null && obj instanceof StormStatus) {
StormStatus newStatus = (StormStatus) obj;
// update status to ZK
data.getStormClusterState().update_storm(topologyId, newStatus);
LOG.info("Successfully updated " + topologyId + " to status " + newStatus);
}
LOG.info("Successfully apply event: changing status " + topologyId + " -> " + changeStatus.getStatus());
}