热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

org.apache.metron.common.utils.JSONUtils.toJSONPretty()方法的使用及代码示例

本文整理了Java中org.apache.metron.common.utils.JSONUtils.toJSONPretty()方法的一些代码示例,展示了

本文整理了Java中org.apache.metron.common.utils.JSONUtils.toJSONPretty()方法的一些代码示例,展示了JSONUtils.toJSONPretty()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSONUtils.toJSONPretty()方法的具体详情如下:
包路径:org.apache.metron.common.utils.JSONUtils
类名称:JSONUtils
方法名:toJSONPretty

JSONUtils.toJSONPretty介绍

暂无

代码示例

代码示例来源:origin: apache/metron

public static void writeGlobalConfigToZookeeper(Map globalConfig, CuratorFramework client) throws Exception {
writeGlobalConfigToZookeeper(JSONUtils.INSTANCE.toJSONPretty(globalConfig), client);
}

代码示例来源:origin: apache/metron

public static void writeSensorParserConfigToZookeeper(String sensorType, SensorParserConfig sensorParserConfig, String zookeeperUrl) throws Exception {
writeSensorParserConfigToZookeeper(sensorType, JSONUtils.INSTANCE.toJSONPretty(sensorParserConfig), zookeeperUrl);
}

代码示例来源:origin: apache/metron

public static void writeSensorIndexingConfigToZookeeper(String sensorType, Map sensorIndexingConfig, String zookeeperUrl) throws Exception {
writeSensorIndexingConfigToZookeeper(sensorType, JSONUtils.INSTANCE.toJSONPretty(sensorIndexingConfig), zookeeperUrl);
}

代码示例来源:origin: apache/metron

public static void writeSensorEnrichmentConfigToZookeeper(String sensorType, SensorEnrichmentConfig sensorEnrichmentConfig, String zookeeperUrl) throws Exception {
writeSensorEnrichmentConfigToZookeeper(sensorType, JSONUtils.INSTANCE.toJSONPretty(sensorEnrichmentConfig), zookeeperUrl);
}

代码示例来源:origin: apache/metron

public byte[] toJSONPretty(String config) throws IOException {
return toJSONPretty(readTree(config));
}

代码示例来源:origin: apache/metron

public static void writeConfigToZookeeper(String name, Map config, String zookeeperUrl) throws Exception {
writeConfigToZookeeper(Constants.ZOOKEEPER_TOPOLOGY_ROOT + "/" + name, JSONUtils.INSTANCE.toJSONPretty(config), zookeeperUrl);
}

代码示例来源:origin: apache/metron

public byte[] applyPatch(byte[] patch, byte[] source) throws IOException {
JsonNode patchNode = readTree(patch);
JsonNode sourceNode = readTree(source);
return toJSONPretty(JsonPatch.apply(patchNode, sourceNode));
}

代码示例来源:origin: apache/metron

@Test
public void modifiesSingleParserConfiguration() throws Exception {
// write parser configuration
ConfigurationType type = ConfigurationType.PARSER;
String parserName = "a-happy-metron-parser";
byte[] cOnfig= JSONUtils.INSTANCE.toJSONPretty(someParserConfig);
ConfigurationsUtils.writeConfigToZookeeper(type, Optional.of(parserName), config, zookeeperUrl);
// validate the modified parser configuration
byte[] actual = ConfigurationsUtils.readConfigBytesFromZookeeper(type, Optional.of(parserName), zookeeperUrl);
assertThat(actual, equalTo(JSONUtils.INSTANCE.toJSONPretty(someParserConfig)));
}

代码示例来源:origin: apache/metron

protected Put buildPut(Document update) throws IOException {
Key k = new Key(update.getGuid(), update.getSensorType());
Put put = new Put(Key.toBytes(k));
long ts = update.getTimestamp() == null || update.getTimestamp() == 0 ? System.currentTimeMillis() : update.getTimestamp();
byte[] columnQualifier = Bytes.toBytes(ts);
byte[] doc = JSONUtils.INSTANCE.toJSONPretty(update.getDocument());
put.addColumn(cf, columnQualifier, doc);
return put;
}

代码示例来源:origin: apache/metron

