[jira] [Work logged] (KNOX-2301) Trigger discovery for descriptors at gateway start time

2020-03-23 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/KNOX-2301?focusedWorklogId=408062=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-408062
 ]

ASF GitHub Bot logged work on KNOX-2301:


Author: ASF GitHub Bot
Created on: 23/Mar/20 17:05
Start Date: 23/Mar/20 17:05
Worklog Time Spent: 10m 
  Work Description: pzampino commented on pull request #297: KNOX-2301 and 
KNOX-2302
URL: https://github.com/apache/knox/pull/297
 
 
   
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 408062)
Time Spent: 4h 40m  (was: 4.5h)

> Trigger discovery for descriptors at gateway start time
> ---
>
> Key: KNOX-2301
> URL: https://issues.apache.org/jira/browse/KNOX-2301
> Project: Apache Knox
>  Issue Type: Improvement
>  Components: Server
>Affects Versions: 1.4.0
>Reporter: Philip Zampino
>Assignee: Philip Zampino
>Priority: Major
>  Time Spent: 4h 40m
>  Remaining Estimate: 0h
>
> Discovery and topology generation is triggered only by changes to provider 
> configuration or descriptor files on disk. Knox should also perform discovery 
> for all existing descriptors (that include discovery config) when the gateway 
> is started.
> This will help ensure that the generated topologies are accurate reflections 
> of the proxied services' configurations.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (KNOX-2301) Trigger discovery for descriptors at gateway start time

2020-03-23 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/KNOX-2301?focusedWorklogId=407912=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-407912
 ]

ASF GitHub Bot logged work on KNOX-2301:


Author: ASF GitHub Bot
Created on: 23/Mar/20 14:18
Start Date: 23/Mar/20 14:18
Worklog Time Spent: 10m 
  Work Description: pzampino commented on pull request #297: KNOX-2301 and 
KNOX-2302
URL: https://github.com/apache/knox/pull/297#discussion_r396484281
 
 

 ##
 File path: 
gateway-server/src/main/java/org/apache/knox/gateway/services/topology/impl/DefaultTopologyService.java
 ##
 @@ -556,6 +553,11 @@ public void startMonitor() throws Exception {
 
log.remoteConfigurationMonitorStartFailure(remoteMonitor.getClass().getTypeName(),
 e.getLocalizedMessage());
   }
 }
+
+// Trigger descriptor discovery (KNOX-2301)
+for (File descriptor : getDescriptors()) {
+  descriptor.setLastModified(System.currentTimeMillis()); // 'Touch' the 
descriptor
+}
 
 Review comment:
   This is the reason for the comment, but pulling it out into a separate 
explicitly-named method is more clear and resilient to future confusion from 
the comment not being updated.
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 407912)
Time Spent: 4.5h  (was: 4h 20m)

> Trigger discovery for descriptors at gateway start time
> ---
>
> Key: KNOX-2301
> URL: https://issues.apache.org/jira/browse/KNOX-2301
> Project: Apache Knox
>  Issue Type: Improvement
>  Components: Server
>Affects Versions: 1.4.0
>Reporter: Philip Zampino
>Assignee: Philip Zampino
>Priority: Major
>  Time Spent: 4.5h
>  Remaining Estimate: 0h
>
> Discovery and topology generation is triggered only by changes to provider 
> configuration or descriptor files on disk. Knox should also perform discovery 
> for all existing descriptors (that include discovery config) when the gateway 
> is started.
> This will help ensure that the generated topologies are accurate reflections 
> of the proxied services' configurations.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (KNOX-2301) Trigger discovery for descriptors at gateway start time

2020-03-23 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/KNOX-2301?focusedWorklogId=407909=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-407909
 ]

ASF GitHub Bot logged work on KNOX-2301:


Author: ASF GitHub Bot
Created on: 23/Mar/20 14:16
Start Date: 23/Mar/20 14:16
Worklog Time Spent: 10m 
  Work Description: pzampino commented on pull request #297: KNOX-2301 and 
KNOX-2302
URL: https://github.com/apache/knox/pull/297#discussion_r396482734
 
 

 ##
 File path: 
gateway-topology-simple/src/main/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorHandler.java
 ##
 @@ -571,13 +579,49 @@ private static File 
