Created
April 10, 2014 17:47
-
-
Save ncdc/10406196 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/main/java/com/openshift/metrics/extension/Constants.java b/src/main/java/com/openshift/metrics/extension/Constants.java | |
index 5401483..af1dc05 100644 | |
--- a/src/main/java/com/openshift/metrics/extension/Constants.java | |
+++ b/src/main/java/com/openshift/metrics/extension/Constants.java | |
@@ -2,6 +2,7 @@ package com.openshift.metrics.extension; | |
public class Constants { | |
public static final String MODEL_CONTROLLER_CLIENT = "modelControllerClient"; | |
+ public static final String MAX_LINE_LENGTH = "max-line-length"; | |
public static final String METRIC_SOURCES = "metricSources"; | |
public static final String METRICS_SERVICE_NAME = "metrics"; | |
public static final String SOURCE = "source"; | |
@@ -14,6 +15,7 @@ public class Constants { | |
public static final String CRON = "cron"; | |
public static final String MBEAN = "mbean"; | |
public static final String ENABLED = "enabled"; | |
+ public static final String ERRORS_LOGGED = "errorsLogged"; | |
private Constants() {} | |
} | |
diff --git a/src/main/java/com/openshift/metrics/extension/MetricAddHandler.java b/src/main/java/com/openshift/metrics/extension/MetricAddHandler.java | |
index 602faf0..06663b9 100644 | |
--- a/src/main/java/com/openshift/metrics/extension/MetricAddHandler.java | |
+++ b/src/main/java/com/openshift/metrics/extension/MetricAddHandler.java | |
@@ -2,6 +2,7 @@ package com.openshift.metrics.extension; | |
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD; | |
+import java.text.MessageFormat; | |
import java.util.List; | |
import java.util.Locale; | |
@@ -15,14 +16,11 @@ import org.jboss.as.controller.descriptions.DescriptionProvider; | |
import org.jboss.as.controller.descriptions.ModelDescriptionConstants; | |
import org.jboss.as.controller.descriptions.StandardResourceDescriptionResolver; | |
import org.jboss.dmr.ModelNode; | |
-import org.jboss.logging.Logger; | |
import org.jboss.msc.service.ServiceController; | |
public class MetricAddHandler extends AbstractAddStepHandler implements DescriptionProvider { | |
public static final MetricAddHandler INSTANCE = new MetricAddHandler(); | |
- private final Logger log = Logger.getLogger(MetricAddHandler.class); | |
- | |
public MetricAddHandler() { | |
} | |
@@ -43,16 +41,17 @@ public class MetricAddHandler extends AbstractAddStepHandler implements Descript | |
@Override | |
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model, ServiceVerificationHandler verificationHandler, List<ServiceController<?>> newControllers) throws OperationFailedException { | |
MetricsService service = (MetricsService) context.getServiceRegistry(true).getRequiredService(MetricsService.getServiceName()).getValue(); | |
- String key = MetricDefinition.SOURCE_KEY.resolveModelAttribute(context, model).asString(); | |
+ String sourceKey = MetricDefinition.SOURCE_KEY.resolveModelAttribute(context, model).asString(); | |
final String schedule = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.ADDRESS)).getElement(1).getValue(); | |
- final String sourceKey = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.ADDRESS)).getElement(2).getValue(); | |
+ final String sourcePath = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.ADDRESS)).getElement(2).getValue(); | |
String publishKey = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.ADDRESS)).getElement(3).getValue(); | |
boolean enabled = MetricsGroupDefinition.ENABLED.resolveModelAttribute(context, operation).asBoolean(); | |
final String cronExpression = Util.decodeCronExpression(schedule); | |
try { | |
- service.addMetric(cronExpression, sourceKey, key, publishKey, enabled); | |
+ service.addMetric(cronExpression, sourcePath, sourceKey, publishKey, enabled); | |
} catch (Exception e) { | |
- log.errorv(e, "Encountered exception trying to add metric[schedule={0}, source={1}, sourceKey={2}, publishKey={3}, enabled={4}]", cronExpression, sourceKey, sourceKey, publishKey, enabled); | |
+ String message = MessageFormat.format("Encountered exception trying to add metric[schedule={0}, source={1}, sourceKey={2}, publishKey={3}, enabled={4}]", cronExpression, sourcePath, sourceKey, publishKey, enabled); | |
+ throw new OperationFailedException(message, e); | |
} | |
} | |
} | |
diff --git a/src/main/java/com/openshift/metrics/extension/MetricDefinition.java b/src/main/java/com/openshift/metrics/extension/MetricDefinition.java | |
index fcbae37..fdcc934 100644 | |
--- a/src/main/java/com/openshift/metrics/extension/MetricDefinition.java | |
+++ b/src/main/java/com/openshift/metrics/extension/MetricDefinition.java | |
@@ -2,6 +2,8 @@ package com.openshift.metrics.extension; | |
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR; | |
+import java.text.MessageFormat; | |
+ | |
import org.jboss.as.controller.AbstractWriteAttributeHandler; | |
import org.jboss.as.controller.OperationContext; | |
import org.jboss.as.controller.OperationFailedException; | |
@@ -70,7 +72,7 @@ public class MetricDefinition extends SimpleResourceDefinition { | |
modify(context, operation, valueToRestore.asBoolean()); | |
} | |
- private void modify(OperationContext context, ModelNode operation, boolean enabled) { | |
+ private void modify(OperationContext context, ModelNode operation, boolean enabled) throws OperationFailedException { | |
MetricsService service = (MetricsService) context.getServiceRegistry(true).getRequiredService(MetricsService.getServiceName()).getValue(); | |
ModelNode address = operation.require(OP_ADDR); | |
final String schedule = PathAddress.pathAddress(address).getElement(1).getValue(); | |
@@ -80,8 +82,8 @@ public class MetricDefinition extends SimpleResourceDefinition { | |
try { | |
service.enableMetric(cronExpression, sourcePath, publishKey, enabled); | |
} catch (SchedulerException e) { | |
- // TODO Auto-generated catch block | |
- e.printStackTrace(); | |
+ String message = MessageFormat.format("Encountered exception trying to enable/disable metric[schedule={0}, source={1}, publishKey={2}, enabled={3}]", cronExpression, sourcePath, publishKey, enabled); | |
+ throw new OperationFailedException(message, e); | |
} | |
} | |
} | |
diff --git a/src/main/java/com/openshift/metrics/extension/MetricJob.java b/src/main/java/com/openshift/metrics/extension/MetricJob.java | |
index ada39cb..dd34db3 100644 | |
--- a/src/main/java/com/openshift/metrics/extension/MetricJob.java | |
+++ b/src/main/java/com/openshift/metrics/extension/MetricJob.java | |
@@ -1,55 +1,88 @@ | |
package com.openshift.metrics.extension; | |
+import static com.openshift.metrics.extension.Constants.MAX_LINE_LENGTH; | |
import static com.openshift.metrics.extension.Constants.METRIC_SOURCES; | |
import static com.openshift.metrics.extension.Constants.MODEL_CONTROLLER_CLIENT; | |
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP; | |
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR; | |
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.READ_ATTRIBUTE_OPERATION; | |
-import java.io.IOException; | |
import java.lang.management.ManagementFactory; | |
import java.text.MessageFormat; | |
+import java.util.ArrayList; | |
+import java.util.HashSet; | |
+import java.util.List; | |
import java.util.Map; | |
+import java.util.Set; | |
import java.util.StringTokenizer; | |
-import javax.management.AttributeNotFoundException; | |
-import javax.management.InstanceNotFoundException; | |
-import javax.management.MBeanException; | |
import javax.management.MBeanServer; | |
-import javax.management.MalformedObjectNameException; | |
import javax.management.ObjectName; | |
-import javax.management.ReflectionException; | |
import javax.management.openmbean.CompositeData; | |
import org.jboss.as.controller.client.ModelControllerClient; | |
import org.jboss.as.controller.descriptions.ModelDescriptionConstants; | |
import org.jboss.dmr.ModelNode; | |
import org.jboss.logging.Logger; | |
+import org.quartz.DisallowConcurrentExecution; | |
import org.quartz.Job; | |
import org.quartz.JobDataMap; | |
import org.quartz.JobExecutionContext; | |
import org.quartz.JobExecutionException; | |
-import org.quartz.SchedulerException; | |
+import org.quartz.PersistJobDataAfterExecution; | |
+@DisallowConcurrentExecution | |
+@PersistJobDataAfterExecution | |
public class MetricJob implements Job { | |
private final Logger log = Logger.getLogger(MetricJob.class); | |
- private static final String PUBLISH_FORMAT="type=metric cart=jboss {0}={1}"; | |
+ private List<String> metricsToPublish = new ArrayList<String>(); | |
+ | |
+ private int outputLength = 0; | |
+ | |
+ private static final int DEFAULT_MAX_LINE_LENGTH = 1024; | |
+ | |
+ private Integer maxLineLength = null; | |
+ | |
+ private void logError(JobExecutionContext context, String message, Exception e) { | |
+ @SuppressWarnings("unchecked") | |
+ Set<String> errorsLogged = (Set<String>) context.getJobDetail().getJobDataMap().get(Constants.ERRORS_LOGGED); | |
+ | |
+ if(null == errorsLogged) { | |
+ errorsLogged = new HashSet<String>(); | |
+ context.getJobDetail().getJobDataMap().put(Constants.ERRORS_LOGGED, errorsLogged); | |
+ } | |
+ | |
+ if(!errorsLogged.contains(message)) { | |
+ errorsLogged.add(message); | |
+ log.error(message, e); | |
+ } | |
+ } | |
private ModelControllerClient getModelControllerClient(JobExecutionContext context) { | |
ModelControllerClient client = null; | |
try { | |
client = (ModelControllerClient) context.getScheduler().getContext().get(MODEL_CONTROLLER_CLIENT); | |
- } catch (SchedulerException e) { | |
- log.error("Unable to retrieve model controller client from job/scheduler context", e); | |
- //TODO do we need to consider unscheduling this job if we fail to get the client | |
- //some # of times? | |
+ } catch (Exception e) { | |
+ logError(context, "Unable to retrieve model controller client from job/scheduler context", e); | |
} | |
return client; | |
} | |
+ private void lookupMaxLineLength(JobExecutionContext context) { | |
+ try { | |
+ maxLineLength = (Integer)context.getScheduler().getContext().get(MAX_LINE_LENGTH); | |
+ } catch (Exception e) { | |
+ // ignore exception - use default value instead | |
+ } | |
+ | |
+ if(null == maxLineLength) { | |
+ maxLineLength = DEFAULT_MAX_LINE_LENGTH; | |
+ } | |
+ } | |
+ | |
/** | |
* Set the {@code operation}'s address from the {@code source}. | |
* | |
@@ -73,6 +106,8 @@ public class MetricJob implements Job { | |
@Override | |
public void execute(JobExecutionContext context) throws JobExecutionException { | |
+ lookupMaxLineLength(context); | |
+ | |
// the job data map has the metric sources associated with this job | |
final JobDataMap jobDataMap = context.getMergedJobDataMap(); | |
@@ -89,11 +124,15 @@ public class MetricJob implements Job { | |
} | |
if(Constants.MBEAN.equals(source.getType())) { | |
- doMBeanSource(source); | |
+ doMBeanSource(source, context); | |
} else { | |
doNativeSource(source, context); | |
} | |
} | |
+ | |
+ if(metricsToPublish.size() > 0) { | |
+ publish(); | |
+ } | |
} | |
private String[] extractKeyAndSubkey(String key) { | |
@@ -114,7 +153,7 @@ public class MetricJob implements Job { | |
return new String[] {key, subkey}; | |
} | |
- private void doMBeanSource(Source source) { | |
+ private void doMBeanSource(Source source, JobExecutionContext context) { | |
// Get the mBeanServer to access source | |
MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer(); | |
@@ -136,32 +175,26 @@ public class MetricJob implements Job { | |
// Execute getAttribute on mBeanServer with source | |
try { | |
ObjectName name = new ObjectName(source.getPath()); | |
+ | |
Object result = mBeanServer.getAttribute(name, key); | |
+ | |
if(subkey != null) { | |
if(result instanceof CompositeData) { | |
CompositeData cd = (CompositeData) result; | |
+ | |
if(cd.containsKey(subkey)) { | |
result = cd.get(subkey); | |
+ } else { | |
+ continue; | |
} | |
} | |
} | |
+ | |
String metricValue = result.toString(); | |
- publishMetric(publishKey, metricValue); | |
- } catch (AttributeNotFoundException e) { | |
- // TODO Auto-generated catch block | |
- e.printStackTrace(); | |
- } catch (InstanceNotFoundException e) { | |
- // TODO Auto-generated catch block | |
- e.printStackTrace(); | |
- } catch (MBeanException e) { | |
- // TODO Auto-generated catch block | |
- e.printStackTrace(); | |
- } catch (ReflectionException e) { | |
- // TODO Auto-generated catch block | |
- e.printStackTrace(); | |
- } catch (MalformedObjectNameException e) { | |
- // TODO Auto-generated catch block | |
- e.printStackTrace(); | |
+ storeMetric(publishKey, metricValue); | |
+ } catch (Exception e) { | |
+ String message = MessageFormat.format("Error retrieving mbean metric source={0}, source-key={1}", source.getPath(), metric.getSourceKey()); | |
+ logError(context, message, e); | |
} | |
} | |
} | |
@@ -204,8 +237,14 @@ public class MetricJob implements Job { | |
// execute the request | |
ModelNode r = modelControllerClient.execute(op); | |
- // TODO consider checking the status | |
- // get the result | |
+ final ModelNode outcome = r.get(ModelDescriptionConstants.OUTCOME); | |
+ if(null == outcome || !ModelDescriptionConstants.SUCCESS.equals(outcome.asString())) { | |
+ String message = MessageFormat.format("Error retrieving jboss metric source={0}, source-key={1}: {2}", source.getPath(), metric.getSourceKey(), r.get(ModelDescriptionConstants.FAILURE_DESCRIPTION).asString()); | |
+ logError(context, message, null); | |
+ | |
+ continue; | |
+ } | |
+ | |
ModelNode result = r.get(ModelDescriptionConstants.RESULT); | |
if(subkey != null) { | |
@@ -213,18 +252,41 @@ public class MetricJob implements Job { | |
result = result.get(subkey); | |
} | |
- String metricValue = result.asString(); | |
- publishMetric(publishKey, metricValue); | |
- } catch (IOException e) { | |
- log.error("Error executing operation " + op, e); | |
- // TODO anything else to do here? | |
+ if (result.isDefined()) { | |
+ String metricValue = result.asString(); | |
+ storeMetric(publishKey, metricValue); | |
+ } | |
+ } catch (Exception e) { | |
+ String message = MessageFormat.format("Error retrieving jboss metric source={0}, source-key={1}", source.getPath(), metric.getSourceKey()); | |
+ logError(context, message, e); | |
} | |
} | |
} | |
- private void publishMetric(String publishKey, String metricValue) { | |
- //TODO switch to syslog? | |
- log.info(MessageFormat.format(PUBLISH_FORMAT, publishKey, metricValue)); | |
+ private void storeMetric(String publishKey, String metricValue) { | |
+ final String newMetric = publishKey + "=" + metricValue; | |
+ final int newMetricLength = newMetric.length() + 1; | |
+ if (outputLength + newMetricLength > maxLineLength) { | |
+ publish(); | |
+ } | |
+ metricsToPublish.add(newMetric); | |
+ outputLength += newMetricLength; | |
} | |
+ private void publish() { | |
+ //TODO consider allowing user to configure "cart" text in config file | |
+ StringBuilder sb = new StringBuilder("type=metric cart=jboss "); | |
+ for(int i = 0, n = metricsToPublish.size(); i < n; i++) { | |
+ String s = metricsToPublish.get(i); | |
+ sb.append(s); | |
+ if(i < n - 1) { | |
+ sb.append(" "); | |
+ } | |
+ } | |
+ | |
+ log.info(sb.toString()); | |
+ | |
+ metricsToPublish.clear(); | |
+ outputLength = 0; | |
+ } | |
} | |
diff --git a/src/main/java/com/openshift/metrics/extension/MetricRemoveHandler.java b/src/main/java/com/openshift/metrics/extension/MetricRemoveHandler.java | |
index 9f9fc56..62ed1fb 100644 | |
--- a/src/main/java/com/openshift/metrics/extension/MetricRemoveHandler.java | |
+++ b/src/main/java/com/openshift/metrics/extension/MetricRemoveHandler.java | |
@@ -2,6 +2,7 @@ package com.openshift.metrics.extension; | |
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.REMOVE; | |
+import java.text.MessageFormat; | |
import java.util.Locale; | |
import org.jboss.as.controller.AbstractRemoveStepHandler; | |
@@ -13,13 +14,10 @@ import org.jboss.as.controller.descriptions.DescriptionProvider; | |
import org.jboss.as.controller.descriptions.ModelDescriptionConstants; | |
import org.jboss.as.controller.descriptions.StandardResourceDescriptionResolver; | |
import org.jboss.dmr.ModelNode; | |
-import org.jboss.logging.Logger; | |
public class MetricRemoveHandler extends AbstractRemoveStepHandler implements DescriptionProvider { | |
public static final MetricRemoveHandler INSTANCE = new MetricRemoveHandler(); | |
- private final Logger log = Logger.getLogger(MetricRemoveHandler.class); | |
- | |
public MetricRemoveHandler() { | |
} | |
@@ -42,7 +40,8 @@ public class MetricRemoveHandler extends AbstractRemoveStepHandler implements De | |
try { | |
service.removeMetric(cronExpression, source, publishKey); | |
} catch (Exception e) { | |
- log.errorv(e, "Encountered exception trying to remove metric[schedule={0}, source={1}, publishKey={2}]", cronExpression, source, publishKey); | |
+ String message = MessageFormat.format("Encountered exception trying to remove metric[schedule={0}, source={1}, publishKey={2}]", cronExpression, source, publishKey); | |
+ throw new OperationFailedException(message, e); | |
} | |
} | |
} | |
diff --git a/src/main/java/com/openshift/metrics/extension/MetricsGroupAddHandler.java b/src/main/java/com/openshift/metrics/extension/MetricsGroupAddHandler.java | |
index 1b23809..8cd4c8c 100644 | |
--- a/src/main/java/com/openshift/metrics/extension/MetricsGroupAddHandler.java | |
+++ b/src/main/java/com/openshift/metrics/extension/MetricsGroupAddHandler.java | |
@@ -3,6 +3,7 @@ package com.openshift.metrics.extension; | |
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD; | |
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR; | |
+import java.text.MessageFormat; | |
import java.util.List; | |
import java.util.Locale; | |
@@ -14,14 +15,11 @@ import org.jboss.as.controller.ServiceVerificationHandler; | |
import org.jboss.as.controller.descriptions.DefaultOperationDescriptionProvider; | |
import org.jboss.as.controller.descriptions.DescriptionProvider; | |
import org.jboss.dmr.ModelNode; | |
-import org.jboss.logging.Logger; | |
import org.jboss.msc.service.ServiceController; | |
public class MetricsGroupAddHandler extends AbstractAddStepHandler implements DescriptionProvider { | |
public static final MetricsGroupAddHandler INSTANCE = new MetricsGroupAddHandler(); | |
- private final Logger log = Logger.getLogger(MetricsGroupAddHandler.class); | |
- | |
public MetricsGroupAddHandler() { | |
} | |
@@ -46,7 +44,8 @@ public class MetricsGroupAddHandler extends AbstractAddStepHandler implements De | |
try { | |
service.createJob(cronExpression, enabled); | |
} catch (Exception e) { | |
- log.errorv(e, "Encountered exception trying to add metrics group[schedule={0}]", cronExpression); | |
+ String message = MessageFormat.format("Encountered exception trying to add metrics group[schedule={0}]", cronExpression); | |
+ throw new OperationFailedException(message, e); | |
} | |
} | |
} | |
diff --git a/src/main/java/com/openshift/metrics/extension/MetricsGroupDefinition.java b/src/main/java/com/openshift/metrics/extension/MetricsGroupDefinition.java | |
index 9decdba..1c5486d 100644 | |
--- a/src/main/java/com/openshift/metrics/extension/MetricsGroupDefinition.java | |
+++ b/src/main/java/com/openshift/metrics/extension/MetricsGroupDefinition.java | |
@@ -2,6 +2,8 @@ package com.openshift.metrics.extension; | |
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR; | |
+import java.text.MessageFormat; | |
+ | |
import org.jboss.as.controller.AbstractWriteAttributeHandler; | |
import org.jboss.as.controller.OperationContext; | |
import org.jboss.as.controller.OperationFailedException; | |
@@ -77,7 +79,7 @@ public class MetricsGroupDefinition extends SimpleResourceDefinition { | |
modify(context, operation, valueToRestore.asBoolean()); | |
} | |
- private void modify(OperationContext context, ModelNode operation, boolean enabled) { | |
+ private void modify(OperationContext context, ModelNode operation, boolean enabled) throws OperationFailedException { | |
MetricsService service = (MetricsService) context.getServiceRegistry(true).getRequiredService(MetricsService.getServiceName()).getValue(); | |
ModelNode address = operation.require(OP_ADDR); | |
String schedule = PathAddress.pathAddress(address).getLastElement().getValue(); | |
@@ -89,8 +91,8 @@ public class MetricsGroupDefinition extends SimpleResourceDefinition { | |
service.disableJob(cronExpression); | |
} | |
} catch (SchedulerException e) { | |
- // TODO Auto-generated catch block | |
- e.printStackTrace(); | |
+ String message = MessageFormat.format("Encountered exception trying to enable/disable metric group[schedule={0}, enabled={1}]", cronExpression, enabled); | |
+ throw new OperationFailedException(message, e); | |
} | |
} | |
diff --git a/src/main/java/com/openshift/metrics/extension/MetricsGroupRemoveHandler.java b/src/main/java/com/openshift/metrics/extension/MetricsGroupRemoveHandler.java | |
index e239fb1..baacd36 100644 | |
--- a/src/main/java/com/openshift/metrics/extension/MetricsGroupRemoveHandler.java | |
+++ b/src/main/java/com/openshift/metrics/extension/MetricsGroupRemoveHandler.java | |
@@ -3,6 +3,7 @@ package com.openshift.metrics.extension; | |
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR; | |
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.REMOVE; | |
+import java.text.MessageFormat; | |
import java.util.Locale; | |
import org.jboss.as.controller.AbstractRemoveStepHandler; | |
@@ -13,13 +14,10 @@ import org.jboss.as.controller.PathAddress; | |
import org.jboss.as.controller.descriptions.DefaultOperationDescriptionProvider; | |
import org.jboss.as.controller.descriptions.DescriptionProvider; | |
import org.jboss.dmr.ModelNode; | |
-import org.jboss.logging.Logger; | |
public class MetricsGroupRemoveHandler extends AbstractRemoveStepHandler implements DescriptionProvider { | |
public static final MetricsGroupRemoveHandler INSTANCE = new MetricsGroupRemoveHandler(); | |
- private final Logger log = Logger.getLogger(MetricsGroupRemoveHandler.class); | |
- | |
public MetricsGroupRemoveHandler() { | |
} | |
@@ -38,7 +36,8 @@ public class MetricsGroupRemoveHandler extends AbstractRemoveStepHandler impleme | |
try { | |
service.removeJob(cronExpression); | |
} catch (Exception e) { | |
- log.errorv(e, "Encountered exception trying to remove metrics group[schedule={0}]", cronExpression); | |
+ String message = MessageFormat.format("Encountered exception trying to remove metrics group[schedule={0}]", cronExpression); | |
+ throw new OperationFailedException(message, e); | |
} | |
} | |
} | |
diff --git a/src/main/java/com/openshift/metrics/extension/MetricsService.java b/src/main/java/com/openshift/metrics/extension/MetricsService.java | |
index e920c14..685221e 100644 | |
--- a/src/main/java/com/openshift/metrics/extension/MetricsService.java | |
+++ b/src/main/java/com/openshift/metrics/extension/MetricsService.java | |
@@ -47,31 +47,26 @@ public class MetricsService implements Service<MetricsService> { | |
private ExecutorService managementOperationExecutor; | |
- public MetricsService() { | |
- try { | |
- // I originally had this in start() but it looks like start() and | |
- // the various ADD operations that are invoked after the subsystem | |
- // is parsed can run in separate threads, so I had a race condition | |
- // where something like createJob() would run before start(), resulting | |
- // in an NPE because the scheduler was null. Not sure of the best way | |
- // to do this... | |
- log.debug("Creating metrics scheduler"); | |
- scheduler = StdSchedulerFactory.getDefaultScheduler(); | |
- | |
- // Is this the most appropriate executor type? | |
- managementOperationExecutor = Executors.newSingleThreadExecutor(new ThreadFactory() { | |
- @Override | |
- public Thread newThread(Runnable run) { | |
- Thread thread = new Thread(run); | |
- thread.setName("Metrics Management Client Thread"); | |
- thread.setDaemon(true); | |
- return thread; | |
- } | |
- }); | |
- } catch (SchedulerException e) { | |
- //TODO better error handling | |
- e.printStackTrace(); | |
- } | |
+ public MetricsService() throws SchedulerException { | |
+ // I originally had this in start() but it looks like start() and | |
+ // the various ADD operations that are invoked after the subsystem | |
+ // is parsed can run in separate threads, so I had a race condition | |
+ // where something like createJob() would run before start(), resulting | |
+ // in an NPE because the scheduler was null. Not sure of the best way | |
+ // to do this... | |
+ log.debug("Creating metrics scheduler"); | |
+ scheduler = StdSchedulerFactory.getDefaultScheduler(); | |
+ | |
+ // Is this the most appropriate executor type? | |
+ managementOperationExecutor = Executors.newSingleThreadExecutor(new ThreadFactory() { | |
+ @Override | |
+ public Thread newThread(Runnable run) { | |
+ Thread thread = new Thread(run); | |
+ thread.setName("Metrics Management Client Thread"); | |
+ thread.setDaemon(true); | |
+ return thread; | |
+ } | |
+ }); | |
} | |
/** | |
@@ -305,6 +300,14 @@ public class MetricsService implements Service<MetricsService> { | |
return trigger; | |
} | |
+ public Integer getMaxLineLength() throws SchedulerException { | |
+ return (Integer)scheduler.getContext().get(Constants.MAX_LINE_LENGTH); | |
+ } | |
+ | |
+ public void setMaxLineLength(Integer value) throws SchedulerException { | |
+ scheduler.getContext().put(Constants.MAX_LINE_LENGTH, value); | |
+ } | |
+ | |
/** | |
* Get the model controller | |
* @return the model controller | |
diff --git a/src/main/java/com/openshift/metrics/extension/OpenShiftSubsystemAdd.java b/src/main/java/com/openshift/metrics/extension/OpenShiftSubsystemAdd.java | |
index 962b2bf..fdf22af 100644 | |
--- a/src/main/java/com/openshift/metrics/extension/OpenShiftSubsystemAdd.java | |
+++ b/src/main/java/com/openshift/metrics/extension/OpenShiftSubsystemAdd.java | |
@@ -12,14 +12,17 @@ import org.jboss.as.controller.descriptions.DefaultOperationDescriptionProvider; | |
import org.jboss.as.controller.descriptions.DescriptionProvider; | |
import org.jboss.as.server.Services; | |
import org.jboss.dmr.ModelNode; | |
+import org.jboss.logging.Logger; | |
import org.jboss.msc.service.ServiceBuilder.DependencyType; | |
import org.jboss.msc.service.ServiceController; | |
import org.jboss.msc.service.ServiceController.Mode; | |
+import org.quartz.SchedulerException; | |
/** | |
* Handler responsible for adding the subsystem resource to the model | |
*/ | |
class OpenShiftSubsystemAdd extends AbstractAddStepHandler implements DescriptionProvider { | |
+ private final Logger log = Logger.getLogger(OpenShiftSubsystemAdd.class); | |
static final OpenShiftSubsystemAdd INSTANCE = new OpenShiftSubsystemAdd(); | |
@@ -35,19 +38,32 @@ class OpenShiftSubsystemAdd extends AbstractAddStepHandler implements Descriptio | |
/** {@inheritDoc} */ | |
@Override | |
protected void performRuntime(org.jboss.as.controller.OperationContext context, ModelNode operation, ModelNode model, org.jboss.as.controller.ServiceVerificationHandler verificationHandler, java.util.List<org.jboss.msc.service.ServiceController<?>> newControllers) throws OperationFailedException { | |
- MetricsService service = new MetricsService(); | |
- | |
- ServiceController<MetricsService> controller = context.getServiceTarget() | |
- .addService(MetricsService.getServiceName(), service) | |
- .addDependency(DependencyType.REQUIRED, | |
- Services.JBOSS_SERVER_CONTROLLER, | |
- ModelController.class, | |
- service.getInjectedModelController()) | |
- .addListener(verificationHandler) | |
- .setInitialMode(Mode.ACTIVE) | |
- .install(); | |
- | |
- newControllers.add(controller); | |
+ try { | |
+ MetricsService service = new MetricsService(); | |
+ | |
+ if(operation.hasDefined(Constants.MAX_LINE_LENGTH)) { | |
+ Integer value = operation.get(Constants.MAX_LINE_LENGTH).asInt(); | |
+ try { | |
+ service.setMaxLineLength(value); | |
+ } catch (SchedulerException e) { | |
+ log.warnv(e, "Error setting max line length to {0}: {1}", value, e.getMessage()); | |
+ } | |
+ } | |
+ | |
+ ServiceController<MetricsService> controller = context.getServiceTarget() | |
+ .addService(MetricsService.getServiceName(), service) | |
+ .addDependency(DependencyType.REQUIRED, | |
+ Services.JBOSS_SERVER_CONTROLLER, | |
+ ModelController.class, | |
+ service.getInjectedModelController()) | |
+ .addListener(verificationHandler) | |
+ .setInitialMode(Mode.ACTIVE) | |
+ .install(); | |
+ | |
+ newControllers.add(controller); | |
+ } catch (SchedulerException e) { | |
+ throw new OperationFailedException("Error adding metrics subsystem", e); | |
+ } | |
} | |
@Override | |
diff --git a/src/main/java/com/openshift/metrics/extension/OpenShiftSubsystemDefinition.java b/src/main/java/com/openshift/metrics/extension/OpenShiftSubsystemDefinition.java | |
index eb514d8..e840533 100644 | |
--- a/src/main/java/com/openshift/metrics/extension/OpenShiftSubsystemDefinition.java | |
+++ b/src/main/java/com/openshift/metrics/extension/OpenShiftSubsystemDefinition.java | |
@@ -1,11 +1,28 @@ | |
package com.openshift.metrics.extension; | |
+import org.jboss.as.controller.AbstractWriteAttributeHandler; | |
+import org.jboss.as.controller.OperationContext; | |
+import org.jboss.as.controller.OperationFailedException; | |
+import org.jboss.as.controller.SimpleAttributeDefinition; | |
+import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; | |
import org.jboss.as.controller.SimpleResourceDefinition; | |
+import org.jboss.as.controller.registry.AttributeAccess; | |
import org.jboss.as.controller.registry.ManagementResourceRegistration; | |
+import org.jboss.dmr.ModelNode; | |
+import org.jboss.dmr.ModelType; | |
+import org.quartz.SchedulerException; | |
public class OpenShiftSubsystemDefinition extends SimpleResourceDefinition { | |
public static final OpenShiftSubsystemDefinition INSTANCE = new OpenShiftSubsystemDefinition(); | |
+ protected static final SimpleAttributeDefinition MAX_LINE_LENGTH = | |
+ new SimpleAttributeDefinitionBuilder(Constants.MAX_LINE_LENGTH, ModelType.INT) | |
+ .setAllowExpression(false) | |
+ .setXmlName(Constants.MAX_LINE_LENGTH) | |
+ .setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES) | |
+ .setAllowNull(true) | |
+ .build(); | |
+ | |
private OpenShiftSubsystemDefinition() { | |
super(OpenShiftSubsystemExtension.SUBSYSTEM_PATH, | |
OpenShiftSubsystemExtension.getResourceDescriptionResolver(), | |
@@ -18,4 +35,51 @@ public class OpenShiftSubsystemDefinition extends SimpleResourceDefinition { | |
super.registerChildren(resourceRegistration); | |
resourceRegistration.registerSubModel(MetricsGroupDefinition.INSTANCE); | |
} | |
+ | |
+ @Override | |
+ public void registerAttributes(ManagementResourceRegistration resourceRegistration) { | |
+ super.registerAttributes(resourceRegistration); | |
+ resourceRegistration.registerReadWriteAttribute(MAX_LINE_LENGTH, null, MaxLineLengthHandler.INSTANCE); | |
+ } | |
+ | |
+ static class MaxLineLengthHandler extends AbstractWriteAttributeHandler<Boolean> { | |
+ public static final MaxLineLengthHandler INSTANCE = new MaxLineLengthHandler(); | |
+ | |
+ private MaxLineLengthHandler() { | |
+ super(OpenShiftSubsystemDefinition.MAX_LINE_LENGTH); | |
+ } | |
+ | |
+ @Override | |
+ protected boolean applyUpdateToRuntime( | |
+ OperationContext context, | |
+ ModelNode operation, | |
+ String attributeName, | |
+ ModelNode resolvedValue, | |
+ ModelNode currentValue, | |
+ org.jboss.as.controller.AbstractWriteAttributeHandler.HandbackHolder<Boolean> handbackHolder) | |
+ throws OperationFailedException { | |
+ | |
+ modify(context, operation, resolvedValue.asInt()); | |
+ | |
+ return false; | |
+ } | |
+ | |
+ @Override | |
+ protected void revertUpdateToRuntime(OperationContext context, | |
+ ModelNode operation, String attributeName, | |
+ ModelNode valueToRestore, ModelNode valueToRevert, Boolean handback) | |
+ throws OperationFailedException { | |
+ | |
+ modify(context, operation, valueToRestore.asInt()); | |
+ } | |
+ | |
+ private void modify(OperationContext context, ModelNode operation, Integer value) { | |
+ try { | |
+ MetricsService service = (MetricsService) context.getServiceRegistry(true).getRequiredService(MetricsService.getServiceName()).getValue(); | |
+ service.setMaxLineLength(value); | |
+ } catch (SchedulerException e) { | |
+ } | |
+ } | |
+ | |
+ } | |
} | |
diff --git a/src/main/java/com/openshift/metrics/extension/OpenShiftSubsystemParser.java b/src/main/java/com/openshift/metrics/extension/OpenShiftSubsystemParser.java | |
index 5d01e14..6cdc914 100644 | |
--- a/src/main/java/com/openshift/metrics/extension/OpenShiftSubsystemParser.java | |
+++ b/src/main/java/com/openshift/metrics/extension/OpenShiftSubsystemParser.java | |
@@ -31,7 +31,13 @@ public class OpenShiftSubsystemParser implements XMLStreamConstants, XMLElementR | |
@Override | |
public void writeContent(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context) throws XMLStreamException { | |
context.startSubsystemElement(OpenShiftSubsystemExtension.NAMESPACE, false); | |
+ | |
ModelNode node = context.getModelNode(); | |
+ | |
+ if(node.hasDefined(Constants.MAX_LINE_LENGTH)) { | |
+ OpenShiftSubsystemDefinition.MAX_LINE_LENGTH.marshallAsElement(node, writer); | |
+ } | |
+ | |
ModelNode metricsGroups = node.get(Constants.METRICS_GROUP); | |
writeMetricsGroups(writer, metricsGroups); | |
writer.writeEndElement(); | |
@@ -105,11 +111,14 @@ public class OpenShiftSubsystemParser implements XMLStreamConstants, XMLElementR | |
list.add(subsystem); | |
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { | |
- if(!reader.getLocalName().equals(Constants.METRICS_GROUP)) { | |
+ if(reader.getLocalName().equals(Constants.MAX_LINE_LENGTH)) { | |
+ final String value = parseElementNoAttributes(reader); | |
+ OpenShiftSubsystemDefinition.MAX_LINE_LENGTH.parseAndSetParameter(value, subsystem, reader); | |
+ } else if(reader.getLocalName().equals(Constants.METRICS_GROUP)) { | |
+ readMetricsGroups(reader, address, list); | |
+ } else { | |
throw ParseUtils.unexpectedElement(reader); | |
} | |
- | |
- readMetricsGroups(reader, address, list); | |
} | |
} | |
@@ -201,4 +210,11 @@ public class OpenShiftSubsystemParser implements XMLStreamConstants, XMLElementR | |
addMetricOperation.get(OP_ADDR).set(address.toModelNode()); | |
list.add(addMetricOperation); | |
} | |
+ | |
+ private String parseElementNoAttributes(final XMLExtendedStreamReader reader) throws XMLStreamException { | |
+ // no attributes | |
+ ParseUtils.requireNoAttributes(reader); | |
+ | |
+ return reader.getElementText().trim(); | |
+ } | |
} | |
\ No newline at end of file | |
diff --git a/src/main/java/com/openshift/metrics/extension/SourceAddHandler.java b/src/main/java/com/openshift/metrics/extension/SourceAddHandler.java | |
index 9d2f8a6..132b813 100644 | |
--- a/src/main/java/com/openshift/metrics/extension/SourceAddHandler.java | |
+++ b/src/main/java/com/openshift/metrics/extension/SourceAddHandler.java | |
@@ -2,6 +2,7 @@ package com.openshift.metrics.extension; | |
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD; | |
+import java.text.MessageFormat; | |
import java.util.List; | |
import java.util.Locale; | |
@@ -14,14 +15,11 @@ import org.jboss.as.controller.descriptions.DefaultOperationDescriptionProvider; | |
import org.jboss.as.controller.descriptions.DescriptionProvider; | |
import org.jboss.as.controller.descriptions.ModelDescriptionConstants; | |
import org.jboss.dmr.ModelNode; | |
-import org.jboss.logging.Logger; | |
import org.jboss.msc.service.ServiceController; | |
public class SourceAddHandler extends AbstractAddStepHandler implements DescriptionProvider { | |
public static final SourceAddHandler INSTANCE = new SourceAddHandler(); | |
- private final Logger log = Logger.getLogger(SourceAddHandler.class); | |
- | |
public SourceAddHandler() { | |
} | |
@@ -50,7 +48,8 @@ public class SourceAddHandler extends AbstractAddStepHandler implements Descript | |
try { | |
service.addMetricSource(cronExpression, source); | |
} catch (Exception e) { | |
- log.errorv(e, "Encountered exception trying to add source[schedule={0}, path={1}]", cronExpression, source); | |
+ String message = MessageFormat.format("Encountered exception trying to add source[schedule={0}, path={1}]", cronExpression, source); | |
+ throw new OperationFailedException(message, e); | |
} | |
} | |
} | |
diff --git a/src/main/java/com/openshift/metrics/extension/SourceDefinition.java b/src/main/java/com/openshift/metrics/extension/SourceDefinition.java | |
index 83c9e77..c4f16de 100644 | |
--- a/src/main/java/com/openshift/metrics/extension/SourceDefinition.java | |
+++ b/src/main/java/com/openshift/metrics/extension/SourceDefinition.java | |
@@ -2,6 +2,8 @@ package com.openshift.metrics.extension; | |
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR; | |
+import java.text.MessageFormat; | |
+ | |
import org.jboss.as.controller.AbstractWriteAttributeHandler; | |
import org.jboss.as.controller.OperationContext; | |
import org.jboss.as.controller.OperationFailedException; | |
@@ -76,7 +78,7 @@ public class SourceDefinition extends SimpleResourceDefinition { | |
modify(context, operation, valueToRestore.asBoolean()); | |
} | |
- private void modify(OperationContext context, ModelNode operation, boolean enabled) { | |
+ private void modify(OperationContext context, ModelNode operation, boolean enabled) throws OperationFailedException { | |
MetricsService service = (MetricsService) context.getServiceRegistry(true).getRequiredService(MetricsService.getServiceName()).getValue(); | |
ModelNode address = operation.require(OP_ADDR); | |
final String schedule = PathAddress.pathAddress(address).getElement(1).getValue(); | |
@@ -85,8 +87,8 @@ public class SourceDefinition extends SimpleResourceDefinition { | |
try { | |
service.enableMetricSource(cronExpression, sourcePath, enabled); | |
} catch (SchedulerException e) { | |
- // TODO Auto-generated catch block | |
- e.printStackTrace(); | |
+ String message = MessageFormat.format("Encountered exception trying to enable/disable metric source[schedule={0}, source={1}, enabled={2}]", cronExpression, sourcePath, enabled); | |
+ throw new OperationFailedException(message, e); | |
} | |
} | |
diff --git a/src/main/java/com/openshift/metrics/extension/SourceRemoveHandler.java b/src/main/java/com/openshift/metrics/extension/SourceRemoveHandler.java | |
index 88c148c..2aa7abd 100644 | |
--- a/src/main/java/com/openshift/metrics/extension/SourceRemoveHandler.java | |
+++ b/src/main/java/com/openshift/metrics/extension/SourceRemoveHandler.java | |
@@ -2,6 +2,7 @@ package com.openshift.metrics.extension; | |
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.REMOVE; | |
+import java.text.MessageFormat; | |
import java.util.Locale; | |
import org.jboss.as.controller.AbstractRemoveStepHandler; | |
@@ -13,13 +14,10 @@ import org.jboss.as.controller.descriptions.DefaultOperationDescriptionProvider; | |
import org.jboss.as.controller.descriptions.DescriptionProvider; | |
import org.jboss.as.controller.descriptions.ModelDescriptionConstants; | |
import org.jboss.dmr.ModelNode; | |
-import org.jboss.logging.Logger; | |
public class SourceRemoveHandler extends AbstractRemoveStepHandler implements DescriptionProvider { | |
public static final SourceRemoveHandler INSTANCE = new SourceRemoveHandler(); | |
- private final Logger log = Logger.getLogger(SourceRemoveHandler.class); | |
- | |
public SourceRemoveHandler() { | |
} | |
@@ -39,7 +37,8 @@ public class SourceRemoveHandler extends AbstractRemoveStepHandler implements De | |
try { | |
service.removeMetricSource(cronExpression, source); | |
} catch (Exception e) { | |
- log.errorv(e, "Encountered exception trying to add source[schedule={0}, path={1}]", cronExpression, source); | |
+ String message = MessageFormat.format("Encountered exception trying to add source[schedule={0}, path={1}]", cronExpression, source); | |
+ throw new OperationFailedException(message, e); | |
} | |
} | |
} | |
diff --git a/src/main/resources/com/openshift/metrics/extension/LocalDescriptions.properties b/src/main/resources/com/openshift/metrics/extension/LocalDescriptions.properties | |
index 889a603..c6fbfc7 100644 | |
--- a/src/main/resources/com/openshift/metrics/extension/LocalDescriptions.properties | |
+++ b/src/main/resources/com/openshift/metrics/extension/LocalDescriptions.properties | |
@@ -1,6 +1,7 @@ | |
metrics=Metrics | |
-metrics.add=Operation Adds subsystem | |
-metrics.remove=Operation Removes subsystem | |
+metrics.add=Operation adds subsystem | |
+metrics.remove=Operation removes subsystem | |
+metrics.max-line-length=Maximum metrics line length | |
metrics.metrics-group=Metrics group | |
metrics.metrics-group.add=Add metrics group | |
metrics.metrics-group.remove=Remove metrics group | |
diff --git a/src/main/resources/schema/metrics.xsd b/src/main/resources/schema/metrics.xsd | |
index 7978e04..ef9d2a4 100644 | |
--- a/src/main/resources/schema/metrics.xsd | |
+++ b/src/main/resources/schema/metrics.xsd | |
@@ -3,28 +3,32 @@ | |
elementFormDefault="qualified" attributeFormDefault="unqualified" | |
version="1.0"> | |
- <!-- The subsystem root element --> | |
<xs:element name="subsystem" type="subsystemType" /> | |
+ | |
<xs:complexType name="subsystemType"> | |
- <xs:choice minOccurs="0" maxOccurs="unbounded"> | |
- <xs:element name="metrics-group" type="metricsGroupType" /> | |
- </xs:choice> | |
+ <xs:sequence> | |
+ <xs:element name="max-line-length" type="xs:integer" minOccurs="0" maxOccurs="1"/> | |
+ <xs:element name="metrics-group" type="metricsGroupType" minOccurs="1" maxOccurs="unbounded"/> | |
+ </xs:sequence> | |
</xs:complexType> | |
+ | |
<xs:complexType name="metricsGroupType"> | |
- <xs:choice minOccurs="1" maxOccurs="unbounded"> | |
- <xs:element name="source" type="sourceType" /> | |
- </xs:choice> | |
+ <xs:sequence> | |
+ <xs:element name="source" type="sourceType" minOccurs="1" maxOccurs="unbounded"/> | |
+ </xs:sequence> | |
<xs:attribute name="cron" use="required" /> | |
<xs:attribute name="enabled" type="xs:boolean" /> | |
</xs:complexType> | |
+ | |
<xs:complexType name="sourceType"> | |
- <xs:choice minOccurs="1" maxOccurs="unbounded"> | |
- <xs:element name="metric" type="metricType" /> | |
- </xs:choice> | |
+ <xs:sequence> | |
+ <xs:element name="metric" type="metricType" minOccurs="1" maxOccurs="unbounded"/> | |
+ </xs:sequence> | |
<xs:attribute name="node" use="required" /> | |
<xs:attribute name="type" use="required" /> | |
<xs:attribute name="enabled" type="xs:boolean" /> | |
</xs:complexType> | |
+ | |
<xs:complexType name="metricType"> | |
<xs:attribute name="source-key" use="required" /> | |
<xs:attribute name="publish-key" use="required" /> | |
diff --git a/src/test/java/com/openshift/metrics/extension/SubsystemParsingTestCase.java b/src/test/java/com/openshift/metrics/extension/SubsystemParsingTestCase.java | |
index e9d13b4..95d11bb 100644 | |
--- a/src/test/java/com/openshift/metrics/extension/SubsystemParsingTestCase.java | |
+++ b/src/test/java/com/openshift/metrics/extension/SubsystemParsingTestCase.java | |
@@ -137,6 +137,26 @@ public class SubsystemParsingTestCase extends AbstractSubsystemTest { | |
validateAddMetricOp(op, "g2.s1.sk1", "g2.s1.pk1"); | |
} | |
+ @Test | |
+ public void testParseSubsystemWithMaxLineLength() throws Exception { | |
+ String xml = | |
+ "<subsystem xmlns=\"" + OpenShiftSubsystemExtension.NAMESPACE + "\">" + | |
+ " <max-line-length>100</max-line-length>" + | |
+ " <metrics-group cron=\"* * * * * ?\">" + | |
+ " <source type=\"jboss\" path=\"g2.s1\">" + | |
+ " <metric source-key=\"g2.s1.sk1\" publish-key=\"g2.s1.pk1\" />" + | |
+ " </source>" + | |
+ " </metrics-group>" + | |
+ "</subsystem>"; | |
+ | |
+ //Parse the subsystem xml into operations | |
+ List<ModelNode> operations = super.parse(xml); | |
+ | |
+ // op1: add subsystem | |
+ ModelNode op = operations.get(0); | |
+ validateAddSubsystemOp(op, 100); | |
+ } | |
+ | |
private void validateAddMetricOp(ModelNode op, String sourceKey, String publishKey) { | |
final PathAddress addr = PathAddress.pathAddress(op.get(OP_ADDR)); | |
final PathElement element = addr.getElement(3); | |
@@ -163,11 +183,18 @@ public class SubsystemParsingTestCase extends AbstractSubsystemTest { | |
} | |
private void validateAddSubsystemOp(ModelNode op) { | |
+ validateAddSubsystemOp(op, null); | |
+ } | |
+ | |
+ private void validateAddSubsystemOp(ModelNode op, Integer maxLineLength) { | |
Assert.assertEquals(ADD, op.get(OP).asString()); | |
PathAddress addr = PathAddress.pathAddress(op.get(OP_ADDR)); | |
PathElement element = addr.getElement(0); | |
Assert.assertEquals(SUBSYSTEM, element.getKey()); | |
Assert.assertEquals(OpenShiftSubsystemExtension.SUBSYSTEM_NAME, element.getValue()); | |
+ if(maxLineLength != null) { | |
+ Assert.assertEquals(maxLineLength, (Integer)op.get(Constants.MAX_LINE_LENGTH).asInt()); | |
+ } | |
} | |
/** |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment