本文整理汇总了Java中backtype.storm.generated.DRPCExecutionException类的典型用法代码示例。如果您正苦于以下问题:Java DRPCExecutionException类的具体用法?Java DRPCExecutionException怎么用?Java DRPCExecutionException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DRPCExecutionException类属于backtype.storm.generated包,在下文中一共展示了DRPCExecutionException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import backtype.storm.generated.DRPCExecutionException; //导入依赖的package包/类
@Override
public void run() {
for (Entry<String, Integer> e : drpcService.getIdtoStart().entrySet()) {
if (TimeUtils.time_delta(e.getValue()) > REQUEST_TIMEOUT_SECS) {
String id = e.getKey();
drpcService.getIdtoResult().put(id, new DRPCExecutionException(
"Request timed out"));
Semaphore s = drpcService.getIdtoSem().get(id);
if (s != null) {
s.release();
}
drpcService.cleanup(id);
LOG.info("Clear request " + id);
}
}
JStormUtils.sleepMs(10);
}
示例2: run
import backtype.storm.generated.DRPCExecutionException; //导入依赖的package包/类
@Override
public void run() {
for (Entry<String, Integer> e : drpcService.getIdtoStart().entrySet()) {
if (TimeUtils.time_delta(e.getValue()) > REQUEST_TIMEOUT_SECS) {
String id = e.getKey();
drpcService.getIdtoResult().put(id, new DRPCExecutionException("Request timed out"));
Semaphore s = drpcService.getIdtoSem().get(id);
if (s != null) {
s.release();
}
drpcService.cleanup(id);
LOG.info("Clear request " + id);
}
}
JStormUtils.sleepMs(10);
}
示例3: main
import backtype.storm.generated.DRPCExecutionException; //导入依赖的package包/类
public static void main(final String[] args) throws IOException, TException, DRPCExecutionException {
if (args.length < 3) {
System.err.println("Where are the arguments? args -- DrpcServer DrpcFunctionName folder");
return;
}
final DRPCClient client = new DRPCClient(args[0], 3772, 1000000 /*timeout*/);
final Queue<String> featureFiles = new ArrayDeque<String>();
SpoutUtils.listFilesForFolder(new File(args[2]), featureFiles);
Scanner scanner = new Scanner(featureFiles.peek());
int i = 0;
while (scanner.hasNextLine() && i++ < 1) {
List<Map<String, List<Double>>> dict = SpoutUtils.pythonDictToJava(scanner.nextLine());
for (Map<String, List<Double>> map : dict) {
final Double[] features = map.get("chi1").toArray(new Double[0]);
final Double[] moreFeatures = map.get("chi2").toArray(new Double[0]);
final Double[] both = (Double[]) ArrayUtils.addAll(features, moreFeatures);
final String parameters = serializeFeatureVector(ArrayUtils.toPrimitive(both));
Logger.getAnonymousLogger().log(Level.INFO, runQuery(args[1], parameters, client));
}
}
client.close();
}
示例4: failRequest
import backtype.storm.generated.DRPCExecutionException; //导入依赖的package包/类
@Override
public void failRequest(String id) throws TException {
Semaphore sem = this.idtoSem.get(id);
LOG.info("failRequest result for id " + id + " at "
+ (System.currentTimeMillis()));
if (sem != null) {
this.idtoResult.put(id,
new DRPCExecutionException("Request failed"));
sem.release();
}
}
示例5: main
import backtype.storm.generated.DRPCExecutionException; //导入依赖的package包/类
/**
* @param args
* @throws DRPCExecutionException
* @throws TException
*/
public static void main(String[] args) throws TException, DRPCExecutionException {
if (args.length < 1) {
throw new IllegalArgumentException("Invalid parameter");
}
//"foo.com/blog/1" "engineering.twitter.com/blog/5"
DRPCClient client = new DRPCClient(args[0], 4772);
String result = client.execute(ReachTopology.TOPOLOGY_NAME, "tech.backtype.com/blog/123");
System.out.println("\n!!! Drpc result:" + result);
}
示例6: execute
import backtype.storm.generated.DRPCExecutionException; //导入依赖的package包/类
@Override
public String execute(String function, String args) throws DRPCExecutionException, TException {
LOG.info("Received DRPC request for " + function + " " + args + " at " + (System.currentTimeMillis()));
int idinc = this.ctr.incrementAndGet();
int maxvalue = 1000000000;
int newid = idinc % maxvalue;
if (idinc != newid) {
this.ctr.compareAndSet(idinc, newid);
}
String strid = String.valueOf(newid);
Semaphore sem = new Semaphore(0);
DRPCRequest req = new DRPCRequest(args, strid);
this.idtoStart.put(strid, TimeUtils.current_time_secs());
this.idtoSem.put(strid, sem);
ConcurrentLinkedQueue<DRPCRequest> queue = acquireQueue(function);
queue.add(req);
LOG.info("Waiting for DRPC request for " + function + " " + args + " at " + (System.currentTimeMillis()));
try {
sem.acquire();
} catch (InterruptedException e) {
LOG.error("acquire fail ", e);
}
LOG.info("Acquired for DRPC request for " + function + " " + args + " at " + (System.currentTimeMillis()));
Object result = this.idtoResult.get(strid);
LOG.info("Returning for DRPC request for " + function + " " + args + " at " + (System.currentTimeMillis()));
this.cleanup(strid);
if (result instanceof DRPCExecutionException) {
throw (DRPCExecutionException) result;
}
return String.valueOf(result);
}
示例7: failRequest
import backtype.storm.generated.DRPCExecutionException; //导入依赖的package包/类
@Override
public void failRequest(String id) throws TException {
Semaphore sem = this.idtoSem.get(id);
LOG.info("failRequest result for id " + id + " at " + (System.currentTimeMillis()));
if (sem != null) {
this.idtoResult.put(id, new DRPCExecutionException("Request failed"));
sem.release();
}
}
示例8: execute
import backtype.storm.generated.DRPCExecutionException; //导入依赖的package包/类
private long execute(String arg, PrintWriter writer) throws TException, DRPCExecutionException {
LOG.debug(String.format("executing %s('%s')", function, arg));
DRPCClient client = new DRPCClient(server, port);
long start = System.currentTimeMillis();
String result = client.execute(function, arg);
long end = System.currentTimeMillis();
long latency = end - start;
writer.println(String.format("%s('%s') = %s, latency = %d ms", function, arg, result, latency));
writer.flush();
return latency;
}
示例9: main
import backtype.storm.generated.DRPCExecutionException; //导入依赖的package包/类
public static void main(String[] args) throws TException, DRPCExecutionException {
DRPCClient cl = new DRPCClient("localhost",3772, 9000);
if (args.length != 2){
System.err.println("<functionName> <arguments>");
}else{
String func = args[0];
String argument = args[1];
System.out.println(cl.execute(func, argument));
}
}
示例10: main
import backtype.storm.generated.DRPCExecutionException; //导入依赖的package包/类
public static void main(final String[] args) throws IOException, TException, DRPCExecutionException {
if (args.length < 3) {
System.err.println("Where are the arguments? args -- HoldoutDataFile DrpcServer DrpcFunctionName");
return;
}
double correct = 0, total = 0;
final DRPCClient client = new DRPCClient(args[1], 3772, 1000000 /*timeout*/);
for (Map.Entry<Double, double[]> features : generateHoldOutDataset(args[0])) {
double label = features.getKey();
double[] fv = features.getValue();
final String parameters = serializeFeatureVector(fv);
String result = runQuery(args[2], parameters, client);
Gson gson = new Gson();
Object[] deserialized = gson.fromJson(result, Object[].class);
for (Object obj : deserialized) {
// Storm always returns a list
List l = ((List) obj);
double yHat = (Double) l.get(0);
if (yHat == label) {
correct++;
System.out.println(Arrays.toString(fv) + " CORRECT");
} else {
System.out.println(Arrays.toString(fv) + " INCORRECT");
}
total++;
}
}
System.err.println(correct / total + " percent correct");
client.close();
}
示例11: main
import backtype.storm.generated.DRPCExecutionException; //导入依赖的package包/类
public static void main(final String[] args) throws IOException, TException, DRPCExecutionException {
if (args.length < 3) {
System.err.println("Where are the arguments? args -- DrpcServer DrpcFunctionName parameters");
return;
}
final DRPCClient client = new DRPCClient(args[0], 3772, 1000000 /*timeout*/);
System.err.println(runQuery(args[1], args[2], client));
client.close();
}
示例12: main
import backtype.storm.generated.DRPCExecutionException; //导入依赖的package包/类
public static void main(String[] args) throws TException, DRPCExecutionException {
DRPCClient client = new DRPCClient(args[0], Integer.parseInt(args[1]));
while (true) {
System.out.println("Word count: " + client.execute("words", "cow"));
Utils.sleep(1000);
}
}
示例13: failRequest
import backtype.storm.generated.DRPCExecutionException; //导入依赖的package包/类
@Override
public void failRequest(String id) throws TException {
Semaphore sem = this.idToSem.get(id);
LOG.info("failRequest result for id " + id + " at " + (System.currentTimeMillis()));
if (sem != null) {
this.idToResult.put(id, new DRPCExecutionException("Request failed"));
sem.release();
}
}
示例14: execute
import backtype.storm.generated.DRPCExecutionException; //导入依赖的package包/类
@Override
public String execute(String function, String args)
throws DRPCExecutionException, TException {
LOG.info("Received DRPC request for " + function + " " + args + " at "
+ (System.currentTimeMillis()));
int idinc = this.ctr.incrementAndGet();
int maxvalue = 1000000000;
int newid = idinc % maxvalue;
if (idinc != newid) {
this.ctr.compareAndSet(idinc, newid);
}
String strid = String.valueOf(newid);
Semaphore sem = new Semaphore(0);
DRPCRequest req = new DRPCRequest(args, strid);
this.idtoStart.put(strid, TimeUtils.current_time_secs());
this.idtoSem.put(strid, sem);
ConcurrentLinkedQueue<DRPCRequest> queue = acquireQueue(function);
queue.add(req);
LOG.info("Waiting for DRPC request for " + function + " " + args
+ " at " + (System.currentTimeMillis()));
try {
sem.acquire();
} catch (InterruptedException e) {
LOG.error("acquire fail ", e);
}
LOG.info("Acquired for DRPC request for " + function + " " + args
+ " at " + (System.currentTimeMillis()));
Object result = this.idtoResult.get(strid);
LOG.info("Returning for DRPC request for " + function + " " + args
+ " at " + (System.currentTimeMillis()));
this.cleanup(strid);
if (result instanceof DRPCExecutionException) {
throw (DRPCExecutionException) result;
}
return String.valueOf(result);
}
示例15: execute
import backtype.storm.generated.DRPCExecutionException; //导入依赖的package包/类
public String execute(String func, String args) throws TException, DRPCExecutionException, AuthorizationException {
return client.execute(func, args);
}