resolveProviderConfigurationReference(final String reference
 if (topologyFilename == null) {
 topologyFilename = desc.getCluster();
 }
+
 topologyDescriptor = new File(destDirectory, topologyFilename + 
".xml");
 
-try (OutputStream outputStream = 
Files.newOutputStream(topologyDescriptor.toPath());
- OutputStreamWriter outputStreamWriter = new 
OutputStreamWriter(outputStream, StandardCharsets.UTF_8);
- BufferedWriter fw = new BufferedWriter(outputStreamWriter)) {
-  fw.write(sw.toString());
-  fw.flush();
+// KNOX-2302
+boolean persistGenerated = false;
+// Determine if the topology already exists.
+if (topologyDescriptor.exists()) {
 
 Review comment:
   +1
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 407909)
Time Spent: 4h 20m  (was: 4h 10m)

> Trigger discovery for descriptors at gateway start time
> ---
>
> Key: KNOX-2301
> URL: https://issues.apache.org/jira/browse/KNOX-2301
> Project: Apache Knox
>  Issue Type: Improvement
>  Components: Server
>Affects Versions: 1.4.0
>Reporter: Philip Zampino
>Assignee: Philip Zampino
>Priority: Major
>  Time Spent: 4h 20m
>  Remaining Estimate: 0h
>
> Discovery and topology generation is triggered only by changes to provider 
> configuration or descriptor files on disk. Knox should also perform discovery 
> for all existing descriptors (that include discovery config) when the gateway 
> is started.
> This will help ensure that the generated topologies are accurate reflections 
> of the proxied services' configurations.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (KNOX-2301) Trigger discovery for descriptors at gateway start time

2020-03-23 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/KNOX-2301?focusedWorklogId=407904=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-407904
 ]

ASF GitHub Bot logged work on KNOX-2301:


Author: ASF GitHub Bot
Created on: 23/Mar/20 14:06
Start Date: 23/Mar/20 14:06
Worklog Time Spent: 10m 
  Work Description: pzampino commented on pull request #297: KNOX-2301 and 
KNOX-2302
URL: https://github.com/apache/knox/pull/297#discussion_r396475589
 
 

 ##
 File path: 
gateway-topology-simple/src/main/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorHandler.java
 ##
 @@ -571,13 +579,49 @@ private static File 
resolveProviderConfigurationReference(final String reference
 if (topologyFilename == null) {
 topologyFilename = desc.getCluster();
 }
+
 topologyDescriptor = new File(destDirectory, topologyFilename + 
".xml");
 
-try (OutputStream outputStream = 
Files.newOutputStream(topologyDescriptor.toPath());
- OutputStreamWriter outputStreamWriter = new 
OutputStreamWriter(outputStream, StandardCharsets.UTF_8);
- BufferedWriter fw = new BufferedWriter(outputStreamWriter)) {
-  fw.write(sw.toString());
-  fw.flush();
+// KNOX-2302
+boolean persistGenerated = false;
+// Determine if the topology already exists.
+if (topologyDescriptor.exists()) {
+// If it does, only overwrite it if it has changed (KNOX-2302)
+// Compare the generated topology with the in-memory topology
+Topology existing = null;
+TopologyService topologyService = 
gwServices.getService(ServiceType.TOPOLOGY_SERVICE);
+for (Topology t : topologyService.getTopologies()) {
+if (topologyFilename.equals(t.getName())) {
+existing = t;
+break;
+}
 
 Review comment:
   I feel this is out of scope. It is not required for this PR.
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 407904)
Time Spent: 4h 10m  (was: 4h)

> Trigger discovery for descriptors at gateway start time
> ---
>
> Key: KNOX-2301
> URL: https://issues.apache.org/jira/browse/KNOX-2301
> Project: Apache Knox
>  Issue Type: Improvement
>  Components: Server
>Affects Versions: 1.4.0
>Reporter: Philip Zampino
>Assignee: Philip Zampino
>Priority: Major
>  Time Spent: 4h 10m
>  Remaining Estimate: 0h
>
> Discovery and topology generation is triggered only by changes to provider 
> configuration or descriptor files on disk. Knox should also perform discovery 
> for all existing descriptors (that include discovery config) when the gateway 
> is started.
> This will help ensure that the generated topologies are accurate reflections 
> of the proxied services' configurations.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (KNOX-2301) Trigger discovery for descriptors at gateway start time

2020-03-23 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/KNOX-2301?focusedWorklogId=407903=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-407903
 ]

ASF GitHub Bot logged work on KNOX-2301:


Author: ASF GitHub Bot
Created on: 23/Mar/20 14:05
Start Date: 23/Mar/20 14:05
Worklog Time Spent: 10m 
  Work Description: pzampino commented on pull request #297: KNOX-2301 and 
KNOX-2302
URL: https://github.com/apache/knox/pull/297#discussion_r396475018
 
 

 ##
 File path: 
gateway-spi/src/main/java/org/apache/knox/gateway/topology/Service.java
 ##
 @@ -122,32 +122,61 @@ public boolean equals(Object object) {
   return false;
 }
 Service that = (Service) object;
-String thatName = that.getName();
+String thatName = that.name;
 if (thatName != null && !(thatName.equals(name))) {
 return false;
 }
-String thatRole = that.getRole();
+String thatRole = that.role;
 if (thatRole != null && !thatRole.equals(role)) {
 return false;
 }
-Version thatVersion = that.getVersion();
+Version thatVersion = that.version;
 if (thatVersion != null && !(thatVersion.equals(version))) {
 return false;
 }
+
+// URLs
+if (urls.size() != that.urls.size()) {
+  return false;
+}
+
+for (String url : urls) {
+  if (!that.urls.contains(url)) {
+return false;
+  }
+}
+
+// Params
+if (params.size() != that.params.size()) {
+  return false;
+}
+
+for (Map.Entry param : params.entrySet()) {
+  if (!param.getValue().equals(that.params.get(param.getKey( {
+return false;
+  }
+}
+
 return true;
   }
 
   @Override
   public int hashCode() {
 
 Review comment:
   +1
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 407903)
Time Spent: 4h  (was: 3h 50m)

> Trigger discovery for descriptors at gateway start time
> ---
>
> Key: KNOX-2301
> URL: https://issues.apache.org/jira/browse/KNOX-2301
> Project: Apache Knox
>  Issue Type: Improvement
>  Components: Server
>Affects Versions: 1.4.0
>Reporter: Philip Zampino
>Assignee: Philip Zampino
>Priority: Major
>  Time Spent: 4h
>  Remaining Estimate: 0h
>
> Discovery and topology generation is triggered only by changes to provider 
> configuration or descriptor files on disk. Knox should also perform discovery 
> for all existing descriptors (that include discovery config) when the gateway 
> is started.
> This will help ensure that the generated topologies are accurate reflections 
> of the proxied services' configurations.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (KNOX-2301) Trigger discovery for descriptors at gateway start time

2020-03-23 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/KNOX-2301?focusedWorklogId=407898=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-407898
 ]

ASF GitHub Bot logged work on KNOX-2301:


Author: ASF GitHub Bot
Created on: 23/Mar/20 13:53
Start Date: 23/Mar/20 13:53
Worklog Time Spent: 10m 
  Work Description: pzampino commented on pull request #297: KNOX-2301 and 
KNOX-2302
URL: https://github.com/apache/knox/pull/297#discussion_r396466614
 
 

 ##
 File path: 
gateway-test/src/test/java/org/apache/knox/gateway/AmbariServiceDefinitionTest.java
 ##
 @@ -114,6 +114,12 @@ public static void setupGateway() throws Exception {
 File deployDir = new File( config.getGatewayDeploymentDir() );
 deployDir.mkdirs();
 
+File descDir = new File( config.getGatewayDescriptorsDir() );
 
 Review comment:
   I had to make these changes to get the tests to pass. It is a side-effect 
requirement of the changes in this PR.
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 407898)
Time Spent: 3h 40m  (was: 3.5h)

> Trigger discovery for descriptors at gateway start time
> ---
>
> Key: KNOX-2301
> URL: https://issues.apache.org/jira/browse/KNOX-2301
> Project: Apache Knox
>  Issue Type: Improvement
>  Components: Server
>Affects Versions: 1.4.0
>Reporter: Philip Zampino
>Assignee: Philip Zampino
>Priority: Major
>  Time Spent: 3h 40m
>  Remaining Estimate: 0h
>
> Discovery and topology generation is triggered only by changes to provider 
> configuration or descriptor files on disk. Knox should also perform discovery 
> for all existing descriptors (that include discovery config) when the gateway 
> is started.
> This will help ensure that the generated topologies are accurate reflections 
> of the proxied services' configurations.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (KNOX-2301) Trigger discovery for descriptors at gateway start time

2020-03-23 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/KNOX-2301?focusedWorklogId=407899=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-407899
 ]

ASF GitHub Bot logged work on KNOX-2301:


Author: ASF GitHub Bot
Created on: 23/Mar/20 13:53
Start Date: 23/Mar/20 13:53
Worklog Time Spent: 10m 
  Work Description: pzampino commented on pull request #297: KNOX-2301 and 
KNOX-2302
URL: https://github.com/apache/knox/pull/297#discussion_r396466990
 
 

 ##
 File path: 
gateway-spi/src/main/java/org/apache/knox/gateway/topology/Provider.java
 ##
 @@ -82,4 +84,41 @@ public void setRole( String role ) {
 this.role = role;
   }
 
+  @Override
+  public int hashCode() {
+return new HashCodeBuilder().append(name)
+.append(role)
+.append(params)
+.append(enabled)
+.build();
+  }
+
+  @Override
+  public boolean equals(Object obj) {
 
 Review comment:
   +1
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 407899)
Time Spent: 3h 50m  (was: 3h 40m)

> Trigger discovery for descriptors at gateway start time
> ---
>
> Key: KNOX-2301
> URL: https://issues.apache.org/jira/browse/KNOX-2301
> Project: Apache Knox
>  Issue Type: Improvement
>  Components: Server
>Affects Versions: 1.4.0
>Reporter: Philip Zampino
>Assignee: Philip Zampino
>Priority: Major
>  Time Spent: 3h 50m
>  Remaining Estimate: 0h
>
> Discovery and topology generation is triggered only by changes to provider 
> configuration or descriptor files on disk. Knox should also perform discovery 
> for all existing descriptors (that include discovery config) when the gateway 
> is started.
> This will help ensure that the generated topologies are accurate reflections 
> of the proxied services' configurations.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (KNOX-2301) Trigger discovery for descriptors at gateway start time

2020-03-23 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/KNOX-2301?focusedWorklogId=407894=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-407894
 ]

ASF GitHub Bot logged work on KNOX-2301:


Author: ASF GitHub Bot
Created on: 23/Mar/20 13:52
Start Date: 23/Mar/20 13:52
Worklog Time Spent: 10m 
  Work Description: pzampino commented on pull request #297: KNOX-2301 and 
KNOX-2302
URL: https://github.com/apache/knox/pull/297#discussion_r396466116
 
 

 ##
 File path: 
gateway-spi/src/main/java/org/apache/knox/gateway/topology/Topology.java
 ##
 @@ -153,4 +161,106 @@ public void addProvider( Provider provider ) {
 nameMap.put( provider.getName(), provider );
   }
 
+  @Override
+  public int hashCode() {
+return (new HashCodeBuilder(17, 31)).append(name)
+.append(providerList)
+.append(services)
+.append(applications)
+.build();
+  }
+
+  @Override
+  public boolean equals(Object obj) {
 
 Review comment:
   Not using EqualsBuilder here because it does not handle potentially-null 
fields well.
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 407894)
Time Spent: 3.5h  (was: 3h 20m)

> Trigger discovery for descriptors at gateway start time
> ---
>
> Key: KNOX-2301
> URL: https://issues.apache.org/jira/browse/KNOX-2301
> Project: Apache Knox
>  Issue Type: Improvement
>  Components: Server
>Affects Versions: 1.4.0
>Reporter: Philip Zampino
>Assignee: Philip Zampino
>Priority: Major
>  Time Spent: 3.5h
>  Remaining Estimate: 0h
>
> Discovery and topology generation is triggered only by changes to provider 
> configuration or descriptor files on disk. Knox should also perform discovery 
> for all existing descriptors (that include discovery config) when the gateway 
> is started.
> This will help ensure that the generated topologies are accurate reflections 
> of the proxied services' configurations.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (KNOX-2301) Trigger discovery for descriptors at gateway start time

2020-03-23 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/KNOX-2301?focusedWorklogId=407890=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-407890
 ]

ASF GitHub Bot logged work on KNOX-2301:


Author: ASF GitHub Bot
Created on: 23/Mar/20 13:39
Start Date: 23/Mar/20 13:39
Worklog Time Spent: 10m 
  Work Description: pzampino commented on pull request #297: KNOX-2301 and 
KNOX-2302
URL: https://github.com/apache/knox/pull/297#discussion_r396455084
 
 

 ##
 File path: 
gateway-spi/src/main/java/org/apache/knox/gateway/topology/Topology.java
 ##
 @@ -153,4 +161,106 @@ public void addProvider( Provider provider ) {
 nameMap.put( provider.getName(), provider );
   }
 
+  @Override
+  public int hashCode() {
+return (new HashCodeBuilder(17, 31)).append(name)
+.append(providerList)
+.append(services)
+.append(applications)
+.build();
+  }
+
+  @Override
+  public boolean equals(Object obj) {
 
 Review comment:
   The reason for not using EqualsBuilder here is that equals() for Lists 
requires the ordering to be the same. However, for the purpose of evaluating 
topologies for equality, such ordering is not important.
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 407890)
Time Spent: 3h 20m  (was: 3h 10m)

> Trigger discovery for descriptors at gateway start time
> ---
>
> Key: KNOX-2301
> URL: https://issues.apache.org/jira/browse/KNOX-2301
> Project: Apache Knox
>  Issue Type: Improvement
>  Components: Server
>Affects Versions: 1.4.0
>Reporter: Philip Zampino
>Assignee: Philip Zampino
>Priority: Major
>  Time Spent: 3h 20m
>  Remaining Estimate: 0h
>
> Discovery and topology generation is triggered only by changes to provider 
> configuration or descriptor files on disk. Knox should also perform discovery 
> for all existing descriptors (that include discovery config) when the gateway 
> is started.
> This will help ensure that the generated topologies are accurate reflections 
> of the proxied services' configurations.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (KNOX-2301) Trigger discovery for descriptors at gateway start time

2020-03-23 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/KNOX-2301?focusedWorklogId=407887=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-407887
 ]

ASF GitHub Bot logged work on KNOX-2301:


Author: ASF GitHub Bot
Created on: 23/Mar/20 13:36
Start Date: 23/Mar/20 13:36
Worklog Time Spent: 10m 
  Work Description: pzampino commented on pull request #297: KNOX-2301 and 
KNOX-2302
URL: https://github.com/apache/knox/pull/297#discussion_r396455084
 
 

 ##
 File path: 
gateway-spi/src/main/java/org/apache/knox/gateway/topology/Topology.java
 ##
 @@ -153,4 +161,106 @@ public void addProvider( Provider provider ) {
 nameMap.put( provider.getName(), provider );
   }
 
+  @Override
+  public int hashCode() {
+return (new HashCodeBuilder(17, 31)).append(name)
+.append(providerList)
+.append(services)
+.append(applications)
+.build();
+  }
+
+  @Override
+  public boolean equals(Object obj) {
 
 Review comment:
   The reason for not using EqualsBuilder here is that equals() for Lists 
requires the ordering to be the same. However, for the purpose of evaluating 
topologies for equality, such ordering is not important.
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 407887)
Time Spent: 3h 10m  (was: 3h)

> Trigger discovery for descriptors at gateway start time
> ---
>
> Key: KNOX-2301
> URL: https://issues.apache.org/jira/browse/KNOX-2301
> Project: Apache Knox
>  Issue Type: Improvement
>  Components: Server
>Affects Versions: 1.4.0
>Reporter: Philip Zampino
>Assignee: Philip Zampino
>Priority: Major
>  Time Spent: 3h 10m
>  Remaining Estimate: 0h
>
> Discovery and topology generation is triggered only by changes to provider 
> configuration or descriptor files on disk. Knox should also perform discovery 
> for all existing descriptors (that include discovery config) when the gateway 
> is started.
> This will help ensure that the generated topologies are accurate reflections 
> of the proxied services' configurations.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (KNOX-2301) Trigger discovery for descriptors at gateway start time

2020-03-23 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/KNOX-2301?focusedWorklogId=407885=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-407885
 ]

