...28import org.openqa.selenium.grid.config.MapConfig;29import org.openqa.selenium.grid.server.BaseServerFlags;30import org.openqa.selenium.grid.server.BaseServerOptions;31import org.openqa.selenium.grid.server.EventBusFlags;32import org.openqa.selenium.grid.server.EventBusOptions;33import org.openqa.selenium.grid.server.Server;34import org.openqa.selenium.netty.server.NettyServer;35import org.openqa.selenium.remote.http.HttpResponse;36import org.openqa.selenium.remote.http.Route;37import java.util.Set;38import java.util.concurrent.CountDownLatch;39import java.util.concurrent.TimeUnit;40import java.util.logging.Logger;41import static org.openqa.selenium.json.Json.JSON_UTF_8;42import static org.openqa.selenium.remote.http.Contents.asJson;43@AutoService(CliCommand.class)44public class MessageBusCommand extends TemplateGridCommand {45 private static final Logger LOG = Logger.getLogger(MessageBusCommand.class.getName());46 @Override47 public String getName() {48 return "message-bus";49 }50 @Override51 public String getDescription() {52 return "Standalone instance of the message bus.";53 }54 @Override55 public boolean isShown() {56 return false;57 }58 @Override59 protected Set<Object> getFlagObjects() {60 return ImmutableSet.of(61 new BaseServerFlags(),62 new EventBusFlags());63 }64 @Override65 protected String getSystemPropertiesConfigPrefix() {66 return "selenium";67 }68 @Override69 protected Config getDefaultConfig() {70 return new MapConfig(ImmutableMap.of(71 "events", ImmutableMap.of(72 "bind", true,73 "publish", "tcp://*:4442",74 "subscribe", "tcp://*:4443"),75 "server", ImmutableMap.of(76 "port", 5557)));77 }78 @Override79 protected void execute(Config config) {80 EventBusOptions events = new EventBusOptions(config);81 EventBus bus = events.getEventBus();82 BaseServerOptions serverOptions = new BaseServerOptions(config);83 Server<?> server = new NettyServer(84 serverOptions,85 Route.get("/status").to(() -> req -> {86 CountDownLatch latch = new CountDownLatch(1);87 Type healthCheck = new Type("healthcheck");88 bus.addListener(healthCheck, event -> latch.countDown());89 bus.fire(new Event(healthCheck, "ping"));90 try {91 if (latch.await(5, TimeUnit.SECONDS)) {92 return httpResponse(true, "Event bus running");93 } else {94 return httpResponse(false, "Event bus could not deliver a test message in 5 seconds");...