com.facebook.presto.spi.Node.getHostAndPort()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(12.7k)|赞(0)|评价(0)|浏览(79)

本文整理了Java中com.facebook.presto.spi.Node.getHostAndPort()方法的一些代码示例,展示了Node.getHostAndPort()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.getHostAndPort()方法的具体详情如下:
包路径:com.facebook.presto.spi.Node
类名称:Node
方法名:getHostAndPort

Node.getHostAndPort介绍

暂无

代码示例

代码示例来源:origin: prestodb/presto

@Inject
public MemoryPageSinkProvider(MemoryPagesStore pagesStore, NodeManager nodeManager)
{
  this(pagesStore, requireNonNull(nodeManager, "nodeManager is null").getCurrentNode().getHostAndPort());
}

代码示例来源:origin: prestodb/presto

public synchronized Map<String, Optional<MemoryInfo>> getWorkerMemoryInfo()
{
  Map<String, Optional<MemoryInfo>> memoryInfo = new HashMap<>();
  for (Entry<String, RemoteNodeMemory> entry : nodes.entrySet()) {
    // workerId is of the form "node_identifier [node_host]"
    String workerId = entry.getKey() + " [" + entry.getValue().getNode().getHostAndPort().getHostText() + "]";
    memoryInfo.put(workerId, entry.getValue().getInfo());
  }
  return memoryInfo;
}

代码示例来源:origin: prestodb/presto

@Override
  public ConnectorSplitSource getSplits(ConnectorTransactionHandle transaction, ConnectorSession session, ConnectorTableLayoutHandle layout, SplitSchedulingStrategy splitSchedulingStrategy)
  {
    TpcdsTableHandle tableHandle = ((TpcdsTableLayoutHandle) layout).getTable();

    Set<Node> nodes = nodeManager.getRequiredWorkerNodes();
    checkState(!nodes.isEmpty(), "No TPCDS nodes available");

    int totalParts = nodes.size() * splitsPerNode;
    int partNumber = 0;

    // Split the data using split and skew by the number of nodes available.
    ImmutableList.Builder<ConnectorSplit> splits = ImmutableList.builder();
    for (Node node : nodes) {
      for (int i = 0; i < splitsPerNode; i++) {
        splits.add(new TpcdsSplit(tableHandle, partNumber, totalParts, ImmutableList.of(node.getHostAndPort()), noSexism));
        partNumber++;
      }
    }
    return new FixedSplitSource(splits.build());
  }
}

代码示例来源:origin: prestodb/presto

@Override
  public ConnectorSplitSource getSplits(ConnectorTransactionHandle transaction, ConnectorSession session, ConnectorTableLayoutHandle layout, SplitSchedulingStrategy splitSchedulingStrategy)
  {
    TpchTableLayoutHandle tableLayoutHandle = (TpchTableLayoutHandle) layout;
    TpchTableHandle tableHandle = tableLayoutHandle.getTable();

    Set<Node> nodes = nodeManager.getRequiredWorkerNodes();

    int totalParts = nodes.size() * splitsPerNode;
    int partNumber = 0;

    // Split the data using split and skew by the number of nodes available.
    ImmutableList.Builder<ConnectorSplit> splits = ImmutableList.builder();
    for (Node node : nodes) {
      for (int i = 0; i < splitsPerNode; i++) {
        splits.add(new TpchSplit(tableHandle, partNumber, totalParts, ImmutableList.of(node.getHostAndPort()), tableLayoutHandle.getPredicate()));
        partNumber++;
      }
    }
    return new FixedSplitSource(splits.build());
  }
}

代码示例来源:origin: prestodb/presto

@Override
  public ConnectorSplitSource getSplits(ConnectorTransactionHandle transaction, ConnectorSession session, ConnectorTableLayoutHandle layout, SplitSchedulingStrategy splitSchedulingStrategy)
  {
    InformationSchemaTableLayoutHandle handle = (InformationSchemaTableLayoutHandle) layout;

    List<HostAddress> localAddress = ImmutableList.of(nodeManager.getCurrentNode().getHostAndPort());

    ConnectorSplit split = new InformationSchemaSplit(handle.getTable(), handle.getPrefixes(), localAddress);

    return new FixedSplitSource(ImmutableList.of(split));
  }
}

