当前位置: 首页>>代码示例>>Java>>正文


Java Task.getUUID方法代码示例

本文整理汇总了Java中us.codecraft.webmagic.Task.getUUID方法的典型用法代码示例。如果您正苦于以下问题:Java Task.getUUID方法的具体用法?Java Task.getUUID怎么用?Java Task.getUUID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在us.codecraft.webmagic.Task的用法示例。


在下文中一共展示了Task.getUUID方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: process

import us.codecraft.webmagic.Task; //导入方法依赖的package包/类
@Override
public void process(ResultItems resultItems, Task task) {
    String path = this.path + PATH_SEPERATOR + task.getUUID() + PATH_SEPERATOR;
    try {
        PrintWriter printWriter = new PrintWriter(new FileWriter(getFile(path + DigestUtils.md5Hex(resultItems.getRequest().getUrl()) + ".html")));
        printWriter.println("url:\t" + resultItems.getRequest().getUrl());
        for (Map.Entry<String, Object> entry : resultItems.getAll().entrySet()) {
            if (entry.getValue() instanceof Iterable) {
                Iterable value = (Iterable) entry.getValue();
                printWriter.println(entry.getKey() + ":");
                for (Object o : value) {
                    printWriter.println(o);
                }
            } else {
                printWriter.println(entry.getKey() + ":\t" + entry.getValue());
            }
        }
        printWriter.close();
    } catch (IOException e) {
        logger.warn("write file error", e);
    }
}
 
开发者ID:yuany,项目名称:en-webmagic,代码行数:23,代码来源:FilePipeline.java

示例2: process

import us.codecraft.webmagic.Task; //导入方法依赖的package包/类
@Override
public void process(Object o, Task task) {
    String path = this.path + "/" + task.getUUID() + "/";
    try {
        String filename;
        if (o instanceof HasKey) {
            filename = path + ((HasKey)o).key() + ".json";
        } else {
            filename = path + DigestUtils.md5Hex(ToStringBuilder.reflectionToString(o)) + ".json";
        }
        PrintWriter printWriter = new PrintWriter(new FileWriter(getFile(filename)));
        printWriter.write(JSON.toJSONString(o));
        printWriter.close();
    } catch (IOException e) {
        logger.warn("write file error", e);
    }
}
 
开发者ID:yuany,项目名称:en-webmagic,代码行数:18,代码来源:JsonFilePageModelPipeline.java

示例3: poll

import us.codecraft.webmagic.Task; //导入方法依赖的package包/类
@Override
public synchronized Request poll(Task task) {
    Jedis jedis = pool.getResource();
    try {
        String url = jedis.lpop(QUEUE_PREFIX + task.getUUID());
        if (url == null) {
            return null;
        }
        String key = ITEM_PREFIX + task.getUUID();
        String field = DigestUtils.shaHex(url);
        byte[] bytes = jedis.hget(key.getBytes(), field.getBytes());
        if (bytes != null) {
            Request o = JSON.parseObject(new String(bytes), Request.class);
            return o;
        }
        Request request = new Request(url);
        return request;
    } finally {
        pool.returnResource(jedis);
    }
}
 
开发者ID:yuany,项目名称:en-webmagic,代码行数:22,代码来源:RedisScheduler.java

示例4: process

import us.codecraft.webmagic.Task; //导入方法依赖的package包/类
@Override
public void process(ResultItems resultItems, Task task) {
    String path = this.path + PATH_SEPERATOR + task.getUUID() + PATH_SEPERATOR;
    try {
        PrintWriter printWriter = new PrintWriter(new OutputStreamWriter(new FileOutputStream(getFile(path + DigestUtils.md5Hex(resultItems.getRequest().getUrl()) + ".html")),"UTF-8"));
        printWriter.println("url:\t" + resultItems.getRequest().getUrl());
        for (Map.Entry<String, Object> entry : resultItems.getAll().entrySet()) {
            if (entry.getValue() instanceof Iterable) {
                Iterable value = (Iterable) entry.getValue();
                printWriter.println(entry.getKey() + ":");
                for (Object o : value) {
                    printWriter.println(o);
                }
            } else {
                printWriter.println(entry.getKey() + ":\t" + entry.getValue());
            }
        }
        printWriter.close();
    } catch (IOException e) {
        logger.warn("write file error", e);
    }
}
 
开发者ID:code4craft,项目名称:webmagic,代码行数:23,代码来源:FilePipeline.java

示例5: process

import us.codecraft.webmagic.Task; //导入方法依赖的package包/类
@Override
public void process(Object o, Task task) {
    String path = this.path + PATH_SEPERATOR + task.getUUID() + PATH_SEPERATOR;
    try {
        String filename;
        if (o instanceof HasKey) {
            filename = path + ((HasKey) o).key() + ".json";
        } else {
            filename = path + DigestUtils.md5Hex(ToStringBuilder.reflectionToString(o)) + ".json";
        }
        PrintWriter printWriter = new PrintWriter(new FileWriter(getFile(filename)));
        printWriter.write(JSON.toJSONString(o));
        printWriter.close();
    } catch (IOException e) {
        logger.warn("write file error", e);
    }
}
 
开发者ID:code4craft,项目名称:webmagic,代码行数:18,代码来源:JsonFilePageModelPipeline.java

示例6: process

