public static List<NodeInfo> discoverNodesIfNeeded(Settings settings, Log log) { if (settings.getNodesDiscovery()) { RestClient bootstrap = new RestClient(settings); try { List<NodeInfo> discoveredNodes = bootstrap.getHttpNodes(false); if (log.isDebugEnabled()) { log.debug(String.format("Nodes discovery enabled - found %s", discoveredNodes)); } SettingsUtils.addDiscoveredNodes(settings, discoveredNodes); return discoveredNodes; } finally { bootstrap.close(); } } return null; }
public static EsMajorVersion discoverEsVersion(Settings settings, Log log) { String version = settings.getProperty(InternalConfigurationOptions.INTERNAL_ES_VERSION); if (StringUtils.hasText(version)) { if (log.isDebugEnabled()) { log.debug(String.format("Elasticsearch version [%s] already present in configuration; skipping discovery", version)); } return EsMajorVersion.parse(version); } RestClient bootstrap = new RestClient(settings); // first get ES version try { EsMajorVersion esVersion = bootstrap.remoteEsVersion(); if (log.isDebugEnabled()) { log.debug(String.format("Discovered Elasticsearch version [%s]", esVersion)); } settings.setInternalVersion(esVersion); return esVersion; } catch (EsHadoopException ex) { throw new EsHadoopIllegalArgumentException(String.format("Cannot detect ES version - " + "typically this happens if the network/Elasticsearch cluster is not accessible or when targeting " + "a WAN/Cloud instance without the proper setting '%s'", ConfigurationOptions.ES_NODES_WAN_ONLY), ex); } finally { bootstrap.close(); } }
bootstrap.close();
bootstrap.close();
bootstrap.close();
@Override public void close() { if (log.isDebugEnabled()) { log.debug("Closing repository and connection to Elasticsearch ..."); } // bail out if closed before if (client == null) { return; } try { if (bulkProcessor != null) { bulkProcessor.close(); // Aggregate stats before discarding them. stats.aggregate(bulkProcessor.stats()); bulkProcessor = null; } if (bulkEntryWriter != null) { bulkEntryWriter.close(); bulkEntryWriter = null; } } finally { client.close(); // Aggregate stats before discarding them. stats.aggregate(client.stats()); client = null; } }
bootstrap.close();
public static void checkIndexStatus(Settings settings) { if (!settings.getIndexReadAllowRedStatus()) { RestClient bootstrap = new RestClient(settings); Resource readResource = new Resource(settings, true); try { if (bootstrap.indexExists(readResource.index())) { RestClient.Health status = bootstrap.getHealth(readResource.index()); if (status == RestClient.Health.RED) { throw new EsHadoopIllegalStateException("Index specified [" + readResource.index() + "] is either red or " + "includes an index that is red, and thus all requested data cannot be safely and fully loaded. " + "Bailing out..."); } } } finally { bootstrap.close(); } } }
public static boolean discoverNodesIfNeeded(Settings settings, Log log) { if (settings.getNodesDiscovery()) { RestClient bootstrap = new RestClient(settings); try { List<String> discoveredNodes = bootstrap.discoverNodes(); if (log.isDebugEnabled()) { log.debug(String.format("Nodes discovery enabled - found %s", discoveredNodes)); } SettingsUtils.addDiscoveredNodes(settings, discoveredNodes); } finally { bootstrap.close(); } return true; } return false; }
public static List<NodeInfo> discoverNodesIfNeeded(Settings settings, Log log) { if (settings.getNodesDiscovery()) { RestClient bootstrap = new RestClient(settings); try { List<NodeInfo> discoveredNodes = bootstrap.getHttpNodes(false); if (log.isDebugEnabled()) { log.debug(String.format("Nodes discovery enabled - found %s", discoveredNodes)); } SettingsUtils.addDiscoveredNodes(settings, discoveredNodes); return discoveredNodes; } finally { bootstrap.close(); } } return null; }
public static List<NodeInfo> discoverNodesIfNeeded(Settings settings, Log log) { if (settings.getNodesDiscovery()) { RestClient bootstrap = new RestClient(settings); try { List<NodeInfo> discoveredNodes = bootstrap.getHttpNodes(false); if (log.isDebugEnabled()) { log.debug(String.format("Nodes discovery enabled - found %s", discoveredNodes)); } SettingsUtils.addDiscoveredNodes(settings, discoveredNodes); return discoveredNodes; } finally { bootstrap.close(); } } return null; }
public static List<NodeInfo> discoverNodesIfNeeded(Settings settings, Log log) { if (settings.getNodesDiscovery()) { RestClient bootstrap = new RestClient(settings); try { List<NodeInfo> discoveredNodes = bootstrap.getHttpNodes(false); if (log.isDebugEnabled()) { log.debug(String.format("Nodes discovery enabled - found %s", discoveredNodes)); } SettingsUtils.addDiscoveredNodes(settings, discoveredNodes); return discoveredNodes; } finally { bootstrap.close(); } } return null; }
public static String discoverEsVersion(Settings settings, Log log) { String version = settings.getProperty(InternalConfigurationOptions.INTERNAL_ES_VERSION); if (StringUtils.hasText(version)) { if (log.isDebugEnabled()) { log.debug(String.format("Elasticsearch version [%s] already present in configuration; skipping discovery", version)); } return version; } RestClient bootstrap = new RestClient(settings); // first get ES version try { String esVersion = bootstrap.esVersion(); if (log.isDebugEnabled()) { log.debug(String.format("Discovered Elasticsearch version [%s]", esVersion)); } // validate version (make sure it's running against ES 1.x or 2.x) if (!(esVersion.startsWith("1.") || esVersion.startsWith("2."))) { throw new EsHadoopIllegalArgumentException("Unsupported/Unknown Elasticsearch version " + esVersion); } settings.setProperty(InternalConfigurationOptions.INTERNAL_ES_VERSION, esVersion); return esVersion; } catch (EsHadoopException ex) { throw new EsHadoopIllegalArgumentException(String.format("Cannot detect ES version - " + "typically this happens if the network/Elasticsearch cluster is not accessible or when targeting " + "a WAN/Cloud instance without the proper setting '%s'", ConfigurationOptions.ES_NODES_WAN_ONLY), ex); } finally { bootstrap.close(); } }
public static EsMajorVersion discoverEsVersion(Settings settings, Log log) { String version = settings.getProperty(InternalConfigurationOptions.INTERNAL_ES_VERSION); if (StringUtils.hasText(version)) { if (log.isDebugEnabled()) { log.debug(String.format("Elasticsearch version [%s] already present in configuration; skipping discovery", version)); } return EsMajorVersion.parse(version); } RestClient bootstrap = new RestClient(settings); // first get ES version try { EsMajorVersion esVersion = bootstrap.remoteEsVersion(); if (log.isDebugEnabled()) { log.debug(String.format("Discovered Elasticsearch version [%s]", esVersion)); } settings.setInternalVersion(esVersion); return esVersion; } catch (EsHadoopException ex) { throw new EsHadoopIllegalArgumentException(String.format("Cannot detect ES version - " + "typically this happens if the network/Elasticsearch cluster is not accessible or when targeting " + "a WAN/Cloud instance without the proper setting '%s'", ConfigurationOptions.ES_NODES_WAN_ONLY), ex); } finally { bootstrap.close(); } }
public static EsMajorVersion discoverEsVersion(Settings settings, Log log) { String version = settings.getProperty(InternalConfigurationOptions.INTERNAL_ES_VERSION); if (StringUtils.hasText(version)) { if (log.isDebugEnabled()) { log.debug(String.format("Elasticsearch version [%s] already present in configuration; skipping discovery", version)); } return EsMajorVersion.parse(version); } RestClient bootstrap = new RestClient(settings); // first get ES version try { EsMajorVersion esVersion = bootstrap.remoteEsVersion(); if (log.isDebugEnabled()) { log.debug(String.format("Discovered Elasticsearch version [%s]", esVersion)); } settings.setInternalVersion(esVersion); return esVersion; } catch (EsHadoopException ex) { throw new EsHadoopIllegalArgumentException(String.format("Cannot detect ES version - " + "typically this happens if the network/Elasticsearch cluster is not accessible or when targeting " + "a WAN/Cloud instance without the proper setting '%s'", ConfigurationOptions.ES_NODES_WAN_ONLY), ex); } finally { bootstrap.close(); } }
public static EsMajorVersion discoverEsVersion(Settings settings, Log log) { String version = settings.getProperty(InternalConfigurationOptions.INTERNAL_ES_VERSION); if (StringUtils.hasText(version)) { if (log.isDebugEnabled()) { log.debug(String.format("Elasticsearch version [%s] already present in configuration; skipping discovery", version)); } return EsMajorVersion.parse(version); } RestClient bootstrap = new RestClient(settings); // first get ES version try { EsMajorVersion esVersion = bootstrap.remoteEsVersion(); if (log.isDebugEnabled()) { log.debug(String.format("Discovered Elasticsearch version [%s]", esVersion)); } settings.setInternalVersion(esVersion); return esVersion; } catch (EsHadoopException ex) { throw new EsHadoopIllegalArgumentException(String.format("Cannot detect ES version - " + "typically this happens if the network/Elasticsearch cluster is not accessible or when targeting " + "a WAN/Cloud instance without the proper setting '%s'", ConfigurationOptions.ES_NODES_WAN_ONLY), ex); } finally { bootstrap.close(); } }
@Override public void close() { if (log.isDebugEnabled()) { log.debug("Closing repository and connection to Elasticsearch ..."); } // bail out if closed before if (client == null) { return; } try { if (bulkProcessor != null) { bulkProcessor.close(); // Aggregate stats before discarding them. stats.aggregate(bulkProcessor.stats()); bulkProcessor = null; } if (bulkEntryWriter != null) { bulkEntryWriter.close(); bulkEntryWriter = null; } } finally { client.close(); // Aggregate stats before discarding them. stats.aggregate(client.stats()); client = null; } }
public static void checkIndexStatus(Settings settings) { if (!settings.getIndexReadAllowRedStatus()) { RestClient bootstrap = new RestClient(settings); Resource readResource = new Resource(settings, true); try { if (bootstrap.indexExists(readResource.index())) { RestClient.Health status = bootstrap.getHealth(readResource.index()); if (status == RestClient.Health.RED) { throw new EsHadoopIllegalStateException("Index specified [" + readResource.index() + "] is either red or " + "includes an index that is red, and thus all requested data cannot be safely and fully loaded. " + "Bailing out..."); } } } finally { bootstrap.close(); } } }
public static void checkIndexStatus(Settings settings) { if (!settings.getIndexReadAllowRedStatus()) { RestClient bootstrap = new RestClient(settings); Resource readResource = new Resource(settings, true); try { if (bootstrap.indexExists(readResource.index())) { RestClient.Health status = bootstrap.getHealth(readResource.index()); if (status == RestClient.Health.RED) { throw new EsHadoopIllegalStateException("Index specified [" + readResource.index() + "] is either red or " + "includes an index that is red, and thus all requested data cannot be safely and fully loaded. " + "Bailing out..."); } } } finally { bootstrap.close(); } } }
public static void checkIndexStatus(Settings settings) { if (!settings.getIndexReadAllowRedStatus()) { RestClient bootstrap = new RestClient(settings); Resource readResource = new Resource(settings, true); try { if (bootstrap.indexExists(readResource.index())) { RestClient.Health status = bootstrap.getHealth(readResource.index()); if (status == RestClient.Health.RED) { throw new EsHadoopIllegalStateException("Index specified [" + readResource.index() + "] is either red or " + "includes an index that is red, and thus all requested data cannot be safely and fully loaded. " + "Bailing out..."); } } } finally { bootstrap.close(); } } }