ASF GitHub Bot logged work on KNOX-2301:


Author: ASF GitHub Bot
Created on: 23/Mar/20 13:32
Start Date: 23/Mar/20 13:32
Worklog Time Spent: 10m 
  Work Description: pzampino commented on pull request #297: KNOX-2301 and 
KNOX-2302
URL: https://github.com/apache/knox/pull/297#discussion_r396452322
 
 

 ##
 File path: 
gateway-server/src/test/java/org/apache/knox/gateway/services/topology/DefaultTopologyServiceTest.java
 ##
 @@ -177,6 +181,17 @@ public void testGetTopologies() throws Exception {
 }
   }
 
+  /**
+   * Set the static GatewayServices field to the specified value.
+   *
+   * @param gws A GatewayServices object, or null.
+   */
+  private void setGatewayServices(final GatewayServices gws) throws Exception {
+Field gwsField = GatewayServer.class.getDeclaredField("services");
+gwsField.setAccessible(true);
+gwsField.set(null, gws);
+  }
+
 
 Review comment:
   Your understanding is correct.
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 407885)
Time Spent: 3h  (was: 2h 50m)

> Trigger discovery for descriptors at gateway start time
> ---
>
> Key: KNOX-2301
> URL: https://issues.apache.org/jira/browse/KNOX-2301
> Project: Apache Knox
>  Issue Type: Improvement
>  Components: Server
>Affects Versions: 1.4.0
>Reporter: Philip Zampino
>Assignee: Philip Zampino
>Priority: Major
>  Time Spent: 3h
>  Remaining Estimate: 0h
>
> Discovery and topology generation is triggered only by changes to provider 
> configuration or descriptor files on disk. Knox should also perform discovery 
> for all existing descriptors (that include discovery config) when the gateway 
> is started.
> This will help ensure that the generated topologies are accurate reflections 
> of the proxied services' configurations.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (KNOX-2301) Trigger discovery for descriptors at gateway start time

2020-03-23 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/KNOX-2301?focusedWorklogId=407825=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-407825
 ]

ASF GitHub Bot logged work on KNOX-2301:


Author: ASF GitHub Bot
Created on: 23/Mar/20 10:38
Start Date: 23/Mar/20 10:38
Worklog Time Spent: 10m 
  Work Description: smolnar82 commented on pull request #297: KNOX-2301 and 
KNOX-2302
URL: https://github.com/apache/knox/pull/297#discussion_r396341268
 
 

 ##
 File path: 
gateway-spi/src/main/java/org/apache/knox/gateway/topology/Service.java
 ##
 @@ -122,32 +122,61 @@ public boolean equals(Object object) {
   return false;
 }
 Service that = (Service) object;
-String thatName = that.getName();
+String thatName = that.name;
 if (thatName != null && !(thatName.equals(name))) {
 return false;
 }
-String thatRole = that.getRole();
+String thatRole = that.role;
 if (thatRole != null && !thatRole.equals(role)) {
 return false;
 }
-Version thatVersion = that.getVersion();
+Version thatVersion = that.version;
 if (thatVersion != null && !(thatVersion.equals(version))) {
 return false;
 }
