Examples of Shard


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

        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

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

            // 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

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

        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

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

        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

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

        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

Examples of org.elasticsearch.river.mongodb.MongoConfig.Shard

                            settings.globalSettings(), "mongodb_river_slurper_" + shard.getName() + ":" + definition.getIndexName()
                        ).newThread(new OplogSlurper(shard.getLatestOplogTimestamp(), mongoClusterClient, mongoClient, definition, context, esClient));
                    tailerThreads.add(tailerThread);                  
                }
            } else {
                Shard shard = config.getShards().get(0);
                Thread tailerThread = EsExecutors.daemonThreadFactory(
                        settings.globalSettings(), "mongodb_river_slurper_" + shard.getName() + ":" + definition.getIndexName()
                    ).newThread(new OplogSlurper(shard.getLatestOplogTimestamp(), mongoClusterClient, mongoClusterClient, definition, context, esClient));
                tailerThreads.add(tailerThread);                  
            }

            for (Thread thread : tailerThreads) {
                thread.start();
View Full Code Here

Examples of org.elasticsearch.river.mongodb.MongoConfig.Shard

                    List<ServerAddress> shardServers = getServerAddressForReplica(item);
                    if (shardServers != null) {
                        String shardName = item.get(MongoDBRiver.MONGODB_ID_FIELD).toString();
                        MongoClient shardClient = mongoClientService.getMongoShardClient(definition, shardServers);
                        Timestamp<?> latestOplogTimestamp = getCurrentOplogTimestamp(shardClient);
                        shards.add(new Shard(shardName, shardServers, latestOplogTimestamp));
                    }
                }
            }
            return shards;
        } else {
            List<ServerAddress> servers = clusterClient.getServerAddressList();
            Timestamp<?> latestOplogTimestamp = getCurrentOplogTimestamp(clusterClient);
            shards.add(new Shard("unsharded", servers, latestOplogTimestamp));
            return shards;
        }
    }
View Full Code Here

Examples of org.makersoft.shards.Shard

      Map<SqlSessionFactory, Set<ShardId>> sqlSessionFactoryShardIdMap,
      ShardIdResolver shardIdResolver) {
    List<Shard> list = Lists.newArrayList();
    for (Map.Entry<SqlSessionFactory, Set<ShardId>> entry : sqlSessionFactoryShardIdMap
        .entrySet()) {
      Shard shard = new ShardImpl(entry.getValue(), entry.getKey());
      list.add(shard);

    }

    return list;
View Full Code Here

Examples of org.makersoft.shards.Shard

    }
    return shards;
  }

  private SqlSession getSqlSessionForStatement(String statement, List<Shard> shardsToConsider) {
    Shard shard = getShardForStatement(statement, shardsToConsider);
    if (shard == null) {
      return null;
    }
    return shard.establishSqlSession();
  }
View Full Code Here

Examples of org.makersoft.shards.Shard

  @Override
  public ShardId getShardIdForStatementOrParameter(String statement, Object parameter,
      List<Shard> shardsToConsider) {
    // TODO(fengkuok) optimize this by keeping an identity map of objects to shardId
    Shard shard = getShardForStatement(statement, shardsToConsider);
    if (shard == null) {
      return null;
    } else if (shard.getShardIds().size() == 1) {
      return shard.getShardIds().iterator().next();
    } else {
      //TODO(fengkuok) 似乎从来不会走到这个逻辑
      IdGenerator idGenerator = shardedSqlSessionFactory.getIdGenerator();
      if (idGenerator != null) {
        return idGenerator.extractShardId(this.extractId(parameter));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.