代码示例来源:origin: prestodb/presto

@Override
  public ConnectorSplitSource getSplits(ConnectorTransactionHandle transactionHandle, ConnectorSession session, ConnectorTableLayoutHandle layout, SplitSchedulingStrategy splitSchedulingStrategy)
  {
    LocalFileTableLayoutHandle layoutHandle = (LocalFileTableLayoutHandle) layout;
    LocalFileTableHandle tableHandle = layoutHandle.getTable();

    TupleDomain<LocalFileColumnHandle> effectivePredicate = layoutHandle.getConstraint()
        .transform(LocalFileColumnHandle.class::cast);

    List<ConnectorSplit> splits = nodeManager.getAllNodes().stream()
        .map(node -> new LocalFileSplit(node.getHostAndPort(), tableHandle.getSchemaTableName(), effectivePredicate))
        .collect(Collectors.toList());

    return new FixedSplitSource(splits);
  }
}

代码示例来源:origin: prestodb/presto

@Override
  public ConnectorSplitSource getSplits(ConnectorTransactionHandle transaction, ConnectorSession session, ConnectorTableLayoutHandle layout, SplitSchedulingStrategy splitSchedulingStrategy)
  {
    JmxTableLayoutHandle jmxLayout = (JmxTableLayoutHandle) layout;
    JmxTableHandle tableHandle = jmxLayout.getTable();
    TupleDomain<ColumnHandle> predicate = jmxLayout.getConstraint();

    //TODO is there a better way to get the node column?
    Optional<JmxColumnHandle> nodeColumnHandle = tableHandle.getColumnHandles().stream()
        .filter(jmxColumnHandle -> jmxColumnHandle.getColumnName().equals(NODE_COLUMN_NAME))
        .findFirst();
    checkState(nodeColumnHandle.isPresent(), "Failed to find %s column", NODE_COLUMN_NAME);

    List<ConnectorSplit> splits = nodeManager.getAllNodes().stream()
        .filter(node -> {
          NullableValue value = NullableValue.of(createUnboundedVarcharType(), utf8Slice(node.getNodeIdentifier()));
          return predicate.overlaps(fromFixedValues(ImmutableMap.of(nodeColumnHandle.get(), value)));
        })
        .map(node -> new JmxSplit(tableHandle, ImmutableList.of(node.getHostAndPort())))
        .collect(toList());

    return new FixedSplitSource(splits);
  }
}

代码示例来源:origin: prestodb/presto

@Test
public void testScheduleLocal()
{
  Split split = new Split(CONNECTOR_ID, TestingTransactionHandle.create(), new TestSplitLocal());
  Set<Split> splits = ImmutableSet.of(split);
  Map.Entry<Node, Split> assignment = Iterables.getOnlyElement(nodeSelector.computeAssignments(splits, ImmutableList.copyOf(taskMap.values())).getAssignments().entries());
  assertEquals(assignment.getKey().getHostAndPort(), split.getAddresses().get(0));
  assertEquals(assignment.getValue(), split);
}

代码示例来源:origin: prestodb/presto

HostAddress address = nodeManager.getCurrentNode().getHostAndPort();
ConnectorSplit split = new SystemSplit(tableHandle.getConnectorId(), tableHandle, address, constraint);
return new FixedSplitSource(ImmutableList.of(split));
splits.add(new SystemSplit(tableHandle.getConnectorId(), tableHandle, node.getHostAndPort(), constraint));

代码示例来源:origin: prestodb/presto

log.info("Previously active node is missing: %s (last seen at %s)", missingNode.getNodeIdentifier(), missingNode.getHostAndPort());

代码示例来源:origin: prestodb/presto