+
+// URLs
+if (urls.size() != that.urls.size()) {
+  return false;
+}
+
+for (String url : urls) {
+  if (!that.urls.contains(url)) {
+return false;
+  }
+}
+
+// Params
+if (params.size() != that.params.size()) {
+  return false;
+}
+
+for (Map.Entry param : params.entrySet()) {
+  if (!param.getValue().equals(that.params.get(param.getKey( {
+return false;
+  }
+}
+
 return true;
   }
 
   @Override
   public int hashCode() {
 
 Review comment:
   Adding `HashCodeBuilder` and `EqualsBuilder` here too?
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 407825)
Time Spent: 2h 10m  (was: 2h)

> Trigger discovery for descriptors at gateway start time
> ---
>
> Key: KNOX-2301
> URL: https://issues.apache.org/jira/browse/KNOX-2301
> Project: Apache Knox
>  Issue Type: Improvement
>  Components: Server
>Affects Versions: 1.4.0
>Reporter: Philip Zampino
>Assignee: Philip Zampino
>Priority: Major
>  Time Spent: 2h 10m
>  Remaining Estimate: 0h
>
> Discovery and topology generation is triggered only by changes to provider 
> configuration or descriptor files on disk. Knox should also perform discovery 
> for all existing descriptors (that include discovery config) when the gateway 
> is started.
> This will help ensure that the generated topologies are accurate reflections 
> of the proxied services' configurations.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (KNOX-2301) Trigger discovery for descriptors at gateway start time

2020-03-23 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/KNOX-2301?focusedWorklogId=407827=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-407827
 ]

ASF GitHub Bot logged work on KNOX-2301:


Author: ASF GitHub Bot
Created on: 23/Mar/20 10:38
Start Date: 23/Mar/20 10:38
Worklog Time Spent: 10m 
  Work Description: smolnar82 commented on pull request #297: KNOX-2301 and 
KNOX-2302
URL: https://github.com/apache/knox/pull/297#discussion_r396351060
 
 

 ##
 File path: 
gateway-topology-simple/src/main/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorHandler.java
 ##
 @@ -571,13 +579,49 @@ private static File 
resolveProviderConfigurationReference(final String reference
 if (topologyFilename == null) {
 topologyFilename = desc.getCluster();
 }
+
 topologyDescriptor = new File(destDirectory, topologyFilename + 
".xml");
 
-try (OutputStream outputStream = 
Files.newOutputStream(topologyDescriptor.toPath());
- OutputStreamWriter outputStreamWriter = new 
OutputStreamWriter(outputStream, StandardCharsets.UTF_8);
- BufferedWriter fw = new BufferedWriter(outputStreamWriter)) {
-  fw.write(sw.toString());
-  fw.flush();
+// KNOX-2302
+boolean persistGenerated = false;
+// Determine if the topology already exists.
+if (topologyDescriptor.exists()) {
+// If it does, only overwrite it if it has changed (KNOX-2302)
+// Compare the generated topology with the in-memory topology
+Topology existing = null;
+TopologyService topologyService = 
gwServices.getService(ServiceType.TOPOLOGY_SERVICE);
+for (Topology t : topologyService.getTopologies()) {
+if (topologyFilename.equals(t.getName())) {
+existing = t;
+break;
+}
 
 Review comment:
   Maybe introducing `topologyService.getTopology(String topologyName)`?
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 407827)
Time Spent: 2h 20m  (was: 2h 10m)

> Trigger discovery for descriptors at gateway start time
> ---
>
> Key: KNOX-2301
> URL: https://issues.apache.org/jira/browse/KNOX-2301
> Project: Apache Knox
>  Issue Type: Improvement
>  Components: Server
>Affects Versions: 1.4.0
>Reporter: Philip Zampino
>Assignee: Philip Zampino
>Priority: Major
>  Time Spent: 2h 20m
>  Remaining Estimate: 0h
>
> Discovery and topology generation is triggered only by changes to provider 
> configuration or descriptor files on disk. Knox should also perform discovery 
> for all existing descriptors (that include discovery config) when the gateway 
> is started.
> This will help ensure that the generated topologies are accurate reflections 
> of the proxied services' configurations.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (KNOX-2301) Trigger discovery for descriptors at gateway start time

2020-03-23 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/KNOX-2301?focusedWorklogId=407823=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-407823
 ]

ASF GitHub Bot logged work on KNOX-2301:


Author: ASF GitHub Bot
Created on: 23/Mar/20 10:38
Start Date: 23/Mar/20 10:38
Worklog Time Spent: 10m 
  Work Description: smolnar82 commented on pull request #297: KNOX-2301 and 
KNOX-2302
URL: https://github.com/apache/knox/pull/297#discussion_r396333267
 
 

 ##
 File path: 
gateway-server/src/main/java/org/apache/knox/gateway/util/TopologyUtils.java
 ##
 @@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations 
under
+ * the License.
+ */
+package org.apache.knox.gateway.util;
+
+import org.apache.commons.digester3.binder.DigesterLoader;
+import org.apache.knox.gateway.topology.Topology;
+import org.apache.knox.gateway.topology.builder.TopologyBuilder;
+import org.apache.knox.gateway.topology.xml.AmbariFormatXmlTopologyRules;
+import org.apache.knox.gateway.topology.xml.KnoxFormatXmlTopologyRules;
+import org.xml.sax.SAXException;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringReader;
+
+import static org.apache.commons.digester3.binder.DigesterLoader.newLoader;
+
+public class TopologyUtils {
+
+  private static DigesterLoader digesterLoader = newLoader(new 
KnoxFormatXmlTopologyRules(),
 
 Review comment:
   nit: can be `final`
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 407823)
Time Spent: 1h 50m  (was: 1h 40m)

> Trigger discovery for descriptors at gateway start time
> ---
>
> Key: KNOX-2301
> URL: https://issues.apache.org/jira/browse/KNOX-2301
> Project: Apache Knox
>  Issue Type: Improvement
>  Components: Server
>Affects Versions: 1.4.0
>Reporter: Philip Zampino
>Assignee: Philip Zampino
>Priority: Major
>  Time Spent: 1h 50m
>  Remaining Estimate: 0h
>
> Discovery and topology generation is triggered only by changes to provider 
> configuration or descriptor files on disk. Knox should also perform discovery 
> for all existing descriptors (that include discovery config) when the gateway 
> is started.
> This will help ensure that the generated topologies are accurate reflections 
> of the proxied services' configurations.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (KNOX-2301) Trigger discovery for descriptors at gateway start time

2020-03-23 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/KNOX-2301?focusedWorklogId=407826=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-407826
 ]

ASF GitHub Bot logged work on KNOX-2301:


Author: ASF GitHub Bot
Created on: 23/Mar/20 10:38
Start Date: 23/Mar/20 10:38
Worklog Time Spent: 10m 
  Work Description: smolnar82 commented on pull request #297: KNOX-2301 and 
KNOX-2302
URL: https://github.com/apache/knox/pull/297#discussion_r396338380
 
 

 ##
 File path: 
gateway-spi/src/main/java/org/apache/knox/gateway/topology/Provider.java
 ##
 @@ -82,4 +84,41 @@ public void setRole( String role ) {
 this.role = role;
   }
 
+  @Override
+  public int hashCode() {
+return new HashCodeBuilder().append(name)
+.append(role)
+.append(params)
+.append(enabled)
+.build();
+  }
+
+  @Override
+  public boolean equals(Object obj) {
 
 Review comment:
   I really like you are using `HashCodeBuilder` above. Why not use 
`EqualsBuilder` here (this would require to implement `hashCode` and `equals` 
in `Provider` too)?
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 407826)
Time Spent: 2h 10m  (was: 2h)

> Trigger discovery for descriptors at gateway start time
> ---
>
> Key: KNOX-2301
> URL: https://issues.apache.org/jira/browse/KNOX-2301
> Project: Apache Knox
>  Issue Type: Improvement
>  Components: Server
>Affects Versions: 1.4.0
>Reporter: Philip Zampino
>Assignee: Philip Zampino
>Priority: Major
>  Time Spent: 2h 10m
>  Remaining Estimate: 0h
>
> Discovery and topology generation is triggered only by changes to provider 
> configuration or descriptor files on disk. Knox should also perform discovery 
> for all existing descriptors (that include discovery config) when the gateway 
> is started.
> This will help ensure that the generated topologies are accurate reflections 
> of the proxied services' configurations.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (KNOX-2301) Trigger discovery for descriptors at gateway start time

2020-03-23 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/KNOX-2301?focusedWorklogId=407824=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-407824
 ]

ASF GitHub Bot logged work on KNOX-2301:


Author: ASF GitHub Bot
Created on: 23/Mar/20 10:38
Start Date: 23/Mar/20 10:38
Worklog Time Spent: 10m 
  Work Description: smolnar82 commented on pull request #297: KNOX-2301 and 
KNOX-2302
URL: https://github.com/apache/knox/pull/297#discussion_r396332466
 
 

 ##
 File path: 
gateway-server/src/main/java/org/apache/knox/gateway/services/topology/impl/DefaultTopologyService.java
 ##
 @@ -556,6 +553,11 @@ public void startMonitor() throws Exception {
 
log.remoteConfigurationMonitorStartFailure(remoteMonitor.getClass().getTypeName(),
 e.getLocalizedMessage());
   }
 }
+
+// Trigger descriptor discovery (KNOX-2301)
+for (File descriptor : getDescriptors()) {
+  descriptor.setLastModified(System.currentTimeMillis()); // 'Touch' the 
descriptor
+}
 
 Review comment:
   I'd move this out to a new method instead of keeping it in `startMonitor` 
with a good method name. Otherwise, in the future, it'd confuse others why it's 
here.
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 407824)
Time Spent: 2h  (was: 1h 50m)

> Trigger discovery for descriptors at gateway start time
> ---
>
> Key: KNOX-2301
> URL: https://issues.apache.org/jira/browse/KNOX-2301
> Project: Apache Knox
>  Issue Type: Improvement
>  Components: Server
>Affects Versions: 1.4.0
>Reporter: Philip Zampino
>Assignee: Philip Zampino
>Priority: Major
>  Time Spent: 2h
>  Remaining Estimate: 0h
>
> Discovery and topology generation is triggered only by changes to provider 
> configuration or descriptor files on disk. Knox should also perform discovery 
> for all existing descriptors (that include discovery config) when the gateway 
> is started.
> This will help ensure that the generated topologies are accurate reflections 
> of the proxied services' configurations.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (KNOX-2301) Trigger discovery for descriptors at gateway start time

2020-03-23 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/KNOX-2301?focusedWorklogId=407830=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-407830
 ]

ASF GitHub Bot logged work on KNOX-2301:


