Tabnine Logo
JsonUtils
Code IndexAdd Tabnine to your IDE (free)

How to use
JsonUtils
in
org.apache.eagle.alert.utils

Best Java code snippets using org.apache.eagle.alert.utils.JsonUtils (Showing top 11 results out of 315)

origin: apache/eagle

@GET
@Path("/assignments")
public String getAssignments() throws Exception {
  ScheduleState state = alertCoordinator.getState();
  return JsonUtils.writeValueAsString(state);
}
origin: apache/eagle

@Override
protected Object execute(Object data) {
  try {
    return JsonUtils.jsonStringToList((String)data).size();
  } catch (Exception e) {
    LOG.warn("exception found {}", e);
    return 0;
  }
}
origin: apache/eagle

@POST
@Path("/validate")
public String validate() throws Exception {
  ValidateState state = alertCoordinator.validate();
  return JsonUtils.writeValueAsString(state);
}
origin: apache/eagle

/**
 * The main execution method which will be called upon event arrival.
 * when there are more than one function parameter
 * This method calculates subtraction of two List Of Strings
 * Each String is a jobs string needs to be loaded
 * @param data the runtime values of function parameters
 * @return the function result
 */
@Override
protected Object execute(Object[] data) {
  try {
    List<String> ths = JsonUtils.jsonStringToList((String) data[0]);
    List<String> rhs = JsonUtils.jsonStringToList((String) data[1]);
    return org.apache.commons.lang.StringUtils.join(ListUtils.subtract(ths, rhs), "\n");
  } catch (Exception e) {
    LOG.warn("exception found {}", e);
    return null;
  }
}
origin: apache/eagle

@POST
@Path("/build")
public String build() throws Exception {
  ScheduleOption option = new ScheduleOption();
  ScheduleState state = alertCoordinator.schedule(option);
  return JsonUtils.writeValueAsString(state);
}
origin: apache/eagle

LOG.debug("calculated schedule state: {}", JsonUtils.writeValueAsString(state));
origin: apache/eagle

private static Pair<Long, String> createFailureEntity(AtomicLong base, int hostIndex) {
  // TODO: add randomization
  IfEntity ie = new IfEntity();
  ie.host = "boot-vm-0-" + hostIndex + ".datacenter.corp.com";
  ie.instanceUuid = nextUuid;
  ie.message = "boot failure for when try start the given vm!";
  ie.reqId = nextReqId;
  ie.timestamp = base.get();
  base.addAndGet(2000);// simply some interval.
  return Pair.of(base.get(), JsonUtils.writeValueAsString(ie));
}
origin: apache/eagle

public String streamEventToJson(AlertStreamEvent event) {
  Map<String, Object> jsonMap = new HashMap<String, Object>();
  jsonMap.put("policyId", event.getPolicyId());
  jsonMap.put("streamId", event.getStreamId());
  jsonMap.put("createBy", event.getCreatedBy());
  jsonMap.put("createTime", event.getCreatedTime());
  // data
  int size = event.getData().length;
  List<StreamColumn> columns = event.getSchema().getColumns();
  for (int i = 0; i < size; i++) {
    if (columns.size() < i) {
      // redundant check to log inconsistency
      LOG.error(" stream event data have different lenght compare to column definition! ");
    } else {
      jsonMap.put(columns.get(i).getName(), event.getData()[i]);
    }
  }
  return JsonUtils.writeValueAsString(jsonMap);
}
origin: apache/eagle

  @Test
  public void testWriteValueAsString() {

    Map<String, Object> jsonMap = new HashMap<>();
    jsonMap.put("policyId", "policyId");
    jsonMap.put("streamId", "streamId");
    jsonMap.put("createBy", "createBy");
    jsonMap.put("createTime", "createTime");
    Assert.assertEquals("{\"createBy\":\"createBy\",\"policyId\":\"policyId\",\"streamId\":\"streamId\",\"createTime\":\"createTime\"}", JsonUtils.writeValueAsString(jsonMap));

    jsonMap = new HashMap<>();
    Assert.assertEquals("{}", JsonUtils.writeValueAsString(jsonMap));

    Assert.assertEquals("null", JsonUtils.writeValueAsString(null));

    Assert.assertEquals("", JsonUtils.writeValueAsString(new Object()));
  }
}
origin: apache/eagle

private static Pair<Long, String> createEntity(long base, String stream, int hostIndex) {
  // TODO : add randomization
  Entity e = new Entity();
  e.colo = "LVS";
  e.host = String.format(hostTemp, hostIndex);
  if (hostIndex < 3) {
    e.pool = "hadoop-eagle-prod";
  } else {
    e.pool = "raptor-pool1";
  }
  e.timestamp = base;
  e.metric = stream;
  e.value = 92.0;
  base = base + 1000;
  return Pair.of(base, JsonUtils.writeValueAsString(e));
}
origin: apache/eagle

private static Pair<Long, String> createLogEntity(AtomicLong base1, int hostIndex) {
  // TODO: add randomization
  LogEntity le = new LogEntity();
  if (hostIndex < 3) {
    le.component = "NOVA";
    le.host = "nova.000-" + hostIndex + ".datacenter.corp.com";
    le.message = "RabbitMQ Exception - MQ not connectable!";
  } else {
    le.component = "NEUTRON";
    le.host = "neturon.000-" + (hostIndex - 3) + ".datacenter.corp.com";
    le.message = "DNS Exception - Fail to connect to DNS!";
  }
  le.instanceUuid = nextUuid;
  le.logLevel = "ERROR";
  le.reqId = nextReqId;
  le.timestamp = base1.get();
  base1.addAndGet(1000);// simply some interval.
  return Pair.of(base1.get(), JsonUtils.writeValueAsString(le));
}
org.apache.eagle.alert.utilsJsonUtils

Most used methods

  • writeValueAsString
  • jsonStringToList

Popular in Java

  • Start an intent from android
  • runOnUiThread (Activity)
  • putExtra (Intent)
  • getExternalFilesDir (Context)
  • BufferedReader (java.io)
    Wraps an existing Reader and buffers the input. Expensive interaction with the underlying reader is
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • ConcurrentHashMap (java.util.concurrent)
    A plug-in replacement for JDK1.5 java.util.concurrent.ConcurrentHashMap. This version is based on or
  • Collectors (java.util.stream)
  • Reference (javax.naming)
  • StringUtils (org.apache.commons.lang)
    Operations on java.lang.String that arenull safe. * IsEmpty/IsBlank - checks if a String contains
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now