NetworkLocation location = networkLocationCache.get(node.getHostAndPort());
for (int i = 0; i <= location.getSegments().size(); i++) {
  workersByNetworkPath.put(location.subLocation(0, i), node);
byHostAndPort.put(node.getHostAndPort(), node);

代码示例来源:origin: prestodb/presto

@Override
  public ConnectorSplitSource getSplits(ConnectorTransactionHandle transactionHandle, ConnectorSession session, ConnectorTableLayoutHandle layoutHandle, SplitSchedulingStrategy splitSchedulingStrategy)
  {
    AtopTableLayoutHandle handle = (AtopTableLayoutHandle) layoutHandle;

    AtopTableHandle table = handle.getTableHandle();

    List<ConnectorSplit> splits = new ArrayList<>();
    ZonedDateTime end = ZonedDateTime.now(timeZone);
    for (Node node : nodeManager.getWorkerNodes()) {
      ZonedDateTime start = end.minusDays(maxHistoryDays - 1).withHour(0).withMinute(0).withSecond(0).withNano(0);
      while (start.isBefore(end)) {
        ZonedDateTime splitEnd = start.withHour(23).withMinute(59).withSecond(59).withNano(0);
        Domain splitDomain = Domain.create(ValueSet.ofRanges(Range.range(TIMESTAMP_WITH_TIME_ZONE, 1000 * start.toEpochSecond(), true, 1000 * splitEnd.toEpochSecond(), true)), false);
        if (handle.getStartTimeConstraint().overlaps(splitDomain) && handle.getEndTimeConstraint().overlaps(splitDomain)) {
          splits.add(new AtopSplit(table.getTable(), node.getHostAndPort(), start.toEpochSecond(), start.getZone()));
        }
        start = start.plusDays(1).withHour(0).withMinute(0).withSecond(0).withNano(0);
      }
    }

    return new FixedSplitSource(splits);
  }
}

代码示例来源:origin: com.facebook.presto/presto-raptor

private static List<HostAddress> getAddressesForNodes(Map<String, Node> nodeMap, Iterable<String> nodeIdentifiers)
{
  ImmutableList.Builder<HostAddress> nodes = ImmutableList.builder();
  for (String id : nodeIdentifiers) {
    Node node = nodeMap.get(id);
    if (node != null) {
      nodes.add(node.getHostAndPort());
    }
  }
  return nodes.build();
}

代码示例来源:origin: com.facebook.presto/presto-memory

@Inject
public MemoryPageSinkProvider(MemoryPagesStore pagesStore, NodeManager nodeManager)
{
  this(pagesStore, requireNonNull(nodeManager, "nodeManager is null").getCurrentNode().getHostAndPort());
}

代码示例来源:origin: com.facebook.presto/presto-raptor

private ConnectorSplit createBucketSplit(int bucketNumber, Set<ShardNodes> shards)
  {
    // Bucket splits contain all the shards for the bucket
    // and run on the node assigned to the bucket.
    String nodeId = bucketToNode.get().get(bucketNumber);
    Node node = nodesById.get(nodeId);
    if (node == null) {
      throw new PrestoException(NO_NODES_AVAILABLE, "Node for bucket is offline: " + nodeId);
    }
    Set<UUID> shardUuids = shards.stream()
        .map(ShardNodes::getShardUuid)
        .collect(toSet());
    HostAddress address = node.getHostAndPort();
    return new RaptorSplit(connectorId, shardUuids, bucketNumber, address, effectivePredicate, transactionId);
  }
}

代码示例来源:origin: com.facebook.presto/presto-tpcds

@Override
  public ConnectorSplitSource getSplits(ConnectorTransactionHandle transaction, ConnectorSession session, ConnectorTableLayoutHandle layout, SplitSchedulingStrategy splitSchedulingStrategy)
  {
    TpcdsTableHandle tableHandle = ((TpcdsTableLayoutHandle) layout).getTable();

    Set<Node> nodes = nodeManager.getRequiredWorkerNodes();
    checkState(!nodes.isEmpty(), "No TPCDS nodes available");

    int totalParts = nodes.size() * splitsPerNode;
    int partNumber = 0;

    // Split the data using split and skew by the number of nodes available.
    ImmutableList.Builder<ConnectorSplit> splits = ImmutableList.builder();
    for (Node node : nodes) {
      for (int i = 0; i < splitsPerNode; i++) {
        splits.add(new TpcdsSplit(tableHandle, partNumber, totalParts, ImmutableList.of(node.getHostAndPort()), noSexism));
        partNumber++;
      }
    }
    return new FixedSplitSource(splits.build());
  }
}

