Java Code Examples for org.apache.commons.lang.StringUtils#startsWithIgnoreCase()

The following examples show how to use org.apache.commons.lang.StringUtils#startsWithIgnoreCase() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
/**
 * {@inheritDoc}
 */
@Override
public void updated(Dictionary<String, ?> properties) throws ConfigurationException {
    if (properties != null) {
        Enumeration<String> keys = properties.keys();
        while (keys.hasMoreElements()) {
            String key = keys.nextElement();

            String value = StringUtils.trimToNull((String) properties.get(key));
            if (StringUtils.startsWithIgnoreCase(key, "receiver")) {
                parseConfig(key, value);
            }
        }

        for (OpenWebIfConfig config : OpenWebIf.getConfigs().values()) {
            if (!config.isValid()) {
                throw new ConfigurationException("openwebif",
                        "Invalid OpenWebIf receiver configuration: " + config.toString());
            }
            logger.info("{}", config.toString());
        }
    }
}
 
Example 2
@Override
public String buildPagedQuerySQL(String originSql, int page, int pageSize) {
    int _limit = ((page - 1) * pageSize);
    String _tmpSQL = StringUtils.trim(originSql);
    if (StringUtils.startsWithIgnoreCase(_tmpSQL, SELECT)) {
        _tmpSQL = StringUtils.trim(StringUtils.substring(_tmpSQL, SELECT.length()));
    }
    boolean distinct = false;
    if (StringUtils.startsWithIgnoreCase(_tmpSQL, DISTINCT)) {
        _tmpSQL = StringUtils.substring(_tmpSQL, DISTINCT.length());
        distinct = true;
    }
    return ExpressionUtils.bind("SELECT * FROM (SELECT ROW_NUMBER() OVER(ORDER BY __tc__) __rn__, * FROM (SELECT ${_distinct} TOP ${_limit} 0 __tc__, ${_sql}) t) tt WHERE __rn__ > ${_offset}")
            .set("_distinct", distinct ? DISTINCT : StringUtils.EMPTY)
            .set("_limit", String.valueOf(_limit + pageSize))
            .set("_sql", _tmpSQL)
            .set("_offset", String.valueOf(_limit)).getResult();
}
 
Example 3
@Override
public List<String> parse(Object[] message) throws IOException {
    List<String> adresses = new ArrayList<String>();
    if (message != null && message.length > 1) {
        Object[] data = (Object[]) message[1];
        for (int i = 0; i < message.length; i++) {
            String address = getSanitizedAddress(data[i]);
            boolean isDevice = !StringUtils.contains(address, ":")
                    && !StringUtils.startsWithIgnoreCase(address, "BidCos");
            if (isDevice) {
                adresses.add(address);
            }

        }
    }
    return adresses;
}
 
Example 4
Source Project: das   File: SQLValidation.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Validate the SQL Statement
 */
private static SQLValidateResult validate(Long alldbs_id, String sql, int[] paramsTypes, Object[] vals) {
    if (StringUtils.startsWithIgnoreCase(sql, "SELECT")) {
        return queryValidate(alldbs_id, sql, paramsTypes, vals);
    } else {
        return updateValidate(alldbs_id, sql, paramsTypes, vals);
    }
}
 
Example 5
Source Project: cellery-security   File: Utils.java    License: Apache License 2.0 5 votes vote down vote up
private static void validateSignatureAlgorithm(String signatureAlgorithm) throws IdentityOAuth2Exception {

        if (StringUtils.isEmpty(signatureAlgorithm)) {
            throw new IdentityOAuth2Exception("Algorithm must not be null.");

        } else {
            if (log.isDebugEnabled()) {
                log.debug("Signature Algorithm found in the Token Header: " + signatureAlgorithm);
            }
            if (!StringUtils.startsWithIgnoreCase(signatureAlgorithm, "RS")) {
                throw new IdentityOAuth2Exception("Signature validation for algorithm: " + signatureAlgorithm
                        + " is not supported.");
            }
        }
    }
 
Example 6
/**
 * TODO: メソッドコメント
 * 
 * @param instanceNo
 */