Author: ASF GitHub Bot
Created on: 23/Mar/20 10:38
Start Date: 23/Mar/20 10:38
Worklog Time Spent: 10m 
  Work Description: smolnar82 commented on pull request #297: KNOX-2301 and 
KNOX-2302
URL: https://github.com/apache/knox/pull/297#discussion_r396337421
 
 

 ##
 File path: 
gateway-server/src/test/java/org/apache/knox/gateway/services/topology/DefaultTopologyServiceTest.java
 ##
 @@ -177,6 +181,17 @@ public void testGetTopologies() throws Exception {
 }
   }
 
+  /**
+   * Set the static GatewayServices field to the specified value.
+   *
+   * @param gws A GatewayServices object, or null.
+   */
+  private void setGatewayServices(final GatewayServices gws) throws Exception {
+Field gwsField = GatewayServer.class.getDeclaredField("services");
+gwsField.setAccessible(true);
+gwsField.set(null, gws);
+  }
+
 
 Review comment:
   If I understand well this is implemented because EasyMock does not support 
static method mocking. I'm ok with this change, however, you may consider using 
[PowerMock](https://github.com/powermock/powermock)
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 407830)
Time Spent: 2h 40m  (was: 2.5h)

> Trigger discovery for descriptors at gateway start time
> ---
>
> Key: KNOX-2301
> URL: https://issues.apache.org/jira/browse/KNOX-2301
> Project: Apache Knox
>  Issue Type: Improvement
>  Components: Server
>Affects Versions: 1.4.0
>Reporter: Philip Zampino
>Assignee: Philip Zampino
>Priority: Major
>  Time Spent: 2h 40m
>  Remaining Estimate: 0h
>
> Discovery and topology generation is triggered only by changes to provider 
> configuration or descriptor files on disk. Knox should also perform discovery 
> for all existing descriptors (that include discovery config) when the gateway 
> is started.
> This will help ensure that the generated topologies are accurate reflections 
> of the proxied services' configurations.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (KNOX-2301) Trigger discovery for descriptors at gateway start time

2020-03-23 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/KNOX-2301?focusedWorklogId=407829=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-407829
 ]

ASF GitHub Bot logged work on KNOX-2301:


Author: ASF GitHub Bot
Created on: 23/Mar/20 10:38
Start Date: 23/Mar/20 10:38
Worklog Time Spent: 10m 
  Work Description: smolnar82 commented on pull request #297: KNOX-2301 and 
KNOX-2302
URL: https://github.com/apache/knox/pull/297#discussion_r396342594
 
 

 ##
 File path: 
gateway-spi/src/main/java/org/apache/knox/gateway/topology/Topology.java
 ##
 @@ -153,4 +161,106 @@ public void addProvider( Provider provider ) {
 nameMap.put( provider.getName(), provider );
   }
 
+  @Override
+  public int hashCode() {
+return (new HashCodeBuilder(17, 31)).append(name)
+.append(providerList)
+.append(services)
+.append(applications)
+.build();
+  }
+
+  @Override
+  public boolean equals(Object obj) {
 
 Review comment:
   If `Provider`, `Service` and `Application` implements `hashCode` and 
`equals` properly you do not need the private methods below and you can simply 
use `EqualsBuilder` here too.
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 407829)
Time Spent: 2.5h  (was: 2h 20m)

> Trigger discovery for descriptors at gateway start time
> ---
>
> Key: KNOX-2301
> URL: https://issues.apache.org/jira/browse/KNOX-2301
> Project: Apache Knox
>  Issue Type: Improvement
>  Components: Server
>Affects Versions: 1.4.0
>Reporter: Philip Zampino
>Assignee: Philip Zampino
>Priority: Major
>  Time Spent: 2.5h
>  Remaining Estimate: 0h
>
> Discovery and topology generation is triggered only by changes to provider 
> configuration or descriptor files on disk. Knox should also perform discovery 
> for all existing descriptors (that include discovery config) when the gateway 
> is started.
> This will help ensure that the generated topologies are accurate reflections 
> of the proxied services' configurations.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (KNOX-2301) Trigger discovery for descriptors at gateway start time

2020-03-23 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/KNOX-2301?focusedWorklogId=407831=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-407831
 ]

ASF GitHub Bot logged work on KNOX-2301:


Author: ASF GitHub Bot
Created on: 23/Mar/20 10:38
Start Date: 23/Mar/20 10:38
Worklog Time Spent: 10m 
  Work Description: smolnar82 commented on pull request #297: KNOX-2301 and 
KNOX-2302
URL: https://github.com/apache/knox/pull/297#discussion_r396352071
 
 

 ##
 File path: 
gateway-topology-simple/src/main/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorHandler.java
 ##
 @@ -571,13 +579,49 @@ private static File 
resolveProviderConfigurationReference(final String reference
 if (topologyFilename == null) {
 topologyFilename = desc.getCluster();
 }
+
 topologyDescriptor = new File(destDirectory, topologyFilename + 
".xml");
 
-try (OutputStream outputStream = 
Files.newOutputStream(topologyDescriptor.toPath());
- OutputStreamWriter outputStreamWriter = new 
OutputStreamWriter(outputStream, StandardCharsets.UTF_8);
- BufferedWriter fw = new BufferedWriter(outputStreamWriter)) {
-  fw.write(sw.toString());
-  fw.flush();
+// KNOX-2302
+boolean persistGenerated = false;
+// Determine if the topology already exists.
+if (topologyDescriptor.exists()) {
 
 Review comment:
   I'd move this new logic to its own private method with a meaningful name 
(e.g. `shouldRedeployTopology`) to make the code cleaner.
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 407831)
Time Spent: 2h 50m  (was: 2h 40m)

> Trigger discovery for descriptors at gateway start time
> ---
>
> Key: KNOX-2301
> URL: https://issues.apache.org/jira/browse/KNOX-2301
> Project: Apache Knox
>  Issue Type: Improvement
>  Components: Server
>Affects Versions: 1.4.0
>Reporter: Philip Zampino
>Assignee: Philip Zampino
>Priority: Major
>  Time Spent: 2h 50m
>  Remaining Estimate: 0h
>
> Discovery and topology generation is triggered only by changes to provider 
> configuration or descriptor files on disk. Knox should also perform discovery 
> for all existing descriptors (that include discovery config) when the gateway 
> is started.
> This will help ensure that the generated topologies are accurate reflections 
> of the proxied services' configurations.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (KNOX-2301) Trigger discovery for descriptors at gateway start time

2020-03-23 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/KNOX-2301?focusedWorklogId=407828=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-407828
 ]

ASF GitHub Bot logged work on KNOX-2301:


Author: ASF GitHub Bot
Created on: 23/Mar/20 10:38
Start Date: 23/Mar/20 10:38
Worklog Time Spent: 10m 
  Work Description: smolnar82 commented on pull request #297: KNOX-2301 and 
KNOX-2302
URL: https://github.com/apache/knox/pull/297#discussion_r396347775
 
 

 ##
 File path: 
gateway-test/src/test/java/org/apache/knox/gateway/AmbariServiceDefinitionTest.java
 ##
 @@ -114,6 +114,12 @@ public static void setupGateway() throws Exception {
 File deployDir = new File( config.getGatewayDeploymentDir() );
 deployDir.mkdirs();
 
+File descDir = new File( config.getGatewayDescriptorsDir() );
 
 Review comment:
   This is out-of-scope of this JIRA so I filed a new one: 
https://issues.apache.org/jira/browse/KNOX-2309
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 407828)
Time Spent: 2h 20m  (was: 2h 10m)

> Trigger discovery for descriptors at gateway start time
> ---
>
> Key: KNOX-2301
> URL: https://issues.apache.org/jira/browse/KNOX-2301
> Project: Apache Knox
>  Issue Type: Improvement
>  Components: Server
>Affects Versions: 1.4.0
>Reporter: Philip Zampino
>Assignee: Philip Zampino
>Priority: Major
>  Time Spent: 2h 20m
>  Remaining Estimate: 0h
>
> Discovery and topology generation is triggered only by changes to provider 
> configuration or descriptor files on disk. Knox should also perform discovery 
> for all existing descriptors (that include discovery config) when the gateway 
> is started.
> This will help ensure that the generated topologies are accurate reflections 
> of the proxied services' configurations.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (KNOX-2301) Trigger discovery for descriptors at gateway start time

2020-03-21 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/KNOX-2301?focusedWorklogId=407513=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-407513
 ]

ASF GitHub Bot logged work on KNOX-2301:


Author: ASF GitHub Bot
Created on: 21/Mar/20 21:13
Start Date: 21/Mar/20 21:13
Worklog Time Spent: 10m 
  Work Description: pzampino commented on pull request #297: KNOX-2301 and 
