public static FunctionStatus decode(String json) throws IOException { return ObjectMapperFactory.getThreadLocal().readValue(json, FunctionStatus.class); } }
@Override protected ObjectMapper initialValue() throws Exception { return create(); } };
public static OffloaderDefinition getOffloaderDefinition(String narPath) throws IOException { try (NarClassLoader ncl = NarClassLoader.getFromArchive(new File(narPath), Collections.emptySet())) { String configStr = ncl.getServiceDefinition(PULSAR_OFFLOADER_SERVICE_NAME); return ObjectMapperFactory.getThreadLocalYaml().readValue(configStr, OffloaderDefinition.class); } }
@Override protected ObjectMapper initialValue() throws Exception { return createYaml(); } };
@Override protected ObjectMapper initialValue() throws Exception { return createYaml(); } };
public static FunctionStats decode (String json) throws IOException { return ObjectMapperFactory.getThreadLocal().readValue(json, FunctionStats.class); } }
public static Map<String, String> configureFromJsonString(String authParamsString) throws IOException { ObjectMapper jsonMapper = ObjectMapperFactory.create(); return jsonMapper.readValue(authParamsString, new TypeReference<HashMap<String, String>>() { }); }
String configStr = ncl.getServiceDefinition(PULSAR_OFFLOADER_SERVICE_NAME); OffloaderDefinition conf = ObjectMapperFactory.getThreadLocalYaml() .readValue(configStr, OffloaderDefinition.class); if (StringUtils.isEmpty(conf.getOffloaderFactoryClass())) {
public static SinkStatus decode(String json) throws IOException { return ObjectMapperFactory.getThreadLocal().readValue(json, SinkStatus.class); } }
@Override protected ObjectMapper initialValue() throws Exception { return create(); } };
public static OffloaderDefinition getOffloaderDefinition(String narPath) throws IOException { try (NarClassLoader ncl = NarClassLoader.getFromArchive(new File(narPath), Collections.emptySet())) { String configStr = ncl.getServiceDefinition(PULSAR_OFFLOADER_SERVICE_NAME); return ObjectMapperFactory.getThreadLocalYaml().readValue(configStr, OffloaderDefinition.class); } }
public static SourceStatus decode(String json) throws IOException { return ObjectMapperFactory.getThreadLocal().readValue(json, SourceStatus.class); } }
public JacksonConfigurator() { mapper = ObjectMapperFactory.create(); }
public static ConnectorDefinition getConnectorDefinition(String narPath) throws IOException { try (NarClassLoader ncl = NarClassLoader.getFromArchive(new File(narPath), Collections.emptySet())) { String configStr = ncl.getServiceDefinition(PULSAR_IO_SERVICE_NAME); return ObjectMapperFactory.getThreadLocalYaml().readValue(configStr, ConnectorDefinition.class); } }
/** * Get the JSON of this object as a byte[]. * * @return A byte[] of this object's JSON. * @throws JsonProcessingException */ @JsonIgnore public byte[] getJsonBytes() throws JsonProcessingException { return ObjectMapperFactory.getThreadLocal().writeValueAsBytes(this); }
public static Map<String, String> configureFromJsonString(String authParamsString) throws IOException { ObjectMapper jsonMapper = ObjectMapperFactory.create(); return jsonMapper.readValue(authParamsString, new TypeReference<HashMap<String, String>>() { }); }
String configStr = ncl.getServiceDefinition(PULSAR_OFFLOADER_SERVICE_NAME); OffloaderDefinition conf = ObjectMapperFactory.getThreadLocalYaml() .readValue(configStr, OffloaderDefinition.class); if (StringUtils.isEmpty(conf.getOffloaderFactoryClass())) {
/** * Get the JSON of this object as a String. * * @return A String of this object's JSON. * @throws JsonProcessingException */ @JsonIgnore public String getJsonString() throws JsonProcessingException { return ObjectMapperFactory.getThreadLocal().writeValueAsString(this); } }
@Override void run() throws Exception { AllocatorStats stats = admin.brokerStats().getAllocatorStats(params.get(0)); ObjectMapper mapper = ObjectMapperFactory.create(); ObjectWriter writer = mapper.writerWithDefaultPrettyPrinter(); out.write(writer.writeValueAsString(stats)); out.flush(); }
/** * Extract the Pulsar IO Sink class from a connector archive. */ public static String getIOSinkClass(String narPath) throws IOException { try (NarClassLoader ncl = NarClassLoader.getFromArchive(new File(narPath), Collections.emptySet())) { String configStr = ncl.getServiceDefinition(PULSAR_IO_SERVICE_NAME); ConnectorDefinition conf = ObjectMapperFactory.getThreadLocalYaml().readValue(configStr, ConnectorDefinition.class); if (StringUtils.isEmpty(conf.getSinkClass())) { throw new IOException( String.format("The '%s' connector does not provide a sink implementation", conf.getName())); } try { // Try to load source class and check it implements Sink interface Object instance = ncl.loadClass(conf.getSinkClass()).newInstance(); if (!(instance instanceof Sink)) { throw new IOException( "Class " + conf.getSinkClass() + " does not implement interface " + Sink.class.getName()); } } catch (Throwable t) { Exceptions.rethrowIOException(t); } return conf.getSinkClass(); } }