Example usage for org.apache.commons.exec.util StringUtils split

List of usage examples for org.apache.commons.exec.util StringUtils split

Introduction

In this page you can find the example usage for org.apache.commons.exec.util StringUtils split.

Prototype

public static String[] split(final String input, final String splitChar) 

Source Link

Document

Split a string into an array of strings based on a separator.

Usage

From source file:com.nts.alphamale.data.EventLog.java

public EventLog(String eventLog) {
    String[] evLog = StringUtils.split(eventLog, " ");
    cpuTimestamp = Double.valueOf(StringUtils.split(evLog[1], "]")[0]);
    curTimeStamp = System.currentTimeMillis();
    deviceName = evLog[2];/*from ww  w .  jav a2s  .c o m*/
    evSynOrAbs = evLog[3];
    absLabel = evLog[4];
    try {
        absValue = !evLog[5].equals("ffffffff") ? Integer.valueOf(evLog[5], 16) : Integer.MAX_VALUE;
    } catch (NumberFormatException e) {
        if (evLog[5].equalsIgnoreCase("down")) {
            absValue = Integer.MIN_VALUE;
        }
        if (evLog[5].equalsIgnoreCase("up")) {
            absValue = Integer.MAX_VALUE;
        }
    }
}

From source file:com.sina.app.spout.FailKafkaSpout.java

public void Delay(byte[] message, final KafkaMessageId nextId) {
    String entry = new String(message);
    AskFromHbase askFromHbase;/*w w w .  ja  v a 2 s. com*/
    String[] clickLogs = StringUtils.split(entry, "\n");
    for (String oneLog : clickLogs) {
        ClickLog log = new ClickLog(oneLog);
        if (!log.isValid) {
            continue;
        }
        TimeSign timeSign = new TimeSign();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date logDate;
        try {
            logDate = simpleDateFormat.parse(log.timeSign);
        } catch (ParseException e) {
            LOG.error("ClickLog error{}", e);
            continue;
        }
        askFromHbase = new AskFromHbase(log.uuid, log.tableColumnPv);
        boolean askPvExist = askFromHbase.askExist();
        if (askPvExist) {
            _collector.emit("GETK",
                    new Values(askFromHbase.clkWriteToHbase.pvFromHbase + "\t$\t" + log.logclkVal), nextId);
            _collector.emit("GETH", new Values(oneLog), nextId);
            continue;
        }
        Date last = new Date();
        while (true) {
            Date now = new Date();
            if (now.getTime() - last.getTime() > log.secondAskHbaseTimeMax)
                break;
            String redisTime = "";
            try {
                redisTime = timeSign.getTime();
            } catch (Exception e) {
                LOG.error("error get redis Time{}", e);
                break;
            }
            Date redisDate;
            try {
                redisDate = simpleDateFormat.parse(redisTime);
            } catch (ParseException e) {
                LOG.error("get RedisTime error{}", e);
                break;
            }
            Long delt = redisDate.getTime() - logDate.getTime();
            if (delt > log.secondAskHbaseTimeDlt)
                break;
            try {
                Thread.sleep(log.secondAskHbaseSleepTime);
                askPvExist = askFromHbase.askExist();
                if (askPvExist) {
                    _collector.emit("GETK",
                            new Values(askFromHbase.clkWriteToHbase.pvFromHbase + "\t$\t" + log.logclkVal),
                            nextId);
                    _collector.emit("GETH", new Values(oneLog), nextId);
                    break;
                }
            } catch (InterruptedException e) {
                LOG.error("clklog sleep error{}", e);
                break;
            }

        }
    }
}

From source file:com.sina.app.spout.ClkKafkaSpout.java

public void Delay(byte[] message, final KafkaMessageId nextId) {
    String entry = new String(message);
    AskFromHbase askFromHbase;/*  w  w w .  j  a  v  a 2s  .  c o  m*/
    String[] clickLogs = StringUtils.split(entry, "\n");
    for (String oneLog : clickLogs) {
        ClickLog log = new ClickLog(oneLog);
        if (!log.isValid) {
            continue;
        }
        TimeSign timeSign = new TimeSign();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date logDate;
        boolean Inserted = false;
        try {
            logDate = simpleDateFormat.parse(log.timeSign);
        } catch (ParseException e) {
            LOG.error("ClickLog error{}", e);
            continue;
        }
        askFromHbase = new AskFromHbase(log.uuid, log.tableColumnPv);
        boolean askPvExist = askFromHbase.askExist();
        if (askPvExist) {
            _collector.emit("GETK",
                    new Values(askFromHbase.clkWriteToHbase.pvFromHbase + "\t$\t" + log.logclkVal), nextId);
            _collector.emit("GETH", new Values(oneLog), nextId);
            continue;
        }
        Date last = new Date();
        while (true) {
            Date now = new Date();
            if (now.getTime() - last.getTime() > log.secondAskHbaseTimeMax)
                break;
            String redisTime = "";
            try {
                redisTime = timeSign.getTime();
            } catch (Exception e) {
                LOG.error("error get redis Time{}", e);
                break;
            }
            Date redisDate;
            try {
                redisDate = simpleDateFormat.parse(redisTime);
            } catch (ParseException e) {
                LOG.error("get RedisTime error{}", e);
                break;
            }
            Long delt = redisDate.getTime() - logDate.getTime();
            if (delt > log.secondAskHbaseTimeDlt)
                break;
            try {
                Thread.sleep(log.secondAskHbaseSleepTime);
                askPvExist = askFromHbase.askExist();
                if (askPvExist) {
                    Inserted = true;
                    _collector.emit("GETK",
                            new Values(askFromHbase.clkWriteToHbase.pvFromHbase + "\t$\t" + log.logclkVal),
                            nextId);
                    _collector.emit("GETH", new Values(oneLog), nextId);
                    break;
                }
            } catch (InterruptedException e) {
                LOG.error("clklog sleep error{}", e);
                break;
            }

        }
        if (Inserted)
            continue;
        _collector.emit("NOGET", new Values(oneLog), nextId);
    }
}

From source file:org.stem.ExternalNode.java

private CommandLine newJavaCommandLine() {
    String javaExecPath = null;//from   ww  w .j av a2s.c om

    Toolchain toolchain = getToolchain();

    if (toolchain != null) {
        log.info("Toolchain: " + toolchain);
        javaExecPath = toolchain.findTool("java");

    } else if (OS.isFamilyWindows()) {
        String exec = "java.exe";
        String path = System.getenv("PATH");
        if (path != null) {
            for (String elem : StringUtils.split(path, File.pathSeparator)) {
                File file = new File(elem, exec);
                if (file.exists()) {
                    javaExecPath = file.getAbsolutePath();
                    break;
                }
            }
        }

    }

    if (null == javaExecPath) {
        javaExecPath = "java";
    }

    return new CommandLine(javaExecPath);
}