From 4866e0ccf3560efc1f45b92a58b46ae075f1d90b Mon Sep 17 00:00:00 2001 From: Kishore Date: Fri, 8 Jun 2018 16:22:40 -0700 Subject: [PATCH] Fixed local server start issues. Updated docs. Updates to BaseDynoDAOTest per code review. --- README.md | 6 +-- docs/docs/license.md | 2 +- .../dao/es5/index/ElasticSearchModuleV5.java | 5 +- .../conductor/dao/dynomite/BaseDynoDAO.java | 20 ++++---- .../dao/dynomite/BaseDynoDAOTest.java | 48 +++++++++++++++++++ 5 files changed, 63 insertions(+), 18 deletions(-) create mode 100644 redis-persistence/src/test/java/com/netflix/conductor/dao/dynomite/BaseDynoDAOTest.java diff --git a/README.md b/README.md index 5b61bb8668..f9e81fe6c1 100644 --- a/README.md +++ b/README.md @@ -15,10 +15,6 @@ Conductor is an _orchestration_ engine that runs in the cloud. ## Get Conductor Binaries are available from Maven Central and jcenter. -|Group|Artifact|Latest Stable Version| -|-----------|---------------|---------------------| -|com.netflix.conductor|conductor-*|1.5.+| - Below are the various artifacts published: |Artifact|Description| @@ -73,7 +69,7 @@ Conductor is maintained by Media Workflow Infrastructure team at Netflix. Use g ## LICENSE -Copyright (c) 2016 Netflix, Inc. +Copyright (c) 2018 Netflix, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/docs/docs/license.md b/docs/docs/license.md index afeaa78830..21146e7cb0 100644 --- a/docs/docs/license.md +++ b/docs/docs/license.md @@ -1,4 +1,4 @@ -Copyright 2016 Netflix, Inc. +Copyright 2018 Netflix, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/es5-persistence/src/main/java/com/netflix/conductor/dao/es5/index/ElasticSearchModuleV5.java b/es5-persistence/src/main/java/com/netflix/conductor/dao/es5/index/ElasticSearchModuleV5.java index 660aeb71c1..ac63184934 100644 --- a/es5-persistence/src/main/java/com/netflix/conductor/dao/es5/index/ElasticSearchModuleV5.java +++ b/es5-persistence/src/main/java/com/netflix/conductor/dao/es5/index/ElasticSearchModuleV5.java @@ -52,7 +52,10 @@ public Client getClient(Configuration config) throws Exception { log.warn("workflow.elasticsearch.url is not set. Indexing will remain DISABLED."); } - Settings settings = Settings.builder().put("client.transport.ignore_cluster_name",true).put("client.transport.sniff", true).build(); + Settings settings = Settings.builder() + .put("client.transport.ignore_cluster_name",true) + .put("client.transport.sniff", true) + .build(); TransportClient tc = new PreBuiltTransportClient(settings); String[] hosts = clusterAddress.split(","); diff --git a/redis-persistence/src/main/java/com/netflix/conductor/dao/dynomite/BaseDynoDAO.java b/redis-persistence/src/main/java/com/netflix/conductor/dao/dynomite/BaseDynoDAO.java index 6abccce414..e2200998e9 100644 --- a/redis-persistence/src/main/java/com/netflix/conductor/dao/dynomite/BaseDynoDAO.java +++ b/redis-persistence/src/main/java/com/netflix/conductor/dao/dynomite/BaseDynoDAO.java @@ -19,7 +19,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.netflix.conductor.core.config.Configuration; import com.netflix.conductor.metrics.Monitors; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -49,23 +49,21 @@ protected BaseDynoDAO(DynoProxy dynoClient, ObjectMapper objectMapper, Configura String nsKey(String... nsValues) { String rootNamespace = config.getProperty("workflow.namespace.prefix", null); - StringBuilder namespacedKey = new StringBuilder(rootNamespace).append(NAMESPACE_SEP); + StringBuilder namespacedKey = new StringBuilder(); + if (StringUtils.isNotBlank(rootNamespace)) { + namespacedKey.append(rootNamespace).append(NAMESPACE_SEP); + } String stack = config.getStack(); - if (stack != null && !stack.isEmpty()) { + if (StringUtils.isNotBlank(stack)) { namespacedKey.append(stack).append(NAMESPACE_SEP); } - if (domain != null && !domain.isEmpty()) { + if (StringUtils.isNotBlank(domain)) { namespacedKey.append(domain).append(NAMESPACE_SEP); } for (int i = 0; i < nsValues.length; i++) { - namespacedKey.append(nsValues[i]); - if (i < nsValues.length - 1) { - namespacedKey.append(NAMESPACE_SEP); - } + namespacedKey.append(nsValues[i]).append(NAMESPACE_SEP); } - //QUES cpewf.devint.test.WORKFLOW.UUID isSystemTask the stack in here same as the NETFLIX_STACK ? and what about the domain? - //Looking at the data saved in dynomite cpewf.WORKFLOW.UUID - return namespacedKey.toString(); + return StringUtils.removeEnd(namespacedKey.toString(), NAMESPACE_SEP); } public DynoProxy getDyno() { diff --git a/redis-persistence/src/test/java/com/netflix/conductor/dao/dynomite/BaseDynoDAOTest.java b/redis-persistence/src/test/java/com/netflix/conductor/dao/dynomite/BaseDynoDAOTest.java new file mode 100644 index 0000000000..78f3f7c157 --- /dev/null +++ b/redis-persistence/src/test/java/com/netflix/conductor/dao/dynomite/BaseDynoDAOTest.java @@ -0,0 +1,48 @@ +package com.netflix.conductor.dao.dynomite; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.netflix.conductor.core.config.Configuration; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.runners.MockitoJUnitRunner; + +import static org.junit.Assert.*; + +@RunWith(MockitoJUnitRunner.class) +public class BaseDynoDAOTest { + + @Mock + private DynoProxy dynoClient; + + @Mock + private ObjectMapper objectMapper; + + @Mock + private Configuration config; + + private BaseDynoDAO baseDynoDAO; + + @Before + public void setUp() { + this.baseDynoDAO = new BaseDynoDAO(dynoClient, objectMapper, config); + } + + @Test + public void testNsKey() { + assertEquals("", baseDynoDAO.nsKey()); + + String[] keys = {"key1", "key2"}; + assertEquals("key1.key2", baseDynoDAO.nsKey(keys)); + + Mockito.when(config.getProperty("workflow.namespace.prefix", null)).thenReturn("test"); + assertEquals("test", baseDynoDAO.nsKey()); + + assertEquals("test.key1.key2", baseDynoDAO.nsKey(keys)); + + Mockito.when(config.getStack()).thenReturn("stack"); + assertEquals("test.stack.key1.key2", baseDynoDAO.nsKey(keys)); + } +} \ No newline at end of file