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


Java ObjectNode.putArray方法代码示例

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


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

示例1: onDeviceTelemetry

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
@Override
public MqttDeliveryFuture onDeviceTelemetry(String deviceName, List<TsKvEntry> telemetry) {
    final int msgId = msgIdSeq.incrementAndGet();
    log.trace("[{}][{}] Updating device telemetry: {}", deviceName, msgId, telemetry);
    checkDeviceConnected(deviceName);
    ObjectNode node = newNode();
    Map<Long, List<TsKvEntry>> tsMap = telemetry.stream().collect(Collectors.groupingBy(v -> v.getTs()));
    ArrayNode deviceNode = node.putArray(deviceName);
    tsMap.entrySet().forEach(kv -> {
        Long ts = kv.getKey();
        ObjectNode tsNode = deviceNode.addObject();
        tsNode.put("ts", ts);
        ObjectNode valuesNode = tsNode.putObject("values");
        kv.getValue().forEach(v -> putToNode(valuesNode, v));
    });
    final int packSize = telemetry.size();
    MqttMessage msg = new MqttMessage(toBytes(node));
    msg.setId(msgId);
    return publishAsync(GATEWAY_TELEMETRY_TOPIC, msg,
            token -> {
                log.debug("[{}][{}] Device telemetry published to Thingsboard!", msgId, deviceName);
                telemetryCount.addAndGet(packSize);
            },
            error -> log.warn("[{}][{}] Failed to publish device telemetry!", deviceName, msgId, error));
}
 
开发者ID:osswangxining,项目名称:iot-edge-greengrass,代码行数:26,代码来源:MqttGatewayService.java

示例2: toJson

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
public JsonNode toJson() {
    ObjectNode jsonRule = new ObjectMapper().createObjectNode();

    jsonRule.put("ETag", this.eTag);
    jsonRule.put("Id", this.id);
    jsonRule.put("Name", this.name);
    jsonRule.put("DateCreated", this.dateCreated);
    jsonRule.put("DateModified", this.dateModified);
    jsonRule.put("Enabled", this.enabled);
    jsonRule.put("Description", this.description);
    jsonRule.put("GroupId", this.groupId);
    jsonRule.put("Severity", this.severity);

    ArrayNode jsonConditions = jsonRule.putArray("Conditions");
    for (ConditionServiceModel condition : this.conditions) {
        ObjectNode jsonCondition = new ObjectMapper().createObjectNode();
        jsonCondition.put("Field", condition.getField());
        jsonCondition.put("Operator", condition.getOperator());
        jsonCondition.put("Value", condition.getValue());

        jsonConditions.add(jsonCondition);
    }

    return jsonRule;
}
 
开发者ID:Azure,项目名称:device-telemetry-java,代码行数:26,代码来源:RuleServiceModel.java

示例3: getDefinitionForAllPackages

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
/**
 * Mongo chokes on "." in field names. Arguably not a desirable practice
 * anyway
 *
 * @param definitionNode
 * @param location
 * @return
 */
public ObjectNode getDefinitionForAllPackages () {
	ObjectNode applicationDefinition = jacksonMapper.createObjectNode();

	logger.debug( "Definition Folder: {}", getDefinitionFolder() );
	File[] definitionFiles = getDefinitionFolder().listFiles();

	ArrayNode definitions = applicationDefinition.putArray( "definitions" );

	getReleasePackageStream().forEach( releasePackage -> {
		ObjectNode item = definitions.addObject();
		item.put( "fileName", releasePackage.getReleasePackageFileName() );
		try {
			item.put( "content", releasePackage.getJsonModelDefinition().toString() );
		} catch (Exception e) {
			item.put( "content", "Failed to parse:" + e.getMessage() );
			logger.error( "Failed to create definition object for upload: {}", CSAP.getCsapFilteredStackTrace( e ) );
		}
	} );

	return applicationDefinition;
}
 
开发者ID:csap-platform,项目名称:csap-core,代码行数:30,代码来源:Application.java