@Test
public void patchesParserConfigurationViaPatchJSON() throws Exception {
// setup zookeeper with a configuration
final ConfigurationType type = ConfigurationType.PARSER;
final String parserName = "patched-metron-parser";
byte[] cOnfig= JSONUtils.INSTANCE.toJSONPretty(someParserConfig);
ConfigurationsUtils.writeConfigToZookeeper(type, Optional.of(parserName), config, zookeeperUrl);
// patch the configuration
byte[] patch = JSONUtils.INSTANCE.toJSONPretty(patchParserConfig);
ConfigurationsUtils.applyConfigPatchToZookeeper(type, Optional.of(parserName), patch, zookeeperUrl);
// validate the patched configuration
byte[] actual = ConfigurationsUtils.readConfigBytesFromZookeeper(type, Optional.of(parserName), zookeeperUrl);
byte[] expected = JSONUtils.INSTANCE.toJSONPretty(modifiedParserConfig);
assertThat(actual, equalTo(expected));
}

代码示例来源:origin: apache/metron

@Test
public void modifiedGlobalConfiguration() throws Exception {
// write global configuration
ConfigurationType type = ConfigurationType.GLOBAL;
ConfigurationsUtils.writeConfigToZookeeper(type, JSONUtils.INSTANCE.toJSONPretty(someParserConfig), zookeeperUrl);
// validate the modified global configuration
byte[] actual = ConfigurationsUtils.readConfigBytesFromZookeeper(type, zookeeperUrl);
assertThat(actual, equalTo(JSONUtils.INSTANCE.toJSONPretty(someParserConfig)));
}

代码示例来源:origin: apache/metron

private static List getInputMessages(String path){
try{
List ret = TestUtils.readSampleData(path);
{
//we want one of the fields without a destination IP to ensure that enrichments can function
Map sansDestinatiOnIp= JSONUtils.INSTANCE.load(new String(ret.get(ret.size() -1))
, JSONUtils.MAP_SUPPLIER);
sansDestinationIp.remove(Constants.Fields.DST_ADDR.getName());
ret.add(JSONUtils.INSTANCE.toJSONPretty(sansDestinationIp));
}
return ret;
}catch(IOException ioe){
return null;
}
}

代码示例来源:origin: apache/metron

@Test
public void testPatchParserFromKeyValue() throws Exception {
// push the parser config
File cOnfigFile= new File(parsersDir, "myparser.json");
TestUtils.write(configFile, squidParserConfig);
pushConfigs(PARSER, configDir, Optional.of("myparser"));
// patch the parser configuration
patchConfigs(PARSER, Optional.empty(), Optional.of("myparser"), Optional.of(ADD), Optional.of("/parserConfig/timestampField"), Optional.of("\"\"heyjoe\"\""));
// validate the patch
byte[] expected = JSONUtils.INSTANCE.toJSONPretty(expectedPatchedParser);
byte[] actual = JSONUtils.INSTANCE.toJSONPretty(stripLines(dumpConfigs(PARSER, Optional.of("myparser")), 1));
Assert.assertThat(actual, equalTo(expected));
}

代码示例来源:origin: apache/metron

@Test
public void testPatchGlobalFromComplexKeyValue() throws Exception {
// write a global configuration
File cOnfigFile= new File(configDir, "global.json");
TestUtils.write(configFile, globalConfig);
pushConfigs(GLOBAL, configDir, Optional.of("global"));
// patch the global configuration
patchConfigs(GLOBAL, Optional.empty(), Optional.of("global"), Optional.of(ADD), Optional.of("/foo"), Optional.of("{ \"bar\" : { \"baz\" : [ \"bazval1\", \"bazval2\" ] } }"));
// validate the patch
byte[] expected = JSONUtils.INSTANCE.toJSONPretty(expectedComplexConfig);
byte[] actual = JSONUtils.INSTANCE.toJSONPretty(stripLines(dumpConfigs(GLOBAL, Optional.of("global")), 1));
Assert.assertThat(actual, equalTo(expected));
}

代码示例来源:origin: apache/metron

@Test
public void testPushIndexing() throws Exception {
// write the indexing config
File cOnfigFile= new File(indexingDir, "myindex.json");
TestUtils.write(configFile, someIndexingConfig);
// push the index config
pushConfigs(INDEXING, configDir, Optional.of("myindex"));
// validate
byte[] expected = JSONUtils.INSTANCE.toJSONPretty(someIndexingConfig);
byte[] actual = JSONUtils.INSTANCE.toJSONPretty(stripLines(dumpConfigs(INDEXING, Optional.of("myindex")), 1));
Assert.assertThat(actual, equalTo(expected));
}

