@Override
public ConnectorSplitSource getPartitionSplits(ConnectorTableHandle table, List<ConnectorPartition> partitions)
{
checkNotNull(partitions, "partitions is null");
if (partitions.isEmpty()) {
return new FixedSplitSource(SYSTEM_DATASOURCE, ImmutableList.<ConnectorSplit>of());
}
ConnectorPartition partition = Iterables.getOnlyElement(partitions);
SystemPartition systemPartition = checkType(partition, SystemPartition.class, "partition");
SystemTable systemTable = tables.get(systemPartition.getTableHandle().getSchemaTableName());
checkArgument(systemTable != null, "Table %s does not exist", systemPartition.getTableHandle().getTableName());
if (systemTable.isDistributed()) {
ImmutableList.Builder<ConnectorSplit> splits = ImmutableList.builder();
for (Node node : nodeManager.getActiveNodes()) {
splits.add(new SystemSplit(systemPartition.getTableHandle(), node.getHostAndPort()));
}
return new FixedSplitSource(SYSTEM_DATASOURCE, splits.build());
}
HostAddress address = nodeManager.getCurrentNode().getHostAndPort();
ConnectorSplit split = new SystemSplit(systemPartition.getTableHandle(), address);
return new FixedSplitSource(SYSTEM_DATASOURCE, ImmutableList.of(split));
}