public void stopDns(Long instanceNo) {
    Instance instance = instanceDao.read(instanceNo);
    Platform platform = platformDao.read(instance.getPlatformNo());

    if (BooleanUtils.isTrue(platform.getInternal())) {
        // 内部のプラットフォームの場合
        PlatformAws platformAws = platformAwsDao.read(platform.getPlatformNo());

        if (BooleanUtils.isTrue(platformAws.getEuca())) {
            // Eucalyptusの場合
            stopDnsNormal(instanceNo);
        } else {
            // Amazon EC2の場合
            if (BooleanUtils.isTrue(platformAws.getVpc())) {
                // VPC環境の場合
                stopDnsNormal(instanceNo);
            } else {
                // 非VPC環境の場合
                stopDnsClassic(instanceNo);
            }
        }
    } else {
        // 外部のプラットフォームの場合
        Image image = imageDao.read(instance.getImageNo());
        if (StringUtils.startsWithIgnoreCase(image.getOs(), "windows")) {
            // Windowsイメージの場合、VPNを使用していないものとする
            stopDnsClassic(instanceNo);
        } else {
            // VPNを使用している場合
            stopDnsNormal(instanceNo);
        }
    }

    // イベントログ出力
    processLogger.debug(null, instance, "DnsUnregist", new Object[] { instance.getFqdn(), instance.getPublicIp() });
}
 
Example 7
Source Project: canal-1.1.3   File: TableMetaCache.java    License: Apache License 2.0 5 votes vote down vote up
public void clearTableMetaWithSchemaName(String schema) {
    if (tableMetaTSDB != null) {
        // tsdb不需要做,会基于ddl sql自动清理
    } else {
        for (String name : tableMetaDB.asMap().keySet()) {
            if (StringUtils.startsWithIgnoreCase(name, schema + ".")) {
                // removeNames.add(name);
                tableMetaDB.invalidate(name);
            }
        }
    }
}
 
Example 8
private boolean isWebUserAgent(String userAgent) {
    boolean isWeb = false;
    if (jwtProperties != null) {
        String userAgentList[] = jwtProperties.getUserAgentList();
        if (userAgentList != null && userAgentList.length > 0) {
            for (String ua : userAgentList) {
                if (StringUtils.startsWithIgnoreCase(userAgent, ua)) {
                    isWeb = true;
                    break;
                }
            }
        }
    }
    return isWeb;
}
 
Example 9
/**
 * Add sql annotation string.
 *
 * @param cdata the cdata
 * @param oName the o name
 * @param tbName the tb name
 * @return the string
 */
private String addSqlAnnotation(String cdata, String oName, String tbName) {

    String sqlAnnotation = StringUtils.upperCase(CamelCaseUtils.toInlineName(CamelCaseUtils
            .toCamelCase("ms_" + tbName + "_" + oName)));
    if (StringUtils.startsWithIgnoreCase(oName, "insert ")
            || StringUtils.startsWithIgnoreCase(oName, "update")
            || StringUtils.startsWithIgnoreCase(oName, "delete")) {
        if (StringUtils.contains(cdata, "update ")) {
            return StringUtils.replace(cdata, "update ", "update /*" + sqlAnnotation + "*/ ");
        }
        if (StringUtils.contains(cdata, "UPDATE ")) {
            return StringUtils.replace(cdata, "UPDATE ", "UPDATE /*" + sqlAnnotation + "*/ ");
        }
        if (StringUtils.contains(cdata, "insert ")) {
            return StringUtils.replace(cdata, "insert ", "insert /*" + sqlAnnotation + "*/ ");
        }
        if (StringUtils.contains(cdata, "INSERT ")) {
            return StringUtils.replace(cdata, "INSERT ", "INSERT /*" + sqlAnnotation + "*/ ");
        }
        if (StringUtils.contains(cdata, "delete ")) {
            return StringUtils.replace(cdata, "delete ", "delete /*" + sqlAnnotation + "*/ ");
        }
        if (StringUtils.contains(cdata, "DELETE ")) {
            return StringUtils.replace(cdata, "DELETE ", "DELETE /*" + sqlAnnotation + "*/ ");
        }
    } else {
        if (StringUtils.contains(cdata, "select ")) {
            return StringUtils.replace(cdata, "select ", "select /*" + sqlAnnotation + "*/ ");
        }
        if (StringUtils.contains(cdata, "SELECT ")) {
            return StringUtils.replace(cdata, "SELECT", "SELECT /*" + sqlAnnotation + "*/ ");
        }
    }

    return cdata;
}
 