import us.codecraft.webmagic.Task; //导入方法依赖的package包/类
@Override
public void process(Object o, Task task) {
    String path = this.path + PATH_SEPERATOR + task.getUUID() + PATH_SEPERATOR;
    try {
        String filename;
        if (o instanceof HasKey) {
            filename = path + ((HasKey) o).key() + ".html";
        } else {
            filename = path + DigestUtils.md5Hex(ToStringBuilder.reflectionToString(o)) + ".html";
        }
        PrintWriter printWriter = new PrintWriter(new FileWriter(getFile(filename)));
        printWriter.write(ToStringBuilder.reflectionToString(o));
        printWriter.close();
    } catch (IOException e) {
        logger.warn("write file error", e);
    }
}
 
开发者ID:code4craft,项目名称:webmagic,代码行数:18,代码来源:FilePageModelPipeline.java

示例7: poll

import us.codecraft.webmagic.Task; //导入方法依赖的package包/类
@Override
public synchronized Request poll(Task task) {
    Jedis jedis = pool.getResource();
    try {
        String url = jedis.lpop(getQueueKey(task));
        if (url == null) {
            return null;
        }
        String key = ITEM_PREFIX + task.getUUID();
        String field = DigestUtils.shaHex(url);
        byte[] bytes = jedis.hget(key.getBytes(), field.getBytes());
        if (bytes != null) {
            Request o = JSON.parseObject(new String(bytes), Request.class);
            return o;
        }
        Request request = new Request(url);
        return request;
    } finally {
        pool.returnResource(jedis);
    }
}
 
开发者ID:code4craft,项目名称:webmagic,代码行数:22,代码来源:RedisScheduler.java

示例8: process

import us.codecraft.webmagic.Task; //导入方法依赖的package包/类
@Override
public void process(ResultItems resultItems, Task task) {
    String path = this.path + "/" + task.getUUID() + "/";
    try {
        PrintWriter printWriter = new PrintWriter(new FileWriter(new File(path + DigestUtils.md5Hex(resultItems.getRequest().getUrl()) + ".json")));
        printWriter.write(JSON.toJSONString(resultItems.getAll()));
        printWriter.close();
    } catch (IOException e) {
        logger.warn("write file error", e);
    }
}
 
开发者ID:yuany,项目名称:en-webmagic,代码行数:12,代码来源:JsonFilePipeline.java

示例9: process

import us.codecraft.webmagic.Task; //导入方法依赖的package包/类
@Override
public void process(ResultItems resultItems, Task task) {
    String path = this.path + PATH_SEPERATOR + task.getUUID() + PATH_SEPERATOR;
    try {
        PrintWriter printWriter = new PrintWriter(new FileWriter(getFile(path + DigestUtils.md5Hex(resultItems.getRequest().getUrl()) + ".json")));
        printWriter.write(JSON.toJSONString(resultItems.getAll()));
        printWriter.close();
    } catch (IOException e) {
        logger.warn("write file error", e);
    }
}
 
开发者ID:code4craft,项目名称:webmagic,代码行数:12,代码来源:JsonFilePipeline.java

示例10: getSetKey

import us.codecraft.webmagic.Task; //导入方法依赖的package包/类
protected String getSetKey(Task task) {
    return SET_PREFIX + task.getUUID();
}
 
开发者ID:code4craft,项目名称:webmagic,代码行数:4,代码来源:RedisScheduler.java

示例11: getQueueKey

import us.codecraft.webmagic.Task; //导入方法依赖的package包/类
protected String getQueueKey(Task task) {
    return QUEUE_PREFIX + task.getUUID();
}
 
开发者ID:code4craft,项目名称:webmagic,代码行数:4,代码来源:RedisScheduler.java

示例12: getItemKey

import us.codecraft.webmagic.Task; //导入方法依赖的package包/类
protected String getItemKey(Task task) {
    return ITEM_PREFIX + task.getUUID();
}
 
开发者ID:code4craft,项目名称:webmagic,代码行数:4,代码来源:RedisScheduler.java

示例13: getZsetPlusPriorityKey

import us.codecraft.webmagic.Task; //导入方法依赖的package包/类
private String getZsetPlusPriorityKey(Task task)
{
    return ZSET_PREFIX + task.getUUID() + PLUS_PRIORITY_SUFFIX;
}
 
开发者ID:code4craft,项目名称:webmagic,代码行数:5,代码来源:RedisPriorityScheduler.java

示例14: getQueueNoPriorityKey

import us.codecraft.webmagic.Task; //导入方法依赖的package包/类
private String getQueueNoPriorityKey(Task task)
{
    return QUEUE_PREFIX + task.getUUID() + NO_PRIORITY_SUFFIX;
}
 
开发者ID:code4craft,项目名称:webmagic,代码行数:5,代码来源:RedisPriorityScheduler.java

示例15: getZsetMinusPriorityKey

import us.codecraft.webmagic.Task; //导入方法依赖的package包/类
private String getZsetMinusPriorityKey(Task task)
{
    return ZSET_PREFIX + task.getUUID() + MINUS_PRIORITY_SUFFIX;
}
 
开发者ID:code4craft,项目名称:webmagic,代码行数:5,代码来源:RedisPriorityScheduler.java


注:本文中的us.codecraft.webmagic.Task.getUUID方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。