本文整理了Java中org.apache.metron.common.utils.JSONUtils.toJSONPretty()
方法的一些代码示例,展示了JSONUtils.toJSONPretty()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSONUtils.toJSONPretty()
方法的具体详情如下:
包路径:org.apache.metron.common.utils.JSONUtils
类名称:JSONUtils
方法名:toJSONPretty
暂无
代码示例来源:origin: apache/metron
public static void writeGlobalConfigToZookeeper(Map
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
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
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
try{
List
{
//we want one of the fields without a destination IP to ensure that enrichments can function
Map
, 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
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));
}