/** * Fills the shard fetched data with new (data) nodes and a fresh NodeEntry, and removes from * it nodes that are no longer part of the state. */ private void fillShardCacheWithDataNodes(Map<String, NodeEntry<T>> shardCache, DiscoveryNodes nodes) { // verify that all current data nodes are there for (ObjectObjectCursor<String, DiscoveryNode> cursor : nodes.getDataNodes()) { DiscoveryNode node = cursor.value; if (shardCache.containsKey(node.getId()) == false) { shardCache.put(node.getId(), new NodeEntry<T>(node.getId())); } } // remove nodes that are not longer part of the data nodes set shardCache.keySet().removeIf(nodeId -> !nodes.nodeExists(nodeId)); }
NodeEntry<T> nodeEntry = cache.get(response.getNode().getId()); if (nodeEntry != null) { if (nodeEntry.getFetchingRound() != fetchingRound) { assert nodeEntry.getFetchingRound() > fetchingRound : "node entries only replaced by newer rounds"; logger.trace("{} received response for [{}] from node {} for an older fetching round (expected: {} but was: {})", shardId, nodeEntry.getNodeId(), type, nodeEntry.getFetchingRound(), fetchingRound); } else if (nodeEntry.isFailed()) { logger.trace("{} node {} has failed for [{}] (failure [{}])", shardId, nodeEntry.getNodeId(), type, nodeEntry.getFailure()); } else { logger.trace("{} marking {} as done for [{}], result is [{}]", shardId, nodeEntry.getNodeId(), type, response); nodeEntry.doneFetching(response); NodeEntry<T> nodeEntry = cache.get(failure.nodeId()); if (nodeEntry != null) { if (nodeEntry.getFetchingRound() != fetchingRound) { assert nodeEntry.getFetchingRound() > fetchingRound : "node entries only replaced by newer rounds"; logger.trace("{} received failure for [{}] from node {} for an older fetching round (expected: {} but was: {})", shardId, nodeEntry.getNodeId(), type, nodeEntry.getFetchingRound(), fetchingRound); } else if (nodeEntry.isFailed() == false) { unwrappedCause instanceof ReceiveTimeoutTransportException || unwrappedCause instanceof ElasticsearchTimeoutException) { nodeEntry.restartFetching(); } else { logger.warn(() -> new ParameterizedMessage("{}: failed to list shard for {} on node [{}]", shardId, type, failure.nodeId()), failure); nodeEntry.doneFetching(failure.getCause());
nodeEntry.markAsFetching(fetchingRound); if (nodeEntry.isFailed()) { failedNodes.add(nodeEntry.getNodeId()); } else { if (nodeEntry.getValue() != null) { fetchData.put(node, nodeEntry.getValue());
nodeEntry.markAsFetching(fetchingRound); if (nodeEntry.isFailed()) { failedNodes.add(nodeEntry.getNodeId()); } else { if (nodeEntry.getValue() != null) { fetchData.put(node, nodeEntry.getValue());
nodeEntry.markAsFetching(fetchingRound); if (nodeEntry.isFailed()) { failedNodes.add(nodeEntry.getNodeId()); } else { if (nodeEntry.getValue() != null) { fetchData.put(node, nodeEntry.getValue());
NodeEntry<T> nodeEntry = cache.get(response.getNode().getId()); if (nodeEntry != null) { if (nodeEntry.getFetchingRound() != fetchingRound) { assert nodeEntry.getFetchingRound() > fetchingRound : "node entries only replaced by newer rounds"; logger.trace("{} received response for [{}] from node {} for an older fetching round (expected: {} but was: {})", shardId, nodeEntry.getNodeId(), type, nodeEntry.getFetchingRound(), fetchingRound); } else if (nodeEntry.isFailed()) { logger.trace("{} node {} has failed for [{}] (failure [{}])", shardId, nodeEntry.getNodeId(), type, nodeEntry.getFailure()); } else { logger.trace("{} marking {} as done for [{}], result is [{}]", shardId, nodeEntry.getNodeId(), type, response); nodeEntry.doneFetching(response); NodeEntry<T> nodeEntry = cache.get(failure.nodeId()); if (nodeEntry != null) { if (nodeEntry.getFetchingRound() != fetchingRound) { assert nodeEntry.getFetchingRound() > fetchingRound : "node entries only replaced by newer rounds"; logger.trace("{} received failure for [{}] from node {} for an older fetching round (expected: {} but was: {})", shardId, nodeEntry.getNodeId(), type, nodeEntry.getFetchingRound(), fetchingRound); } else if (nodeEntry.isFailed() == false) { unwrappedCause instanceof ReceiveTimeoutTransportException || unwrappedCause instanceof ElasticsearchTimeoutException) { nodeEntry.restartFetching(); } else { logger.warn(() -> new ParameterizedMessage("{}: failed to list shard for {} on node [{}]", shardId, type, failure.nodeId()), failure); nodeEntry.doneFetching(failure.getCause());
nodeEntry.markAsFetching(fetchingRound); if (nodeEntry.isFailed()) { failedNodes.add(nodeEntry.getNodeId()); } else { if (nodeEntry.getValue() != null) { fetchData.put(node, nodeEntry.getValue());
NodeEntry<T> nodeEntry = cache.get(response.getNode().getId()); if (nodeEntry != null) { if (nodeEntry.getFetchingRound() != fetchingRound) { assert nodeEntry.getFetchingRound() > fetchingRound : "node entries only replaced by newer rounds"; logger.trace("{} received response for [{}] from node {} for an older fetching round (expected: {} but was: {})", shardId, nodeEntry.getNodeId(), type, nodeEntry.getFetchingRound(), fetchingRound); } else if (nodeEntry.isFailed()) { logger.trace("{} node {} has failed for [{}] (failure [{}])", shardId, nodeEntry.getNodeId(), type, nodeEntry.getFailure()); } else { logger.trace("{} marking {} as done for [{}], result is [{}]", shardId, nodeEntry.getNodeId(), type, response); nodeEntry.doneFetching(response); NodeEntry<T> nodeEntry = cache.get(failure.nodeId()); if (nodeEntry != null) { if (nodeEntry.getFetchingRound() != fetchingRound) { assert nodeEntry.getFetchingRound() > fetchingRound : "node entries only replaced by newer rounds"; logger.trace("{} received failure for [{}] from node {} for an older fetching round (expected: {} but was: {})", shardId, nodeEntry.getNodeId(), type, nodeEntry.getFetchingRound(), fetchingRound); } else if (nodeEntry.isFailed() == false) { unwrappedCause instanceof ReceiveTimeoutTransportException || unwrappedCause instanceof ElasticsearchTimeoutException) { nodeEntry.restartFetching(); } else { logger.warn(() -> new ParameterizedMessage("{}: failed to list shard for {} on node [{}]", shardId, type, failure.nodeId()), failure); nodeEntry.doneFetching(failure.getCause());
NodeEntry<T> nodeEntry = cache.get(response.getNode().getId()); if (nodeEntry != null) { if (nodeEntry.getFetchingRound() != fetchingRound) { assert nodeEntry.getFetchingRound() > fetchingRound : "node entries only replaced by newer rounds"; logger.trace("{} received response for [{}] from node {} for an older fetching round (expected: {} but was: {})", shardId, nodeEntry.getNodeId(), type, nodeEntry.getFetchingRound(), fetchingRound); } else if (nodeEntry.isFailed()) { logger.trace("{} node {} has failed for [{}] (failure [{}])", shardId, nodeEntry.getNodeId(), type, nodeEntry.getFailure()); } else { logger.trace("{} marking {} as done for [{}], result is [{}]", shardId, nodeEntry.getNodeId(), type, response); nodeEntry.doneFetching(response); NodeEntry<T> nodeEntry = cache.get(failure.nodeId()); if (nodeEntry != null) { if (nodeEntry.getFetchingRound() != fetchingRound) { assert nodeEntry.getFetchingRound() > fetchingRound : "node entries only replaced by newer rounds"; logger.trace("{} received failure for [{}] from node {} for an older fetching round (expected: {} but was: {})", shardId, nodeEntry.getNodeId(), type, nodeEntry.getFetchingRound(), fetchingRound); } else if (nodeEntry.isFailed() == false) { unwrappedCause instanceof ReceiveTimeoutTransportException || unwrappedCause instanceof ElasticsearchTimeoutException) { nodeEntry.restartFetching(); } else { logger.warn((Supplier<?>) () -> new ParameterizedMessage("{}: failed to list shard for {} on node [{}]", shardId, type, failure.nodeId()), failure); nodeEntry.doneFetching(failure.getCause());
continue; if (nodeEntry.isFailed()) { logger.trace("{} node {} has failed for [{}] (failure [{}])", shardId, nodeEntry.getNodeId(), type, nodeEntry.getFailure()); } else { logger.trace("{} marking {} as done for [{}]", shardId, nodeEntry.getNodeId(), type); nodeEntry.doneFetching(response); NodeEntry<T> nodeEntry = cache.get(failure.nodeId()); if (nodeEntry != null && nodeEntry.isFailed() == false) { Throwable unwrappedCause = ExceptionsHelper.unwrapCause(failure.getCause()); nodeEntry.restartFetching(); } else { logger.warn("{}: failed to list shard for {} on node [{}]", failure, shardId, type, failure.nodeId()); nodeEntry.doneFetching(failure.getCause());
/** * Fills the shard fetched data with new (data) nodes and a fresh NodeEntry, and removes from * it nodes that are no longer part of the state. */ private void fillShardCacheWithDataNodes(Map<String, NodeEntry<T>> shardCache, DiscoveryNodes nodes) { // verify that all current data nodes are there for (ObjectObjectCursor<String, DiscoveryNode> cursor : nodes.getDataNodes()) { DiscoveryNode node = cursor.value; if (shardCache.containsKey(node.getId()) == false) { shardCache.put(node.getId(), new NodeEntry<T>(node.getId())); } } // remove nodes that are not longer part of the data nodes set for (Iterator<String> it = shardCache.keySet().iterator(); it.hasNext(); ) { String nodeId = it.next(); if (nodes.nodeExists(nodeId) == false) { it.remove(); } } }
/** * Fills the shard fetched data with new (data) nodes and a fresh NodeEntry, and removes from * it nodes that are no longer part of the state. */ private void fillShardCacheWithDataNodes(Map<String, NodeEntry<T>> shardCache, DiscoveryNodes nodes) { // verify that all current data nodes are there for (ObjectObjectCursor<String, DiscoveryNode> cursor : nodes.dataNodes()) { DiscoveryNode node = cursor.value; if (shardCache.containsKey(node.getId()) == false) { shardCache.put(node.getId(), new NodeEntry<T>(node.getId())); } } // remove nodes that are not longer part of the data nodes set for (Iterator<String> it = shardCache.keySet().iterator(); it.hasNext(); ) { String nodeId = it.next(); if (nodes.nodeExists(nodeId) == false) { it.remove(); } } }
/** * Fills the shard fetched data with new (data) nodes and a fresh NodeEntry, and removes from * it nodes that are no longer part of the state. */ private void fillShardCacheWithDataNodes(Map<String, NodeEntry<T>> shardCache, DiscoveryNodes nodes) { // verify that all current data nodes are there for (ObjectObjectCursor<String, DiscoveryNode> cursor : nodes.getDataNodes()) { DiscoveryNode node = cursor.value; if (shardCache.containsKey(node.getId()) == false) { shardCache.put(node.getId(), new NodeEntry<T>(node.getId())); } } // remove nodes that are not longer part of the data nodes set for (Iterator<String> it = shardCache.keySet().iterator(); it.hasNext(); ) { String nodeId = it.next(); if (nodes.nodeExists(nodeId) == false) { it.remove(); } } }
/** * Fills the shard fetched data with new (data) nodes and a fresh NodeEntry, and removes from * it nodes that are no longer part of the state. */ private void fillShardCacheWithDataNodes(Map<String, NodeEntry<T>> shardCache, DiscoveryNodes nodes) { // verify that all current data nodes are there for (ObjectObjectCursor<String, DiscoveryNode> cursor : nodes.getDataNodes()) { DiscoveryNode node = cursor.value; if (shardCache.containsKey(node.getId()) == false) { shardCache.put(node.getId(), new NodeEntry<T>(node.getId())); } } // remove nodes that are not longer part of the data nodes set for (Iterator<String> it = shardCache.keySet().iterator(); it.hasNext(); ) { String nodeId = it.next(); if (nodes.nodeExists(nodeId) == false) { it.remove(); } } }
Throwable getFailure() { assert hasData() : "getting failure when data has not been fetched"; return failure; }
Throwable getFailure() { assert hasData() : "getting failure when data has not been fetched"; return failure; }
Throwable getFailure() { assert hasData() : "getting failure when data has not been fetched"; return failure; }
/** * Finds all the nodes that need to be fetched. Those are nodes that have no * data, and are not in fetch mode. */ private List<NodeEntry<T>> findNodesToFetch(Map<String, NodeEntry<T>> shardCache) { List<NodeEntry<T>> nodesToFetch = new ArrayList<>(); for (NodeEntry<T> nodeEntry : shardCache.values()) { if (nodeEntry.hasData() == false && nodeEntry.isFetching() == false) { nodesToFetch.add(nodeEntry); } } return nodesToFetch; }
/** * Finds all the nodes that need to be fetched. Those are nodes that have no * data, and are not in fetch mode. */ private Set<NodeEntry<T>> findNodesToFetch(Map<String, NodeEntry<T>> shardCache) { Set<NodeEntry<T>> nodesToFetch = new HashSet<>(); for (NodeEntry<T> nodeEntry : shardCache.values()) { if (nodeEntry.hasData() == false && nodeEntry.isFetching() == false) { nodesToFetch.add(nodeEntry); } } return nodesToFetch; }