Package org.elasticsearch.hadoop.serialization.dto

Examples of org.elasticsearch.hadoop.serialization.dto.Shard


        info.put("index", "index");
        info.put("relocating_node", "none");
        info.put("node", "1");
        info.put("primary", "true");

        Shard sh1 = new Shard(info);
        Node node1 = new Node("1", info);

        info.put("name", "2");
        info.put("shard", 2);

        Shard sh2 = new Shard(info);
        Node node2 = new Node("2", info);

        info.put("name", "3");
        info.put("shard", 3);

        Shard sh3 = new Shard(info);
        Node node3 = new Node("3", info);

        info.put("name", "4");
        info.put("shard", 4);

        Shard sh4 = new Shard(info);
        Node node4 = new Node("4", info);

        info.put("name", "5");
        info.put("shard", 5);

        Shard sh5 = new Shard(info);
        Node node5 = new Node("5", info);

        info.put("name", "6");
        info.put("shard", 6);

        Shard sh6 = new Shard(info);
        Node node6 = new Node("6", info);

        pd1 = new PartitionDefinition(sh1, node1, null, null);
        pd2 = new PartitionDefinition(sh2, node2, null, null);
        pd3 = new PartitionDefinition(sh3, node3, null, null);
View Full Code Here


        // if there's no task info, just pick a random bucket
        if (currentInstance <= 0) {
            currentInstance = new Random().nextInt(targetShards.size()) + 1;
        }
        int bucket = currentInstance % targetShards.size();
        Shard chosenShard = orderedShards.get(bucket);
        Node targetNode = targetShards.get(chosenShard);

        // pin settings
        SettingsUtils.pinNode(settings, targetNode.getIpAddress(), targetNode.getHttpPort());
        String node = SettingsUtils.getPinnedNode(settings);
        repository = new RestRepository(settings);

        if (log.isDebugEnabled()) {
            log.debug(String.format("Partition writer instance [%s] assigned to primary shard [%s] at address [%s]",
                    currentInstance, chosenShard.getName(), node));
        }

        return repository;
    }
View Full Code Here

        List<List<Map<String, Object>>> info = client.targetShards(resourceR.index());

        for (List<Map<String, Object>> shardGroup : info) {
            // find the first started shard in each group (round-robin)
            for (Map<String, Object> shardData : shardGroup) {
                Shard shard = new Shard(shardData);
                if (shard.getState().isStarted()) {
                    Node node = nodes.get(shard.getNode());
                    Assert.notNull(node, String.format("Cannot find node with id [%s] (is HTTP enabled?) from shard [%s] in nodes [%s]; layout [%s]", shard.getNode(), shard, shardGroup, info));
                    shards.put(shard, node);
                    break;
                }
            }
        }
View Full Code Here

        Map<Shard, Node> shards = new LinkedHashMap<Shard, Node>(info.size());

        for (List<Map<String, Object>> shardGroup : info) {
            // consider only primary shards
            for (Map<String, Object> shardData : shardGroup) {
                Shard shard = new Shard(shardData);
                if (shard.isPrimary()) {
                    Node node = nodes.get(shard.getNode());
                    Assert.notNull(node, String.format("Cannot find node with id [%s] (is HTTP enabled?) from shard [%s] in nodes [%s]; layout [%s]", shard.getNode(), shard, shardGroup, info));
                    shards.put(shard, node);
                    break;
                }
            }
        }
View Full Code Here

            // if there's no task info, just pick a random bucket
            if (currentInstance <= 0) {
                currentInstance = new Random().nextInt(targetShards.size()) + 1;
            }
            int bucket = currentInstance % targetShards.size();
            Shard chosenShard = orderedShards.get(bucket);
            Node targetNode = targetShards.get(chosenShard);

            // override the global settings to communicate directly with the target node
            settings.setHosts(targetNode.getIpAddress()).setPort(targetNode.getHttpPort());
            repository = new RestRepository(settings);
            uri = SettingsUtils.nodes(settings).get(0);

            if (log.isDebugEnabled()) {
                log.debug(String.format("EsRecordWriter instance [%s] assigned to primary shard [%s] at address [%s]", currentInstance, chosenShard.getName(), uri));
            }
        }
View Full Code Here

        ShardInputSplit[] splits = new ShardInputSplit[targetShards.size()];

        int index = 0;
        for (Entry<Shard, Node> entry : targetShards.entrySet()) {
            Shard shard = entry.getKey();
            Node node = entry.getValue();
            splits[index++] =
                        new ShardInputSplit(node.getIpAddress(), node.getHttpPort(), node.getId(), node.getName(), shard.getName(), savedMapping, savedSettings);
        }

        log.info(String.format("Created [%d] shard-splits", splits.length));
        return splits;
    }
View Full Code Here

        List<List<Map<String, Object>>> info = client.targetShards(resourceR.index());

        for (List<Map<String, Object>> shardGroup : info) {
            // find the first started shard in each group (round-robin)
            for (Map<String, Object> shardData : shardGroup) {
                Shard shard = new Shard(shardData);
                if (shard.getState().isStarted()) {
                    Node node = nodes.get(shard.getNode());
                    Assert.notNull(node, "Cannot find node with id [" + shard.getNode() + "]");
                    shards.put(shard, node);
                    break;
                }
            }
        }
View Full Code Here

        Map<Shard, Node> shards = new LinkedHashMap<Shard, Node>(info.size());

        for (List<Map<String, Object>> shardGroup : info) {
            // consider only primary shards
            for (Map<String, Object> shardData : shardGroup) {
                Shard shard = new Shard(shardData);
                if (shard.isPrimary()) {
                    Node node = nodes.get(shard.getNode());
                    Assert.notNull(node, "Cannot find node with id [" + shard.getNode() + "]");
                    shards.put(shard, node);
                    break;
                }
            }
        }
View Full Code Here

TOP

Related Classes of org.elasticsearch.hadoop.serialization.dto.Shard

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.