Example 10
/**
 * Process a piece of the message that has color content by creating a span with that color style set
 *
 * @param messagePiece String piece with color content
 * @param currentMessageComponent the state of the current text based message being built
 * @param view current View
 * @return currentMessageComponent with the new textual content generated by this method appended to its
 *         messageText
 */
private static Message processColorContent(String messagePiece, Message currentMessageComponent, View view) {
    if (!StringUtils.startsWithIgnoreCase(messagePiece, "/")) {
        messagePiece = StringUtils.remove(messagePiece, "'");
        messagePiece = StringUtils.remove(messagePiece, "\"");
        messagePiece = "<span style='color: " + StringUtils.removeStart(messagePiece,
                KRADConstants.MessageParsing.COLOR + "=") + ";'>";
    } else {
        messagePiece = "</span>";
    }

    return concatenateStringMessageContent(currentMessageComponent, messagePiece, view);
}
 
Example 11
private boolean isWebUserAgent(String userAgent) {
    boolean isWeb = false;
    if (jwtProperties != null) {
        String userAgentList[] = jwtProperties.getUserAgentList();
        if (userAgentList != null && userAgentList.length > 0) {
            for (String ua : userAgentList) {
                if (StringUtils.startsWithIgnoreCase(userAgent, ua)) {
                    isWeb = true;
                    break;
                }
            }
        }
    }
    return isWeb;
}
 
Example 12
/**
 * Returns the list of branched items associated with the source item provided.
 * Note that the ">>" denotes the source item and the order and indentation denote the relationship.
 * The leading underscore is not actually part of the output (it just keeps the formatting correct.
 * <p/>
 * _ $/tfsTest_03/Folder1/model
 * _ >>      $/tfsTest_03/Folder1/model_01     Branched from version 8 <<
 * _              $/tfsTest_03/Folder1/model_01_copy Branched from version 207
 * _         $/tfsTest_03/Folder1/model_02     Branched from version 8
 * _         $/tfsTest_03/Folder1/model_03     Branched from version 8
 * _         $/tfsTest_03/Folder1/model_04     Branched from version 8
 * _         $/tfsTest_03/Folder2/model_05   Branched from version 8
 * _         $/tfsTest_03/model_branch_44    Branched from version 8
 * _         $/tfsTest_03/model_branch_06    Branched from version 8
 * _         $/tfsTest_03/Folder1/model_11     Branched from version 8
 * _         $/tfsTest_03/Folder333  Branched from version 8
 */
@Override
public List<String> parseOutput(final String stdout, final String stderr) {
    throwIfError(stderr);

    final String[] output = getLines(stdout);
    final List<String> result = new ArrayList<String>(output.length);

    for (String line : output) {
        // First see if this line holds the current item we passed in marked with >>
        // If it is the current item, then don't add it to the list
        if (!StringUtils.startsWithIgnoreCase(line, CURRENT_PREFIX)) {
            // Parse out the server path
            final String serverPath;
            final int branchedFromIndex = StringUtils.indexOf(line, BRANCHED_FROM_PREFIX);
            if (branchedFromIndex >= 0) {
                serverPath = line.substring(0, branchedFromIndex).trim();
            } else {
                serverPath = line.trim();
            }

            if (StringUtils.isNotBlank(line)) {
                result.add(serverPath);
            }
        }
    }

    return result;
}
 
Example 13
private Map<String, String[]> parseParameterMap() {
  // 1.post method already parsed by servlet
  // 2.not APPLICATION_FORM_URLENCODED, no need to enhance
  if (getMethod().equalsIgnoreCase(HttpMethod.POST)
      || !StringUtils.startsWithIgnoreCase(getContentType(), MediaType.APPLICATION_FORM_URLENCODED)) {
    return super.getParameterMap();
  }

  Map<String, List<String>> listMap = parseUrlEncodedBody();
  mergeParameterMaptoListMap(listMap);
  return convertListMapToArrayMap(listMap);
}
 
