use of com.netflix.conductor.common.utils.JsonMapperProvider in project conductor by Netflix.
the class TestElasticSearchDAOV5 method startServer.
@BeforeClass
public static void startServer() throws Exception {
System.setProperty(ElasticSearchConfiguration.EMBEDDED_PORT_PROPERTY_NAME, "9203");
System.setProperty(ElasticSearchConfiguration.ELASTIC_SEARCH_URL_PROPERTY_NAME, "localhost:9303");
System.setProperty(ElasticSearchConfiguration.ELASTIC_SEARCH_INDEX_BATCH_SIZE_PROPERTY_NAME, "1");
configuration = new SystemPropertiesElasticSearchConfiguration();
String host = configuration.getEmbeddedHost();
int port = configuration.getEmbeddedPort();
String clusterName = configuration.getEmbeddedClusterName();
embeddedElasticSearch = new EmbeddedElasticSearchV5(clusterName, host, port);
embeddedElasticSearch.start();
ElasticSearchTransportClientProvider transportClientProvider = new ElasticSearchTransportClientProvider(configuration);
elasticSearchClient = transportClientProvider.get();
elasticSearchClient.admin().cluster().prepareHealth().setWaitForGreenStatus().execute().get();
ObjectMapper objectMapper = new JsonMapperProvider().get();
indexDAO = new ElasticSearchDAOV5(elasticSearchClient, configuration, objectMapper);
}
use of com.netflix.conductor.common.utils.JsonMapperProvider in project conductor by Netflix.
the class ElasticSearchBaseDAO method applyIndexPrefixToTemplate.
private String applyIndexPrefixToTemplate(String text) throws JsonProcessingException {
ObjectMapper mapper = new JsonMapperProvider().get();
String indexPatternsFieldName = "index_patterns";
JsonNode root = mapper.readTree(text);
if (root != null) {
JsonNode indexPatternsNodeValue = root.get(indexPatternsFieldName);
if (indexPatternsNodeValue != null && indexPatternsNodeValue.isArray()) {
ArrayList<String> patternsWithPrefix = new ArrayList<>();
indexPatternsNodeValue.forEach(v -> {
String patternText = v.asText();
StringBuffer sb = new StringBuffer();
if (patternText.startsWith("*")) {
sb.append("*").append(indexPrefix).append("_").append(patternText.substring(1));
} else {
sb.append(indexPrefix).append("_").append(patternText);
}
patternsWithPrefix.add(sb.toString());
});
((ObjectNode) root).set(indexPatternsFieldName, mapper.valueToTree(patternsWithPrefix));
System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(root));
return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(root);
}
}
return text;
}
use of com.netflix.conductor.common.utils.JsonMapperProvider in project conductor by Netflix.
the class TestElasticSearchRestDAOV6 method startElasticSearchWithBatchSize.
private void startElasticSearchWithBatchSize(int i) throws Exception {
System.setProperty(ElasticSearchConfiguration.ELASTIC_SEARCH_INDEX_BATCH_SIZE_PROPERTY_NAME, String.valueOf(i));
configuration = new SystemPropertiesElasticSearchConfiguration();
String host = configuration.getEmbeddedHost();
int port = configuration.getEmbeddedPort();
String clusterName = configuration.getEmbeddedClusterName();
embeddedElasticSearch = new EmbeddedElasticSearchV6(clusterName, host, port);
embeddedElasticSearch.start();
ElasticSearchRestClientBuilderProvider restClientProvider = new ElasticSearchRestClientBuilderProvider(configuration);
RestClientBuilder restClientBuilder = restClientProvider.get();
restClient = restClientBuilder.build();
Map<String, String> params = new HashMap<>();
params.put("wait_for_status", "yellow");
params.put("timeout", "30s");
restClient.performRequest("GET", "/_cluster/health", params);
objectMapper = new JsonMapperProvider().get();
indexDAO = new ElasticSearchRestDAOV6(restClientBuilder, configuration, objectMapper);
}
use of com.netflix.conductor.common.utils.JsonMapperProvider in project conductor by Netflix.
the class ExecutionDAOFacadeTest method setUp.
@Before
public void setUp() {
executionDAO = mock(ExecutionDAO.class);
queueDAO = mock(QueueDAO.class);
indexDAO = mock(IndexDAO.class);
rateLimitingDao = mock(RateLimitingDAO.class);
pollDataDAO = mock(PollDataDAO.class);
objectMapper = new JsonMapperProvider().get();
Configuration configuration = new TestConfiguration();
executionDAOFacade = new ExecutionDAOFacade(executionDAO, queueDAO, indexDAO, rateLimitingDao, pollDataDAO, objectMapper, configuration);
}
use of com.netflix.conductor.common.utils.JsonMapperProvider in project conductor by Netflix.
the class JsonMapperProviderTest method testWorkflowSerDe.
@Test
public void testWorkflowSerDe() throws IOException {
WorkflowDef workflowDef = new WorkflowDef();
workflowDef.setName("testDef");
workflowDef.setVersion(2);
Workflow workflow = new Workflow();
workflow.setWorkflowDefinition(workflowDef);
workflow.setWorkflowId("test-workflow-id");
workflow.setStatus(Workflow.WorkflowStatus.RUNNING);
workflow.setStartTime(10L);
workflow.setInput(null);
Map<String, Object> data = new HashMap<>();
data.put("someKey", null);
data.put("someId", "abc123");
workflow.setOutput(data);
ObjectMapper objectMapper = new JsonMapperProvider().get();
String workflowPayload = objectMapper.writeValueAsString(workflow);
Workflow workflow1 = objectMapper.readValue(workflowPayload, Workflow.class);
assertTrue(workflow1.getOutput().containsKey("someKey"));
assertNull(workflow1.getOutput().get("someKey"));
assertNotNull(workflow1.getInput());
}
Aggregations