private Map<Integer, JSONObject> listSessions() throws IOException { String sessionsUrl = livyUrl + "/sessions"; int numSessions; JSONObject sessionsInfo; Map<Integer, JSONObject> sessionsMap = new HashMap<>(); Map<String, String> headers = new HashMap<>(); headers.put("Content-Type", APPLICATION_JSON); headers.put("X-Requested-By", USER); try { sessionsInfo = readJSONFromUrl(sessionsUrl, headers); numSessions = sessionsInfo.getJSONArray("sessions").length(); for (int i = 0; i < numSessions; i++) { int currentSessionId = sessionsInfo.getJSONArray("sessions").getJSONObject(i).getInt("id"); JSONObject currentSession = sessionsInfo.getJSONArray("sessions").getJSONObject(i); sessionsMap.put(currentSessionId, currentSession); } } catch (JSONException e) { throw new IOException(e); } return sessionsMap; }
JSONObject agentObj = jArr.getJSONObject(i);
public Set<String> getSubmittedYarnApps() throws Exception { String rmHost = PhoenixMRJobUtil.getActiveResourceManagerHost(conf, zkQuorum); Map<String, String> urlParams = new HashMap<String, String>(); urlParams.put(YarnApplication.APP_STATES_ELEMENT, YarnApplication.state.NEW.toString() + "," + YarnApplication.state.ACCEPTED + "," + YarnApplication.state.SUBMITTED + "," + YarnApplication.state.RUNNING); int rmPort = PhoenixMRJobUtil.getRMPort(conf); String response = PhoenixMRJobUtil.getJobsInformationFromRM(rmHost, rmPort, urlParams); LOG.debug("Already Submitted/Running Apps = " + response); JSONObject jobsJson = new JSONObject(response); JSONObject appsJson = jobsJson.optJSONObject(YarnApplication.APPS_ELEMENT); Set<String> yarnApplicationSet = new HashSet<String>(); if (appsJson == null) { return yarnApplicationSet; } JSONArray appJson = appsJson.optJSONArray(YarnApplication.APP_ELEMENT); if (appJson == null) { return yarnApplicationSet; } for (int i = 0; i < appJson.length(); i++) { Gson gson = new GsonBuilder().create(); YarnApplication yarnApplication = gson.fromJson(appJson.getJSONObject(i).toString(), new TypeToken<YarnApplication>() { }.getType()); yarnApplicationSet.add(yarnApplication.getName()); } return yarnApplicationSet; }
@Override public List<SModelCheckerInstance> getAllRepositoryModelCheckers() throws ServerException, UserException { requireRealUserAuthentication(); try { List<SModelCheckerInstance> modelCheckers = new ArrayList<SModelCheckerInstance>(); String content = NetUtils.getContent(new URL(getServiceMap().get(SettingsInterface.class).getServiceRepositoryUrl() + "/modelcheckers"), 5000); JSONObject root = new JSONObject(new JSONTokener(content)); JSONArray modelCheckersJson = root.getJSONArray("modelcheckers"); for (int i = 0; i < modelCheckersJson.length(); i++) { JSONObject modelCheckerJson = modelCheckersJson.getJSONObject(i); SModelCheckerInstance sModelChecker = new SModelCheckerInstance(); sModelChecker.setName(modelCheckerJson.getString("name")); sModelChecker.setCode(modelCheckerJson.getString("code")); sModelChecker.setDescription(modelCheckerJson.getString("description")); sModelChecker.setModelCheckerPluginClassName(modelCheckerJson.getString("modelCheckerPluginClassName")); modelCheckers.add(sModelChecker); } return modelCheckers; } catch (Exception e) { return handleException(e); } }
JSONArray extendedDataSchemasJson = root.getJSONArray("extendeddataschemas"); for (int i = 0; i < extendedDataSchemasJson.length(); i++) { JSONObject extendedDataSchemaJson = extendedDataSchemasJson.getJSONObject(i);
protected JSONObject getJsonObject( JSONArray entitiesNode, int index ) { try { return entitiesNode.getJSONObject( index ); } catch( JSONException exception ) { throw new CascadingException( exception ); } } }
private List<JSONObject> extractObjectListFromRecords(JSONObject object) throws JSONException { List<JSONObject> objects = new ArrayList<>(); if (object != null) { JSONArray records = object.getJSONArray("records"); for (int i = 0; i < records.length(); i++) { objects.add(records.getJSONObject(i)); } } return objects; }
private void initAssociations(JSONArray associations) throws JSONException { for (int index = 0; index < associations.length(); index++) { JSONObject childObject = associations.getJSONObject(index); _routeTableAssociations.add(new RouteTableAssociation(childObject)); } }
private void initIpPerms(List<IpPermissions> ipPermsList, JSONArray ipPermsJson) throws JSONException { for (int index = 0; index < ipPermsJson.length(); index++) { JSONObject childObject = ipPermsJson.getJSONObject(index); ipPermsList.add(new IpPermissions(childObject)); } }
private void initRoutes(JSONArray routes) throws JSONException { for (int index = 0; index < routes.length(); index++) { JSONObject childObject = routes.getJSONObject(index); _routes.add(new Route(childObject)); } } }
public List<Member> createMembersListFromJson(JSONObject results) { List<Member> members = new ArrayList<>(); try { JSONArray records = results.getJSONArray("records"); for (int i = 0; i < records.length(); i++) { members.add(createMemberFromSalesForceRecord(records.getJSONObject(i))); } } catch (JSONException e) { throw new RuntimeException("Error getting member records from SalesForce JSON", e); } return members; }
@Override public Iterable<T> parse(JSONArray json) throws JSONException { ArrayList<T> res = new ArrayList<T>(json.length()); for (int i = 0; i < json.length(); i++) { res.add(jsonParser.parse(json.getJSONObject(i))); } return res; } }
private void initSecurityGroups(JSONArray securityGroupsArray) throws JSONException { for (int index = 0; index < securityGroupsArray.length(); index++) { JSONObject securityGroup = securityGroupsArray.getJSONObject(index); if (securityGroup.getString(JSON_KEY_STATUS).equalsIgnoreCase("active")) { _securityGroups.add(securityGroup.getString(JSON_KEY_VPC_SECURITY_GROUP_ID)); } } }
@Override public Iterable<BasicProject> parse(JSONArray json) throws JSONException { ArrayList<BasicProject> res = new ArrayList<BasicProject>(json.length()); for (int i = 0; i < json.length(); i++) { res.add(basicProjectJsonParser.parse(json.getJSONObject(i))); } return res; } }
@Override public Iterable<T> parse(JSONArray json) throws JSONException { ArrayList<T> res = new ArrayList<T>(json.length()); for (int i = 0; i < json.length(); i++) { res.add(jsonParser.parse(json.getJSONObject(i))); } return res; } }
JSONArray services = root.getJSONArray("services"); for (int i = 0; i < services.length(); i++) { JSONObject service = services.getJSONObject(i); SServiceDescriptor sServiceDescriptor = new SServiceDescriptor(); sServiceDescriptor.setName(service.getString("name"));
public InternetGateway(JSONObject jObj) throws JSONException { _internetGatewayId = jObj.getString(JSON_KEY_INTERNET_GATEWAY_ID); JSONArray attachments = jObj.getJSONArray(JSON_KEY_ATTACHMENTS); for (int index = 0; index < attachments.length(); index++) { JSONObject childObject = attachments.getJSONObject(index); _attachmentVpcIds.add(childObject.getString(JSON_KEY_VPC_ID)); } }
public VpnGateway(JSONObject jObj) throws JSONException { _vpnGatewayId = jObj.getString(JSON_KEY_VPN_GATEWAY_ID); JSONArray attachments = jObj.getJSONArray(JSON_KEY_VPC_ATTACHMENTS); for (int index = 0; index < attachments.length(); index++) { JSONObject childObject = attachments.getJSONObject(index); _attachmentVpcIds.add(childObject.getString(JSON_KEY_VPC_ID)); } }
private JSONObject getSubQueue(JSONObject queue, String subQueue) throws JSONException { JSONArray queues = queue.getJSONObject("queues").getJSONArray("queue"); for (int i=0; i<queues.length(); ++i) { checkResourcesUsed(queues.getJSONObject(i)); if (queues.getJSONObject(i).getString("queueName").equals(subQueue) ) { return queues.getJSONObject(i); } } return null; }
public void verifyJobAttempts(JSONObject info, Job job) throws JSONException { JSONArray attempts = info.getJSONArray("jobAttempt"); assertEquals("incorrect number of elements", 2, attempts.length()); for (int i = 0; i < attempts.length(); i++) { JSONObject attempt = attempts.getJSONObject(i); verifyJobAttemptsGeneric(job, attempt.getString("nodeHttpAddress"), attempt.getString("nodeId"), attempt.getInt("id"), attempt.getLong("startTime"), attempt.getString("containerId"), attempt.getString("logsLink")); } }