提交 2ff63852 编写于 作者: Z zhourui

修改logLevel为String,允许设置legLeve

上级 5a86ac4a
package com.x.base.core.container;
public enum LogLevel {
FATAL, ERROR, WARN, INFO, TRACE
}
......@@ -6,7 +6,6 @@ import java.util.List;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.container.LogLevel;
import com.x.base.core.project.annotation.FieldDescribe;
public class DataServer extends ConfigObject {
......@@ -21,8 +20,7 @@ public class DataServer extends ConfigObject {
private static final String DEFAULT_STATFILTER = "mergeStat";
private static final Integer DEFAULT_SLOWSQLMILLIS = 2000;
private static final Integer DEFAULT_LOCKTIMEOUT = 120000;
private static final String DEFAULT_LOGLEVEL = "WARN";
public static DataServer defaultInstance() {
return new DataServer();
......@@ -38,7 +36,7 @@ public class DataServer extends ConfigObject {
this.jmxEnable = DEFAULT_JMXENABLE;
this.maxTotal = DEFAULT_MAXTOTAL;
this.maxIdle = DEFAULT_MAXIDLE;
this.logLevel = LogLevel.WARN;
this.logLevel = DEFAULT_LOGLEVEL;
this.statEnable = DEFAULT_STATENABLE;
this.statFilter = DEFAULT_STATFILTER;
this.slowSqlMillis = DEFAULT_SLOWSQLMILLIS;
......@@ -59,8 +57,8 @@ public class DataServer extends ConfigObject {
private Boolean jmxEnable;
@FieldDescribe("H2数据库缓存大小,设置H2用于作为缓存的内存大小,以M作为单位,这里默认为512M.")
private Integer cacheSize;
@FieldDescribe("默认日志级别")
private LogLevel logLevel = LogLevel.WARN;
@FieldDescribe("默认日志级别,FATAL, ERROR, WARN, INFO, TRACE. 完成的配置为DefaultLevel=WARN, Tool=TRACE, Enhance=TRACE, METADATA=TRACE, Runtime=TRACE, Query=TRACE, DataCache=TRACE, JDBC=TRACE, SQL=TRACE")
private String logLevel;
@FieldDescribe("最大使用连接数")
private Integer maxTotal;
@FieldDescribe("最大空闲连接数")
......@@ -73,13 +71,13 @@ public class DataServer extends ConfigObject {
private Integer slowSqlMillis;
@FieldDescribe("默认锁超时时间()毫秒).")
private Integer lockTimeout;
public Integer getLockTimeout() {
return (null == this.lockTimeout || this.lockTimeout < 1) ? DEFAULT_LOCKTIMEOUT : this.lockTimeout;
}
public LogLevel getLogLevel() {
return this.logLevel == null ? LogLevel.WARN : this.logLevel;
public String getLogLevel() {
return StringUtils.isEmpty(this.logLevel) ? DEFAULT_LOGLEVEL : this.logLevel;
}
public Integer getSlowSqlMillis() {
......@@ -178,7 +176,7 @@ public class DataServer extends ConfigObject {
this.cacheSize = cacheSize;
}
public void setLogLevel(LogLevel logLevel) {
public void setLogLevel(String logLevel) {
this.logLevel = logLevel;
}
......
......@@ -6,7 +6,6 @@ import java.util.List;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.container.LogLevel;
import com.x.base.core.container.factory.SlicePropertiesBuilder;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.tools.Crypto;
......@@ -27,7 +26,7 @@ public class ExternalDataSource extends ConfigObject {
this.dictionary = "";
this.maxTotal = DEFAULT_MAXTOTAL;
this.maxIdle = DEFAULT_MAXIDLE;
this.logLevel = LogLevel.WARN;
this.logLevel = DEFAULT_LOGLEVEL;
this.statEnable = DEFAULT_STATENABLE;
this.statFilter = DEFAULT_STATFILTER;
this.slowSqlMillis = DEFAULT_SLOWSQLMILLIS;
......@@ -64,8 +63,8 @@ public class ExternalDataSource extends ConfigObject {
private List<String> includes;
@FieldDescribe("在此节点上不存储的类,和includes一起设置实际存储的类,可以使用通配符*")
private List<String> excludes;
@FieldDescribe("默认日志级别")
private LogLevel logLevel = LogLevel.WARN;
@FieldDescribe("默认日志级别,FATAL, ERROR, WARN, INFO, TRACE. 完成的配置为DefaultLevel=WARN, Tool=TRACE, Enhance=TRACE, METADATA=TRACE, Runtime=TRACE, Query=TRACE, DataCache=TRACE, JDBC=TRACE, SQL=TRACE")
private String logLevel = DEFAULT_LOGLEVEL;
public static final Integer DEFAULT_MAXTOTAL = 50;
......@@ -77,8 +76,10 @@ public class ExternalDataSource extends ConfigObject {
public static final Integer DEFAULT_SLOWSQLMILLIS = 2000;
public LogLevel getLogLevel() {
return this.logLevel == null ? LogLevel.WARN : this.logLevel;
public static final String DEFAULT_LOGLEVEL = "WARN";
public String getLogLevel() {
return StringUtils.isEmpty(this.logLevel) ? DEFAULT_LOGLEVEL : this.logLevel;
}
public String getDriverClassName() throws Exception {
......@@ -182,7 +183,7 @@ public class ExternalDataSource extends ConfigObject {
this.maxTotal = maxTotal;
}
public void setLogLevel(LogLevel logLevel) {
public void setLogLevel(String logLevel) {
this.logLevel = logLevel;
}
......
......@@ -85,10 +85,14 @@ public class ExternalDataSources extends CopyOnWriteArrayList<ExternalDataSource
if (BooleanUtils.isTrue(o.getEnable())) {
String n = "s" + ("" + (1000 + idx)).substring(1);
if (StringUtils.equals(n, name)) {
String value = o.getLogLevel().toString();
return "DefaultLevel=WARN, Tool=" + value + ", Enhance=" + value + ", METADATA=" + value
+ ", Runtime=" + value + ", Query=" + value + ", DataCache=" + value + ", JDBC=" + value
+ ", SQL=" + value;
String value = o.getLogLevel();
if (StringUtils.contains(value, "=")) {
return value;
} else {
return "DefaultLevel=WARN, Tool=" + value + ", Enhance=" + value + ", METADATA=" + value
+ ", Runtime=" + value + ", Query=" + value + ", DataCache=" + value + ", JDBC=" + value
+ ", SQL=" + value;
}
}
}
}
......
......@@ -42,6 +42,8 @@ public class Snap extends SliceJpaObject {
public static final String TYPE_SUSPEND = "suspend";
public static final String TYPE_ABANDONED = "abandoned";
public String getId() {
return id;
}
......
package com.x.processplatform.service.processing.jaxrs.snap;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.project.config.Communicate.Clean;
import com.x.base.core.project.exception.ExceptionEntityNotExist;
import com.x.base.core.project.executor.ProcessPlatformExecutorFactory;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WoId;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.tools.ListTools;
import com.x.processplatform.core.entity.content.Attachment;
import com.x.processplatform.core.entity.content.DocumentVersion;
import com.x.processplatform.core.entity.content.Read;
import com.x.processplatform.core.entity.content.ReadCompleted;
import com.x.processplatform.core.entity.content.Record;
import com.x.processplatform.core.entity.content.Review;
import com.x.processplatform.core.entity.content.Snap;
import com.x.processplatform.core.entity.content.Task;
import com.x.processplatform.core.entity.content.TaskCompleted;
import com.x.processplatform.core.entity.content.Work;
import com.x.processplatform.core.entity.content.WorkLog;
import com.x.processplatform.service.processing.Business;
import com.x.query.core.entity.Item;
class ActionTypeAbandoned extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionTypeAbandoned.class);
ActionResult<Wo> execute(EffectivePerson effectivePerson, String workId) throws Exception {
String job = null;
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Work work = emc.fetch(workId, Work.class, ListTools.toList(Work.job_FIELDNAME));
if (null == work) {
throw new ExceptionEntityNotExist(workId, Work.class);
}
job = work.getJob();
}
return ProcessPlatformExecutorFactory.get(job).submit(new CallableImpl(workId)).get();
}
public class CallableImpl implements Callable<ActionResult<Wo>> {
private String id;
public CallableImpl(String id) {
this.id = id;
}
public ActionResult<Wo> call() throws Exception {
ActionResult<Wo> result = new ActionResult<>();
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
Business business = new Business(emc);
Work work = emc.find(id, Work.class);
if (null == work) {
throw new ExceptionEntityNotExist(id, Work.class);
}
Snap snap = new Snap(work);
List<Item> items = new ArrayList<>();
List<Work> works = new ArrayList<>();
List<Task> tasks = new ArrayList<>();
List<TaskCompleted> taskCompleteds = new ArrayList<>();
List<Read> reads = new ArrayList<>();
List<ReadCompleted> readCompleteds = new ArrayList<>();
List<Review> reviews = new ArrayList<>();
List<WorkLog> workLogs = new ArrayList<>();
List<Record> records = new ArrayList<>();
List<Attachment> attachments = new ArrayList<>();
List<DocumentVersion> documentVersions = new ArrayList<>();
snap.setProperties(snap(business, work.getJob(), items, works, tasks, taskCompleteds, reads,
readCompleteds, reviews, workLogs, records, attachments, documentVersions));
snap.setType(Snap.TYPE_ABANDONED);
emc.beginTransaction(Snap.class);
emc.persist(snap, CheckPersistType.all);
emc.commit();
clean(business, items, works, tasks, taskCompleteds, reads, readCompleteds, reviews, workLogs, records,
attachments, documentVersions);
emc.commit();
Wo wo = new Wo();
wo.setId(snap.getId());
result.setData(wo);
return result;
}
}
}
public static class Wo extends WoId {
private static final long serialVersionUID = -2577413577740827608L;
}
}
......@@ -76,7 +76,7 @@ class ActionTypeSuspend extends BaseAction {
List<DocumentVersion> documentVersions = new ArrayList<>();
snap.setProperties(snap(business, work.getJob(), items, works, tasks, taskCompleteds, reads,
readCompleteds, reviews, workLogs, records, attachments, documentVersions));
snap.setType(Snap.TYPE_SNAP);
snap.setType(Snap.TYPE_SUSPEND);
emc.beginTransaction(Snap.class);
emc.persist(snap, CheckPersistType.all);
emc.commit();
......
......@@ -65,6 +65,24 @@ public class SnapAction extends StandardJaxrsAction {
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "废弃工作", action = ActionTypeAbandoned.class)
@GET
@Path("work/{workId}/type/abandoned")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void typeAbandoned(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("工作标识") @PathParam("workId") String workId) {
ActionResult<ActionTypeAbandoned.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionTypeAbandoned().execute(effectivePerson, workId);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "删除快照", action = ActionDelete.class)
@DELETE
@Path("{id}")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册