private RBlockingQueue<Request> getQueue(String crawlerName){ RBlockingQueue<Request> rBlockingQueue = queueCache.get(crawlerName); if (rBlockingQueue == null){ rBlockingQueue = redisson.getBlockingQueue(quueNamePrefix + crawlerName, new FstCodec()); queueCache.put(crawlerName,rBlockingQueue); } return rBlockingQueue; }
@Override public <T> void register(Class<T> remoteInterface, T object, int workers, ExecutorService executor) { if (workers < 1) { throw new IllegalArgumentException("executorsAmount can't be lower than 1"); } for (Method method : remoteInterface.getMethods()) { RemoteServiceMethod value = new RemoteServiceMethod(method, object); RemoteServiceKey key = new RemoteServiceKey(remoteInterface, method.getName(), getMethodSignatures(method)); if (beans.put(key, value) != null) { return; } } remoteMap.put(remoteInterface, new Entry(workers)); String requestQueueName = getRequestQueueName(remoteInterface); RBlockingQueue<String> requestQueue = redisson.getBlockingQueue(requestQueueName, StringCodec.INSTANCE); subscribe(remoteInterface, requestQueue, executor); }
@Override public <T> void register(Class<T> remoteInterface, T object, int workers, ExecutorService executor) { if (workers < 1) { throw new IllegalArgumentException("executorsAmount can't be lower than 1"); } for (Method method : remoteInterface.getMethods()) { RemoteServiceMethod value = new RemoteServiceMethod(method, object); RemoteServiceKey key = new RemoteServiceKey(remoteInterface, method.getName(), getMethodSignatures(method)); if (beans.put(key, value) != null) { return; } } remoteMap.put(remoteInterface, new Entry(workers)); String requestQueueName = getRequestQueueName(remoteInterface); RBlockingQueue<String> requestQueue = redisson.getBlockingQueue(requestQueueName, StringCodec.INSTANCE); subscribe(remoteInterface, requestQueue, executor); }
List<Result> list = entry.getResponses().get(key); if (list == null) { RBlockingQueue<RRemoteServiceResponse> responseQueue = redisson.getBlockingQueue(responseQueueName, codec); responseQueue.takeAsync().addListener(this); return; responses.remove(responseQueueName, entry); } else { RBlockingQueue<RRemoteServiceResponse> responseQueue = redisson.getBlockingQueue(responseQueueName, codec); responseQueue.takeAsync().addListener(this);
List<Result> list = entry.getResponses().get(key); if (list == null) { RBlockingQueue<RRemoteServiceResponse> responseQueue = redisson.getBlockingQueue(responseQueueName, codec); responseQueue.takeAsync().addListener(this); return; responses.remove(responseQueueName, entry); } else { RBlockingQueue<RRemoteServiceResponse> responseQueue = redisson.getBlockingQueue(responseQueueName, codec); responseQueue.takeAsync().addListener(this);
RBlockingQueue<RRemoteServiceResponse> responseQueue = redisson.getBlockingQueue(responseQueueName, codec); RFuture<RRemoteServiceResponse> future = responseQueue.takeAsync(); future.addListener(new FutureListener<RRemoteServiceResponse>() {
RBlockingQueue<RRemoteServiceResponse> responseQueue = redisson.getBlockingQueue(responseQueueName, codec); RFuture<RRemoteServiceResponse> future = responseQueue.takeAsync(); future.addListener(new FutureListener<RRemoteServiceResponse>() {
RBlockingQueueAsync<RRemoteServiceResponse> queue = redisson.getBlockingQueue(responseName, codec); RFuture<Void> clientsFuture = queue.putAsync(responseHolder.get()); queue.expireAsync(timeout, TimeUnit.MILLISECONDS);
RBlockingQueueAsync<RRemoteServiceResponse> queue = redisson.getBlockingQueue(responseName, codec); RFuture<Void> clientsFuture = queue.putAsync(responseHolder.get()); queue.expireAsync(timeout, TimeUnit.MILLISECONDS);
/** * Get blocking queue r blocking queue. * * @param <V> the type parameter * @param objectName the object name * @return the r blocking queue */ public static <V> RBlockingQueue<V> getBlockingQueue(String objectName){ return redissonClient.getBlockingQueue(objectName); }
@Override @SuppressWarnings("all") public <T> Queue<T> getQueue(String name) { return (Queue) queueCache.computeIfAbsent(name, n -> new RedissonQueue<T>(redissonClient.getBlockingQueue(prefix + name), executorService) { @Override public void close() { super.close(); queueCache.remove(name); } }); }
@Override public <T> void register(Class<T> remoteInterface, T object, int workers, ExecutorService executor) { if (workers < 1) { throw new IllegalArgumentException("executorsAmount can't be lower than 1"); } for (Method method : remoteInterface.getMethods()) { RemoteServiceMethod value = new RemoteServiceMethod(method, object); RemoteServiceKey key = new RemoteServiceKey(remoteInterface, method.getName(), getMethodSignatures(method)); if (beans.put(key, value) != null) { return; } } remoteMap.put(remoteInterface, new Entry(workers)); String requestQueueName = getRequestQueueName(remoteInterface); RBlockingQueue<String> requestQueue = redisson.getBlockingQueue(requestQueueName, StringCodec.INSTANCE); subscribe(remoteInterface, requestQueue, executor); }
List<Result> list = entry.getResponses().get(key); if (list == null) { RBlockingQueue<RRemoteServiceResponse> responseQueue = redisson.getBlockingQueue(responseQueueName, codec); responseQueue.takeAsync().addListener(this); return; responses.remove(responseQueueName, entry); } else { RBlockingQueue<RRemoteServiceResponse> responseQueue = redisson.getBlockingQueue(responseQueueName, codec); responseQueue.takeAsync().addListener(this);
RBlockingQueue<RRemoteServiceResponse> responseQueue = redisson.getBlockingQueue(responseQueueName, codec); RFuture<RRemoteServiceResponse> future = responseQueue.takeAsync(); future.addListener(new FutureListener<RRemoteServiceResponse>() {
RBlockingQueue<String> queue = redisson.getBlockingQueue("myQueue"); queue.add("1"); queue.add("2");
RBlockingQueueAsync<RRemoteServiceResponse> queue = redisson.getBlockingQueue(responseName, codec); RFuture<Void> clientsFuture = queue.putAsync(responseHolder.get()); queue.expireAsync(timeout, TimeUnit.MILLISECONDS);