congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
JsonUtils.writeValueAsString
Code IndexAdd Tabnine to your IDE (free)

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

Best Java code snippets using org.apache.eagle.alert.utils.JsonUtils.writeValueAsString (Showing top 9 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

@POST
@Path("/validate")
public String validate() throws Exception {
  ValidateState state = alertCoordinator.validate();
  return JsonUtils.writeValueAsString(state);
}
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.utilsJsonUtilswriteValueAsString

Popular methods of JsonUtils

  • jsonStringToList

Popular in Java

  • Reactive rest calls using spring rest template
  • scheduleAtFixedRate (Timer)
  • putExtra (Intent)
  • findViewById (Activity)
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • Menu (java.awt)
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • Dictionary (java.util)
    Note: Do not use this class since it is obsolete. Please use the Map interface for new implementatio
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
  • CodeWhisperer alternatives
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