Skip to content

Commit

Permalink
first commit project
Browse files Browse the repository at this point in the history
  • Loading branch information
MrJiao committed Feb 17, 2017
1 parent c54ba6a commit 593dda9
Show file tree
Hide file tree
Showing 134 changed files with 10,016 additions and 0 deletions.
Empty file.
Empty file.
Binary file added SpiderJackson/libs/commons-cli-1.2.jar
Binary file not shown.
Binary file added SpiderJackson/libs/commons-codec-1.9.jar
Binary file not shown.
Binary file added SpiderJackson/libs/commons-logging-1.2.jar
Binary file not shown.
Binary file added SpiderJackson/libs/disruptor-3.2.1.jar
Binary file not shown.
Binary file added SpiderJackson/libs/fluent-hc-4.5.2.jar
Binary file not shown.
Binary file added SpiderJackson/libs/httpclient-4.5.2.jar
Binary file not shown.
Binary file added SpiderJackson/libs/httpclient-cache-4.5.2.jar
Binary file not shown.
Binary file added SpiderJackson/libs/httpclient-win-4.5.2.jar
Binary file not shown.
Binary file added SpiderJackson/libs/httpcore-4.4.5.jar
Binary file not shown.
Binary file added SpiderJackson/libs/httpcore-ab-4.4.5.jar
Binary file not shown.
Binary file added SpiderJackson/libs/httpcore-nio-4.4.5.jar
Binary file not shown.
Binary file added SpiderJackson/libs/httpmime-4.5.2.jar
Binary file not shown.
Binary file added SpiderJackson/libs/jna-4.1.0.jar
Binary file not shown.
Binary file added SpiderJackson/libs/jna-platform-4.1.0.jar
Binary file not shown.
Binary file added SpiderJackson/libs/jsoup-1.9.2.jar
Binary file not shown.
Binary file added SpiderJackson/libs/junit-4.10.jar
Binary file not shown.
Binary file added SpiderJackson/libs/log4j-api-2.7.jar
Binary file not shown.
Binary file added SpiderJackson/libs/log4j-core-2.7.jar
Binary file not shown.
Empty file added SpiderJackson/logs/All_Log.log
Empty file.
Binary file added SpiderJackson/mybatisLibs/asm-4.2.jar
Binary file not shown.
Binary file added SpiderJackson/mybatisLibs/cglib-3.1.jar
Binary file not shown.
Binary file not shown.
Binary file added SpiderJackson/mybatisLibs/log4j-1.2.17.jar
Binary file not shown.
Binary file added SpiderJackson/mybatisLibs/mybatis-3.3.0.jar
Binary file not shown.
Binary file not shown.
Binary file added SpiderJackson/mybatisLibs/slf4j-api-1.7.12.jar
Binary file not shown.
Binary file not shown.
114 changes: 114 additions & 0 deletions SpiderJackson/src/com/jackson/bean/Bundle.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
package com.jackson.bean;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.HashMap;

/**
* Created by Jackson on 2017/1/17.
*/
public class Bundle {

private static Logger logger = LogManager.getLogger(Bundle.class.getName());
HashMap<String, Object> mMap = null;


private Bundle(){
mMap = new HashMap<>();
}

public static Bundle newInstance(){
return new Bundle();
}



public void put(String key,Object obj){
mMap.put(key, obj);
}

public Object get(String key,Object defaultValue){
Object o = mMap.get(key);
if (o == null) {
return defaultValue;
}
try {
return o;
} catch (ClassCastException e) {
logger.warn("key{},Type{},defaultValue{},Exception{}",key,"Object",defaultValue,e);
return defaultValue;
}
}



public void putBoolean(String key,int value){
mMap.put(key,value);
}

public boolean getBoolean(String key,boolean defaultValue){
Object o = mMap.get(key);
if (o == null) {
return defaultValue;
}
try {
return (boolean) o;
} catch (ClassCastException e) {
logger.warn("key{},Type{},defaultValue{},Exception{}",key,"boolean",defaultValue,e);
return defaultValue;
}
}

public void putInt(String key,int value){
mMap.put(key,value);
}

public int getInt(String key,int defaultValue){
Object o = mMap.get(key);
if (o == null) {
return defaultValue;
}
try {
return (int) o;
} catch (ClassCastException e) {
logger.warn("key{},Type{},defaultValue{},Exception{}",key,"int",defaultValue,e);
return defaultValue;
}
}

public void putString(String key,String value){
mMap.put(key,value);
}

public String getString(String key,String defaultValue){
Object o = mMap.get(key);
if (o == null) {
return defaultValue;
}
try {
return (String) o;
} catch (ClassCastException e) {
logger.warn("key{},Type{},defaultValue{},Exception{}",key,"String",defaultValue,e);
return defaultValue;
}
}

public void putLong(String key,long value){
mMap.put(key,value);
}

public long getLong(String key,long defaultValue){
Object o = mMap.get(key);
if (o == null) {
return defaultValue;
}
try {
return (long) o;
} catch (ClassCastException e) {
logger.warn("key{},Type{},defaultValue{},Exception{}",key,"long",defaultValue,e);
return defaultValue;
}
}

}
61 changes: 61 additions & 0 deletions SpiderJackson/src/com/jackson/bean/ContextSrc.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package com.jackson.bean;

