本文整理汇总了Java中org.jboss.as.controller.client.helpers.ClientConstants类的典型用法代码示例。如果您正苦于以下问题:Java ClientConstants类的具体用法?Java ClientConstants怎么用?Java ClientConstants使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ClientConstants类属于org.jboss.as.controller.client.helpers包,在下文中一共展示了ClientConstants类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: executeReload
import org.jboss.as.controller.client.helpers.ClientConstants; //导入依赖的package包/类
private static void executeReload(ModelControllerClient client, boolean adminOnly) {
ModelNode operation = new ModelNode();
operation.get(OP_ADDR).setEmptyList();
operation.get(OP).set("reload");
operation.get("admin-only").set(adminOnly);
try {
ModelNode result = client.execute(operation);
if (!"success".equals(result.get(ClientConstants.OUTCOME).asString())) {
fail("Reload operation didn't finished successfully: " + result.asString());
}
} catch(IOException e) {
final Throwable cause = e.getCause();
if (!(cause instanceof ExecutionException) && !(cause instanceof CancellationException)) {
throw new RuntimeException(e);
} // else ignore, this might happen if the channel gets closed before we got the response
}
}
示例2: testFilteringKeystoreCli
import org.jboss.as.controller.client.helpers.ClientConstants; //导入依赖的package包/类
@Test
public void testFilteringKeystoreCli() throws Exception {
ModelNode operation = new ModelNode();
operation.get(ClientConstants.OP_ADDR).add("subsystem","elytron").add(ElytronDescriptionConstants.FILTERING_KEY_STORE,"FilteringKeyStore");
operation.get(ClientConstants.OP).set(ElytronDescriptionConstants.READ_ALIASES);
List<ModelNode> nodes = assertSuccess(services.executeOperation(operation)).get(ClientConstants.RESULT).asList();
Assert.assertEquals(1, nodes.size());
Assert.assertEquals("firefly", nodes.get(0).asString());
operation = new ModelNode();
operation.get(ClientConstants.OP_ADDR).add("subsystem","elytron").add(ElytronDescriptionConstants.FILTERING_KEY_STORE,"FilteringKeyStore");
operation.get(ClientConstants.OP).set(ElytronDescriptionConstants.READ_ALIAS);
operation.get(ElytronDescriptionConstants.ALIAS).set("firefly");
ModelNode firefly = assertSuccess(services.executeOperation(operation)).get(ClientConstants.RESULT);
Assert.assertEquals("firefly", firefly.get(ElytronDescriptionConstants.ALIAS).asString());
Assert.assertEquals(KeyStore.PrivateKeyEntry.class.getSimpleName(), firefly.get(ElytronDescriptionConstants.ENTRY_TYPE).asString());
Assert.assertTrue(firefly.get(ElytronDescriptionConstants.CERTIFICATE_CHAIN).isDefined());
}
示例3: testDuplicateRealmValidation
import org.jboss.as.controller.client.helpers.ClientConstants; //导入依赖的package包/类
/**
* Regression test for WFCORE-2614 - don't allow duplicating realms referenced from a single domain.
*/
@Test
public void testDuplicateRealmValidation() throws Exception {
init();
ModelNode realmNode = new ModelNode();
ModelNode operation = Util.createEmptyOperation("list-add", PathAddress.pathAddress("subsystem", "elytron")
.append(ElytronDescriptionConstants.SECURITY_DOMAIN, "MyDomain"));
operation.get(ClientConstants.NAME).set(ElytronDescriptionConstants.REALMS);
realmNode.get("realm").set("PropRealm");
operation.get("value").set(realmNode);
Assert.assertNotNull(assertFail(services.executeOperation(operation)).get(ClientConstants.RESULT).asString());
realmNode.get("realm").set("FileRealm");
operation.get("value").set(realmNode);
Assert.assertNotNull(assertFail(services.executeOperation(operation)).get(ClientConstants.RESULT).asString());
realmNode.get("realm").set("NonDomainRealm");
operation.get("value").set(realmNode);
Assert.assertNotNull(assertSuccess(services.executeOperation(operation)).get(ClientConstants.RESULT).asString());
}
示例4: executeReload
import org.jboss.as.controller.client.helpers.ClientConstants; //导入依赖的package包/类
private void executeReload(StartMode startMode, String serverConfig) {
ModelNode operation = new ModelNode();
operation.get(OP_ADDR).setEmptyList();
operation.get(OP).set("reload");
if(startMode == StartMode.ADMIN_ONLY) {
operation.get("admin-only").set(true);
} else if(startMode == StartMode.SUSPEND) {
operation.get("start-mode").set("suspend");
}
if (serverConfig != null) {
operation.get(SERVER_CONFIG).set(serverConfig);
}
try {
ModelNode result = client.getControllerClient().execute(operation);
Assert.assertEquals("success", result.get(ClientConstants.OUTCOME).asString());
} catch (IOException e) {
final Throwable cause = e.getCause();
if (!(cause instanceof ExecutionException) && !(cause instanceof CancellationException) && !(cause instanceof SocketException) ) {
throw new RuntimeException(e);
} // else ignore, this might happen if the channel gets closed before we got the response
}finally {
safeCloseClient();//close existing client
}
}
示例5: deploy
import org.jboss.as.controller.client.helpers.ClientConstants; //导入依赖的package包/类
/**
* Deploys the archive to the running server.
*
* @param archive the archive to deploy
* @param runtimeName the runtime name for the deployment
*
* @throws IOException if an error occurs deploying the archive
*/
public static void deploy(final Archive<?> archive, final String runtimeName) throws IOException {
// Use an operation to allow overriding the runtime name
final ModelNode address = Operations.createAddress(DEPLOYMENT, archive.getName());
final ModelNode addOp = createAddOperation(address);
if (runtimeName != null && !archive.getName().equals(runtimeName)) {
addOp.get(RUNTIME_NAME).set(runtimeName);
}
addOp.get("enabled").set(true);
// Create the content for the add operation
final ModelNode contentNode = addOp.get(CONTENT);
final ModelNode contentItem = contentNode.get(0);
contentItem.get(ClientConstants.INPUT_STREAM_INDEX).set(0);
// Create an operation and add the input archive
final OperationBuilder builder = OperationBuilder.create(addOp);
builder.addInputStream(archive.as(ZipExporter.class).exportAsInputStream());
// Deploy the content and check the results
final ModelNode result = client.getControllerClient().execute(builder.build());
if (!Operations.isSuccessfulOutcome(result)) {
Assert.fail(String.format("Failed to deploy %s: %s", archive, Operations.getFailureDescription(result).asString()));
}
}
示例6: doesServerRequireRestart
import org.jboss.as.controller.client.helpers.ClientConstants; //导入依赖的package包/类
/**
* Check if the server is in restart-required state, that means
* management operation return "response-headers" : {"process-state" : "restart-required"}
*
* @return true if the server is in "restart-required" state
* @throws Exception
*/
public static boolean doesServerRequireRestart() throws Exception {
try (CLIWrapper cli = new CLIWrapper(true)) {
cli.sendLine("patch info --json-output", true);
String response = cli.readOutput();
ModelNode responseNode = ModelNode.fromJSONString(response);
ModelNode respHeaders = responseNode.get("response-headers");
if (respHeaders != null && respHeaders.isDefined()) {
ModelNode processState = respHeaders.get("process-state");
return processState != null && processState.isDefined() && processState.asString()
.equals(ClientConstants.CONTROLLER_PROCESS_STATE_RESTART_REQUIRED);
} else {
return false;
}
}
}
示例7: testDeployment
import org.jboss.as.controller.client.helpers.ClientConstants; //导入依赖的package包/类
private void testDeployment(final Archive<?> archive) throws IOException {
final ModelControllerClient client = domainMasterLifecycleUtil.getDomainClient();
final ModelNode readServerSubsystems = Operations.createOperation(ClientConstants.READ_CHILDREN_NAMES_OPERATION,
Operations.createAddress("host", "master", "server", "main-one"));
readServerSubsystems.get(ClientConstants.CHILD_TYPE).set(ClientConstants.SUBSYSTEM);
final String name = archive.getName();
// Deploy the archive
execute(client, createDeployAddOperation(archive.as(ZipExporter.class).exportAsInputStream(), name, null));
Assert.assertTrue("Deployment " + name + " was not deployed.", hasDeployment(client, name));
// Validate the subsystem child names on a server
ModelNode result = execute(client, readServerSubsystems);
validateSubsystemModel("/host=master/server=main-one", result);
// Fully replace the deployment, but with the 'enabled' flag set to false, triggering undeploy
final Operation fullReplaceOp = createReplaceAndDisableOperation(archive.as(ZipExporter.class).exportAsInputStream(), name, null);
execute(client, fullReplaceOp);
// Below validates that WFCORE-1577 is fixed, the model should not be missing on the /host=master/server=main-one or main-two
// Validate the subsystem child names
result = execute(client, readServerSubsystems);
validateSubsystemModel("/host=master/server=main-one", result);
}
示例8: hasDeployment
import org.jboss.as.controller.client.helpers.ClientConstants; //导入依赖的package包/类
private static boolean hasDeployment(final ModelControllerClient client, final String name) throws IOException {
final ModelNode op = Operations.createOperation(ClientConstants.READ_CHILDREN_NAMES_OPERATION);
op.get(CHILD_TYPE).set(DEPLOYMENT);
final ModelNode listDeploymentsResult;
try {
listDeploymentsResult = client.execute(op);
// Check to make sure there is an outcome
if (Operations.isSuccessfulOutcome(listDeploymentsResult)) {
final List<ModelNode> deployments = Operations.readResult(listDeploymentsResult).asList();
for (ModelNode deployment : deployments) {
if (name.equals(deployment.asString())) {
return true;
}
}
} else {
throw new IllegalStateException(Operations.getFailureDescription(listDeploymentsResult).asString());
}
} catch (IOException e) {
throw new IllegalStateException(String.format("Could not execute operation '%s'", op), e);
}
return false;
}
示例9: registerAttributes
import org.jboss.as.controller.client.helpers.ClientConstants; //导入依赖的package包/类
@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
resourceRegistration.registerReadOnlyAttribute(ServerRootResourceDefinition.LAUNCH_TYPE, (context,operation) -> {
readResourceServerConfig(context, operation);
context.getResult().set(ServerEnvironment.LaunchType.DOMAIN.toString());
});
resourceRegistration.registerReadOnlyAttribute(ServerRootResourceDefinition.SERVER_STATE, (context, operation) -> {
readResourceServerConfig(context, operation);
// note this is inconsistent with the other values, should be lower case, preserved for now.
context.getResult().set("STOPPED");
});
resourceRegistration.registerReadOnlyAttribute(ServerRootResourceDefinition.RUNTIME_CONFIGURATION_STATE,
(context, operation) -> {
readResourceServerConfig(context, operation);
context.getResult().set(ClientConstants.CONTROLLER_PROCESS_STATE_STOPPED);
}
);
}
示例10: get
import org.jboss.as.controller.client.helpers.ClientConstants; //导入依赖的package包/类
@Override
public ServerDeploymentPlanResult get() throws InterruptedException, ExecutionException {
boolean cleanup = true;
ModelNode node;
try {
node = nodeFuture.get();
} catch (InterruptedException ie) {
cleanup = false; // still may be in progress, so wait for finalize()
throw ie;
} finally {
if (cleanup) {
plan.cleanup();
}
}
return getResultFromNode(node.get(ClientConstants.RESULT));
}
示例11: testEmptyRoot
import org.jboss.as.controller.client.helpers.ClientConstants; //导入依赖的package包/类
@Test
public void testEmptyRoot() throws Exception {
KernelServices kernelServices = createEmptyRoot();
ModelNode model = kernelServices.readWholeModel(false, true);
assertAttribute(model, ModelDescriptionConstants.NAMESPACES, new ModelNode().setEmptyList());
assertAttribute(model, ModelDescriptionConstants.SCHEMA_LOCATIONS, new ModelNode().setEmptyList());
assertAttribute(model, ModelDescriptionConstants.NAME, new ModelNode(getDefaultServerName()));
assertAttribute(model, ModelDescriptionConstants.PRODUCT_NAME, null);
assertAttribute(model, ModelDescriptionConstants.PRODUCT_VERSION, null);
assertAttribute(model, ModelDescriptionConstants.MANAGEMENT_MAJOR_VERSION, new ModelNode(Version.MANAGEMENT_MAJOR_VERSION));
assertAttribute(model, ModelDescriptionConstants.MANAGEMENT_MINOR_VERSION, new ModelNode(Version.MANAGEMENT_MINOR_VERSION));
assertAttribute(model, ModelDescriptionConstants.MANAGEMENT_MICRO_VERSION, new ModelNode(Version.MANAGEMENT_MICRO_VERSION));
assertAttribute(model, ServerDescriptionConstants.PROCESS_STATE, new ModelNode("running"));
assertAttribute(model, ServerDescriptionConstants.RUNTIME_CONFIGURATION_STATE, new ModelNode(ClientConstants.CONTROLLER_PROCESS_STATE_OK));
assertAttribute(model, ServerDescriptionConstants.PROCESS_TYPE, new ModelNode("Server"));
assertAttribute(model, ServerDescriptionConstants.LAUNCH_TYPE, new ModelNode("STANDALONE"));
//These two cannot work in tests - placeholder
assertAttribute(model, ModelDescriptionConstants.RELEASE_VERSION, new ModelNode("Unknown"));
assertAttribute(model, ModelDescriptionConstants.RELEASE_CODENAME, new ModelNode(""));
//Try changing namespaces, schema-locations and name
}
示例12: getServerGroupServers
import org.jboss.as.controller.client.helpers.ClientConstants; //导入依赖的package包/类
protected Set<String> getServerGroupServers(final String name) throws IOException {
final Set<String> servers = new LinkedHashSet<>();
final ModelNode address = Operations.createAddress(ClientConstants.HOST, "*", ClientConstants.SERVER_CONFIG, "*");
final ModelNode op = Operations.createReadAttributeOperation(address, "group");
final ModelNode result = executeForSuccess(op);
for (ModelNode n : result.asList()) {
// Get the address and parse it out as we only need the two values
final List<ModelNode> segments = Operations.getOperationAddress(n).asList();
// Should be at least two address segments
if (segments.size() >= 2) {
final String serverGroupName = Operations.readResult(n).asString();
if (name.equals(serverGroupName)) {
servers.add(segments.get(1).get(ClientConstants.SERVER_CONFIG).asString());
}
}
}
return Collections.unmodifiableSet(servers);
}
示例13: testConnection
import org.jboss.as.controller.client.helpers.ClientConstants; //导入依赖的package包/类
private String testConnection( final ModelControllerClient client ) throws Exception {
try {
final ModelNode op = new ModelNode( );
op.get( ClientConstants.OP ).set( "read-resource" );
final ModelNode returnVal = client.execute( new OperationBuilder( op ).build( ) );
final String productName = returnVal.get( "result" ).get( "product-name" ).asString( );
final String productVersion = returnVal.get( "result" ).get( "product-version" ).asString( );
final String releaseVersion = returnVal.get( "result" ).get( "release-version" ).asString( );
final String releaseCodeName = returnVal.get( "result" ).get( "release-codename" ).asString( );
final StringBuilder stringBuilder = new StringBuilder( );
stringBuilder.append( productName + ", " + productVersion );
stringBuilder.append( " (" + releaseCodeName + ", " + releaseVersion + ")" );
return stringBuilder.toString( );
} catch ( Exception e ) {
logger.error( "It was not possible to open connection to Wildfly/EAP server.", e );
throw new Exception( "It was not possible to open connection to server. " + e.getMessage( ) );
}
}
示例14: getFailureDescriptionAsString
import org.jboss.as.controller.client.helpers.ClientConstants; //导入依赖的package包/类
/**
* Parses the result and returns the failure description. If the result was successful, an empty string is
* returned.
*
* @param result the result of executing an operation
*
* @return the failure message or an empty string
*/
public static String getFailureDescriptionAsString(final ModelNode result) {
if (isSuccessfulOutcome(result)) {
return "";
}
final String msg;
if (result.hasDefined(ClientConstants.FAILURE_DESCRIPTION)) {
if (result.hasDefined(ClientConstants.OP)) {
msg = String.format("Operation '%s' at address '%s' failed: %s", result.get(ClientConstants.OP), result.get(ClientConstants.OP_ADDR), result
.get(ClientConstants.FAILURE_DESCRIPTION));
} else {
msg = String.format("Operation failed: %s", result.get(ClientConstants.FAILURE_DESCRIPTION));
}
} else {
msg = String.format("An unexpected response was found checking the deployment. Result: %s", result);
}
return msg;
}
示例15: testDeployNewServerGroup
import org.jboss.as.controller.client.helpers.ClientConstants; //导入依赖的package包/类
@Test
public void testDeployNewServerGroup() throws Exception {
// Make sure the deployment is deployed to the main-server-group and not deployed to the other-server-group
if (!deploymentManager.hasDeployment(DEPLOYMENT_NAME, "main-server-group")) {
deploymentManager.deploy(getDeployment().addServerGroup("main-server-group"));
}
if (deploymentManager.hasDeployment(DEPLOYMENT_NAME, "other-server-group")) {
deploymentManager.undeploy(UndeployDescription.of(DEPLOYMENT_NAME).addServerGroup("other-deployment-group"));
}
// Set up the other-server-group servers to ensure the full deployment process works correctly
final ModelNode op = ServerOperations.createOperation("start-servers", ServerOperations.createAddress(ClientConstants.SERVER_GROUP, "other-server-group"));
op.get("blocking").set(true);
executeOperation(op);
// Deploy to both server groups and ensure the deployment exists on both, it should already be on the
// main-server-group and should have been added to the other-server-group
final Set<String> serverGroups = new HashSet<>(Arrays.asList("main-server-group", "other-server-group"));
executeAndVerifyDeploymentExists("deploy", "deploy-multi-server-group-pom.xml", null, serverGroups);
deploymentManager.undeploy(UndeployDescription.of(DEPLOYMENT_NAME).addServerGroups(serverGroups));
}