代码示例来源:origin: apache/metron

@Test
public void testPushParser() throws Exception {
// create a parser config
File cOnfigFile= new File(parsersDir, "myparser.json");
TestUtils.write(configFile, squidParserConfig);
// push the parser config
pushConfigs(PARSER, configDir, Optional.of("myparser"));
// validate
byte[] expected = JSONUtils.INSTANCE.toJSONPretty(squidParserConfig);
byte[] actual = JSONUtils.INSTANCE.toJSONPretty(stripLines(dumpConfigs(PARSER, Optional.of("myparser")), 1));
Assert.assertThat(actual, equalTo(expected));
}

代码示例来源:origin: apache/metron

@Test
public void testPushEnrichment() throws Exception {
// create enrichment config
File cOnfigFile= new File(enrichmentsDir, "myenrichment.json");
TestUtils.write(configFile, someEnrichmentConfig);
// push enrichment config
pushConfigs(ENRICHMENT, configDir, Optional.of("myenrichment"));
// validate
byte[] expected = JSONUtils.INSTANCE.toJSONPretty(someEnrichmentConfig);
byte[] actual = JSONUtils.INSTANCE.toJSONPretty(stripLines(dumpConfigs(ENRICHMENT, Optional.of("myenrichment")), 1));
Assert.assertThat(actual, equalTo(expected));
}

代码示例来源:origin: apache/metron

@Test
public void testPatchGlobalFromFile() throws Exception {
// create a patch file
File patchFile = new File(tmpDir, "global-config-patch.json");
TestUtils.write(patchFile, somePatchConfig);
// create the global config
File cOnfigFile= new File(configDir, "global.json");
TestUtils.write(configFile, globalConfig);
pushConfigs(GLOBAL, configDir, Optional.of("global"));
// patch the global config
patchConfigs(GLOBAL, Optional.of(patchFile), Optional.of("global"), Optional.empty(), Optional.empty(), Optional.empty());
// validate the patch
byte[] expected = JSONUtils.INSTANCE.toJSONPretty(expectedSomeConfig);
byte[] actual = JSONUtils.INSTANCE.toJSONPretty(stripLines(dumpConfigs(GLOBAL, Optional.of("global")), 1));
Assert.assertThat(actual, equalTo(expected));
}

代码示例来源:origin: apache/metron

@Test
public void testPushGlobal() throws Exception {
// create the config
File cOnfigFile= new File(configDir, "global.json");
TestUtils.write(configFile, globalConfig);
// push the global config
pushConfigs(GLOBAL, configDir);
// validate
byte[] expected = JSONUtils.INSTANCE.toJSONPretty(globalConfig);
byte[] actual = JSONUtils.INSTANCE.toJSONPretty(stripLines(dumpConfigs(GLOBAL), 1));
Assert.assertThat(actual, equalTo(expected));
}

代码示例来源:origin: apache/metron

@Test
public void testPushProfiler() throws Exception {
// create the profiler config
File cOnfigFile= new File(configDir, "profiler.json");
TestUtils.write(configFile, someProfilerConfig);
// push the profiler config
Optional cOnfigName= Optional.empty();
pushConfigs(PROFILER, configDir, configName);
// validate
byte[] expected = JSONUtils.INSTANCE.toJSONPretty(someProfilerConfig);
byte[] actual = JSONUtils.INSTANCE.toJSONPretty(stripLines(dumpConfigs(PROFILER, configName), 1));
Assert.assertThat(actual, equalTo(expected));
}

