io.lettuce.core.RedisConnectionException Java Examples
The following examples show how to use
io.lettuce.core.RedisConnectionException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RedisFeatureSink.java From feast with Apache License 2.0 | 6 votes |
@Override public PCollection<FeatureSetReference> prepareWrite( PCollection<KV<FeatureSetReference, FeatureSetProto.FeatureSetSpec>> featureSetSpecs) { if (getRedisConfig() != null) { RedisClient redisClient = RedisClient.create( RedisURI.create(getRedisConfig().getHost(), getRedisConfig().getPort())); try { redisClient.connect(); } catch (RedisConnectionException e) { throw new RuntimeException( String.format( "Failed to connect to Redis at host: '%s' port: '%d'. Please check that your Redis is running and accessible from Feast.", getRedisConfig().getHost(), getRedisConfig().getPort())); } redisClient.shutdown(); } else if (getRedisClusterConfig() == null) { throw new RuntimeException( "At least one RedisConfig or RedisClusterConfig must be provided to Redis Sink"); } specsView = featureSetSpecs.apply(ParDo.of(new ReferenceToString())).apply(View.asMultimap()); return featureSetSpecs.apply(Keys.create()); }
Example #2
Source File: RedisSessionFactoryImpl.java From kafka-connect-redis with Apache License 2.0 | 6 votes |
@Override public RedisSession create(RedisConnectorConfig config) { int attempts = 0; RedisSession result; while (true) { attempts++; try { log.info("Creating Redis session. Attempt {} of {}", attempts, config.maxAttempts); result = RedisSessionImpl.create(config); break; } catch (RedisConnectionException ex) { if (attempts == config.maxAttempts) { throw ex; } else { log.warn("Exception thrown connecting to redis. Waiting {} ms to try again.", config.retryDelay); this.time.sleep(config.retryDelay); } } } return result; }
Example #3
Source File: LettuceDriver.java From redis-scheduler with MIT License | 5 votes |
@Override public <T> T fetch(Function<Commands, T> block) { try (StatefulRedisConnection<String, String> connection = client.connect()) { RedisCommands<String, String> commands = connection.sync(); return block.apply(new LettuceCommands(commands)); } catch (RedisConnectionException e) { throw new RedisConnectException(e); } }
Example #4
Source File: GlobalExceptionHandler.java From EosProxyServer with GNU Lesser General Public License v3.0 | 4 votes |
@ExceptionHandler @ResponseStatus public ResponseEntity<MessageResult> hadleServerException(Exception exception) { //默认打印错误,并且返回server error exception.printStackTrace(); HttpStatus httpStatus = HttpStatus.INTERNAL_SERVER_ERROR; Integer code = ErrorCodeEnumChain.unknown_error_exception.getMsg_id(); String msg = ErrorCodeEnumChain.getMsgById(code); //不支持的method if(exception instanceof HttpRequestMethodNotSupportedException) { httpStatus = HttpStatus.NOT_FOUND; code = ErrorCodeEnumChain.not_supported_exception.getMsg_id(); msg = exception.getMessage(); } //没有handler else if (exception instanceof NoHandlerFoundException) { httpStatus = HttpStatus.BAD_REQUEST; code = ErrorCodeEnumChain.not_supported_exception.getMsg_id(); msg = exception.getMessage(); } //缺失parameter else if (exception instanceof MissingServletRequestParameterException) { httpStatus = HttpStatus.BAD_REQUEST; code = ErrorCodeEnumChain.not_supported_exception.getMsg_id(); msg = exception.getMessage(); } else if (exception instanceof RedisConnectionException) { httpStatus = HttpStatus.BAD_REQUEST; code = ErrorCodeEnumChain.redis_connection_exception.getMsg_id(); msg = exception.getMessage(); } else if(exception instanceof MethodArgumentTypeMismatchException){ httpStatus = HttpStatus.BAD_REQUEST; code = ErrorCodeEnumChain.request_format_exception.getMsg_id(); msg = exception.getMessage(); } else if(exception instanceof MethodArgumentNotValidException){ httpStatus = HttpStatus.BAD_REQUEST; code = ErrorCodeEnumChain.request_format_exception.getMsg_id(); BindingResult bindingResult = ((MethodArgumentNotValidException) exception).getBindingResult(); msg = "parameter validate error:"; for (FieldError fieldError : bindingResult.getFieldErrors()) { msg += fieldError.getDefaultMessage() + ", "; } } log.warn("X--->{code:" + code + ",msg:" + msg + ",what:" + exception.getMessage()); return new ResponseEntity(new MessageResult(msg, code, exception.getMessage()), httpStatus); }