本文整理了Java中io.prestosql.spi.Node.getHostAndPort()
方法的一些代码示例,展示了Node.getHostAndPort()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.getHostAndPort()
方法的具体详情如下:
包路径:io.prestosql.spi.Node
类名称:Node
方法名:getHostAndPort
暂无
代码示例来源:origin: prestosql/presto
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: prestosql/presto
@Inject
public MemoryPageSinkProvider(MemoryPagesStore pagesStore, NodeManager nodeManager)
{
this(pagesStore, requireNonNull(nodeManager, "nodeManager is null").getCurrentNode().getHostAndPort());
}
代码示例来源:origin: io.prestosql/presto-memory
@Inject
public MemoryPageSinkProvider(MemoryPagesStore pagesStore, NodeManager nodeManager)
{
this(pagesStore, requireNonNull(nodeManager, "nodeManager is null").getCurrentNode().getHostAndPort());
}
代码示例来源:origin: prestosql/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: io.prestosql/presto-main
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: prestosql/presto
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: io.prestosql/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: prestosql/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: prestosql/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: prestosql/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: io.prestosql/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: io.prestosql/presto-main
@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: prestosql/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: prestosql/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: prestosql/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: prestosql/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: io.prestosql/presto-main
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: io.prestosql/presto-main
@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: prestosql/presto
private ConnectorSplit createSplit(BucketShards bucketShards)
{
if (bucketShards.getBucketNumber().isPresent()) {
return createBucketSplit(bucketShards.getBucketNumber().getAsInt(), bucketShards.getShards());
}
verify(bucketShards.getShards().size() == 1, "wrong shard count for non-bucketed table");
ShardNodes shard = getOnlyElement(bucketShards.getShards());
UUID shardId = shard.getShardUuid();
Set<String> nodeIds = shard.getNodeIdentifiers();
List<HostAddress> addresses = getAddressesForNodes(nodesById, nodeIds);
if (addresses.isEmpty()) {
if (!backupAvailable) {
throw new PrestoException(RAPTOR_NO_HOST_FOR_SHARD, format("No host for shard %s found: %s", shardId, nodeIds));
}
// Pick a random node and optimistically assign the shard to it.
// That node will restore the shard from the backup location.
Set<Node> availableNodes = nodeSupplier.getWorkerNodes();
if (availableNodes.isEmpty()) {
throw new PrestoException(NO_NODES_AVAILABLE, "No nodes available to run query");
}
Node node = selectRandom(availableNodes);
shardManager.replaceShardAssignment(tableId, shardId, node.getNodeIdentifier(), true);
addresses = ImmutableList.of(node.getHostAndPort());
}
return new RaptorSplit(connectorId, shardId, addresses, effectivePredicate, transactionId);
}
代码示例来源:origin: prestosql/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);
}
}
内容来源于网络,如有侵权,请联系作者删除!