推荐阅读
  • 本文分析了Wince程序内存和存储内存的分布及作用。Wince内存包括系统内存、对象存储和程序内存,其中系统内存占用了一部分SDRAM,而剩下的30M为程序内存和存储内存。对象存储是嵌入式wince操作系统中的一个新概念,常用于消费电子设备中。此外,文章还介绍了主电源和后备电池在操作系统中的作用。 ... [详细]
  • 本文介绍了Oracle数据库中tnsnames.ora文件的作用和配置方法。tnsnames.ora文件在数据库启动过程中会被读取,用于解析LOCAL_LISTENER,并且与侦听无关。文章还提供了配置LOCAL_LISTENER和1522端口的示例,并展示了listener.ora文件的内容。 ... [详细]
  • http:my.oschina.netleejun2005blog136820刚看到群里又有同学在说HTTP协议下的Get请求参数长度是有大小限制的,最大不能超过XX ... [详细]
  • 标题: ... [详细]
  • 本文介绍了在处理不规则数据时如何使用Python自动提取文本中的时间日期,包括使用dateutil.parser模块统一日期字符串格式和使用datefinder模块提取日期。同时,还介绍了一段使用正则表达式的代码,可以支持中文日期和一些特殊的时间识别,例如'2012年12月12日'、'3小时前'、'在2012/12/13哈哈'等。 ... [详细]
  • 本文介绍了一个适用于PHP应用快速接入TRX和TRC20数字资产的开发包,该开发包支持使用自有Tron区块链节点的应用场景,也支持基于Tron官方公共API服务的轻量级部署场景。提供的功能包括生成地址、验证地址、查询余额、交易转账、查询最新区块和查询交易信息等。详细信息可参考tron-php的Github地址:https://github.com/Fenguoz/tron-php。 ... [详细]
  • 图像因存在错误而无法显示 ... [详细]
  • 本文介绍了RxJava在Android开发中的广泛应用以及其在事件总线(Event Bus)实现中的使用方法。RxJava是一种基于观察者模式的异步java库,可以提高开发效率、降低维护成本。通过RxJava,开发者可以实现事件的异步处理和链式操作。对于已经具备RxJava基础的开发者来说,本文将详细介绍如何利用RxJava实现事件总线,并提供了使用建议。 ... [详细]
  • Gitlab接入公司内部单点登录的安装和配置教程
    本文介绍了如何将公司内部的Gitlab系统接入单点登录服务,并提供了安装和配置的详细教程。通过使用oauth2协议,将原有的各子系统的独立登录统一迁移至单点登录。文章包括Gitlab的安装环境、版本号、编辑配置文件的步骤,并解决了在迁移过程中可能遇到的问题。 ... [详细]
  • YOLOv7基于自己的数据集从零构建模型完整训练、推理计算超详细教程
    本文介绍了关于人工智能、神经网络和深度学习的知识点,并提供了YOLOv7基于自己的数据集从零构建模型完整训练、推理计算的详细教程。文章还提到了郑州最低生活保障的话题。对于从事目标检测任务的人来说,YOLO是一个熟悉的模型。文章还提到了yolov4和yolov6的相关内容,以及选择模型的优化思路。 ... [详细]
  • 安装mysqlclient失败解决办法
    本文介绍了在MAC系统中,使用django使用mysql数据库报错的解决办法。通过源码安装mysqlclient或将mysql_config添加到系统环境变量中,可以解决安装mysqlclient失败的问题。同时,还介绍了查看mysql安装路径和使配置文件生效的方法。 ... [详细]
  • 本文介绍了Web学习历程记录中关于Tomcat的基本概念和配置。首先解释了Web静态Web资源和动态Web资源的概念,以及C/S架构和B/S架构的区别。然后介绍了常见的Web服务器,包括Weblogic、WebSphere和Tomcat。接着详细讲解了Tomcat的虚拟主机、web应用和虚拟路径映射的概念和配置过程。最后简要介绍了http协议的作用。本文内容详实,适合初学者了解Tomcat的基础知识。 ... [详细]
  • 解决VS写C#项目导入MySQL数据源报错“You have a usable connection already”问题的正确方法
    本文介绍了在VS写C#项目导入MySQL数据源时出现报错“You have a usable connection already”的问题,并给出了正确的解决方法。详细描述了问题的出现情况和报错信息,并提供了解决该问题的步骤和注意事项。 ... [详细]
  • Oracle seg,V$TEMPSEG_USAGE与Oracle排序的关系及使用方法
    本文介绍了Oracle seg,V$TEMPSEG_USAGE与Oracle排序之间的关系,V$TEMPSEG_USAGE是V_$SORT_USAGE的同义词,通过查询dba_objects和dba_synonyms视图可以了解到它们的详细信息。同时,还探讨了V$TEMPSEG_USAGE的使用方法。 ... [详细]
  • 本文介绍了Python爬虫技术基础篇面向对象高级编程(中)中的多重继承概念。通过继承,子类可以扩展父类的功能。文章以动物类层次的设计为例,讨论了按照不同分类方式设计类层次的复杂性和多重继承的优势。最后给出了哺乳动物和鸟类的设计示例,以及能跑、能飞、宠物类和非宠物类的增加对类数量的影响。 ... [详细]
author-avatar
weneay
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有