private AvailabilityType waitForServerToStart(long start) throws InterruptedException { AvailabilityType avail; //detect whether startWaitMax property has been set. Configuration pluginConfig = serverComponent.getResourceContext().getPluginConfiguration(); PropertySimple property = pluginConfig.getSimple(TomcatServerComponent.START_WAIT_MAX_PROP); //if set and valid, update startWaitMax value if ((property != null) && (property.getIntegerValue() != null)) { int newValue = property.getIntegerValue(); if (newValue >= 1) { START_WAIT_MAX = 1000L * 60 * newValue; } } while (((avail = this.serverComponent.getAvailability()) == AvailabilityType.DOWN) && (System.currentTimeMillis() < (start + START_WAIT_MAX))) { Thread.sleep(START_WAIT_INTERVAL); } return avail; }
protected Object getPropertyValueAsType(PropertySimple propSimple, String typeName) { Object value; if (typeName.equals(String.class.getName())) { value = (propSimple == null) ? null : propSimple.getStringValue(); } else if (typeName.equals(Boolean.class.getName()) || typeName.equals(boolean.class.getName())) { value = (propSimple == null) ? null : propSimple.getBooleanValue(); } else if (typeName.equals(Integer.class.getName()) || typeName.equals(int.class.getName())) { value = (propSimple == null) ? null : propSimple.getIntegerValue(); } else if (typeName.equals(Long.class.getName()) || typeName.equals(long.class.getName())) { value = (propSimple == null) ? null : propSimple.getLongValue(); } else if (typeName.equals(Float.class.getName()) || typeName.equals(float.class.getName())) { value = (propSimple == null) ? null : propSimple.getFloatValue(); } else if (typeName.equals(Double.class.getName()) || typeName.equals(double.class.getName())) { value = (propSimple == null) ? null : propSimple.getDoubleValue(); } else { throw new IllegalStateException("Operation parameter maps to MBean parameter with an unsupported type (" + typeName + ")."); } // TODO GH: Handle rest of types. (I think i have a mapper for this in mc4j return value; } }
} else if (expectedReturn.getName().equals(Integer.class.getName()) || expectedReturn.getName().equals(Integer.TYPE.getName())) { return simple.getIntegerValue(); } else if (expectedReturn.getName().equals(Long.class.getName()) || expectedReturn.getName().equals(Long.TYPE.getName())) {
private AvailabilityType waitForServerToShutdown() throws InterruptedException { //detect whether stopWaitMax property has been set. Configuration pluginConfig = serverComponent.getResourceContext().getPluginConfiguration(); PropertySimple property = pluginConfig.getSimple(TomcatServerComponent.STOP_WAIT_MAX_PROP); //if set and valid, update startWaitMax value if ((property != null) && (property.getIntegerValue() != null)) { int newValue = property.getIntegerValue(); if (newValue >= 1) { STOP_WAIT_MAX = 1000L * 60 * newValue; } } for (long wait = 0L; (wait < STOP_WAIT_MAX) && (AvailabilityType.UP == this.serverComponent.getAvailability()); wait += STOP_WAIT_INTERVAL) { Thread.sleep(STOP_WAIT_INTERVAL); } // After the server shows unavailable, wait a little longer to hopefully ensure shutdown is complete. Thread.sleep(STOP_WAIT_FINAL); return this.serverComponent.getAvailability(); }
PropertySimple timeoutProperty = parameters.getSimple(OperationDefinition.TIMEOUT_PARAM_NAME); if (timeoutProperty != null) { timeout = timeoutProperty.getIntegerValue();
private BundleDeployment createBundleDeploymentImpl(Subject subject, BundleVersion bundleVersion, BundleDestination bundleDestination, String name, String description, Configuration configuration) throws Exception { ConfigurationDefinition configDef = bundleVersion.getConfigurationDefinition(); if (null != configDef) { if (null == configuration) { throw new IllegalArgumentException( "Missing Configuration. Configuration is required when the specified BundleVersion defines Configuration Properties."); } // passing in the default configuration will make sure that the readonly properties with the non-null // default values defined in the config def cannot be overridden by the caller. // Those properties are meant to be set by the bundle plugins, not by the user. Configuration defaultConfig = ConfigurationUtility.createDefaultConfiguration(configDef); List<String> errors = ConfigurationUtility.validateConfiguration(configuration, defaultConfig, configDef); if (!errors.isEmpty()) { throw new IllegalArgumentException("Invalid Configuration: " + errors.toString()); } } BundleDeployment deployment = new BundleDeployment(bundleVersion, bundleDestination, name); deployment.setDescription(description); deployment.setConfiguration(configuration); deployment.setSubjectName(subject.getName()); PropertySimple discoveryDelayProperty = configuration.getSimple("org.rhq.discoveryDelay"); if(discoveryDelayProperty != null) { deployment.setDiscoveryDelay(discoveryDelayProperty.getIntegerValue()); } entityManager.persist(deployment); return deployment; }
@Override public OperationResult invokeOperation(final String name, final Configuration parameters) throws InterruptedException, Exception { if (OPERATION_RESET.equals(name)) { final Service service = getService(); final Application application = getApplication(); if ((service != null) && (application != null)) { final String serviceName = service.getName().toString(); final String applicationName = application.getName().toString(); execute(new ResetServiceMetrics(applicationName, serviceName), Void.class); clearServiceMetrics(); } } else if (OPERATION_SET_THROTTLING.equals(name)) { final PropertySimple enabled = (PropertySimple) parameters.get(OPERATION_PARAMETER_ENABLED); final PropertySimple maxRequests = (PropertySimple) parameters.get(OPERATION_PARAMETER_MAX_REQUESTS); final Service service = getService(); final Application application = getApplication(); if ((service != null) && (application != null)) { final String serviceName = service.getName().toString(); final String applicationName = application.getName().toString(); execute(new UpdateThrottling(applicationName, serviceName, (enabled != null ? enabled.getBooleanValue() : null), (maxRequests != null ? maxRequests.getIntegerValue() : null)), Void.class); clearApplications(); } } else if (LOG.isDebugEnabled()) { LOG.warn("Unknown Service operation " + name); } return null; }
/** * Return the object representation of the passed PropertySimple for the passed type * @param prop Property to evaluate * @param type Type to convert into * @return Converted object -- if no valid type is found, a String-value is returned. */ private Object getObjectForProperty(PropertySimple prop, PropertySimpleType type) { switch (type) { case STRING: return prop.getStringValue(); case INTEGER: return prop.getIntegerValue(); case BOOLEAN: return prop.getBooleanValue(); case LONG: return prop.getLongValue(); case FLOAT: return prop.getFloatValue(); case DOUBLE: return prop.getDoubleValue(); default: return prop.getStringValue(); } }
@Override public OperationResult invokeOperation(String name, Configuration parameters) throws InterruptedException, Exception { Operation op = new Operation(name, getAddress()); Result res = getASConnection().execute(op, parameters.getSimple("responseTimeout").getIntegerValue()); OperationResult result = new OperationResult(); if (res.isSuccess()) { result.setSimpleResult(SUCCESS); } else { result.setErrorMessage(res.getFailureDescription()); } return result; }
switch (def.getType()) { case INTEGER: { attribute.setValue(property.getIntegerValue()); break;
PropertySimple offset = rc.getSimple("socket-binding-port-offset"); if (offset != null && offset.getStringValue() != null) op.addAdditionalProperty("socket-binding-port-offset", offset.getIntegerValue());