本文整理汇总了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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例10: getSetKey
import us.codecraft.webmagic.Task; //导入方法依赖的package包/类
protected String getSetKey(Task task) {
return SET_PREFIX + task.getUUID();
}
示例11: getQueueKey
import us.codecraft.webmagic.Task; //导入方法依赖的package包/类
protected String getQueueKey(Task task) {
return QUEUE_PREFIX + task.getUUID();
}
示例12: getItemKey
import us.codecraft.webmagic.Task; //导入方法依赖的package包/类
protected String getItemKey(Task task) {
return ITEM_PREFIX + task.getUUID();
}
示例13: getZsetPlusPriorityKey
import us.codecraft.webmagic.Task; //导入方法依赖的package包/类
private String getZsetPlusPriorityKey(Task task)
{
return ZSET_PREFIX + task.getUUID() + PLUS_PRIORITY_SUFFIX;
}
示例14: getQueueNoPriorityKey
import us.codecraft.webmagic.Task; //导入方法依赖的package包/类
private String getQueueNoPriorityKey(Task task)
{
return QUEUE_PREFIX + task.getUUID() + NO_PRIORITY_SUFFIX;
}
示例15: getZsetMinusPriorityKey
import us.codecraft.webmagic.Task; //导入方法依赖的package包/类
private String getZsetMinusPriorityKey(Task task)
{
return ZSET_PREFIX + task.getUUID() + MINUS_PRIORITY_SUFFIX;
}