KNOX-2302
URL: https://github.com/apache/knox/pull/297#discussion_r396029708
 
 

 ##
 File path: 
gateway-topology-simple/src/main/java/org/apache/knox/gateway/topology/simple/TopologyComparisonUtil.java
 ##
 @@ -0,0 +1,192 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations 
under
+ * the License.
+ */
+package org.apache.knox.gateway.topology.simple;
+
+import org.apache.knox.gateway.topology.Application;
+import org.apache.knox.gateway.topology.Provider;
+import org.apache.knox.gateway.topology.Service;
+import org.apache.knox.gateway.topology.Topology;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Utility for comparing Topology objects for equivalence.
+ */
+class TopologyComparisonUtil {
 
 Review comment:
   Moved to Topology#equals() method.
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 407513)
Time Spent: 1h 40m  (was: 1.5h)

> Trigger discovery for descriptors at gateway start time
> ---
>
> Key: KNOX-2301
> URL: https://issues.apache.org/jira/browse/KNOX-2301
> Project: Apache Knox
>  Issue Type: Improvement
>  Components: Server
>Affects Versions: 1.4.0
>Reporter: Philip Zampino
>Assignee: Philip Zampino
>Priority: Major
>  Time Spent: 1h 40m
>  Remaining Estimate: 0h
>
> Discovery and topology generation is triggered only by changes to provider 
> configuration or descriptor files on disk. Knox should also perform discovery 
> for all existing descriptors (that include discovery config) when the gateway 
> is started.
> This will help ensure that the generated topologies are accurate reflections 
> of the proxied services' configurations.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (KNOX-2301) Trigger discovery for descriptors at gateway start time

2020-03-21 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/KNOX-2301?focusedWorklogId=407430=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-407430
 ]

ASF GitHub Bot logged work on KNOX-2301:


Author: ASF GitHub Bot
Created on: 21/Mar/20 14:15
Start Date: 21/Mar/20 14:15
Worklog Time Spent: 10m 
  Work Description: pzampino commented on pull request #297: KNOX-2301 and 
KNOX-2302
URL: https://github.com/apache/knox/pull/297#discussion_r395996190
 
 

 ##
 File path: 
gateway-topology-simple/src/main/java/org/apache/knox/gateway/topology/simple/TopologyComparisonUtil.java
 ##
 @@ -0,0 +1,192 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations 
under
+ * the License.
+ */
+package org.apache.knox.gateway.topology.simple;
+
+import org.apache.knox.gateway.topology.Application;
+import org.apache.knox.gateway.topology.Provider;
+import org.apache.knox.gateway.topology.Service;
+import org.apache.knox.gateway.topology.Topology;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Utility for comparing Topology objects for equivalence.
+ */
+class TopologyComparisonUtil {
 
 Review comment:
   I'm already converting JSON to a Topology object for this purpose, and would 
prefer to avoid re-converting them back to JSON for the sake of comparison.
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 407430)
Time Spent: 1.5h  (was: 1h 20m)

> Trigger discovery for descriptors at gateway start time
> ---
>
> Key: KNOX-2301
> URL: https://issues.apache.org/jira/browse/KNOX-2301
> Project: Apache Knox
>  Issue Type: Improvement
>  Components: Server
>Affects Versions: 1.4.0
>Reporter: Philip Zampino
>Assignee: Philip Zampino
>Priority: Major
>  Time Spent: 1.5h
>  Remaining Estimate: 0h
>
> Discovery and topology generation is triggered only by changes to provider 
> configuration or descriptor files on disk. Knox should also perform discovery 
> for all existing descriptors (that include discovery config) when the gateway 
> is started.
> This will help ensure that the generated topologies are accurate reflections 
> of the proxied services' configurations.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (KNOX-2301) Trigger discovery for descriptors at gateway start time

2020-03-21 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/KNOX-2301?focusedWorklogId=407429=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-407429
 ]

ASF GitHub Bot logged work on KNOX-2301:


Author: ASF GitHub Bot
Created on: 21/Mar/20 14:14
Start Date: 21/Mar/20 14:14
Worklog Time Spent: 10m 
  Work Description: pzampino commented on pull request #297: KNOX-2301 and 
KNOX-2302
URL: https://github.com/apache/knox/pull/297#discussion_r395996016
 
 

 ##
 File path: 
gateway-topology-simple/src/main/java/org/apache/knox/gateway/topology/simple/TopologyComparisonUtil.java
 ##
 @@ -0,0 +1,192 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations 
under
+ * the License.
+ */
+package org.apache.knox.gateway.topology.simple;
+
+import org.apache.knox.gateway.topology.Application;
+import org.apache.knox.gateway.topology.Provider;
+import org.apache.knox.gateway.topology.Service;
+import org.apache.knox.gateway.topology.Topology;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Utility for comparing Topology objects for equivalence.
+ */
+class TopologyComparisonUtil {
 
 Review comment:
   This thought had crossed my mind as I was implementing it; I think the fact 
that this requirement doesn't care about the URI, default service path or 
timestamp is what made me opt for this. I think a complete equals() 
implementation would include at least the URI, but if others disagree, I could 
be persuaded to move this logic into the Topology equals() method.
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 407429)
Time Spent: 1h 20m  (was: 1h 10m)

> Trigger discovery for descriptors at gateway start time
> ---
>
> Key: KNOX-2301
> URL: https://issues.apache.org/jira/browse/KNOX-2301
> Project: Apache Knox
>  Issue Type: Improvement
>  Components: Server
>Affects Versions: 1.4.0
>Reporter: Philip Zampino
>Assignee: Philip Zampino
>Priority: Major
>  Time Spent: 1h 20m
>  Remaining Estimate: 0h
>
> Discovery and topology generation is triggered only by changes to provider 
> configuration or descriptor files on disk. Knox should also perform discovery 
> for all existing descriptors (that include discovery config) when the gateway 
> is started.
> This will help ensure that the generated topologies are accurate reflections 
> of the proxied services' configurations.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (KNOX-2301) Trigger discovery for descriptors at gateway start time

2020-03-21 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/KNOX-2301?focusedWorklogId=407427=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-407427
 ]

ASF GitHub Bot logged work on KNOX-2301:


Author: ASF GitHub Bot
Created on: 21/Mar/20 14:01
Start Date: 21/Mar/20 14:01
Worklog Time Spent: 10m 
  Work Description: pzampino commented on pull request #297: KNOX-2301 and 
KNOX-2302
URL: https://github.com/apache/knox/pull/297#discussion_r395995104
 
 

 ##
 File path: 
gateway-server/src/test/java/org/apache/knox/gateway/services/topology/DefaultTopologyServiceTest.java
 ##
 @@ -177,6 +181,21 @@ public void testGetTopologies() throws Exception {
 }
   }
 
+  /**
+   * Set the static GatewayServices field to the specified value.
+   *
+   * @param gws A GatewayServices object, or null.
+   */
+  private void setGatewayServices(final GatewayServices gws) {
+try {
+  Field gwsField = GatewayServer.class.getDeclaredField("services");
+  gwsField.setAccessible(true);
+  gwsField.set(null, gws);
+} catch (Exception e) {
+  e.printStackTrace();
 
 Review comment:
   +1
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 407427)
Time Spent: 1h 10m  (was: 1h)

> Trigger discovery for descriptors at gateway start time
> ---
>
> Key: KNOX-2301
> URL: https://issues.apache.org/jira/browse/KNOX-2301
> Project: Apache Knox
>  Issue Type: Improvement
>  Components: Server
>Affects Versions: 1.4.0
>Reporter: Philip Zampino
>Assignee: Philip Zampino
>Priority: Major
>  Time Spent: 1h 10m
>  Remaining Estimate: 0h
>
> Discovery and topology generation is triggered only by changes to provider 
> configuration or descriptor files on disk. Knox should also perform discovery 
> for all existing descriptors (that include discovery config) when the gateway 
> is started.
> This will help ensure that the generated topologies are accurate reflections 
> of the proxied services' configurations.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (KNOX-2301) Trigger discovery for descriptors at gateway start time

2020-03-21 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/KNOX-2301?focusedWorklogId=407426=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-407426
 ]

ASF GitHub Bot logged work on KNOX-2301:


Author: ASF GitHub Bot
Created on: 21/Mar/20 14:00
Start Date: 21/Mar/20 14:00
Worklog Time Spent: 10m 
  Work Description: pzampino commented on pull request #297: KNOX-2301 and 
KNOX-2302
URL: https://github.com/apache/knox/pull/297#discussion_r395995034
 
 

 ##
 File path: 
gateway-server/src/main/java/org/apache/knox/gateway/services/topology/impl/DefaultTopologyService.java
 ##
 @@ -153,17 +146,18 @@ private Topology loadTopology(File file) throws 
