public ChoosableSet(int initialSize) { ids = new ConcurrentHashSet<>(initialSize); }
public HttpServerMetric getMetric(HttpServerRequest request) { return requests.stream().filter(m -> m.request == request).findFirst().orElse(null); }
@Override public HttpServerMetric requestBegin(SocketMetric socketMetric, HttpServerRequest request) { HttpServerMetric metric = new HttpServerMetric(request, socketMetric); requests.add(metric); return metric; }
@Override public void responseEnd(HttpServerMetric requestMetric, HttpServerResponse response) { requests.remove(requestMetric); }
@Override public void requestReset(HttpServerMetric requestMetric) { requestMetric.failed.set(true); requests.remove(requestMetric); }
protected Set<Deployment> takeDeploymentSnapshot(int pos) { Set<Deployment> snapshot = new ConcurrentHashSet<>(); VertxInternal v = (VertxInternal)vertices[pos]; for (String depID: v.deploymentIDs()) { snapshot.add(v.getDeployment(depID)); } return snapshot; }
public HttpServerMetric getMetric(HttpServerResponse response) { return requests.stream().filter(m -> m.response.get() == response).findFirst().orElse(null); }
@Override public WebSocketMetric connected(SocketMetric socketMetric, HttpServerMetric requestMetric, ServerWebSocket serverWebSocket) { if (!requests.remove(requestMetric)) { throw new IllegalStateException(); } WebSocketMetric metric = new WebSocketMetric(socketMetric, serverWebSocket); if (webSockets.put(serverWebSocket, metric) != null) { throw new AssertionError(); } return metric; }
@Override public HttpServerMetric responsePushed(SocketMetric socketMetric, HttpMethod method, String uri, HttpServerResponse response) { HttpServerMetric requestMetric = new HttpServerMetric(null, socketMetric); requestMetric.response.set(response); requests.add(requestMetric); return requestMetric; }
Set<HttpServer> connectedServers = new ConcurrentHashSet<>(); Map<HttpServer, Integer> connectCount = new ConcurrentHashMap<>();
public HttpServerMetric getMetric(HttpServerRequest request) { return requests.stream().filter(m -> m.request == request).findFirst().orElse(null); }
@Override public void responseEnd(HttpServerMetric requestMetric, HttpServerResponse response) { requests.remove(requestMetric); }
@Override public HttpServerMetric responsePushed(SocketMetric socketMetric, HttpMethod method, String uri, HttpServerResponse response) { HttpServerMetric requestMetric = new HttpServerMetric(null, socketMetric); requestMetric.response.set(response); requests.add(requestMetric); return requestMetric; }
Set<Context> contexts = new ConcurrentHashSet<>(); for (int i = 0; i < numServers; i++) { HttpServer theServer = vertx.createHttpServer(new HttpServerOptions().setPort(DEFAULT_HTTP_PORT));
public HttpServerMetric getMetric(HttpServerResponse response) { return requests.stream().filter(m -> m.response.get() == response).findFirst().orElse(null); }
@Override public void requestReset(HttpServerMetric requestMetric) { requestMetric.failed.set(true); requests.remove(requestMetric); }
@Override public HttpServerMetric requestBegin(SocketMetric socketMetric, HttpServerRequest request) { HttpServerMetric metric = new HttpServerMetric(request, socketMetric); requests.add(metric); return metric; }
@Test public void testContextsPublish() throws Exception { Set<ContextInternal> contexts = new ConcurrentHashSet<>(); AtomicInteger cnt = new AtomicInteger(); int numHandlers = 10; for (int i = 0; i < numHandlers; i++) { vertx.eventBus().consumer(ADDRESS1).handler(msg -> { contexts.add(((VertxInternal) vertx).getContext()); if (cnt.incrementAndGet() == numHandlers) { assertEquals(numHandlers, contexts.size()); testComplete(); } }); } vertx.eventBus().publish(ADDRESS1, "foo"); await(); }
public static Set<Class<?>> getClasses(final Predicate<Class<?>> filter, final String... zeroScans) { if (CLASSES.isEmpty()) { if (0 < zeroScans.length) { CLASSES.addAll(multiClasses(zeroScans, filter)); } else { final Package[] packages = Package.getPackages(); final Set<String> packageDirs = new HashSet<>(); for (final Package pkg : packages) { final String pending = pkg.getName(); final boolean skip = FORBIDDEN.stream().anyMatch(pending::startsWith); if (!skip) { packageDirs.add(pending); } } // Fix big issue of current classpath scan, Must put . of classpath into current scan path. packageDirs.add(Strings.DOT); LOGGER.info(Info.PACKAGES, String.valueOf(packageDirs.size()), String.valueOf(packages.length)); CLASSES.addAll(multiClasses(packageDirs.toArray(new String[]{}), filter)); } } return CLASSES; }
@Override public WebSocketMetric connected(SocketMetric socketMetric, HttpServerMetric requestMetric, ServerWebSocket serverWebSocket) { if (!requests.remove(requestMetric)) { throw new IllegalStateException(); } WebSocketMetric metric = new WebSocketMetric(socketMetric, serverWebSocket); if (webSockets.put(serverWebSocket, metric) != null) { throw new AssertionError(); } return metric; }