private KeyManager[] loadKeyManagers() throws GeneralSecurityException, IOException { if (!StringUtils.hasText(keyStoreLocation)) { LOG.debug("No keystore location specified! SSL is continuing with no keystore."); return null; } char[] pass = (StringUtils.hasText(keyStorePass) ? keyStorePass.trim().toCharArray() : null); KeyStore keyStore = loadKeyStore(keyStoreLocation, pass); KeyManagerFactory kmFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); kmFactory.init(keyStore, pass); return kmFactory.getKeyManagers(); }
public static void hasText(CharSequence sequence, String message) { if (!StringUtils.hasText(sequence)) { throw new EsHadoopIllegalArgumentException(message); } }
public static void hasNoText(CharSequence sequence, String message) { if (StringUtils.hasText(sequence)) { throw new EsHadoopIllegalArgumentException(message); } }
protected boolean shouldKeep(String parentField, String name) { name = StringUtils.hasText(parentField) ? parentField + "." + name : name; return FieldFilter.filter(name, includes, excludes).matched; } }
public EsSpout(String target, String query, Map configuration) { if (configuration != null) { spoutConfig.putAll(configuration); } if (StringUtils.hasText(query)) { spoutConfig.put(ES_QUERY, query); } if (StringUtils.hasText(target)) { spoutConfig.put(ES_RESOURCE_READ, target); } tupleFields = new StormSettings(spoutConfig).getStormSpoutFields(); }
public Integer getMaxDocsPerPartition() { String value = getProperty(ES_MAX_DOCS_PER_PARTITION); if (StringUtils.hasText(value)) { return Integer.parseInt(value); } return null; }
public boolean hasUpdateScript() { String op = getOperation(); boolean hasScript = false; if (ConfigurationOptions.ES_OPERATION_UPDATE.equals(op) || ConfigurationOptions.ES_OPERATION_UPSERT.equals(op)) { hasScript = StringUtils.hasText(getUpdateScriptInline()); hasScript |= StringUtils.hasText(getUpdateScriptFile()); hasScript |= StringUtils.hasText(getUpdateScriptStored()); } return hasScript; }
@Override public void checkSchema(ResourceSchema s) throws IOException { Properties props = getUDFProperties(); // save schema to back-end for JSON translation if (!StringUtils.hasText(props.getProperty(ResourceSchema.class.getName()))) { // save the schema as String (used JDK serialization since toString() screws up the signature - see the testcase) props.setProperty(ResourceSchema.class.getName(), IOUtils.serializeToBase64(s)); } }
public Tap createTap(Scheme scheme, String path, SinkMode sinkMode, Properties properties) { if (!(scheme instanceof EsScheme)) { throw new EsHadoopIllegalArgumentException("Unknown scheme; expected " + EsScheme.class.getName()); } String host = properties.getProperty("host"); String portString = properties.getProperty("port"); int port = (StringUtils.hasText(portString) ? Integer.parseInt(portString) : -1); String query = properties.getProperty("query"); return CascadingUtils.hadoopTap(host, port, path, query, ((EsScheme) scheme).fields, properties); }
private String getLegacyProperty(String legacyProperty, String newProperty, String defaultValue) { String legacy = getProperty(legacyProperty); if (StringUtils.hasText(legacy)) { LogFactory.getLog(Settings.class).warn(String.format(Locale.ROOT, "[%s] property has been deprecated - use [%s] instead", legacyProperty, newProperty)); return legacy; } return getProperty(newProperty, defaultValue); }
public static boolean setValueReaderIfNotSet(Settings settings, Class<? extends ValueReader> clazz, Log log) { if (!StringUtils.hasText(settings.getSerializerValueReaderClassName())) { settings.setProperty(ConfigurationOptions.ES_SERIALIZATION_READER_VALUE_CLASS, clazz.getName()); Log logger = (log != null ? log : LogFactory.getLog(clazz)); if (logger.isDebugEnabled()) { logger.debug(String.format("Using pre-defined reader serializer [%s] as default", settings.getSerializerValueReaderClassName())); } return true; } return false; } }
@Override public String format(String value) { if (!StringUtils.hasText(value)) { return null; } Calendar calendar = DateUtils.parseDate(value); dateFormat.setCalendar(calendar); return dateFormat.format(calendar.getTime()); } }
public int getStormBulkSize() { String value = getProperty(ES_STORM_BOLT_FLUSH_ENTRIES_SIZE); if (StringUtils.hasText(value)) { return Integer.valueOf(value); } return getBatchSizeInEntries(); }
public static boolean setFieldExtractorIfNotSet(Settings settings, Class<? extends FieldExtractor> clazz, Log log) { if (!StringUtils.hasText(settings.getMappingIdExtractorClassName())) { Log logger = (log != null ? log : LogFactory.getLog(clazz)); String name = clazz.getName(); settings.setProperty(ConfigurationOptions.ES_MAPPING_DEFAULT_EXTRACTOR_CLASS, name); if (logger.isDebugEnabled()) { logger.debug(String.format("Using pre-defined field extractor [%s] as default", settings.getMappingIdExtractorClassName())); } return true; } return false; }
public static boolean setBytesConverterIfNeeded(Settings settings, Class<? extends BytesConverter> clazz, Log log) { if (settings.getInputAsJson() && !StringUtils.hasText(settings.getSerializerBytesConverterClassName())) { settings.setProperty(ConfigurationOptions.ES_SERIALIZATION_WRITER_BYTES_CLASS, clazz.getName()); Log logger = (log != null ? log : LogFactory.getLog(clazz)); if (logger.isDebugEnabled()) { logger.debug(String.format("JSON input specified; using pre-defined bytes/json converter [%s] as default", settings.getSerializerBytesConverterClassName())); } return true; } return false; }
public Resource getResourceRead() { if (resourceRead == null) { if (StringUtils.hasText(resourceSettings.getResourceRead())) { resourceRead = new Resource(resourceSettings, true); } } return resourceRead; }
public EsMajorVersion remoteEsVersion() { Map<String, String> result = get("", "version"); if (result == null || !StringUtils.hasText(result.get("number"))) { throw new EsHadoopIllegalStateException("Unable to retrieve elasticsearch version."); } return EsMajorVersion.parse(result.get("number")); }
public static List<String> discoveredOrDeclaredNodes(Settings settings) { // returned the discovered nodes or, if not defined, the set nodes String discoveredNodes = settings.getProperty(InternalConfigurationOptions.INTERNAL_ES_DISCOVERED_NODES); return (StringUtils.hasText(discoveredNodes) ? StringUtils.tokenize(discoveredNodes) : declaredNodes(settings)); }
private void addHttpAuth(Settings settings, SecureSettings secureSettings, Object[] authSettings) { if (StringUtils.hasText(settings.getNetworkHttpAuthUser())) { HttpState state = (authSettings[1] != null ? (HttpState) authSettings[1] : new HttpState()); authSettings[1] = state; state.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(settings.getNetworkHttpAuthUser(), secureSettings.getSecureProperty(ConfigurationOptions.ES_NET_HTTP_AUTH_PASS))); if (log.isDebugEnabled()) { log.info("Using detected HTTP Auth credentials..."); } } }
private BulkCommand create(Settings settings) { if (!StringUtils.hasText(settings.getResourceWrite())) { settings.setProperty(ConfigurationOptions.ES_WRITE_OPERATION, operation); } return BulkCommands.create(settings, null, version); }