import com.jackson.db.po.Account;
import com.jackson.db.po.Ip;
import com.jackson.db.po.Proxy;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.impl.client.BasicCookieStore;
import org.apache.http.protocol.HttpContext;


/**
* Created by Jackson on 2017/1/6.
* 请求相关对象上下文
*/
public class ContextSrc {
private Account account;
private HttpClientContext httpContext ;
private String userAgent;
private Proxy proxy;

public ContextSrc(){
httpContext = HttpClientContext.create();
httpContext.setCookieStore(new BasicCookieStore());
}

public Account getAccount() {
return account;
}

public ContextSrc setAccount(Account account) {
this.account = account;
return this;
}

public HttpClientContext getHttpContext() {
return httpContext;
}

public ContextSrc setHttpContext(HttpClientContext httpContext) {
this.httpContext = httpContext;
return this;
}

public String getUserAgent() {
return userAgent;
}

public ContextSrc setUserAgent(String userAgent) {
this.userAgent = userAgent;
return this;
}

public Proxy getProxy() {
return proxy;
}

public ContextSrc setProxy(Proxy proxy) {
this.proxy = proxy;
return this;
}
}
89 changes: 89 additions & 0 deletions SpiderJackson/src/com/jackson/common/control/ControlConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package com.jackson.common.control;

/**
* Created by Jackson on 2016/12/26.
*/
public class ControlConfig {
//线程数
private int corePoolSize;
//线程池中的最大任务数
private int maxTaskCache;
//线程池中的最小任务数,当小于这个数时,开始添加任务
private int minTaskCache;
//url池中最小缓存数
private int minServiceCatch;
//每次从数据库中获取的url数量
private int getServiceCatchSize;

private ControlConfig(int corePoolSize, int maxTaskCache, int minTaskCache, int minServiceCatch, int getServiceCatchSize) {
this.corePoolSize = corePoolSize;
this.maxTaskCache = maxTaskCache;
this.minTaskCache = minTaskCache;
this.minServiceCatch = minServiceCatch;
this.getServiceCatchSize = getServiceCatchSize;
}

public int getCorePoolSize() {
return corePoolSize;
}

public int getMaxTaskCache() {
return maxTaskCache;
}

public int getMinTaskCache() {
return minTaskCache;
}

public int getMinServiceCatch() {
return minServiceCatch;
}

public int getGetServiceCatchSize() {
return getServiceCatchSize;
}

public static Builder builder(){
return new Builder();
}


public static class Builder{
private Builder(){}

private int corePoolSize = 10;
private int maxTaskCache = 80;
private int minTaskCache = 20;
private int minServiceCatch = 10;
private int getServiceCatchSize = 100;

public Builder setCorePoolSize(int corePoolSize) {
this.corePoolSize = corePoolSize;
return this;
}

public Builder setMaxTaskCache(int maxTaskCache) {
this.maxTaskCache = maxTaskCache;
return this;
}

public Builder setMinTaskCache(int minTaskCache) {
this.minTaskCache = minTaskCache;
return this;
}

public Builder setMinServiceCatch(int minServiceCatch) {
this.minServiceCatch = minServiceCatch;
return this;
}

public Builder setGetServiceCatchSize(int getServiceCatchSize) {
this.getServiceCatchSize = getServiceCatchSize;
return this;
}

public ControlConfig build(){
return new ControlConfig(this.corePoolSize,this.maxTaskCache,this.minTaskCache,this.minServiceCatch,this.getServiceCatchSize);
}
}
}
Loading

0 comments on commit 593dda9

Please sign in to comment.