Skip to content

Commit

Permalink
Merge pull request #3 from uavorg/master
Browse files Browse the repository at this point in the history
update
  • Loading branch information
wanglinlin8 committed Apr 27, 2018
2 parents 79683cb + 5593e2e commit 1b922be
Show file tree
Hide file tree
Showing 18 changed files with 714 additions and 187 deletions.
2 changes: 1 addition & 1 deletion com.creditease.uav.agent.buildComponent/bin/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export CLASSPATH=bin/com.creditease.uav.base-1.0-boot.jar
echo $CLASSPATH
javaAgent="-javaagent:../uavmof/com.creditease.uav.agent/com.creditease.uav.monitorframework.agent-1.0-agent.jar"
javaOpts="-server -Xms64m -Xmx256m -Xss256k -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:+CMSIncrementalPacing -XX:CMSIncrementalDutyCycleMin=0 -XX:CMSIncrementalDutyCycle=10 -XX:+UseParNewGC -XX:+UseCMSCompactAtFullCollection -XX:-CMSParallelRemarkEnabled -XX:CMSFullGCsBeforeCompaction=0 -XX:CMSInitiatingOccupancyFraction=70 -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=."
$executeJava $javaAgent $javaOpts -XX:OnOutOfMemoryError='kill -9 %p' -DNetCardIndex=$netcardIndex -DNetCardName=$netcardName -DJAppID=$2 -DJAppGroup=UNKNOWN -classpath $CLASSPATH com.creditease.mscp.boot.MSCPBoot -p $1 &
$executeJava $javaAgent $javaOpts -XX:OnOutOfMemoryError='kill -9 %p' -DNetCardIndex=$netcardIndex -DNetCardName=$netcardName -DJAppID=$2 -DJAppGroup=UAV -classpath $CLASSPATH com.creditease.mscp.boot.MSCPBoot -p $1 &