Example 14
Source Project: soundwave   File: InstanceTagger.java    License: Apache License 2.0 5 votes vote down vote up
public InstanceTags getTags(String name) throws Exception {
  InstanceTags tags = new InstanceTags();
  String matchName = name;
  //All docker instances have been added a prefix cmp-. For ex:
  // pinshot-04215101
  // cmp-pinshot-newkernel-0a0111e9
  // To find out the tag, we need to get rid of the prefix.
  //
  if (StringUtils.isNotEmpty(name) && StringUtils.startsWithIgnoreCase(name, "cmp-")) {
    matchName = name.substring(4);
  }
  List<EsServiceMapping>
      mappings =
      InstanceTagger.getInstance().findMapping(matchName);
  HashSet<String> serviceMapping = new HashSet<>();
  HashSet<String> svcTag = new HashSet<>();
  HashSet<String> sysTag = new HashSet<>();
  HashSet<String> usageTag = new HashSet<>();

  for (EsServiceMapping mapping : mappings) {
    serviceMapping.add(mapping.getName());
    svcTag.add(mapping.getServiceTag());
    sysTag.add(mapping.getSysTag());
    if (!StringUtils.equals(mapping.getUsageTag(), "n/a")) {
      usageTag.add(mapping.getUsageTag());
    }
  }

  tags.setServiceMappings(serviceMapping.toArray(new String[serviceMapping.size()]));
  tags.setSvcTags(svcTag.toArray(new String[svcTag.size()]));
  tags.setSysTags(sysTag.toArray(new String[sysTag.size()]));
  tags.setUsageTags(usageTag.toArray(new String[usageTag.size()]));
  return tags;
}
 
Example 15
protected ComponentProcessContext createContext(Long farmNo) {
    ComponentProcessContext context = new ComponentProcessContext();
    context.setFarmNo(farmNo);

    // 処理対象のサーバを取得
    List<Instance> instances = instanceDao.readByFarmNo(farmNo);
    List<Long> runningInstanceNos = new ArrayList<Long>();
    for (Instance instance : instances) {
        // サーバが起動していない場合は対象外
        if (InstanceStatus.fromStatus(instance.getStatus()) != InstanceStatus.RUNNING) {
            continue;
        }

        // ロードバランサのサーバは対象外
        if (BooleanUtils.isTrue(instance.getLoadBalancer())) {
            continue;
        }

        // PuppetInstanceレコードがなければ対象外  ただしOSがwindowsの場合はカウントする
        PuppetInstance puppetInstance = puppetInstanceDao.read(instance.getInstanceNo());
        Image image = imageDao.read(instance.getImageNo());
        if (puppetInstance == null && !StringUtils.startsWithIgnoreCase(image.getOs(), PCCConstant.OS_NAME_WIN)) {
            continue;
        }

        runningInstanceNos.add(instance.getInstanceNo());
    }
    context.setRunningInstanceNos(runningInstanceNos);

    // 処理対象のコンポーネントを取得
    List<ComponentInstance> componentInstances = componentInstanceDao.readInInstanceNos(runningInstanceNos);
    Map<Long, List<Long>> enableInstanceNoMap = new HashMap<Long, List<Long>>();
    Map<Long, List<Long>> disableInstanceNoMap = new HashMap<Long, List<Long>>();
    for (ComponentInstance componentInstance : componentInstances) {
        Map<Long, List<Long>> map;
        if (BooleanUtils.isTrue(componentInstance.getEnabled())) {
            map = enableInstanceNoMap;
        } else {
            map = disableInstanceNoMap;
        }

        List<Long> list = map.get(componentInstance.getComponentNo());
        if (list == null) {
            list = new ArrayList<Long>();
            map.put(componentInstance.getComponentNo(), list);
        }
        list.add(componentInstance.getInstanceNo());
    }
    context.setEnableInstanceNoMap(enableInstanceNoMap);
    context.setDisableInstanceNoMap(disableInstanceNoMap);

    // 処理対象のロードバランサを取得
    List<LoadBalancer> loadBalancers = loadBalancerDao.readByFarmNo(farmNo);
    List<Long> loadBalancerNos = new ArrayList<Long>();
    for (LoadBalancer loadBalancer : loadBalancers) {
        LoadBalancerStatus status = LoadBalancerStatus.fromStatus(loadBalancer.getStatus());

        if (BooleanUtils.isTrue(loadBalancer.getEnabled())) {
            // 有効なロードバランサの場合、起動状態でなければ対象外
            if (status != LoadBalancerStatus.RUNNING) {
                continue;
            }
        } else {
            // 無効なロードバランサの場合、起動または異常状態でなければ対象外
            if (status != LoadBalancerStatus.RUNNING && status != LoadBalancerStatus.WARNING) {
                continue;
            }
        }

        loadBalancerNos.add(loadBalancer.getLoadBalancerNo());
    }
    context.setTargetLoadBalancerNos(loadBalancerNos);

    return context;
}
 