代码示例来源:origin: uk.co.nichesolutions.presto/presto-tpch

@Override
  public ConnectorSplitSource getSplits(ConnectorTransactionHandle transaction, ConnectorSession session, ConnectorTableLayoutHandle layout)
  {
    TpchTableHandle tableHandle = checkType(layout, TpchTableLayoutHandle.class, "layout").getTable();

    Set<Node> nodes = nodeManager.getActiveDatasourceNodes(connectorId);
    checkState(!nodes.isEmpty(), "No TPCH nodes available");

    int totalParts = nodes.size() * splitsPerNode;
    int partNumber = 0;

    // Split the data using split and skew by the number of nodes available.
    ImmutableList.Builder<ConnectorSplit> splits = ImmutableList.builder();
    for (Node node : nodes) {
      for (int i = 0; i < splitsPerNode; i++) {
        splits.add(new TpchSplit(tableHandle, partNumber, totalParts, ImmutableList.of(node.getHostAndPort())));
        partNumber++;
      }
    }
    return new FixedSplitSource(connectorId, splits.build());
  }
}

代码示例来源:origin: uk.co.nichesolutions.presto/presto-main

@Override
  public ConnectorSplitSource getSplits(ConnectorTransactionHandle transaction, ConnectorSession session, ConnectorTableLayoutHandle layout)
  {
    InformationSchemaTableLayoutHandle handle = checkType(layout, InformationSchemaTableLayoutHandle.class, "layout");
    Map<ColumnHandle, NullableValue> bindings = extractFixedValues(handle.getConstraint()).orElse(ImmutableMap.of());

    List<HostAddress> localAddress = ImmutableList.of(nodeManager.getCurrentNode().getHostAndPort());

    Map<String, NullableValue> filters = bindings.entrySet().stream().collect(toMap(
        entry -> checkType(entry.getKey(), InformationSchemaColumnHandle.class, "column").getColumnName(),
        Entry::getValue));

    ConnectorSplit split = new InformationSchemaSplit(handle.getTable(), filters, localAddress);

    return new FixedSplitSource(null, ImmutableList.of(split));
  }
}

代码示例来源:origin: com.facebook.presto/presto-tpch

@Override
  public ConnectorSplitSource getSplits(ConnectorTransactionHandle transaction, ConnectorSession session, ConnectorTableLayoutHandle layout, SplitSchedulingStrategy splitSchedulingStrategy)
  {
    TpchTableLayoutHandle tableLayoutHandle = (TpchTableLayoutHandle) layout;
    TpchTableHandle tableHandle = tableLayoutHandle.getTable();

    Set<Node> nodes = nodeManager.getRequiredWorkerNodes();

    int totalParts = nodes.size() * splitsPerNode;
    int partNumber = 0;

    // Split the data using split and skew by the number of nodes available.
    ImmutableList.Builder<ConnectorSplit> splits = ImmutableList.builder();
    for (Node node : nodes) {
      for (int i = 0; i < splitsPerNode; i++) {
        splits.add(new TpchSplit(tableHandle, partNumber, totalParts, ImmutableList.of(node.getHostAndPort()), tableLayoutHandle.getPredicate()));
        partNumber++;
      }
    }
    return new FixedSplitSource(splits.build());
  }
}

代码示例来源:origin: uk.co.nichesolutions.presto/presto-main

@Test
public void testScheduleLocal()
    throws Exception
{
  Split split = new Split("foo", TestingTransactionHandle.create("test"), new TestSplitLocal());
  Set<Split> splits = ImmutableSet.of(split);
  Map.Entry<Node, Split> assignment = Iterables.getOnlyElement(nodeSelector.computeAssignments(splits, ImmutableList.copyOf(taskMap.values())).entries());
  assertEquals(assignment.getKey().getHostAndPort(), split.getAddresses().get(0));
  assertEquals(assignment.getValue(), split);
}

相关文章

微信公众号

最新文章

更多