@Override protected void work() { for(int i=0; i<reqCnt; i++){ try { jredis.dbsize(); } catch (RedisException e) { e.printStackTrace(); } } } };
public String toString () { return "Exception on [" + command.code + "] => " + getMessage(); } }
/** * Determines if a completed request encountered errors and will throw an {@link ExecutionException} wrapping * the original cause. Called by the {@link PendingRequest#get} methods. * @throws ExecutionException */ private final void checkStatus () throws ExecutionException { // check for runtime or provider exceptions if(excepted) { if(cre != null) { if(cre instanceof ProviderException) throw new ExecutionException ("Provider Exception", cre); else if( cre instanceof ClientRuntimeException) throw new ExecutionException ("Client Runtime Exception", cre); } else { throw new ExecutionException ("Bug -- Request processing encountered exceptions but CRE is null", new ProviderException("unknown cause")); } } // check for Redis Errors if(response.isError()) throw new ExecutionException("Redis Exception on ["+cmd.name()+"] " + response.getStatus().message(), new RedisException(cmd, response.getStatus().message())); }
System.err.format("BENCHMARK::REDIS %s ERROR => %s\nWorker will stop.\n", e.getCommand(), e.getLocalizedMessage()); System.exit (1);
Log.error("Failed to connect to Redis using JRedisClient default ConnectionSpec -- password perhaps? => " + e.getLocalizedMessage()); Log.error("Failed to connect to Redis using JRedisClient default ConnectionSpec -- password perhaps? => " + e.getLocalizedMessage()); Log.error("Failed to connect to Redis using JRedisClient default ConnectionSpec -- password perhaps? => " + e.getLocalizedMessage());
private void run(String password) { try { ConnectionSpec spec = DefaultConnectionSpec.newSpec().setCredentials(password); JRedis jredis = new JRedisClient(spec); jredis.ping(); if(!jredis.exists(bkey)) { jredis.set(bkey, "Hello Again!"); System.out.format("Hello! You should run me again!\n"); } else { String msg = toStr ( jredis.get(bkey) ); System.out.format("%s\n", msg); } jredis.quit(); } catch (RedisException e){ if (e.getCommand()==Command.PING){ System.out.format("I'll need that password! Try again with password as command line arg for this program.\n"); } } catch (ProviderException e){ System.out.format("Oh no, an 'un-documented feature': %s\nKindly report it.", e.getMessage()); } catch (ClientRuntimeException e){ System.out.format("%s\n", e.getMessage()); } } }
/** * Determines if a completed request encountered errors and will throw an {@link ExecutionException} wrapping * the original cause. Called by the {@link PendingRequest#get} methods. * @throws ExecutionException */ private final void checkStatus () throws ExecutionException { // check for runtime or provider exceptions if(excepted) { if(cre != null) { if(cre instanceof ProviderException) throw new ExecutionException ("Provider Exception", cre); else throw new ExecutionException ("Client Runtime Exception", cre); } else { throw new ExecutionException ("Bug -- Request processing encountered exceptions but CRE is null", new ProviderException("unknown cause")); } } // check for Redis Errors if(response.isError()) throw new ExecutionException("Redis Exception on ["+cmd.name()+"] " + response.getStatus().message(), new RedisException(cmd, response.getStatus().message())); }
Log.error("Failed to connect to Redis using JRedisClient custom ConnectionSpec -- password perhaps? => " + e.getLocalizedMessage());
@Override protected void prep() { for(int i=0; i<reqCnt; i++) { try { jredis.sadd (key, i); } catch (RedisException e) { e.printStackTrace(); } } } @Override
/** * Determines if a completed request encountered errors and will throw an {@link ExecutionException} wrapping * the original cause. Called by the {@link PendingRequest#get} methods. * @throws ExecutionException */ private final void checkStatus () throws ExecutionException { // check for runtime or provider exceptions if(excepted) { if(cre != null) { if(cre instanceof ProviderException) throw new ExecutionException ("Provider Exception", cre); else throw new ExecutionException ("Client Runtime Exception", cre); } else { throw new ExecutionException ("Bug -- Request processing encountered exceptions but CRE is null", new ProviderException("unknown cause")); } } // check for Redis Errors if(response.isError()) throw new ExecutionException("Redis Exception on ["+cmd.name()+"] " + response.getStatus().message(), new RedisException(cmd, response.getStatus().message())); }
public String toString () { return "Exception on [" + command.code + "] => " + getMessage(); } }
@Override protected void work() { for(int i=0; i<reqCnt; i++) { try { jredis.incr (key); } catch (RedisException e) { e.printStackTrace(); } } } };
public List<byte[]> smembers(String key) throws RedisException { byte[] keydata = null; if((keydata = getKeyBytes(key)) == null) throw new RedisException (Command.KEYS, "ERR Invalid key."); List<byte[]> multiBulkData= null; try { MultiBulkResponse MultiBulkResponse = (MultiBulkResponse) this.serviceRequest(Command.SMEMBERS, keydata); multiBulkData = MultiBulkResponse.getMultiBulkData(); } catch (ClassCastException e){ throw new ProviderException("Expecting a MultiBulkResponse here => " + e.getLocalizedMessage(), e); } return multiBulkData; } // @Override
public String toString () { return "Exception on [" + command.code + "] => " + getMessage(); } }
@Override protected void prep() { try { for(int i=0; i<reqCnt; i++){ jredis.set(key, data); } } catch (RedisException e) { e.printStackTrace(); } } @Override
if(status.isError()) { Log.error ("Error response for " + cmd.code + " => " + status.message()); throw new RedisException(cmd, status.message());
private void elicitErrors () { String key = "foo" ; try { jredis.set(key, "bar"); jredis.sadd(key, "foobar"); } catch (RedisException e) { Log.log("Expected elicited error: %s", e.getMessage()); } }
@Override protected void work() { for(int i=0; i<reqCnt; i++) { try { jredis.scard (key); } catch (RedisException e) { e.printStackTrace(); } } } };
if(status.isError()) { Log.error ("Error response for " + cmd.code + " => " + status.message()); throw new RedisException(cmd, status.message());
@Override protected void work() { for(int i=0; i<reqCnt; i++) { try { jredis.lpop (key); } catch (RedisException e) { e.printStackTrace(); } } } };