示例4: encode

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
@Override
public ObjectNode encode(TrafficSelector selector, CodecContext context) {
    checkNotNull(selector, "Traffic selector cannot be null");

    final ObjectNode result = context.mapper().createObjectNode();
    final ArrayNode jsonCriteria = result.putArray(CRITERIA);

    if (selector.criteria() != null) {
        final JsonCodec<Criterion> criterionCodec =
                context.codec(Criterion.class);
        for (final Criterion criterion : selector.criteria()) {
            jsonCriteria.add(criterionCodec.encode(criterion, context));
        }
    }

    return result;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:18,代码来源:TrafficSelectorCodec.java

示例5: encode

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
@Override
public ObjectNode encode(Host host, CodecContext context) {
    checkNotNull(host, "Host cannot be null");
    final JsonCodec<HostLocation> locationCodec =
            context.codec(HostLocation.class);
    final ObjectNode result = context.mapper().createObjectNode()
            .put("id", host.id().toString())
            .put("mac", host.mac().toString())
            .put("vlan", host.vlan().toString());

    final ArrayNode jsonIpAddresses = result.putArray("ipAddresses");
    for (final IpAddress ipAddress : host.ipAddresses()) {
        jsonIpAddresses.add(ipAddress.toString());
    }
    result.set("ipAddresses", jsonIpAddresses);
    result.set("location", locationCodec.encode(host.location(), context));

    return annotate(result, host, context);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:20,代码来源:HostCodec.java

示例6: getMetricsConfiguriation

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
private ObjectNode getMetricsConfiguriation ( ReleasePackage releasePackage ) {
	ObjectNode configJson = jacksonMapper.createObjectNode();

	// String type = reqType;
	// if (reqType.startsWith("jmx"))
	// type = "jmx";
	for ( String metricType : lifeCycleSettings()
		.getMetricToSecondsMap()
		.keySet() ) {

		ArrayNode samplesArray = configJson.putArray( metricType );
		for ( Integer sampleInterval : lifeCycleSettings()
			.getMetricToSecondsMap()
			.get( metricType ) ) {
			samplesArray.add( sampleInterval );
		}
	}

	return configJson;
}
 
开发者ID:csap-platform,项目名称:csap-core,代码行数:21,代码来源:Application.java

示例7: ensureJmxStandardCacheInitialized

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
private void ensureJmxStandardCacheInitialized ( Map<String, ObjectNode> jmxResultCacheNode ) {

		if ( !jmxResultCacheNode.containsKey( serviceInstance.getServiceName_Port() ) ) {

			logger.debug( "Creating jmx results storage for: {}", serviceInstance.getServiceName() );

			ObjectNode serviceMetricNode = jacksonMapper.createObjectNode();
			serviceMetricNode.putArray( "timeStamp" );
			for ( JmxCommonEnum jmxMetric : JmxCommonEnum.values() ) {

				// some jvms are not tomcat, so skip tomcat specific metrics
				if ( !serviceInstance.isTomcatJarsPresent() && jmxMetric.isTomcatOnly() ) {
					continue;
				}

				String metricFullName = jmxMetric.value + "_"
						+ serviceInstance.getServiceName_Port();
				serviceMetricNode.putArray( metricFullName );
			}

			jmxResultCacheNode.put( serviceInstance.getServiceName_Port(),
				serviceMetricNode );

		}
	}
 
开发者ID:csap-platform,项目名称:csap-core,代码行数:26,代码来源:ServiceCollectionResults.java

示例8: addSpeaker

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
/**
 * Adds BGP speaker to configuration.
 *
 * @param speaker BGP speaker configuration entry
 */
public void addSpeaker(BgpSpeakerConfig speaker) {
    ObjectNode speakerNode = JsonNodeFactory.instance.objectNode();

    speakerNode.put(NAME, speaker.name().get());

    speakerNode.put(VLAN, speaker.vlan().toString());

    speakerNode.put(CONNECT_POINT, speaker.connectPoint().elementId().toString()
            + "/" + speaker.connectPoint().port().toString());

    ArrayNode peersNode = speakerNode.putArray(PEERS);
    for (IpAddress peerAddress: speaker.peers()) {
        peersNode.add(peerAddress.toString());
    }

    ArrayNode speakersArray = bgpSpeakers().isEmpty() ?
            initBgpConfiguration() : (ArrayNode) object.get(SPEAKERS);
    speakersArray.add(speakerNode);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:25,代码来源:BgpConfig.java

示例9: getState

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
public JsonNode getState() {
	ObjectMapper mapper = new ObjectMapper();

	ObjectNode state = mapper.createObjectNode();

	state.put("name", this.gameClass.getSimpleName());

	ArrayNode rooms = state.putArray("rooms");
	for (GameRoom room : this.rooms.values()) {
		rooms.add(room.getState(false));
	}

	ArrayNode players = state.putArray("players");
	for (GamePlayer player : this.players.values()) {
		players.add(player.getState());
	}
	return state;
}
 
开发者ID:edwardxia,项目名称:board-server,代码行数:19,代码来源:GameLobby.java

示例10: getRegionDevices

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
/**
 * Returns the set of devices that belong to the specified region.
 *
 * @param regionId region identifier
 * @return 200 OK with set of devices that belong to the specified region
 * @onos.rsModel RegionDeviceIds
 */
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("{regionId}/devices")
public Response getRegionDevices(@PathParam("regionId") String regionId) {
    final RegionId rid = RegionId.regionId(regionId);
    final Iterable<DeviceId> deviceIds = regionService.getRegionDevices(rid);
    final ObjectNode root = mapper().createObjectNode();
    final ArrayNode deviceIdsNode = root.putArray("deviceIds");
    deviceIds.forEach(did -> deviceIdsNode.add(did.toString()));
    return ok(root).build();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:RegionsWebResource.java

示例11: alertsBuilder

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
/**
 *
 * Add errors to errorList.
 *
 * @param hostName
 * @param errorList
 * @param responseFromHostStatusJson
 */
public ObjectNode alertsBuilder ( double alertLevel, String hostName, ObjectNode responseFromHostStatusJson ) {

	ObjectNode alertMessages = jacksonMapper.createObjectNode();
	ArrayNode errorArray = alertMessages.putArray( Application.VALIDATION_ERRORS );

	if ( responseFromHostStatusJson.has( "error" ) ) {
		errorArray.add( hostName + ": " + responseFromHostStatusJson
			.path( "error" )
			.textValue() );
		// return result;
		return alertMessages;
	}

	ObjectNode hostStatsNode = (ObjectNode) responseFromHostStatusJson.path( HostKeys.hostStats.jsonId );
	if ( hostStatsNode == null ) {
		errorArray.add( hostName + ": " + "Host response missing attribute: hostStats" );
		// return result;
		return alertMessages;
	}

	alertsForHostCpu( hostStatsNode, hostName, alertLevel, errorArray, alertMessages );

	alertsForHostMemory( hostStatsNode, hostName, errorArray, alertMessages );

	alertsForHostDisk( hostStatsNode, hostName, alertLevel, errorArray, alertMessages );

	ObjectNode serviceHealthCollected = (ObjectNode) responseFromHostStatusJson.path( "services" );
	if ( serviceHealthCollected == null ) {
		errorArray.add( hostName + ": " + "Host response missing attribute: services" );
		// return result;
		return alertMessages;
	}

	alertsForServices( hostName, serviceHealthCollected, errorArray, alertLevel, alertMessages );

	return alertMessages;
}
 
开发者ID:csap-platform,项目名称:csap-core,代码行数:46,代码来源:HostAlertProcessor.java

示例12: encodeWaypointConstraint

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
/**
 * Encodes a waypoint constraint.
 *
 * @return JSON ObjectNode representing the constraint
 */
private ObjectNode encodeWaypointConstraint() {
    checkNotNull(constraint, "Waypoint constraint cannot be null");
    final WaypointConstraint waypointConstraint =
            (WaypointConstraint) constraint;

    final ObjectNode result = context.mapper().createObjectNode();
    final ArrayNode jsonWaypoints = result.putArray("waypoints");

    for (DeviceId did : waypointConstraint.waypoints()) {
        jsonWaypoints.add(did.toString());
    }

    return result;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:20,代码来源:EncodeConstraintCodecHelper.java

示例13: setUsers

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
public static void setUsers(ObjectNode task, String... users)
{
	ArrayNode userArray = task.putArray("users");
	for( String user : users )
	{
		userArray.add(user);
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:9,代码来源:Workflows.java

示例14: createWorkflowTask

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
protected ObjectNode createWorkflowTask(String name, boolean allowEditing, String... users)
{
	ObjectNode node = mapper.createObjectNode();
	node.put("name", name);
	node.put("type", "t");
	ArrayNode userArray = node.putArray("users");
	for( String user : users )
	{
		userArray.add(user);
	}
	node.put("allowEditing", allowEditing);
	return node;
}
 
开发者ID:equella,项目名称:Equella,代码行数:14,代码来源:AbstractEntityApiTest.java

示例15: updateIoCache

import com.fasterxml.jackson.databind.node.ObjectNode; //导入方法依赖的package包/类
private ObjectNode updateIoCache ( boolean isInitialRun ) {
	ObjectNode diskActivityReport = jacksonMapper.createObjectNode();

	String[] diskTestScript = {
			"#!/bin/bash",
			"iostat -dm",
			"" };
	String iostatOutput = "";
	try {
		iostatOutput = osCommandRunner.runUsingDefaultUser( "diskTest", diskTestScript );

		// Device: tps MB_read/s MB_wrtn/s MB_read MB_wrtn

		if ( isInitialRun ) {
			logger.info( "Results from {}, \n {}", Arrays.asList( diskTestScript ), iostatOutput );
		}

		if ( Application.isRunningOnDesktop() ) {

			iostatOutput = Application.getContents( new File( getClass()
				.getResource( "/linux/ioStatResults.txt" ).getFile() ) );

		}

		String[] iostatLines = iostatOutput.split( LINE_SEPARATOR );

		ArrayNode filteredLines = diskActivityReport.putArray( "filteredOutput" );
		int totalDiskReadMb = 0;
		int totalDiskWriteMb = 0;
		for ( int i = 0; i < iostatLines.length; i++ ) {

			String curline = iostatLines[i].replaceAll( "\\s+", " " );

			logger.debug( "Processing line: {}", curline );

			if ( curline != null && !curline.isEmpty() && curline.matches( csapApp.lifeCycleSettings().getIostatDeviceFilter() ) ) {
				filteredLines.add( curline );
				String[] fields = curline.split( " " );
				if ( fields.length == 6 ) {
					totalDiskReadMb += Integer.parseInt( fields[4] );
					totalDiskWriteMb += Integer.parseInt( fields[5] );
				}
			}

		}
		diskActivityReport.put( "totalDiskReadMb", totalDiskReadMb );
		diskActivityReport.put( "totalDiskWriteMb", totalDiskWriteMb );
	} catch (Exception e) {
		logger.info( "Results from {}, \n {}, \n {}",
			Arrays.asList( diskTestScript ), iostatOutput,
			CSAP.getCsapFilteredStackTrace( e ) );
	}

	return diskActivityReport;

}
 
开发者ID:csap-platform,项目名称:csap-core,代码行数:57,代码来源:OsManager.java


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