IOException, SAXException, Inter
 return topology;
   }
 
+  @Override
+  public Topology parse(final InputStream content) throws IOException, 
SAXException {
+return TopologyUtils.parse(content);
+  }
+
   private Topology loadTopologyAttempt(File file) throws IOException, 
SAXException {
-Topology topology;
-Digester digester = digesterLoader.newDigester();
-TopologyBuilder topologyBuilder = 
digester.parse(FileUtils.openInputStream(file));
-if (null == topologyBuilder) {
-  return null;
-}
-topology = topologyBuilder.build();
-topology.setUri(file.toURI());
-topology.setName(FilenameUtils.removeExtension(file.getName()));
-topology.setTimestamp(file.lastModified());
+Topology topology = parse(FileUtils.openInputStream(file));
 
 Review comment:
   The reason for the TopologyService method taking an InputStream (rather than 
a File) is that there is not a File available in every case. In one case, it is 
being used to parse a generated String. There could be two signatures, but I 
think the InputStream signature supports the two existing cases well enough. 
The streams must be closed though.
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 407426)
Time Spent: 1h  (was: 50m)

> Trigger discovery for descriptors at gateway start time
> ---
>
> Key: KNOX-2301
> URL: https://issues.apache.org/jira/browse/KNOX-2301
> Project: Apache Knox
>  Issue Type: Improvement
>  Components: Server
>Affects Versions: 1.4.0
>Reporter: Philip Zampino
>Assignee: Philip Zampino
>Priority: Major
>  Time Spent: 1h
>  Remaining Estimate: 0h
>
> Discovery and topology generation is triggered only by changes to provider 
> configuration or descriptor files on disk. Knox should also perform discovery 
> for all existing descriptors (that include discovery config) when the gateway 
> is started.
> This will help ensure that the generated topologies are accurate reflections 
> of the proxied services' configurations.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (KNOX-2301) Trigger discovery for descriptors at gateway start time

2020-03-20 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/KNOX-2301?focusedWorklogId=407091=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-407091
 ]

ASF GitHub Bot logged work on KNOX-2301:


Author: ASF GitHub Bot
Created on: 20/Mar/20 15:24
Start Date: 20/Mar/20 15:24
Worklog Time Spent: 10m 
  Work Description: smolnar82 commented on pull request #297: KNOX-2301 and 
KNOX-2302
URL: https://github.com/apache/knox/pull/297#discussion_r395711086
 
 

 ##
 File path: 
gateway-topology-simple/src/main/java/org/apache/knox/gateway/topology/simple/TopologyComparisonUtil.java
 ##
 @@ -0,0 +1,192 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations 
under
+ * the License.
+ */
+package org.apache.knox.gateway.topology.simple;
+
+import org.apache.knox.gateway.topology.Application;
+import org.apache.knox.gateway.topology.Provider;
+import org.apache.knox.gateway.topology.Service;
+import org.apache.knox.gateway.topology.Topology;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Utility for comparing Topology objects for equivalence.
+ */
+class TopologyComparisonUtil {
 
 Review comment:
   Assuming the JSON representation of `topology1` and `topology2` are the same 
in case they are equal you can simply do a test like:
   
`org.apache.knox.gateway.util.JsonUtils.renderAsJsonString(topology1).equals(JsonUtils.renderAsJsonString(topology2)`
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 407091)
Time Spent: 50m  (was: 40m)

> Trigger discovery for descriptors at gateway start time
> ---
>
> Key: KNOX-2301
> URL: https://issues.apache.org/jira/browse/KNOX-2301
> Project: Apache Knox
>  Issue Type: Improvement
>  Components: Server
>Affects Versions: 1.4.0
>Reporter: Philip Zampino
>Assignee: Philip Zampino
>Priority: Major
>  Time Spent: 50m
>  Remaining Estimate: 0h
>
> Discovery and topology generation is triggered only by changes to provider 
> configuration or descriptor files on disk. Knox should also perform discovery 
> for all existing descriptors (that include discovery config) when the gateway 
> is started.
> This will help ensure that the generated topologies are accurate reflections 
> of the proxied services' configurations.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (KNOX-2301) Trigger discovery for descriptors at gateway start time

2020-03-20 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/KNOX-2301?focusedWorklogId=407076=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-407076
 ]

ASF GitHub Bot logged work on KNOX-2301:


Author: ASF GitHub Bot
Created on: 20/Mar/20 14:51
Start Date: 20/Mar/20 14:51
Worklog Time Spent: 10m 
  Work Description: pzampino commented on pull request #297: KNOX-2301 and 
KNOX-2302
URL: https://github.com/apache/knox/pull/297#discussion_r395688935
 
 

 ##
 File path: 
gateway-server/src/main/java/org/apache/knox/gateway/services/topology/impl/DefaultTopologyService.java
 ##
 @@ -153,17 +146,18 @@ private Topology loadTopology(File file) throws 
IOException, SAXException, Inter
 return topology;
   }
 
+  @Override
+  public Topology parse(final InputStream content) throws IOException, 
SAXException {
+return TopologyUtils.parse(content);
+  }
+
   private Topology loadTopologyAttempt(File file) throws IOException, 
SAXException {
-Topology topology;
-Digester digester = digesterLoader.newDigester();
-TopologyBuilder topologyBuilder = 
digester.parse(FileUtils.openInputStream(file));
-if (null == topologyBuilder) {
-  return null;
-}
-topology = topologyBuilder.build();
-topology.setUri(file.toURI());
-topology.setName(FilenameUtils.removeExtension(file.getName()));
-topology.setTimestamp(file.lastModified());
+Topology topology = parse(FileUtils.openInputStream(file));
 
 Review comment:
   That makes sense.
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 407076)
Time Spent: 40m  (was: 0.5h)

> Trigger discovery for descriptors at gateway start time
> ---
>
> Key: KNOX-2301
> URL: https://issues.apache.org/jira/browse/KNOX-2301
> Project: Apache Knox
>  Issue Type: Improvement
>  Components: Server
>Affects Versions: 1.4.0
>Reporter: Philip Zampino
>Assignee: Philip Zampino
>Priority: Major
>  Time Spent: 40m
>  Remaining Estimate: 0h
>
> Discovery and topology generation is triggered only by changes to provider 
> configuration or descriptor files on disk. Knox should also perform discovery 
> for all existing descriptors (that include discovery config) when the gateway 
> is started.
> This will help ensure that the generated topologies are accurate reflections 
> of the proxied services' configurations.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (KNOX-2301) Trigger discovery for descriptors at gateway start time

2020-03-20 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/KNOX-2301?focusedWorklogId=406938=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-406938
 ]

ASF GitHub Bot logged work on KNOX-2301:


Author: ASF GitHub Bot
Created on: 20/Mar/20 09:12
Start Date: 20/Mar/20 09:12
Worklog Time Spent: 10m 
  Work Description: risdenk commented on pull request #297: KNOX-2301 and 
KNOX-2302
URL: https://github.com/apache/knox/pull/297#discussion_r395508911
 
 

 ##
 File path: 
gateway-server/src/main/java/org/apache/knox/gateway/services/topology/impl/DefaultTopologyService.java
 ##
 @@ -153,17 +146,18 @@ private Topology loadTopology(File file) throws 
IOException, SAXException, Inter
 return topology;
   }
 
+  @Override
+  public Topology parse(final InputStream content) throws IOException, 
SAXException {
+return TopologyUtils.parse(content);
+  }
+
   private Topology loadTopologyAttempt(File file) throws IOException, 
SAXException {
-Topology topology;
-Digester digester = digesterLoader.newDigester();
-TopologyBuilder topologyBuilder = 
digester.parse(FileUtils.openInputStream(file));
-if (null == topologyBuilder) {
-  return null;
-}
-topology = topologyBuilder.build();
-topology.setUri(file.toURI());
-topology.setName(FilenameUtils.removeExtension(file.getName()));
-topology.setTimestamp(file.lastModified());
+Topology topology = parse(FileUtils.openInputStream(file));
+if (topology != null) {
+  topology.setUri(file.toURI());
+  topology.setName(FilenameUtils.removeExtension(file.getName()));
+  topology.setTimestamp(file.lastModified());
+}
 
 Review comment:
   If we pass in the file reference, you can move this logic in there too and 
get the full topology object back.
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 406938)
Time Spent: 0.5h  (was: 20m)

