public InMemoryNodeManager(URI localUri) { localNode = new PrestoNode("local", localUri, NodeVersion.UNKNOWN, false); }
private static PrestoNode findCurrentNode(List<ServiceDescriptor> allServices, String currentNodeId, NodeVersion expectedNodeVersion, boolean httpsRequired) { for (ServiceDescriptor service : allServices) { URI uri = getHttpUri(service, httpsRequired); NodeVersion nodeVersion = getNodeVersion(service); if (uri != null && nodeVersion != null) { PrestoNode node = new PrestoNode(service.getNodeId(), uri, nodeVersion, isCoordinator(service)); if (node.getNodeIdentifier().equals(currentNodeId)) { checkState( node.getNodeVersion().equals(expectedNodeVersion), "INVARIANT: current node version (%s) should be equal to %s", node.getNodeVersion(), expectedNodeVersion); return node; } } } throw new IllegalStateException("INVARIANT: current node not returned from service selector"); }
private NodeState getNodeState(PrestoNode node) { if (expectedNodeVersion.equals(node.getNodeVersion())) { if (isNodeShuttingDown(node.getNodeIdentifier())) { return SHUTTING_DOWN; } else { return ACTIVE; } } else { return INACTIVE; } }
@Test public void testAssignRandomNodeWhenBackupAvailable() throws URISyntaxException { TestingNodeManager nodeManager = new TestingNodeManager(); RaptorConnectorId connectorId = new RaptorConnectorId("raptor"); NodeSupplier nodeSupplier = nodeManager::getWorkerNodes; PrestoNode node = new PrestoNode(UUID.randomUUID().toString(), new URI("http://127.0.0.1/"), NodeVersion.UNKNOWN, false); nodeManager.addNode(node); RaptorSplitManager raptorSplitManagerWithBackup = new RaptorSplitManager(connectorId, nodeSupplier, shardManager, true); deleteShardNodes(); ConnectorTableLayoutResult layout = getOnlyElement(metadata.getTableLayouts(SESSION, tableHandle, Constraint.alwaysTrue(), Optional.empty())); ConnectorSplitSource partitionSplit = getSplits(raptorSplitManagerWithBackup, layout); List<ConnectorSplit> batch = getSplits(partitionSplit, 1); assertEquals(getOnlyElement(getOnlyElement(batch).getAddresses()), node.getHostAndPort()); }
private static String getNodeVersion(Node node) { if (node instanceof PrestoNode) { return ((PrestoNode) node).getNodeVersion().toString(); } return ""; }
@Test public void testGetCurrentNode() { NodeInfo nodeInfo = new NodeInfo(new NodeConfig() .setEnvironment("test") .setNodeId(currentNode.getNodeIdentifier())); DiscoveryNodeManager manager = new DiscoveryNodeManager(selector, nodeInfo, new NoOpFailureDetector(), expectedVersion, testHttpClient, internalCommunicationConfig); try { assertEquals(manager.getCurrentNode(), currentNode); } finally { manager.stop(); } }
private NodeState getNodeState(PrestoNode node) { if (expectedNodeVersion.equals(node.getNodeVersion())) { if (isNodeShuttingDown(node.getNodeIdentifier())) { return SHUTTING_DOWN; } else { return ACTIVE; } } else { return INACTIVE; } }
private static String getNodeVersion(Node node) { if (node instanceof PrestoNode) { return ((PrestoNode) node).getNodeVersion().toString(); } return ""; }
@Test public void testGetCurrentNode() { NodeInfo nodeInfo = new NodeInfo(new NodeConfig() .setEnvironment("test") .setNodeId(currentNode.getNodeIdentifier())); DiscoveryNodeManager manager = new DiscoveryNodeManager(selector, nodeInfo, new NoOpFailureDetector(), expectedVersion, testHttpClient, internalCommunicationConfig); try { assertEquals(manager.getCurrentNode(), currentNode); } finally { manager.stop(); } }
public InMemoryNodeManager(URI localUri) { localNode = new PrestoNode("local", localUri, NodeVersion.UNKNOWN, false); }
private static PrestoNode findCurrentNode(List<ServiceDescriptor> allServices, String currentNodeId, NodeVersion expectedNodeVersion, boolean httpsRequired) { for (ServiceDescriptor service : allServices) { URI uri = getHttpUri(service, httpsRequired); NodeVersion nodeVersion = getNodeVersion(service); if (uri != null && nodeVersion != null) { PrestoNode node = new PrestoNode(service.getNodeId(), uri, nodeVersion, isCoordinator(service)); if (node.getNodeIdentifier().equals(currentNodeId)) { checkState( node.getNodeVersion().equals(expectedNodeVersion), "INVARIANT: current node version (%s) should be equal to %s", node.getNodeVersion(), expectedNodeVersion); return node; } } } throw new IllegalStateException("INVARIANT: current node not returned from service selector"); }
private synchronized void announceNodes(Set<Node> activeNodes, Set<Node> inactiveNodes) { ImmutableList.Builder<ServiceDescriptor> descriptors = ImmutableList.builder(); for (Node node : Iterables.concat(activeNodes, inactiveNodes)) { descriptors.add(serviceDescriptor("presto") .setNodeId(node.getNodeIdentifier()) .addProperty("http", node.getHttpUri().toString()) .addProperty("node_version", ((PrestoNode) node).getNodeVersion().toString()) .addProperty("coordinator", String.valueOf(node.isCoordinator())) .build()); } this.descriptors = descriptors.build(); }
public TestingNodeManager(String environment) { this(environment, new PrestoNode("local", URI.create("local://127.0.0.1"), NodeVersion.UNKNOWN, true), ImmutableSet.of()); }
private synchronized void announceNodes(Set<Node> activeNodes, Set<Node> inactiveNodes) { ImmutableList.Builder<ServiceDescriptor> descriptors = ImmutableList.builder(); for (Node node : Iterables.concat(activeNodes, inactiveNodes)) { descriptors.add(serviceDescriptor("presto") .setNodeId(node.getNodeIdentifier()) .addProperty("http", node.getHttpUri().toString()) .addProperty("node_version", ((PrestoNode) node).getNodeVersion().toString()) .addProperty("coordinator", String.valueOf(node.isCoordinator())) .build()); } this.descriptors = descriptors.build(); }
public TestingNodeManager(String environment) { this(environment, new PrestoNode("local", URI.create("local://127.0.0.1"), NodeVersion.UNKNOWN, true), ImmutableSet.of()); }
private static Node createTestingNode(String nodeIdentifier) { return new PrestoNode(nodeIdentifier, URI.create("http://test"), NodeVersion.UNKNOWN, false); } }
private static Node createTestingNode(String identifier) { return new PrestoNode(identifier, URI.create("http://test"), NodeVersion.UNKNOWN, false); }
private static Node createTestingNode(String hostname) { return new PrestoNode(hostname, URI.create(format("http://%s:8080", hostname)), NodeVersion.UNKNOWN, false); } }
public TestSourcePartitionedScheduler() { nodeManager.addNode(CONNECTOR_ID, new PrestoNode("other1", URI.create("http://127.0.0.1:11"), NodeVersion.UNKNOWN, false), new PrestoNode("other2", URI.create("http://127.0.0.1:12"), NodeVersion.UNKNOWN, false), new PrestoNode("other3", URI.create("http://127.0.0.1:13"), NodeVersion.UNKNOWN, false)); }
public TestSourcePartitionedScheduler() { nodeManager.addNode(CONNECTOR_ID, new PrestoNode("other1", URI.create("http://127.0.0.1:11"), NodeVersion.UNKNOWN, false), new PrestoNode("other2", URI.create("http://127.0.0.1:12"), NodeVersion.UNKNOWN, false), new PrestoNode("other3", URI.create("http://127.0.0.1:13"), NodeVersion.UNKNOWN, false)); }