Package com.facebook.presto.metadata

Examples of com.facebook.presto.metadata.Split


    private Split getLocalQuerySplit(TableHandle tableHandle)
    {
        try {
            List<Partition> partitions = splitManager.getPartitions(tableHandle, Optional.<TupleDomain<ColumnHandle>>absent()).getPartitions();
            SplitSource splitSource = splitManager.getPartitionSplits(tableHandle, partitions);
            Split split = Iterables.getOnlyElement(splitSource.getNextBatch(1000));
            checkState(splitSource.isFinished(), "Expected only one split for a local query");
            return split;
        }
        catch (InterruptedException e) {
            Thread.currentThread().interrupt();
View Full Code Here


        }
    }

    private Split newMockSplit()
    {
        return new Split("test", new MockSplit());
    }
View Full Code Here

    static class TestSplit
            implements ConnectorSplit
    {
        static Split createRecordSetSplit()
        {
            return new Split("test", new TestSplit(true));
        }
View Full Code Here

            return new Split("test", new TestSplit(true));
        }

        static Split createNormalSplit()
        {
            return new Split("test", new TestSplit(false));
        }
View Full Code Here

    @Test
    public void testScheduleLocal()
            throws Exception
    {
        Set<Split> splits = new HashSet<>();
        Split localSplit = new Split("foo", new TestSplitLocal());
        splits.add(localSplit);
        Multimap<Node, Split> assignments = nodeSelector.computeAssignments(splits);
        Map.Entry<Node, Split> onlyEntry = Iterables.getOnlyElement(assignments.entries());
        assertEquals(onlyEntry.getKey().getHostAndPort(), localSplit.getAddresses().get(0));
        assertEquals(onlyEntry.getValue(), localSplit);
    }
View Full Code Here

    @Test
    public void testScheduleRemote()
            throws Exception
    {
        Set<Split> splits = new HashSet<>();
        splits.add(new Split("foo", new TestSplitRemote()));
        Multimap<Node, Split> assignments = nodeSelector.computeAssignments(splits);
        assertEquals(assignments.size(), 1);
    }
View Full Code Here

            throws Exception
    {
        // One split for each node
        Set<Split> splits = new HashSet<>();
        for (int i = 0; i < 3; i++) {
            splits.add(new Split("foo", new TestSplitRemote()));
        }
        Multimap<Node, Split> assignments = nodeSelector.computeAssignments(splits);
        assertEquals(assignments.entries().size(), 3);
        for (Node node : nodeManager.getActiveDatasourceNodes("foo")) {
            assertTrue(assignments.keySet().contains(node));
View Full Code Here

        Node newNode = new PrestoNode("other4", URI.create("http://127.0.0.1:14"), NodeVersion.UNKNOWN);
        nodeManager.addNode("foo", newNode);

        ImmutableList.Builder<Split> initialSplits = ImmutableList.builder();
        for (int i = 0; i < 10; i++) {
            initialSplits.add(new Split("foo", new TestSplitRemote()));
        }

        MockRemoteTaskFactory remoteTaskFactory = new MockRemoteTaskFactory(remoteTaskExecutor);
        // Max out number of splits on node
        RemoteTask remoteTask1 = remoteTaskFactory.createTableScanTask(newNode, initialSplits.build());
        nodeTaskMap.addTask(newNode, remoteTask1);
        RemoteTask remoteTask2 = remoteTaskFactory.createTableScanTask(newNode, initialSplits.build());
        nodeTaskMap.addTask(newNode, remoteTask2);

        Set<Split> splits = new HashSet<>();
        for (int i = 0; i < 5; i++) {
            splits.add(new Split("foo", new TestSplitRemote()));
        }
        Multimap<Node, Split> assignments = nodeSelector.computeAssignments(splits);

        // no split should be assigned to the newNode, as it already has maxNodeSplits assigned to it
        assertFalse(assignments.keySet().contains(newNode));
View Full Code Here

        Node newNode = new PrestoNode("other4", URI.create("http://127.0.0.1:14"), NodeVersion.UNKNOWN);
        nodeManager.addNode("foo", newNode);

        ImmutableList.Builder<Split> initialSplits = ImmutableList.builder();
        for (int i = 0; i < 20; i++) {
            initialSplits.add(new Split("foo", new TestSplitRemote()));
        }

        MockRemoteTaskFactory remoteTaskFactory = new MockRemoteTaskFactory(remoteTaskExecutor);
        for (Node node : nodeManager.getActiveDatasourceNodes("foo")) {
            // Max out number of splits on node
            RemoteTask remoteTask = remoteTaskFactory.createTableScanTask(node, initialSplits.build());
            nodeTaskMap.addTask(node, remoteTask);
        }

        RemoteTask newRemoteTask = remoteTaskFactory.createTableScanTask(newNode, initialSplits.build());
        // Max out pending splits on new node
        taskMap.put(newNode, newRemoteTask);

        Set<Split> splits = new HashSet<>();
        for (int i = 0; i < 5; i++) {
            splits.add(new Split("foo", new TestSplitRemote()));
        }
        Multimap<Node, Split> assignments = nodeSelector.computeAssignments(splits);

        // no split should be assigned to the newNode, as it already has
        // maxSplitsPerNode + maxSplitsPerNodePerTask assigned to it
View Full Code Here

    public void testTaskCompletion()
            throws Exception
    {
        MockRemoteTaskFactory remoteTaskFactory = new MockRemoteTaskFactory(remoteTaskExecutor);
        Node chosenNode = Iterables.get(nodeManager.getActiveDatasourceNodes("foo"), 0);
        RemoteTask remoteTask = remoteTaskFactory.createTableScanTask(chosenNode, ImmutableList.of(new Split("foo", new TestSplitRemote())));
        nodeTaskMap.addTask(chosenNode, remoteTask);
        assertEquals(nodeTaskMap.getPartitionedSplitsOnNode(chosenNode), 1);
        remoteTask.cancel();
        TimeUnit.MILLISECONDS.sleep(100); // Sleep until cache expires
        assertEquals(nodeTaskMap.getPartitionedSplitsOnNode(chosenNode), 0);
View Full Code Here

TOP

Related Classes of com.facebook.presto.metadata.Split

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.