当前位置: 首页>>代码示例>>Java>>正文


Java JSONObject.getDouble方法代码示例

本文整理汇总了Java中org.codehaus.jettison.json.JSONObject.getDouble方法的典型用法代码示例。如果您正苦于以下问题:Java JSONObject.getDouble方法的具体用法?Java JSONObject.getDouble怎么用?Java JSONObject.getDouble使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.codehaus.jettison.json.JSONObject的用法示例。


在下文中一共展示了JSONObject.getDouble方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: process

import org.codehaus.jettison.json.JSONObject; //导入方法依赖的package包/类
@Override
public void process(String key, String value) {
    try {
        JSONObject jsonMessage = new JSONObject(value);
        Message message = new Message(jsonMessage.getString("id"), context.timestamp(), System.currentTimeMillis(), jsonMessage.getDouble("payload"), jsonMessage.getString("reduction_mode"), jsonMessage.getInt("values"));

        this.context.forward(message.getId(), message);
        this.context.commit();
    } catch (JSONException e) {
        e.printStackTrace();
        System.exit(1);
    }
}
 
开发者ID:gdibernardo,项目名称:streaming-engines-benchmark,代码行数:14,代码来源:MessageProcessor.java

示例2: verifySubQueue

import org.codehaus.jettison.json.JSONObject; //导入方法依赖的package包/类
private void verifySubQueue(JSONObject info, String q, 
    float parentAbsCapacity, float parentAbsMaxCapacity)
    throws JSONException, Exception {
  int numExpectedElements = 13;
  boolean isParentQueue = true;
  if (!info.has("queues")) {
    numExpectedElements = 25;
    isParentQueue = false;
  }
  assertEquals("incorrect number of elements", numExpectedElements, info.length());

  QueueInfo qi = isParentQueue ? new QueueInfo() : new LeafQueueInfo();
  qi.capacity = (float) info.getDouble("capacity");
  qi.usedCapacity = (float) info.getDouble("usedCapacity");
  qi.maxCapacity = (float) info.getDouble("maxCapacity");
  qi.absoluteCapacity = (float) info.getDouble("absoluteCapacity");
  qi.absoluteMaxCapacity = (float) info.getDouble("absoluteMaxCapacity");
  qi.absoluteUsedCapacity = (float) info.getDouble("absoluteUsedCapacity");
  qi.numApplications = info.getInt("numApplications");
  qi.queueName = info.getString("queueName");
  qi.state = info.getString("state");

  verifySubQueueGeneric(q, qi, parentAbsCapacity, parentAbsMaxCapacity);

  if (isParentQueue) {
    JSONArray arr = info.getJSONObject("queues").getJSONArray("queue");
    // test subqueues
    for (int i = 0; i < arr.length(); i++) {
      JSONObject obj = arr.getJSONObject(i);
      String q2 = q + "." + obj.getString("queueName");
      verifySubQueue(obj, q2, qi.absoluteCapacity, qi.absoluteMaxCapacity);
    }
  } else {
    LeafQueueInfo lqi = (LeafQueueInfo) qi;
    lqi.numActiveApplications = info.getInt("numActiveApplications");
    lqi.numPendingApplications = info.getInt("numPendingApplications");
    lqi.numContainers = info.getInt("numContainers");
    lqi.maxApplications = info.getInt("maxApplications");
    lqi.maxApplicationsPerUser = info.getInt("maxApplicationsPerUser");
    lqi.userLimit = info.getInt("userLimit");
    lqi.userLimitFactor = (float) info.getDouble("userLimitFactor");
    verifyLeafQueueGeneric(q, lqi);
    // resourcesUsed and users (per-user resources used) are checked in
    // testPerUserResource()
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:47,代码来源:TestRMWebServicesCapacitySched.java


注:本文中的org.codehaus.jettison.json.JSONObject.getDouble方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。