Example 16
Source Project: incubator-gobblin   File: ClustersNames.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Returns the cluster name on which the application is running. Uses Hadoop configuration passed in to get the
 * url of the resourceManager or jobtracker. The URL is then translated into a human readable cluster name using
 * {@link #getClusterName(String)}
 *
 * <p>
 * <b>MapReduce mode</b> Uses the value for "yarn.resourcemanager.address" from {@link Configuration} excluding the
 * port number.
 * </p>
 *
 * <p>
 * <b>Standalone mode (outside of hadoop)</b> Uses the Hostname of {@link InetAddress#getLocalHost()}
 * </p>
 *
 * <p>
 * Use {@link #getClusterName(String)} if you already have the cluster URL
 * </p>
 *
 * @see #getClusterName()
 * @param conf Hadoop configuration to use to get resourceManager or jobTracker URLs
 */
public String getClusterName(Configuration conf) {
  // ResourceManager address in Hadoop2
  String clusterIdentifier = conf.get("yarn.resourcemanager.address");
  clusterIdentifier = getClusterName(clusterIdentifier);

  // If job is running outside of Hadoop (Standalone) use hostname
  // If clusterIdentifier is localhost or 0.0.0.0 use hostname
  if (clusterIdentifier == null || StringUtils.startsWithIgnoreCase(clusterIdentifier, "localhost")
      || StringUtils.startsWithIgnoreCase(clusterIdentifier, "0.0.0.0")) {
    try {
      clusterIdentifier = InetAddress.getLocalHost().getHostName();
    } catch (UnknownHostException e) {
      // Do nothing. Tag will not be generated
    }
  }

  return clusterIdentifier;
}
 
Example 17
Source Project: pipeline-maven-plugin   File: XmlUtils.java    License: MIT License 4 votes vote down vote up
/**
 * Relativize path
 * <p>
 * TODO replace all the workarounds (JENKINS-44088, JENKINS-46084, mac special folders...) by a unique call to
 * {@link File#getCanonicalPath()} on the workspace for the whole "MavenSpyLogProcessor#processMavenSpyLogs" code block.
 * We donb't want to pay an RPC call to {@link File#getCanonicalPath()} each time.
 *
 * @return relativized path
 * @throws IllegalArgumentException if {@code other} is not a {@code Path} that can be relativized
 *                                  against this path
 * @see java.nio.file.Path#relativize(Path)
 */
@Nonnull
public static String getPathInWorkspace(@Nonnull final String absoluteFilePath, @Nonnull FilePath workspace) {
    boolean windows = FileUtils.isWindows(workspace);

    final String workspaceRemote = workspace.getRemote();

    String sanitizedAbsoluteFilePath;
    String sanitizedWorkspaceRemote;
    if (windows) {
        // sanitize to workaround JENKINS-44088
        sanitizedWorkspaceRemote = workspaceRemote.replace('/', '\\');
        sanitizedAbsoluteFilePath = absoluteFilePath.replace('/', '\\');
    } else if (workspaceRemote.startsWith("/var/") && absoluteFilePath.startsWith("/private/var/")) {
        // workaround MacOSX special folders path
        // eg String workspace = "/var/folders/lq/50t8n2nx7l316pwm8gc_2rt40000gn/T/jenkinsTests.tmp/jenkins3845105900446934883test/workspace/build-on-master-with-tool-provided-maven";
        // eg String absolutePath = "/private/var/folders/lq/50t8n2nx7l316pwm8gc_2rt40000gn/T/jenkinsTests.tmp/jenkins3845105900446934883test/workspace/build-on-master-with-tool-provided-maven/pom.xml";
        sanitizedWorkspaceRemote = workspaceRemote;
        sanitizedAbsoluteFilePath = absoluteFilePath.substring("/private".length());
    } else {
        sanitizedAbsoluteFilePath = absoluteFilePath;
        sanitizedWorkspaceRemote = workspaceRemote;
    }

    if (StringUtils.startsWithIgnoreCase(sanitizedAbsoluteFilePath, sanitizedWorkspaceRemote)) {
        // OK
    } else if (sanitizedWorkspaceRemote.contains("/workspace/") && sanitizedAbsoluteFilePath.contains("/workspace/")) {
        // workaround JENKINS-46084
        // sanitizedAbsoluteFilePath = '/app/Jenkins/home/workspace/testjob/pom.xml'
        // sanitizedWorkspaceRemote = '/var/lib/jenkins/workspace/testjob'
        sanitizedAbsoluteFilePath = "/workspace/" + StringUtils.substringAfter(sanitizedAbsoluteFilePath, "/workspace/");
        sanitizedWorkspaceRemote = "/workspace/" + StringUtils.substringAfter(sanitizedWorkspaceRemote, "/workspace/");
    } else if (sanitizedWorkspaceRemote.endsWith("/workspace") && sanitizedAbsoluteFilePath.contains("/workspace/")) {
        // workspace = "/var/lib/jenkins/jobs/Test-Pipeline/workspace";
        // absolutePath = "/storage/jenkins/jobs/Test-Pipeline/workspace/pom.xml";
        sanitizedAbsoluteFilePath = "workspace/" + StringUtils.substringAfter(sanitizedAbsoluteFilePath, "/workspace/");
        sanitizedWorkspaceRemote = "workspace/";
    } else {
        throw new IllegalArgumentException("Cannot relativize '" + absoluteFilePath + "' relatively to '" + workspace.getRemote() + "'");
    }

    String relativePath = StringUtils.removeStartIgnoreCase(sanitizedAbsoluteFilePath, sanitizedWorkspaceRemote);
    String fileSeparator = windows ? "\\" : "/";

    if (relativePath.startsWith(fileSeparator)) {
        relativePath = relativePath.substring(fileSeparator.length());
    }
    LOGGER.log(Level.FINEST, "getPathInWorkspace({0}, {1}: {2}", new Object[]{absoluteFilePath, workspaceRemote, relativePath});
    return relativePath;
}
 
Example 18
private static void initOfSingleConfigFile(URL url) throws Exception{
    String esClusterName = StringUtils.substringBetween(url.getFile(), "es-config-", ".properties");
    if (StringUtils.isNotBlank(esClusterName)) {
        return;
    }

    Properties properties = new Properties();
    InputStream is = new BufferedInputStream(new FileInputStream(url.getFile()));
    properties.load(is);

    String clusterName = "elasticsearch";
    Set<HostAndPort> nodes = new HashSet<HostAndPort>();
    long connectTimeout = 8000;
    int poolMaxTotal = 8;
    int poolMaxIdle = 8;
    int poolMinIdle = 0;
    long maxWaitMillis=-1;
    boolean testOnBorrow = false;
    boolean testWhileIdle = false;
    boolean testOnCreate = false;
    boolean testOnReturn = false;

    Iterator<Map.Entry<Object, Object>> iterator = properties.entrySet().iterator();
    while (iterator.hasNext()) {
        Map.Entry<Object, Object> entry = iterator.next();
        String name = String.valueOf(entry.getKey());
        String value = properties.getProperty(name);
        if (StringUtils.startsWithIgnoreCase(name, "cluster.node")) {
            if (StringUtils.isNotBlank(value)) {
                String[] hostAndPort = StringUtils.split(value,":",2);
                if(hostAndPort.length==2&&Integer.parseInt(hostAndPort[1])>0) {
                    nodes.add(new HostAndPort(name, hostAndPort[0], Integer.parseInt(hostAndPort[1]), "http"));
                }
            }
        }else if(StringUtils.equalsIgnoreCase(name, "cluster.name")){
            clusterName = properties.getProperty(name);
        }else if(StringUtils.equalsIgnoreCase(name, "timeout")){
            connectTimeout = Integer.parseInt(value);
        }else if(StringUtils.equalsIgnoreCase(name, "maxTotal")){
            poolMaxTotal = Integer.parseInt(value);
        }else if(StringUtils.equalsIgnoreCase(name, "maxIdle")){
            poolMaxIdle = Integer.parseInt(value);
        }else if(StringUtils.equalsIgnoreCase(name, "minIdle")){
            poolMinIdle = Integer.parseInt(value);
        }else if(StringUtils.equalsIgnoreCase(name, "testOnBorrow")){
            testOnBorrow = Boolean.parseBoolean(value);
        }else if(StringUtils.equalsIgnoreCase(name, "testWhileIdle")){
            testWhileIdle = Boolean.parseBoolean(value);
        }else if(StringUtils.equalsIgnoreCase(name, "testOnCreate")){
            testOnCreate = Boolean.parseBoolean(value);
        }else if(StringUtils.equalsIgnoreCase(name, "testOnReturn")){
            testOnReturn = Boolean.parseBoolean(value);
        }else if(StringUtils.equalsIgnoreCase(name, "maxWaitMillis")){
            maxWaitMillis = Long.parseLong(value);
        }
    }

    if(poolMap.get(clusterName)!=null){
        return;
    }

    if(nodes.isEmpty()){
        return;
    }

    ElasticSearchPoolConfig clusterConfig = new ElasticSearchPoolConfig();
    clusterConfig.setConnectTimeMillis(connectTimeout);
    clusterConfig.setMaxTotal(poolMaxTotal);
    clusterConfig.setMaxIdle(poolMaxIdle);
    clusterConfig.setMinIdle(poolMinIdle);
    clusterConfig.setMaxWaitMillis(maxWaitMillis);
    clusterConfig.setTestOnBorrow(testOnBorrow);
    clusterConfig.setTestWhileIdle(testWhileIdle);
    clusterConfig.setTestOnCreate(testOnCreate);
    clusterConfig.setTestOnReturn(testOnReturn);
    clusterConfig.setClusterName(clusterName);
    clusterConfig.setNodes(nodes);

    ElasticSearchPool pool = new ElasticSearchPool(clusterConfig);
    poolMap.put(clusterName,pool);
}
 
Example 19
protected void runPuppet(Instance instance) {
    Image image = imageDao.read(instance.getImageNo());
    // Puppetクライアントの設定更新処理を実行
    try {
        processLogger.debug(null, instance, "PuppetManifestApply",
                new String[] { instance.getFqdn(), "base_coordinate" });

        puppetClient.runClient(instance.getFqdn());
        if (StringUtils.startsWithIgnoreCase(image.getOs(), PCCConstant.OS_NAME_WIN)) {
            // TODO 協調設定が反映されない不具合対応
            // 1回の「puppet run」だと協調設定が空振りする事があるので、同じマニフェストの内容で2回実行する。
            // Linux系OSに関しては、puppetの「postrun_command」で対応可能なので実行は1回のみ
            log.debug(MessageUtils.format(
                    "run the puppet process(base_coordinate) twice for windows instance. (fqdn={0})",
                    instance.getFqdn()));
            puppetClient.runClient(instance.getFqdn());
        }

    } catch (RuntimeException e) {
        processLogger.debug(null, instance, "PuppetManifestApplyFail",
                new String[] { instance.getFqdn(), "base_coordinate" });

        // マニフェスト適用に失敗した場合、警告ログ出力した後にリトライする
        String code = (e instanceof AutoException) ? AutoException.class.cast(e).getCode() : null;
        if ("EPUPPET-000003".equals(code) || "EPUPPET-000007".equals(code)) {
            log.warn(e.getMessage());

            processLogger.debug(null, instance, "PuppetManifestApply",
                    new String[] { instance.getFqdn(), "base_coordinate" });

            try {
                puppetClient.runClient(instance.getFqdn());

            } catch (RuntimeException e2) {
                processLogger.debug(null, instance, "PuppetManifestApplyFail",
                        new String[] { instance.getFqdn(), "base_coordinate" });

                throw e2;
            }
        } else {
            throw e;
        }
    }

    processLogger.debug(null, instance, "PuppetManifestApplyFinish",
            new String[] { instance.getFqdn(), "base_coordinate" });
}
 
Example 20
/**
 * Check if the payload is a redirect
 *
 * @param value the value retrieved
 * @param payload the url that should perform external redirect
 * @return true if it's a valid open redirect
 */
private boolean checkPayload(String value, String payload) {
    // Check both the payload and the standard url format
    return (value != null)
            && (StringUtils.startsWithIgnoreCase(value, payload)
                    || StringUtils.startsWithIgnoreCase(value, "http://" + REDIRECT_SITE));
}