> Trigger discovery for descriptors at gateway start time
> ---
>
> Key: KNOX-2301
> URL: https://issues.apache.org/jira/browse/KNOX-2301
> Project: Apache Knox
>  Issue Type: Improvement
>  Components: Server
>Affects Versions: 1.4.0
>Reporter: Philip Zampino
>Assignee: Philip Zampino
>Priority: Major
>  Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> Discovery and topology generation is triggered only by changes to provider 
> configuration or descriptor files on disk. Knox should also perform discovery 
> for all existing descriptors (that include discovery config) when the gateway 
> is started.
> This will help ensure that the generated topologies are accurate reflections 
> of the proxied services' configurations.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (KNOX-2301) Trigger discovery for descriptors at gateway start time

2020-03-20 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/KNOX-2301?focusedWorklogId=406936=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-406936
 ]

ASF GitHub Bot logged work on KNOX-2301:


Author: ASF GitHub Bot
Created on: 20/Mar/20 09:12
Start Date: 20/Mar/20 09:12
Worklog Time Spent: 10m 
  Work Description: risdenk commented on pull request #297: KNOX-2301 and 
KNOX-2302
URL: https://github.com/apache/knox/pull/297#discussion_r395511204
 
 

 ##
 File path: 
gateway-topology-simple/src/main/java/org/apache/knox/gateway/topology/simple/TopologyComparisonUtil.java
 ##
 @@ -0,0 +1,192 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations 
under
+ * the License.
+ */
+package org.apache.knox.gateway.topology.simple;
+
+import org.apache.knox.gateway.topology.Application;
+import org.apache.knox.gateway.topology.Provider;
+import org.apache.knox.gateway.topology.Service;
+import org.apache.knox.gateway.topology.Topology;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Utility for comparing Topology objects for equivalence.
+ */
+class TopologyComparisonUtil {
 
 Review comment:
   Is this class necessary? Can't we just ask if the two topology objects are 
equal? Most of this logic looks like it should be in an topology equals method. 
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 406936)

> Trigger discovery for descriptors at gateway start time
> ---
>
> Key: KNOX-2301
> URL: https://issues.apache.org/jira/browse/KNOX-2301
> Project: Apache Knox
>  Issue Type: Improvement
>  Components: Server
>Affects Versions: 1.4.0
>Reporter: Philip Zampino
>Assignee: Philip Zampino
>Priority: Major
>  Time Spent: 20m
>  Remaining Estimate: 0h
>
> Discovery and topology generation is triggered only by changes to provider 
> configuration or descriptor files on disk. Knox should also perform discovery 
> for all existing descriptors (that include discovery config) when the gateway 
> is started.
> This will help ensure that the generated topologies are accurate reflections 
> of the proxied services' configurations.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (KNOX-2301) Trigger discovery for descriptors at gateway start time

2020-03-20 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/KNOX-2301?focusedWorklogId=406935=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-406935
 ]

ASF GitHub Bot logged work on KNOX-2301:


Author: ASF GitHub Bot
Created on: 20/Mar/20 09:12
Start Date: 20/Mar/20 09:12
Worklog Time Spent: 10m 
  Work Description: risdenk commented on pull request #297: KNOX-2301 and 
KNOX-2302
URL: https://github.com/apache/knox/pull/297#discussion_r395509835
 
 

 ##
 File path: 
gateway-server/src/test/java/org/apache/knox/gateway/services/topology/DefaultTopologyServiceTest.java
 ##
 @@ -177,6 +181,21 @@ public void testGetTopologies() throws Exception {
 }
   }
 
+  /**
+   * Set the static GatewayServices field to the specified value.
+   *
+   * @param gws A GatewayServices object, or null.
+   */
+  private void setGatewayServices(final GatewayServices gws) {
+try {
+  Field gwsField = GatewayServer.class.getDeclaredField("services");
+  gwsField.setAccessible(true);
+  gwsField.set(null, gws);
+} catch (Exception e) {
+  e.printStackTrace();
 
 Review comment:
   Not sure you need the catch here? Since it's a test probably better to throw 
it?
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 406935)
Time Spent: 20m  (was: 10m)

> Trigger discovery for descriptors at gateway start time
> ---
>
> Key: KNOX-2301
> URL: https://issues.apache.org/jira/browse/KNOX-2301
> Project: Apache Knox
>  Issue Type: Improvement
>  Components: Server
>Affects Versions: 1.4.0
>Reporter: Philip Zampino
>Assignee: Philip Zampino
>Priority: Major
>  Time Spent: 20m
>  Remaining Estimate: 0h
>
> Discovery and topology generation is triggered only by changes to provider 
> configuration or descriptor files on disk. Knox should also perform discovery 
> for all existing descriptors (that include discovery config) when the gateway 
> is started.
> This will help ensure that the generated topologies are accurate reflections 
> of the proxied services' configurations.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (KNOX-2301) Trigger discovery for descriptors at gateway start time

2020-03-20 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/KNOX-2301?focusedWorklogId=406937=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-406937
 ]

ASF GitHub Bot logged work on KNOX-2301:


Author: ASF GitHub Bot
Created on: 20/Mar/20 09:12
Start Date: 20/Mar/20 09:12
Worklog Time Spent: 10m 
  Work Description: risdenk commented on pull request #297: KNOX-2301 and 
KNOX-2302
URL: https://github.com/apache/knox/pull/297#discussion_r395508508
 
 

 ##
 File path: 
gateway-server/src/main/java/org/apache/knox/gateway/services/topology/impl/DefaultTopologyService.java
 ##
 @@ -153,17 +146,18 @@ private Topology loadTopology(File file) throws 
IOException, SAXException, Inter
 return topology;
   }
 
+  @Override
+  public Topology parse(final InputStream content) throws IOException, 
SAXException {
+return TopologyUtils.parse(content);
+  }
+
   private Topology loadTopologyAttempt(File file) throws IOException, 
SAXException {
-Topology topology;
-Digester digester = digesterLoader.newDigester();
-TopologyBuilder topologyBuilder = 
digester.parse(FileUtils.openInputStream(file));
-if (null == topologyBuilder) {
-  return null;
-}
-topology = topologyBuilder.build();
-topology.setUri(file.toURI());
-topology.setName(FilenameUtils.removeExtension(file.getName()));
-topology.setTimestamp(file.lastModified());
+Topology topology = parse(FileUtils.openInputStream(file));
 
 Review comment:
   I think it would be cleaner to open/close input stream in the parse method. 
Basically pass a file reference and not an input stream? 
   
   Otherwise I think we need to make sure to close the input stream?
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 406937)
Time Spent: 0.5h  (was: 20m)

> Trigger discovery for descriptors at gateway start time
> ---
>
> Key: KNOX-2301
> URL: https://issues.apache.org/jira/browse/KNOX-2301
> Project: Apache Knox
>  Issue Type: Improvement
>  Components: Server
>Affects Versions: 1.4.0
>Reporter: Philip Zampino
>Assignee: Philip Zampino
>Priority: Major
>  Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> Discovery and topology generation is triggered only by changes to provider 
> configuration or descriptor files on disk. Knox should also perform discovery 
> for all existing descriptors (that include discovery config) when the gateway 
> is started.
> This will help ensure that the generated topologies are accurate reflections 
> of the proxied services' configurations.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (KNOX-2301) Trigger discovery for descriptors at gateway start time

2020-03-19 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/KNOX-2301?focusedWorklogId=406752=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-406752
 ]

ASF GitHub Bot logged work on KNOX-2301:


Author: ASF GitHub Bot
Created on: 20/Mar/20 03:23
Start Date: 20/Mar/20 03:23
Worklog Time Spent: 10m 
  Work Description: pzampino commented on pull request #297: KNOX-2301 and 
KNOX-2302
URL: https://github.com/apache/knox/pull/297
 
 
   ## What changes were proposed in this pull request?
   
   These are two closely-related issues. Added (actually, removed restrictions 
on) performing re-discovery for every applicable descriptor on gateway 
start-up. To prevent unnecessary redeployments of unchanged topologies, also 
added a check to skip the persistence of generated topologies if there exists 
an equivalent deployed topology of the same name.
   
   ## How was this patch tested?
   
   A great deal of manual testing was performed, and a number of existing tests 
were modified.  Also added some new tests.
 

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 406752)
Remaining Estimate: 0h
Time Spent: 10m

> Trigger discovery for descriptors at gateway start time
> ---
>
> Key: KNOX-2301
> URL: https://issues.apache.org/jira/browse/KNOX-2301
> Project: Apache Knox
>  Issue Type: Improvement
>  Components: Server
>Affects Versions: 1.4.0
>Reporter: Philip Zampino
>Assignee: Philip Zampino
>Priority: Major
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> Discovery and topology generation is triggered only by changes to provider 
> configuration or descriptor files on disk. Knox should also perform discovery 
> for all existing descriptors (that include discovery config) when the gateway 
> is started.
> This will help ensure that the generated topologies are accurate reflections 
> of the proxied services' configurations.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)