Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mod_jk tooling fixes #79

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ class FacingServerConfigurator implements Configurator<FacingServerConfigurator>
}

uriWorkerMapProperties
.setBalancers(balancers)
.setWorkers(jkScenario.getWorkerNodes())
.setStatusWorkers(jkScenario.getStatusWorkerNodes())
.setAdditionalUrlMaps(jkScenario.getAdditionalUrlMaps())
.setBalancers(uriWorkerMapProperties.getBalancers() + balancers)
.setWorkers(uriWorkerMapProperties.getWorkers() + jkScenario.getWorkerNodes())
.setStatusWorkers(uriWorkerMapProperties.getStatusWorkers() + jkScenario.getStatusWorkerNodes())
.setAdditionalUrlMaps(uriWorkerMapProperties.getAdditionalUrlMaps() + jkScenario.getAdditionalUrlMaps())

configurators << uriWorkerMapProperties.configure()
}
Expand All @@ -78,9 +78,9 @@ class FacingServerConfigurator implements Configurator<FacingServerConfigurator>
}

workersProperties
.setBalancers(balancers)
.setWorkers(jkScenario.getWorkerNodes())
.setStatusWorkers(jkScenario.getStatusWorkerNodes())
.setBalancers(workersProperties.getBalancers() + balancers)
.setWorkers(workersProperties.getWorkers() + jkScenario.getWorkerNodes())
.setStatusWorkers(workersProperties.getStatusWorkers() + jkScenario.getStatusWorkerNodes())

configurators << workersProperties.configure()
}
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/groovy/noe/jk/configure/FacingServerNode.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class FacingServerNode {
return uriWorkerMapProperties
}

JkScenario setUriWorkerMapProperties(UriWorkerMapProperties uriWorkerMapProperties) {
FacingServerNode setUriWorkerMapProperties(UriWorkerMapProperties uriWorkerMapProperties) {
this.uriWorkerMapProperties = uriWorkerMapProperties

return this
Expand All @@ -65,7 +65,7 @@ class FacingServerNode {
return workersProperties
}

JkScenario setWorkersProperties(WorkersProperties workersProperties) {
FacingServerNode setWorkersProperties(WorkersProperties workersProperties) {
this.workersProperties = workersProperties

return this
Expand Down
96 changes: 73 additions & 23 deletions core/src/main/groovy/noe/jk/configure/StatusWorkerOperation.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import noe.common.utils.Library
* Example: List balancer summary in text format
* <code>
* new StatusWorkerOperation()
* .setAction(StatusWorkerOperation.Action.LIST)
* .setAction(new StatusWorkerOperation.List())
* .setOutputFormat(StatusWorkerOperation.OutputFormat.TEXT)
* .setBalancerId(balancerId)
* .setHost(facingServer.getHost())
Expand All @@ -26,30 +26,84 @@ class StatusWorkerOperation {
* Chapter: Usage Patterns / Actions
* @link https://tomcat.apache.org/connectors-doc/reference/status.html
*/
enum Action { LIST, SHOW, EDIT, UPDATE, RESET, RECOVER, VERSION, DUMP }
interface Action {
String build()
}

/**
* Chapter: Usage Patterns / Output Format
* @link https://tomcat.apache.org/connectors-doc/reference/status.html
*/
enum OutputFormat { HTML, XML, PROPERTIES, TEXT }
static class List implements Action {
@Override
String build() {
return 'list'
}
}

/**
* Chapter: Request Parameters / Data Parameters for the standard Update Action
* @link https://tomcat.apache.org/connectors-doc/reference/status.html
*/
enum Parameters {
static class Show implements Action {
@Override
String build() {
return 'show'
}
}

static class Reset implements Action {
@Override
String build() {
return 'reset'
}
}

static class Recover implements Action {
@Override
String build() {
return 'recover'
}
}

static class Version implements Action {
@Override
String build() {
return 'version'
}
}

static class Dump implements Action {
@Override
String build() {
return 'dump'
}
}

static class Update implements Action {
Map<String, String> params = [:]

@Override
String build() {
StringBuilder action = new StringBuilder("update")

params.each {String name, String value ->
action.append("&${name.toLowerCase()}=${value}")
}

return action.toString()
}

// load balancer workers
VLR, VLT, VLEE, VLX, VLS, VLF, VLM, VLL,
/**
* Chapter: Request Parameters / Data Parameters for the standard Update Action
* @link https://tomcat.apache.org/connectors-doc/reference/status.html
*/
Update addParameter(String name, String value) {
params.put(name, value)

// load balancer members
VWA, VWF, VWN, VWR, VWC, VWD,
return this
}

// ajp workers and ajp load balancer members
VAHST, VAPRT, VACPT, VACT, VAPT, VART, VAR, VARO, VABL, VAMPS
}

/**
* Chapter: Usage Patterns / Output Format
* @link https://tomcat.apache.org/connectors-doc/reference/status.html
*/
enum OutputFormat { HTML, XML, PROPERTIES, TEXT }

Action action
OutputFormat outputFormat = OutputFormat.PROPERTIES
String host
Expand Down Expand Up @@ -168,7 +222,7 @@ class StatusWorkerOperation {
StringBuilder c = new StringBuilder("?")

if (action != null) {
c.append("cmd=${transformAction(action)}&")
c.append("cmd=${action.build()}&")
}
if (outputFormat != null) {
c.append("mime=${transformOutputType(outputFormat)}&")
Expand Down Expand Up @@ -205,10 +259,6 @@ class StatusWorkerOperation {
return this
}

private String transformAction(Action action) {
return action.toString().toLowerCase()
}

private String transformOutputType(OutputFormat format) {
switch (format){
case OutputFormat.TEXT:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class JkConfiguratorTestIT extends TestAbstract {
ops.startAll()

String res = new StatusWorkerOperation()
.setAction(StatusWorkerOperation.Action.LIST)
.setAction(new StatusWorkerOperation.List())
.setOutputFormat(StatusWorkerOperation.OutputFormat.TEXT)
.setBalancerId(balancerId)
.setAutomaticRefresh(1)
Expand Down