# add crontab process watcher
if [ "$proc_watcher" == "yes" ]; then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,3 +373,21 @@ StgyDiv .edit-div-option:empty:before{
/**
*触发策略 end
*/

.itemTitle {
text-align:left;
color:#333;
border-left:6px solid #57A69C;
padding-left:5px;
margin-bottom:2px;
}

.itemTip {
color:gray;
font-size:14px;
text-align:left;
}

.dateTimeInput {
width:120px;
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import java.util.Map;

import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse;
import org.elasticsearch.action.admin.indices.create.CreateIndexRequest;
import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder;
import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequest;
import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsResponse;
Expand Down Expand Up @@ -111,11 +111,24 @@ public boolean existIndex(String index) {
*
* @param index
* @return
* @throws IOException
*/
public boolean creatIndex(String index) {
public boolean creatIndex(String index) throws IOException {

return creatIndex(index, null, null, null);
}

public boolean creatIndex(String index, String type, Map<String, String> set,
Map<String, Map<String, Object>> mapping) throws IOException {

CreateIndexRequest cir = new CreateIndexRequest(index);
CreateIndexResponse resp = client.admin().indices().create(cir).actionGet();
CreateIndexRequestBuilder createIndexRequestBuilder = client.admin().indices().prepareCreate(index);
if (type != null && mapping != null) {
createIndexRequestBuilder.addMapping(type, createMapping(type, mapping));
}
if (set != null) {
createIndexRequestBuilder.setSettings(createSetting(set));
}
CreateIndexResponse resp = createIndexRequestBuilder.execute().actionGet();

if (resp.isAcknowledged()) {
return true;
Expand All @@ -124,6 +137,42 @@ public boolean creatIndex(String index) {
return false;
}

private Settings createSetting(Map<String, String> set) {

Settings settings = Settings.builder().put(set).build();

return settings;
}

private XContentBuilder createMapping(String type, Map<String, Map<String, Object>> properties) throws IOException {

XContentBuilder mapping;

mapping = jsonBuilder().startObject().startObject(type);

mapping = mapping.startObject("properties");

for (String key : properties.keySet()) {
mapping = mapping.startObject(key);

Map<String, Object> fv = properties.get(key);

for (String field : fv.keySet()) {
mapping = mapping.field(field, fv.get(field));
}

mapping = mapping.endObject();
}

mapping = mapping.endObject();

mapping = mapping.endObject();

mapping = mapping.endObject();

return mapping;
}

/**
* existType
*
Expand Down Expand Up @@ -173,29 +222,7 @@ public boolean updateIndexSetting(String index, Map<String, Object> set) {
public boolean setIndexTypeMapping(String index, String type, Map<String, Map<String, Object>> properties)
throws IOException {

XContentBuilder mapping;

mapping = jsonBuilder().startObject();

mapping = mapping.startObject("properties");

for (String key : properties.keySet()) {
mapping = mapping.startObject(key);

Map<String, Object> fv = properties.get(key);

for (String field : fv.keySet()) {
mapping = mapping.field(field, fv.get(field));
}

mapping = mapping.endObject();
}

mapping = mapping.endObject();

mapping = mapping.endObject();

PutMappingRequest pmp = Requests.putMappingRequest(index).type(type).source(mapping);
PutMappingRequest pmp = Requests.putMappingRequest(index).type(type).source(createMapping(type, properties));
PutMappingResponse resp = client.admin().indices().putMapping(pmp).actionGet();

return resp.isAcknowledged();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,16 @@ public void handle(Message msg) {
// pre insert to process DataStoreMsg
preInsert(dsMsg);

// do insert
boolean insertR = store.doInsert(dsMsg);
boolean insertR = false;

try {
// do insert
insertR = store.doInsert(dsMsg);

}
catch (Exception e) {
log.err(this, "DataStore[" + msgKey + "] INSERT DATA FAIL!", e);
}

if (log.isDebugEnable()) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.alibaba.fastjson.JSONArray;
import com.creditease.agent.helpers.DateTimeHelper;
import com.creditease.agent.helpers.EncodeHelper;
import com.creditease.agent.helpers.JSONHelper;
Expand Down Expand Up @@ -282,7 +283,9 @@ protected static class Expression {
private long range = 0;
private String func;
private float sampling = 1;

private String downsample;
private Boolean[] weekdayLimit=new Boolean[] {true,true,true,true,true,true,true};

private Set<String> matchArgExpr = new HashSet<String>();

private long time_from;
Expand All @@ -291,7 +294,11 @@ protected static class Expression {
private int unit;
private String upperLimit;
private String lowerLimit;

private String time_end;
private String time_start;
private String day_start;
private String day_end;

public Expression(String exprStr) {
for (String op : OPERATORS) {
if (exprStr.contains(op)) {
Expand Down Expand Up @@ -331,6 +338,19 @@ public Expression(Map<String, Object> cond) {
this.time_to = DateTimeHelper
.dateFormat(DateTimeHelper.getToday("yyyy-MM-dd") + " " + cond.get("time_to"), "yyyy-MM-dd HH:mm")
.getTime();

this.time_start=(String) cond.get("time_start");

this.time_end= (String) cond.get("time_end");

this.day_start=(String) cond.get("day_start");

this.day_end= (String) cond.get("day_end");

if(cond.containsKey("weekdayLimit")) {
((JSONArray)cond.get("weekdayLimit")).toArray(this.weekdayLimit);
}

if (cond.get("interval") != null) {
long interval = Long.parseLong((String) cond.get("interval"));
switch (unit) {
Expand All @@ -350,6 +370,7 @@ public Expression(Map<String, Object> cond) {
this.upperLimit = (String) cond.get("upperLimit");
this.lowerLimit = (String) cond.get("lowerLimit");
this.func = (String) cond.get("aggr");
this.downsample=(String) cond.get("downsample");
this.type = Type.TIMER;
}

Expand Down Expand Up @@ -469,6 +490,36 @@ public void setIdx(int idx) {

this.idx = idx;
}

public String getTime_end() {

return time_end;
}

public String getTime_start() {

return time_start;
}

public String getDownsample() {

return downsample;
}

public String getDay_start() {

return day_start;
}

public String getDay_end() {

return day_end;
}

public Boolean[] getWeekdayLimit() {

return weekdayLimit;
}

}

Expand Down

0 comments on commit 1b922be

Please sign in to comment.