@BeforeMethod public void setup() { testHttpClient = new TestingHttpClient(input -> new TestingResponse(OK, ArrayListMultimap.create(), ACTIVE.name().getBytes())); expectedVersion = new NodeVersion("1"); coordinator = new PrestoNode(UUID.randomUUID().toString(), URI.create("https://192.0.2.8"), expectedVersion, false); activeNodes = ImmutableList.of( new PrestoNode(nodeInfo.getNodeId(), URI.create("http://192.0.1.1"), expectedVersion, false), new PrestoNode(UUID.randomUUID().toString(), URI.create("http://192.0.2.1:8080"), expectedVersion, false), new PrestoNode(UUID.randomUUID().toString(), URI.create("http://192.0.2.3"), expectedVersion, false), coordinator); inactiveNodes = ImmutableList.of( new PrestoNode(UUID.randomUUID().toString(), URI.create("https://192.0.3.9"), NodeVersion.UNKNOWN, false), new PrestoNode(UUID.randomUUID().toString(), URI.create("https://192.0.4.9"), new NodeVersion("2"), false)); List<ServiceDescriptor> descriptors = new ArrayList<>(); for (PrestoNode node : Iterables.concat(activeNodes, inactiveNodes)) { descriptors.add(serviceDescriptor("presto") .setNodeId(node.getNodeIdentifier()) .addProperty("http", node.getHttpUri().toString()) .addProperty("node_version", node.getNodeVersion().toString()) .addProperty("coordinator", String.valueOf(node.equals(coordinator))) .build()); } selector = new StaticServiceSelector(descriptors); }
@ForMetadata @Singleton @Provides DataSource createDataSource(JdbcDatabaseConfig config, @ForMetadata MySqlDataSourceConfig mysqlConfig) { ServiceDescriptor descriptor = serviceDescriptor("mysql") .addProperty("jdbc", config.getUrl()) .build(); return new MySqlDataSource(new StaticServiceSelector(descriptor), mysqlConfig); } }
@ForMetadata @Singleton @Provides DataSource createDataSource(JdbcDatabaseConfig config, @ForMetadata MySqlDataSourceConfig mysqlConfig) { ServiceDescriptor descriptor = serviceDescriptor("mysql") .addProperty("jdbc", config.getUrl()) .build(); return new MySqlDataSource(new StaticServiceSelector(descriptor), mysqlConfig); } }
@BeforeMethod public void setup() { testHttpClient = new TestingHttpClient(input -> new TestingResponse(OK, ArrayListMultimap.create(), ACTIVE.name().getBytes())); expectedVersion = new NodeVersion("1"); coordinator = new PrestoNode(UUID.randomUUID().toString(), URI.create("https://192.0.2.8"), expectedVersion); activeNodes = ImmutableList.of( new PrestoNode(nodeInfo.getNodeId(), URI.create("http://192.0.1.1"), expectedVersion), new PrestoNode(UUID.randomUUID().toString(), URI.create("http://192.0.2.1:8080"), expectedVersion), new PrestoNode(UUID.randomUUID().toString(), URI.create("http://192.0.2.3"), expectedVersion), coordinator); inactiveNodes = ImmutableList.of( new PrestoNode(UUID.randomUUID().toString(), URI.create("https://192.0.3.9"), NodeVersion.UNKNOWN), new PrestoNode(UUID.randomUUID().toString(), URI.create("https://192.0.4.9"), new NodeVersion("2")) ); List<ServiceDescriptor> descriptors = new ArrayList<>(); for (PrestoNode node : Iterables.concat(activeNodes, inactiveNodes)) { descriptors.add(serviceDescriptor("presto") .setNodeId(node.getNodeIdentifier()) .addProperty("http", node.getHttpUri().toString()) .addProperty("node_version", node.getNodeVersion().toString()) .addProperty("coordinator", String.valueOf(node.equals(coordinator))) .build()); } selector = new StaticServiceSelector(descriptors); }