repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1
value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
seratch/jslack | src/main/java/com/github/seratch/jslack/api/rtm/RTMEventHandler.java | RTMEventHandler.getEventClass | public Class<E> getEventClass() {
if (cachedClazz != null) {
return cachedClazz;
}
Class<?> clazz = this.getClass();
while (clazz != Object.class) {
try {
Type mySuperclass = clazz.getGenericSuperclass();
Type tType = ((ParameterizedType) mySuperclass).getActualTypeArguments()[0];
cachedClazz = (Class<E>) Class.forName(tType.getTypeName());
return cachedClazz;
} catch (Exception e) {
}
clazz = clazz.getSuperclass();
}
throw new IllegalStateException("Failed to load event class - " + this.getClass().getCanonicalName());
} | java | public Class<E> getEventClass() {
if (cachedClazz != null) {
return cachedClazz;
}
Class<?> clazz = this.getClass();
while (clazz != Object.class) {
try {
Type mySuperclass = clazz.getGenericSuperclass();
Type tType = ((ParameterizedType) mySuperclass).getActualTypeArguments()[0];
cachedClazz = (Class<E>) Class.forName(tType.getTypeName());
return cachedClazz;
} catch (Exception e) {
}
clazz = clazz.getSuperclass();
}
throw new IllegalStateException("Failed to load event class - " + this.getClass().getCanonicalName());
} | [
"public",
"Class",
"<",
"E",
">",
"getEventClass",
"(",
")",
"{",
"if",
"(",
"cachedClazz",
"!=",
"null",
")",
"{",
"return",
"cachedClazz",
";",
"}",
"Class",
"<",
"?",
">",
"clazz",
"=",
"this",
".",
"getClass",
"(",
")",
";",
"while",
"(",
"claz... | Returns the Class object of the Event implementation. | [
"Returns",
"the",
"Class",
"object",
"of",
"the",
"Event",
"implementation",
"."
] | 4a09680f13c97b33f59bc9b8271fef488c8e1c3a | https://github.com/seratch/jslack/blob/4a09680f13c97b33f59bc9b8271fef488c8e1c3a/src/main/java/com/github/seratch/jslack/api/rtm/RTMEventHandler.java#L40-L56 | train |
thymeleaf/thymeleaf-spring | thymeleaf-spring5/src/main/java/org/thymeleaf/spring5/processor/AbstractSpringFieldTagProcessor.java | AbstractSpringFieldTagProcessor.computeId | protected final String computeId(
final ITemplateContext context,
final IProcessableElementTag tag,
final String name, final boolean sequence) {
String id = tag.getAttributeValue(this.idAttributeDefinition.getAttributeName());
if (!org.thymeleaf.util.StringUtils.isEmptyOrWhitespace(id)) {
return (StringUtils.hasText(id) ? id : null);
}
id = FieldUtils.idFromName(name);
if (sequence) {
final Integer count = context.getIdentifierSequences().getAndIncrementIDSeq(id);
return id + count.toString();
}
return id;
} | java | protected final String computeId(
final ITemplateContext context,
final IProcessableElementTag tag,
final String name, final boolean sequence) {
String id = tag.getAttributeValue(this.idAttributeDefinition.getAttributeName());
if (!org.thymeleaf.util.StringUtils.isEmptyOrWhitespace(id)) {
return (StringUtils.hasText(id) ? id : null);
}
id = FieldUtils.idFromName(name);
if (sequence) {
final Integer count = context.getIdentifierSequences().getAndIncrementIDSeq(id);
return id + count.toString();
}
return id;
} | [
"protected",
"final",
"String",
"computeId",
"(",
"final",
"ITemplateContext",
"context",
",",
"final",
"IProcessableElementTag",
"tag",
",",
"final",
"String",
"name",
",",
"final",
"boolean",
"sequence",
")",
"{",
"String",
"id",
"=",
"tag",
".",
"getAttribute... | This method is designed to be called from the diverse subclasses | [
"This",
"method",
"is",
"designed",
"to",
"be",
"called",
"from",
"the",
"diverse",
"subclasses"
] | 9aa15a19017a0938e57646e3deefb8a90ab78dcb | https://github.com/thymeleaf/thymeleaf-spring/blob/9aa15a19017a0938e57646e3deefb8a90ab78dcb/thymeleaf-spring5/src/main/java/org/thymeleaf/spring5/processor/AbstractSpringFieldTagProcessor.java#L207-L224 | train |
thymeleaf/thymeleaf-spring | thymeleaf-spring5/src/main/java/org/thymeleaf/spring5/expression/Themes.java | Themes.code | public String code(final String code) {
if (this.theme == null) {
throw new TemplateProcessingException("Theme cannot be resolved because RequestContext was not found. "
+ "Are you using a Context object without a RequestContext variable?");
}
return this.theme.getMessageSource().getMessage(code, null, "", this.locale);
} | java | public String code(final String code) {
if (this.theme == null) {
throw new TemplateProcessingException("Theme cannot be resolved because RequestContext was not found. "
+ "Are you using a Context object without a RequestContext variable?");
}
return this.theme.getMessageSource().getMessage(code, null, "", this.locale);
} | [
"public",
"String",
"code",
"(",
"final",
"String",
"code",
")",
"{",
"if",
"(",
"this",
".",
"theme",
"==",
"null",
")",
"{",
"throw",
"new",
"TemplateProcessingException",
"(",
"\"Theme cannot be resolved because RequestContext was not found. \"",
"+",
"\"Are you us... | Looks up and returns the value of the given key in the properties file of
the currently-selected theme.
@param code Key to look up in the theme properties file.
@return The value of the code in the current theme properties file, or an
empty string if the code could not be resolved. | [
"Looks",
"up",
"and",
"returns",
"the",
"value",
"of",
"the",
"given",
"key",
"in",
"the",
"properties",
"file",
"of",
"the",
"currently",
"-",
"selected",
"theme",
"."
] | 9aa15a19017a0938e57646e3deefb8a90ab78dcb | https://github.com/thymeleaf/thymeleaf-spring/blob/9aa15a19017a0938e57646e3deefb8a90ab78dcb/thymeleaf-spring5/src/main/java/org/thymeleaf/spring5/expression/Themes.java#L66-L72 | train |
wildfly/wildfly-core | host-controller/src/main/java/org/jboss/as/host/controller/ManagedServerBootCmdFactory.java | ManagedServerBootCmdFactory.resolveDirectoryGrouping | private static DirectoryGrouping resolveDirectoryGrouping(final ModelNode model, final ExpressionResolver expressionResolver) {
try {
return DirectoryGrouping.forName(HostResourceDefinition.DIRECTORY_GROUPING.resolveModelAttribute(expressionResolver, model).asString());
} catch (OperationFailedException e) {
throw new IllegalStateException(e);
}
} | java | private static DirectoryGrouping resolveDirectoryGrouping(final ModelNode model, final ExpressionResolver expressionResolver) {
try {
return DirectoryGrouping.forName(HostResourceDefinition.DIRECTORY_GROUPING.resolveModelAttribute(expressionResolver, model).asString());
} catch (OperationFailedException e) {
throw new IllegalStateException(e);
}
} | [
"private",
"static",
"DirectoryGrouping",
"resolveDirectoryGrouping",
"(",
"final",
"ModelNode",
"model",
",",
"final",
"ExpressionResolver",
"expressionResolver",
")",
"{",
"try",
"{",
"return",
"DirectoryGrouping",
".",
"forName",
"(",
"HostResourceDefinition",
".",
"... | Returns the value of found in the model.
@param model the model that contains the key and value.
@param expressionResolver the expression resolver to use to resolve expressions
@return the directory grouping found in the model.
@throws IllegalArgumentException if the {@link org.jboss.as.controller.descriptions.ModelDescriptionConstants#DIRECTORY_GROUPING directory grouping}
was not found in the model. | [
"Returns",
"the",
"value",
"of",
"found",
"in",
"the",
"model",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/host-controller/src/main/java/org/jboss/as/host/controller/ManagedServerBootCmdFactory.java#L238-L244 | train |
wildfly/wildfly-core | host-controller/src/main/java/org/jboss/as/host/controller/ManagedServerBootCmdFactory.java | ManagedServerBootCmdFactory.addPathProperty | private String addPathProperty(final List<String> command, final String typeName, final String propertyName, final Map<String, String> properties, final DirectoryGrouping directoryGrouping,
final File typeDir, File serverDir) {
final String result;
final String value = properties.get(propertyName);
if (value == null) {
switch (directoryGrouping) {
case BY_TYPE:
result = getAbsolutePath(typeDir, "servers", serverName);
break;
case BY_SERVER:
default:
result = getAbsolutePath(serverDir, typeName);
break;
}
properties.put(propertyName, result);
} else {
final File dir = new File(value);
switch (directoryGrouping) {
case BY_TYPE:
result = getAbsolutePath(dir, "servers", serverName);
break;
case BY_SERVER:
default:
result = getAbsolutePath(dir, serverName);
break;
}
}
command.add(String.format("-D%s=%s", propertyName, result));
return result;
} | java | private String addPathProperty(final List<String> command, final String typeName, final String propertyName, final Map<String, String> properties, final DirectoryGrouping directoryGrouping,
final File typeDir, File serverDir) {
final String result;
final String value = properties.get(propertyName);
if (value == null) {
switch (directoryGrouping) {
case BY_TYPE:
result = getAbsolutePath(typeDir, "servers", serverName);
break;
case BY_SERVER:
default:
result = getAbsolutePath(serverDir, typeName);
break;
}
properties.put(propertyName, result);
} else {
final File dir = new File(value);
switch (directoryGrouping) {
case BY_TYPE:
result = getAbsolutePath(dir, "servers", serverName);
break;
case BY_SERVER:
default:
result = getAbsolutePath(dir, serverName);
break;
}
}
command.add(String.format("-D%s=%s", propertyName, result));
return result;
} | [
"private",
"String",
"addPathProperty",
"(",
"final",
"List",
"<",
"String",
">",
"command",
",",
"final",
"String",
"typeName",
",",
"final",
"String",
"propertyName",
",",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"properties",
",",
"final",
"Dire... | Adds the absolute path to command.
@param command the command to add the arguments to.
@param typeName the type of directory.
@param propertyName the name of the property.
@param properties the properties where the path may already be defined.
@param directoryGrouping the directory group type.
@param typeDir the domain level directory for the given directory type; to be used for by-type grouping
@param serverDir the root directory for the server, to be used for 'by-server' grouping
@return the absolute path that was added. | [
"Adds",
"the",
"absolute",
"path",
"to",
"command",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/host-controller/src/main/java/org/jboss/as/host/controller/ManagedServerBootCmdFactory.java#L530-L559 | train |
wildfly/wildfly-core | logging/src/main/java/org/jboss/as/logging/deployments/LoggingProfileDeploymentProcessor.java | LoggingProfileDeploymentProcessor.findLoggingProfile | private String findLoggingProfile(final ResourceRoot resourceRoot) {
final Manifest manifest = resourceRoot.getAttachment(Attachments.MANIFEST);
if (manifest != null) {
final String loggingProfile = manifest.getMainAttributes().getValue(LOGGING_PROFILE);
if (loggingProfile != null) {
LoggingLogger.ROOT_LOGGER.debugf("Logging profile '%s' found in '%s'.", loggingProfile, resourceRoot);
return loggingProfile;
}
}
return null;
} | java | private String findLoggingProfile(final ResourceRoot resourceRoot) {
final Manifest manifest = resourceRoot.getAttachment(Attachments.MANIFEST);
if (manifest != null) {
final String loggingProfile = manifest.getMainAttributes().getValue(LOGGING_PROFILE);
if (loggingProfile != null) {
LoggingLogger.ROOT_LOGGER.debugf("Logging profile '%s' found in '%s'.", loggingProfile, resourceRoot);
return loggingProfile;
}
}
return null;
} | [
"private",
"String",
"findLoggingProfile",
"(",
"final",
"ResourceRoot",
"resourceRoot",
")",
"{",
"final",
"Manifest",
"manifest",
"=",
"resourceRoot",
".",
"getAttachment",
"(",
"Attachments",
".",
"MANIFEST",
")",
";",
"if",
"(",
"manifest",
"!=",
"null",
")"... | Find the logging profile attached to any resource.
@param resourceRoot the root resource
@return the logging profile name or {@code null} if one was not found | [
"Find",
"the",
"logging",
"profile",
"attached",
"to",
"any",
"resource",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/logging/src/main/java/org/jboss/as/logging/deployments/LoggingProfileDeploymentProcessor.java#L108-L118 | train |
wildfly/wildfly-core | cli/src/main/java/org/jboss/as/cli/parsing/arguments/ArgumentValueState.java | ArgumentValueState.getBytesToken | public static int getBytesToken(ParsingContext ctx) {
String input = ctx.getInput().substring(ctx.getLocation());
int tokenOffset = 0;
int i = 0;
char[] inputChars = input.toCharArray();
for (; i < input.length(); i += 1) {
char c = inputChars[i];
if (c == ' ') {
continue;
}
if (c != BYTES_TOKEN_CHARS[tokenOffset]) {
return -1;
} else {
tokenOffset += 1;
if (tokenOffset == BYTES_TOKEN_CHARS.length) {
// Found the token.
return i;
}
}
}
return -1;
} | java | public static int getBytesToken(ParsingContext ctx) {
String input = ctx.getInput().substring(ctx.getLocation());
int tokenOffset = 0;
int i = 0;
char[] inputChars = input.toCharArray();
for (; i < input.length(); i += 1) {
char c = inputChars[i];
if (c == ' ') {
continue;
}
if (c != BYTES_TOKEN_CHARS[tokenOffset]) {
return -1;
} else {
tokenOffset += 1;
if (tokenOffset == BYTES_TOKEN_CHARS.length) {
// Found the token.
return i;
}
}
}
return -1;
} | [
"public",
"static",
"int",
"getBytesToken",
"(",
"ParsingContext",
"ctx",
")",
"{",
"String",
"input",
"=",
"ctx",
".",
"getInput",
"(",
")",
".",
"substring",
"(",
"ctx",
".",
"getLocation",
"(",
")",
")",
";",
"int",
"tokenOffset",
"=",
"0",
";",
"in... | handle white spaces. | [
"handle",
"white",
"spaces",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/cli/src/main/java/org/jboss/as/cli/parsing/arguments/ArgumentValueState.java#L111-L132 | train |
wildfly/wildfly-core | domain-management/src/main/java/org/jboss/as/domain/management/access/RbacSanityCheckOperation.java | RbacSanityCheckOperation.addOperation | public static void addOperation(final OperationContext context) {
RbacSanityCheckOperation added = context.getAttachment(KEY);
if (added == null) {
// TODO support managed domain
if (!context.isNormalServer()) return;
context.addStep(createOperation(), INSTANCE, Stage.MODEL);
context.attach(KEY, INSTANCE);
}
} | java | public static void addOperation(final OperationContext context) {
RbacSanityCheckOperation added = context.getAttachment(KEY);
if (added == null) {
// TODO support managed domain
if (!context.isNormalServer()) return;
context.addStep(createOperation(), INSTANCE, Stage.MODEL);
context.attach(KEY, INSTANCE);
}
} | [
"public",
"static",
"void",
"addOperation",
"(",
"final",
"OperationContext",
"context",
")",
"{",
"RbacSanityCheckOperation",
"added",
"=",
"context",
".",
"getAttachment",
"(",
"KEY",
")",
";",
"if",
"(",
"added",
"==",
"null",
")",
"{",
"// TODO support manag... | Add the operation at the end of Stage MODEL if this operation has not already been registered.
This operation should be added if any of the following occur: -
- The authorization configuration is removed from a security realm.
- The rbac provider is changed to rbac.
- A role is removed.
- An include is removed from a role.
- A management interface is removed.
Note: This list only includes actions that could invalidate the configuration, actions that would not invalidate the
configuration do not need this operation registering. e.g. Adding a role, if the configuration was already valid this
could not invalidate it.
@param context - The OperationContext to use to register the step. | [
"Add",
"the",
"operation",
"at",
"the",
"end",
"of",
"Stage",
"MODEL",
"if",
"this",
"operation",
"has",
"not",
"already",
"been",
"registered",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/domain-management/src/main/java/org/jboss/as/domain/management/access/RbacSanityCheckOperation.java#L123-L131 | train |
wildfly/wildfly-core | controller-client/src/main/java/org/jboss/as/controller/client/helpers/Operations.java | Operations.getFailureDescription | public static ModelNode getFailureDescription(final ModelNode result) {
if (isSuccessfulOutcome(result)) {
throw ControllerClientLogger.ROOT_LOGGER.noFailureDescription();
}
if (result.hasDefined(FAILURE_DESCRIPTION)) {
return result.get(FAILURE_DESCRIPTION);
}
return new ModelNode();
} | java | public static ModelNode getFailureDescription(final ModelNode result) {
if (isSuccessfulOutcome(result)) {
throw ControllerClientLogger.ROOT_LOGGER.noFailureDescription();
}
if (result.hasDefined(FAILURE_DESCRIPTION)) {
return result.get(FAILURE_DESCRIPTION);
}
return new ModelNode();
} | [
"public",
"static",
"ModelNode",
"getFailureDescription",
"(",
"final",
"ModelNode",
"result",
")",
"{",
"if",
"(",
"isSuccessfulOutcome",
"(",
"result",
")",
")",
"{",
"throw",
"ControllerClientLogger",
".",
"ROOT_LOGGER",
".",
"noFailureDescription",
"(",
")",
"... | Parses the result and returns the failure description.
@param result the result of executing an operation
@return the failure description if defined, otherwise a new undefined model node
@throws IllegalArgumentException if the outcome of the operation was successful | [
"Parses",
"the",
"result",
"and",
"returns",
"the",
"failure",
"description",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller-client/src/main/java/org/jboss/as/controller/client/helpers/Operations.java#L99-L107 | train |
wildfly/wildfly-core | controller-client/src/main/java/org/jboss/as/controller/client/helpers/Operations.java | Operations.getOperationAddress | public static ModelNode getOperationAddress(final ModelNode op) {
return op.hasDefined(OP_ADDR) ? op.get(OP_ADDR) : new ModelNode();
} | java | public static ModelNode getOperationAddress(final ModelNode op) {
return op.hasDefined(OP_ADDR) ? op.get(OP_ADDR) : new ModelNode();
} | [
"public",
"static",
"ModelNode",
"getOperationAddress",
"(",
"final",
"ModelNode",
"op",
")",
"{",
"return",
"op",
".",
"hasDefined",
"(",
"OP_ADDR",
")",
"?",
"op",
".",
"get",
"(",
"OP_ADDR",
")",
":",
"new",
"ModelNode",
"(",
")",
";",
"}"
] | Returns the address for the operation.
@param op the operation
@return the operation address or a new undefined model node | [
"Returns",
"the",
"address",
"for",
"the",
"operation",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller-client/src/main/java/org/jboss/as/controller/client/helpers/Operations.java#L155-L157 | train |
wildfly/wildfly-core | controller-client/src/main/java/org/jboss/as/controller/client/helpers/Operations.java | Operations.getOperationName | public static String getOperationName(final ModelNode op) {
if (op.hasDefined(OP)) {
return op.get(OP).asString();
}
throw ControllerClientLogger.ROOT_LOGGER.operationNameNotFound();
} | java | public static String getOperationName(final ModelNode op) {
if (op.hasDefined(OP)) {
return op.get(OP).asString();
}
throw ControllerClientLogger.ROOT_LOGGER.operationNameNotFound();
} | [
"public",
"static",
"String",
"getOperationName",
"(",
"final",
"ModelNode",
"op",
")",
"{",
"if",
"(",
"op",
".",
"hasDefined",
"(",
"OP",
")",
")",
"{",
"return",
"op",
".",
"get",
"(",
"OP",
")",
".",
"asString",
"(",
")",
";",
"}",
"throw",
"Co... | Returns the name of the operation.
@param op the operation
@return the name of the operation
@throws IllegalArgumentException if the operation was not defined. | [
"Returns",
"the",
"name",
"of",
"the",
"operation",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller-client/src/main/java/org/jboss/as/controller/client/helpers/Operations.java#L168-L173 | train |
wildfly/wildfly-core | controller-client/src/main/java/org/jboss/as/controller/client/helpers/Operations.java | Operations.createReadResourceOperation | public static ModelNode createReadResourceOperation(final ModelNode address, final boolean recursive) {
final ModelNode op = createOperation(READ_RESOURCE_OPERATION, address);
op.get(RECURSIVE).set(recursive);
return op;
} | java | public static ModelNode createReadResourceOperation(final ModelNode address, final boolean recursive) {
final ModelNode op = createOperation(READ_RESOURCE_OPERATION, address);
op.get(RECURSIVE).set(recursive);
return op;
} | [
"public",
"static",
"ModelNode",
"createReadResourceOperation",
"(",
"final",
"ModelNode",
"address",
",",
"final",
"boolean",
"recursive",
")",
"{",
"final",
"ModelNode",
"op",
"=",
"createOperation",
"(",
"READ_RESOURCE_OPERATION",
",",
"address",
")",
";",
"op",
... | Creates an operation to read a resource.
@param address the address to create the read for
@param recursive whether to search recursively or not
@return the operation | [
"Creates",
"an",
"operation",
"to",
"read",
"a",
"resource",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller-client/src/main/java/org/jboss/as/controller/client/helpers/Operations.java#L245-L249 | train |
wildfly/wildfly-core | cli/src/main/java/org/jboss/as/cli/operation/impl/DefaultOperationRequestBuilder.java | DefaultOperationRequestBuilder.buildRequest | public ModelNode buildRequest() throws OperationFormatException {
ModelNode address = request.get(Util.ADDRESS);
if(prefix.isEmpty()) {
address.setEmptyList();
} else {
Iterator<Node> iterator = prefix.iterator();
while (iterator.hasNext()) {
OperationRequestAddress.Node node = iterator.next();
if (node.getName() != null) {
address.add(node.getType(), node.getName());
} else if (iterator.hasNext()) {
throw new OperationFormatException(
"The node name is not specified for type '"
+ node.getType() + "'");
}
}
}
if(!request.hasDefined(Util.OPERATION)) {
throw new OperationFormatException("The operation name is missing or the format of the operation request is wrong.");
}
return request;
} | java | public ModelNode buildRequest() throws OperationFormatException {
ModelNode address = request.get(Util.ADDRESS);
if(prefix.isEmpty()) {
address.setEmptyList();
} else {
Iterator<Node> iterator = prefix.iterator();
while (iterator.hasNext()) {
OperationRequestAddress.Node node = iterator.next();
if (node.getName() != null) {
address.add(node.getType(), node.getName());
} else if (iterator.hasNext()) {
throw new OperationFormatException(
"The node name is not specified for type '"
+ node.getType() + "'");
}
}
}
if(!request.hasDefined(Util.OPERATION)) {
throw new OperationFormatException("The operation name is missing or the format of the operation request is wrong.");
}
return request;
} | [
"public",
"ModelNode",
"buildRequest",
"(",
")",
"throws",
"OperationFormatException",
"{",
"ModelNode",
"address",
"=",
"request",
".",
"get",
"(",
"Util",
".",
"ADDRESS",
")",
";",
"if",
"(",
"prefix",
".",
"isEmpty",
"(",
")",
")",
"{",
"address",
".",
... | Makes sure that the operation name and the address have been set and returns a ModelNode
representing the operation request. | [
"Makes",
"sure",
"that",
"the",
"operation",
"name",
"and",
"the",
"address",
"have",
"been",
"set",
"and",
"returns",
"a",
"ModelNode",
"representing",
"the",
"operation",
"request",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/cli/src/main/java/org/jboss/as/cli/operation/impl/DefaultOperationRequestBuilder.java#L61-L85 | train |
wildfly/wildfly-core | domain-management/src/main/java/org/jboss/as/domain/management/parsing/ManagementXml_5.java | ManagementXml_5.parseUsersAuthentication | private void parseUsersAuthentication(final XMLExtendedStreamReader reader,
final ModelNode realmAddress, final List<ModelNode> list)
throws XMLStreamException {
final ModelNode usersAddress = realmAddress.clone().add(AUTHENTICATION, USERS);
list.add(Util.getEmptyOperation(ADD, usersAddress));
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
requireNamespace(reader, namespace);
final Element element = Element.forName(reader.getLocalName());
switch (element) {
case USER: {
parseUser(reader, usersAddress, list);
break;
}
default: {
throw unexpectedElement(reader);
}
}
}
} | java | private void parseUsersAuthentication(final XMLExtendedStreamReader reader,
final ModelNode realmAddress, final List<ModelNode> list)
throws XMLStreamException {
final ModelNode usersAddress = realmAddress.clone().add(AUTHENTICATION, USERS);
list.add(Util.getEmptyOperation(ADD, usersAddress));
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
requireNamespace(reader, namespace);
final Element element = Element.forName(reader.getLocalName());
switch (element) {
case USER: {
parseUser(reader, usersAddress, list);
break;
}
default: {
throw unexpectedElement(reader);
}
}
}
} | [
"private",
"void",
"parseUsersAuthentication",
"(",
"final",
"XMLExtendedStreamReader",
"reader",
",",
"final",
"ModelNode",
"realmAddress",
",",
"final",
"List",
"<",
"ModelNode",
">",
"list",
")",
"throws",
"XMLStreamException",
"{",
"final",
"ModelNode",
"usersAddr... | The users element defines users within the domain model, it is a simple authentication for some out of the box users. | [
"The",
"users",
"element",
"defines",
"users",
"within",
"the",
"domain",
"model",
"it",
"is",
"a",
"simple",
"authentication",
"for",
"some",
"out",
"of",
"the",
"box",
"users",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/domain-management/src/main/java/org/jboss/as/domain/management/parsing/ManagementXml_5.java#L1238-L1257 | train |
wildfly/wildfly-core | controller/src/main/java/org/jboss/as/controller/access/JmxAction.java | JmxAction.getActionEffects | public Set<Action.ActionEffect> getActionEffects() {
switch(getImpact()) {
case CLASSLOADING:
case WRITE:
return WRITES;
case READ_ONLY:
return READS;
default:
throw new IllegalStateException();
}
} | java | public Set<Action.ActionEffect> getActionEffects() {
switch(getImpact()) {
case CLASSLOADING:
case WRITE:
return WRITES;
case READ_ONLY:
return READS;
default:
throw new IllegalStateException();
}
} | [
"public",
"Set",
"<",
"Action",
".",
"ActionEffect",
">",
"getActionEffects",
"(",
")",
"{",
"switch",
"(",
"getImpact",
"(",
")",
")",
"{",
"case",
"CLASSLOADING",
":",
"case",
"WRITE",
":",
"return",
"WRITES",
";",
"case",
"READ_ONLY",
":",
"return",
"... | Gets the effects of this action.
@return the effects. Will not be {@code null} | [
"Gets",
"the",
"effects",
"of",
"this",
"action",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/access/JmxAction.java#L86-L97 | train |
wildfly/wildfly-core | host-controller/src/main/java/org/jboss/as/host/controller/parsing/HostXml_4.java | HostXml_4.addLocalHost | private ModelNode addLocalHost(final ModelNode address, final List<ModelNode> operationList, final String hostName) {
String resolvedHost = hostName != null ? hostName : defaultHostControllerName;
// All further operations should modify the newly added host so the address passed in is updated.
address.add(HOST, resolvedHost);
// Add a step to setup the ManagementResourceRegistrations for the root host resource
final ModelNode hostAddOp = new ModelNode();
hostAddOp.get(OP).set(HostAddHandler.OPERATION_NAME);
hostAddOp.get(OP_ADDR).set(address);
operationList.add(hostAddOp);
// Add a step to store the HC name
ModelNode nameValue = hostName == null ? new ModelNode() : new ModelNode(hostName);
final ModelNode writeName = Util.getWriteAttributeOperation(address, NAME, nameValue);
operationList.add(writeName);
return hostAddOp;
} | java | private ModelNode addLocalHost(final ModelNode address, final List<ModelNode> operationList, final String hostName) {
String resolvedHost = hostName != null ? hostName : defaultHostControllerName;
// All further operations should modify the newly added host so the address passed in is updated.
address.add(HOST, resolvedHost);
// Add a step to setup the ManagementResourceRegistrations for the root host resource
final ModelNode hostAddOp = new ModelNode();
hostAddOp.get(OP).set(HostAddHandler.OPERATION_NAME);
hostAddOp.get(OP_ADDR).set(address);
operationList.add(hostAddOp);
// Add a step to store the HC name
ModelNode nameValue = hostName == null ? new ModelNode() : new ModelNode(hostName);
final ModelNode writeName = Util.getWriteAttributeOperation(address, NAME, nameValue);
operationList.add(writeName);
return hostAddOp;
} | [
"private",
"ModelNode",
"addLocalHost",
"(",
"final",
"ModelNode",
"address",
",",
"final",
"List",
"<",
"ModelNode",
">",
"operationList",
",",
"final",
"String",
"hostName",
")",
"{",
"String",
"resolvedHost",
"=",
"hostName",
"!=",
"null",
"?",
"hostName",
... | Add the operation to add the local host definition. | [
"Add",
"the",
"operation",
"to",
"add",
"the",
"local",
"host",
"definition",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/host-controller/src/main/java/org/jboss/as/host/controller/parsing/HostXml_4.java#L468-L487 | train |
wildfly/wildfly-core | deployment-repository/src/main/java/org/jboss/as/repository/HashUtil.java | HashUtil.hashPath | public static byte[] hashPath(MessageDigest messageDigest, Path path) throws IOException {
try (InputStream in = getRecursiveContentStream(path)) {
return hashContent(messageDigest, in);
}
} | java | public static byte[] hashPath(MessageDigest messageDigest, Path path) throws IOException {
try (InputStream in = getRecursiveContentStream(path)) {
return hashContent(messageDigest, in);
}
} | [
"public",
"static",
"byte",
"[",
"]",
"hashPath",
"(",
"MessageDigest",
"messageDigest",
",",
"Path",
"path",
")",
"throws",
"IOException",
"{",
"try",
"(",
"InputStream",
"in",
"=",
"getRecursiveContentStream",
"(",
"path",
")",
")",
"{",
"return",
"hashConte... | Hashes a path, if the path points to a directory then hashes the contents recursively.
@param messageDigest the digest used to hash.
@param path the file/directory we want to hash.
@return the resulting hash.
@throws IOException | [
"Hashes",
"a",
"path",
"if",
"the",
"path",
"points",
"to",
"a",
"directory",
"then",
"hashes",
"the",
"contents",
"recursively",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/deployment-repository/src/main/java/org/jboss/as/repository/HashUtil.java#L111-L115 | train |
wildfly/wildfly-core | cli/src/main/java/org/jboss/as/cli/gui/CommandExecutor.java | CommandExecutor.doCommand | public synchronized ModelNode doCommand(String command) throws CommandFormatException, IOException {
ModelNode request = cmdCtx.buildRequest(command);
return execute(request, isSlowCommand(command)).getResponseNode();
} | java | public synchronized ModelNode doCommand(String command) throws CommandFormatException, IOException {
ModelNode request = cmdCtx.buildRequest(command);
return execute(request, isSlowCommand(command)).getResponseNode();
} | [
"public",
"synchronized",
"ModelNode",
"doCommand",
"(",
"String",
"command",
")",
"throws",
"CommandFormatException",
",",
"IOException",
"{",
"ModelNode",
"request",
"=",
"cmdCtx",
".",
"buildRequest",
"(",
"command",
")",
";",
"return",
"execute",
"(",
"request... | Submit a command to the server.
@param command The CLI command
@return The DMR response as a ModelNode
@throws CommandFormatException
@throws IOException | [
"Submit",
"a",
"command",
"to",
"the",
"server",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/cli/src/main/java/org/jboss/as/cli/gui/CommandExecutor.java#L75-L78 | train |
wildfly/wildfly-core | cli/src/main/java/org/jboss/as/cli/gui/CommandExecutor.java | CommandExecutor.doCommandFullResponse | public synchronized Response doCommandFullResponse(String command) throws CommandFormatException, IOException {
ModelNode request = cmdCtx.buildRequest(command);
boolean replacedBytes = replaceFilePathsWithBytes(request);
OperationResponse response = execute(request, isSlowCommand(command) || replacedBytes);
return new Response(command, request, response);
} | java | public synchronized Response doCommandFullResponse(String command) throws CommandFormatException, IOException {
ModelNode request = cmdCtx.buildRequest(command);
boolean replacedBytes = replaceFilePathsWithBytes(request);
OperationResponse response = execute(request, isSlowCommand(command) || replacedBytes);
return new Response(command, request, response);
} | [
"public",
"synchronized",
"Response",
"doCommandFullResponse",
"(",
"String",
"command",
")",
"throws",
"CommandFormatException",
",",
"IOException",
"{",
"ModelNode",
"request",
"=",
"cmdCtx",
".",
"buildRequest",
"(",
"command",
")",
";",
"boolean",
"replacedBytes",... | User-initiated commands use this method.
@param command The CLI command
@return A Response object containing the command line, DMR request, and DMR response
@throws CommandFormatException
@throws IOException | [
"User",
"-",
"initiated",
"commands",
"use",
"this",
"method",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/cli/src/main/java/org/jboss/as/cli/gui/CommandExecutor.java#L88-L93 | train |
wildfly/wildfly-core | server/src/main/java/org/jboss/as/server/ServerEnvironment.java | ServerEnvironment.getFilesFromProperty | private File[] getFilesFromProperty(final String name, final Properties props) {
String sep = WildFlySecurityManager.getPropertyPrivileged("path.separator", null);
String value = props.getProperty(name, null);
if (value != null) {
final String[] paths = value.split(Pattern.quote(sep));
final int len = paths.length;
final File[] files = new File[len];
for (int i = 0; i < len; i++) {
files[i] = new File(paths[i]);
}
return files;
}
return NO_FILES;
} | java | private File[] getFilesFromProperty(final String name, final Properties props) {
String sep = WildFlySecurityManager.getPropertyPrivileged("path.separator", null);
String value = props.getProperty(name, null);
if (value != null) {
final String[] paths = value.split(Pattern.quote(sep));
final int len = paths.length;
final File[] files = new File[len];
for (int i = 0; i < len; i++) {
files[i] = new File(paths[i]);
}
return files;
}
return NO_FILES;
} | [
"private",
"File",
"[",
"]",
"getFilesFromProperty",
"(",
"final",
"String",
"name",
",",
"final",
"Properties",
"props",
")",
"{",
"String",
"sep",
"=",
"WildFlySecurityManager",
".",
"getPropertyPrivileged",
"(",
"\"path.separator\"",
",",
"null",
")",
";",
"S... | Get a File path list from configuration.
@param name the name of the property
@param props the set of configuration properties
@return the CanonicalFile form for the given name. | [
"Get",
"a",
"File",
"path",
"list",
"from",
"configuration",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/server/src/main/java/org/jboss/as/server/ServerEnvironment.java#L1212-L1225 | train |
wildfly/wildfly-core | controller/src/main/java/org/jboss/as/controller/registry/AtomicMapFieldUpdater.java | AtomicMapFieldUpdater.putAtomic | public boolean putAtomic(C instance, K key, V value, Map<K, V> snapshot) {
Assert.checkNotNullParam("key", key);
final Map<K, V> newMap;
final int oldSize = snapshot.size();
if (oldSize == 0) {
newMap = Collections.singletonMap(key, value);
} else if (oldSize == 1) {
final Map.Entry<K, V> entry = snapshot.entrySet().iterator().next();
final K oldKey = entry.getKey();
if (oldKey.equals(key)) {
return false;
} else {
newMap = new FastCopyHashMap<K, V>(snapshot);
newMap.put(key, value);
}
} else {
newMap = new FastCopyHashMap<K, V>(snapshot);
newMap.put(key, value);
}
return updater.compareAndSet(instance, snapshot, newMap);
} | java | public boolean putAtomic(C instance, K key, V value, Map<K, V> snapshot) {
Assert.checkNotNullParam("key", key);
final Map<K, V> newMap;
final int oldSize = snapshot.size();
if (oldSize == 0) {
newMap = Collections.singletonMap(key, value);
} else if (oldSize == 1) {
final Map.Entry<K, V> entry = snapshot.entrySet().iterator().next();
final K oldKey = entry.getKey();
if (oldKey.equals(key)) {
return false;
} else {
newMap = new FastCopyHashMap<K, V>(snapshot);
newMap.put(key, value);
}
} else {
newMap = new FastCopyHashMap<K, V>(snapshot);
newMap.put(key, value);
}
return updater.compareAndSet(instance, snapshot, newMap);
} | [
"public",
"boolean",
"putAtomic",
"(",
"C",
"instance",
",",
"K",
"key",
",",
"V",
"value",
",",
"Map",
"<",
"K",
",",
"V",
">",
"snapshot",
")",
"{",
"Assert",
".",
"checkNotNullParam",
"(",
"\"key\"",
",",
"key",
")",
";",
"final",
"Map",
"<",
"K... | Put a value if and only if the map has not changed since the given snapshot was taken. If the put fails,
it is the caller's responsibility to retry.
@param instance the instance with the map field
@param key the key
@param value the value
@param snapshot the map snapshot
@return {@code false} if the snapshot is out of date and we could not update, {@code true} if the put succeeded | [
"Put",
"a",
"value",
"if",
"and",
"only",
"if",
"the",
"map",
"has",
"not",
"changed",
"since",
"the",
"given",
"snapshot",
"was",
"taken",
".",
"If",
"the",
"put",
"fails",
"it",
"is",
"the",
"caller",
"s",
"responsibility",
"to",
"retry",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/registry/AtomicMapFieldUpdater.java#L97-L117 | train |
wildfly/wildfly-core | controller/src/main/java/org/jboss/as/controller/ListAttributeDefinition.java | ListAttributeDefinition.parseAndSetParameter | @Deprecated
public void parseAndSetParameter(String value, ModelNode operation, XMLStreamReader reader) throws XMLStreamException {
//we use manual parsing here, and not #getParser().. to preserve backward compatibility.
if (value != null) {
for (String element : value.split(",")) {
parseAndAddParameterElement(element.trim(), operation, reader);
}
}
} | java | @Deprecated
public void parseAndSetParameter(String value, ModelNode operation, XMLStreamReader reader) throws XMLStreamException {
//we use manual parsing here, and not #getParser().. to preserve backward compatibility.
if (value != null) {
for (String element : value.split(",")) {
parseAndAddParameterElement(element.trim(), operation, reader);
}
}
} | [
"@",
"Deprecated",
"public",
"void",
"parseAndSetParameter",
"(",
"String",
"value",
",",
"ModelNode",
"operation",
",",
"XMLStreamReader",
"reader",
")",
"throws",
"XMLStreamException",
"{",
"//we use manual parsing here, and not #getParser().. to preserve backward compatibility... | Parses whole value as list attribute
@deprecated in favour of using {@link AttributeParser attribute parser}
@param value String with "," separated string elements
@param operation operation to with this list elements are added
@param reader xml reader from where reading is be done
@throws XMLStreamException if {@code value} is not valid | [
"Parses",
"whole",
"value",
"as",
"list",
"attribute"
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/ListAttributeDefinition.java#L240-L248 | train |
wildfly/wildfly-core | controller/src/main/java/org/jboss/as/controller/ModelControllerLock.java | ModelControllerLock.lock | boolean lock(final Integer permit, final long timeout, final TimeUnit unit) {
boolean result = false;
try {
result = lockInterruptibly(permit, timeout, unit);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
return result;
} | java | boolean lock(final Integer permit, final long timeout, final TimeUnit unit) {
boolean result = false;
try {
result = lockInterruptibly(permit, timeout, unit);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
return result;
} | [
"boolean",
"lock",
"(",
"final",
"Integer",
"permit",
",",
"final",
"long",
"timeout",
",",
"final",
"TimeUnit",
"unit",
")",
"{",
"boolean",
"result",
"=",
"false",
";",
"try",
"{",
"result",
"=",
"lockInterruptibly",
"(",
"permit",
",",
"timeout",
",",
... | Attempts exclusive acquisition with a max wait time.
@param permit - the permit Integer for this operation. May not be {@code null}.
@param timeout - the time value to wait for acquiring the lock
@param unit - See {@code TimeUnit} for valid values
@return {@code boolean} true on success. | [
"Attempts",
"exclusive",
"acquisition",
"with",
"a",
"max",
"wait",
"time",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/ModelControllerLock.java#L74-L82 | train |
wildfly/wildfly-core | controller/src/main/java/org/jboss/as/controller/ModelControllerLock.java | ModelControllerLock.lockShared | boolean lockShared(final Integer permit, final long timeout, final TimeUnit unit) {
boolean result = false;
try {
result = lockSharedInterruptibly(permit, timeout, unit);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
return result;
} | java | boolean lockShared(final Integer permit, final long timeout, final TimeUnit unit) {
boolean result = false;
try {
result = lockSharedInterruptibly(permit, timeout, unit);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
return result;
} | [
"boolean",
"lockShared",
"(",
"final",
"Integer",
"permit",
",",
"final",
"long",
"timeout",
",",
"final",
"TimeUnit",
"unit",
")",
"{",
"boolean",
"result",
"=",
"false",
";",
"try",
"{",
"result",
"=",
"lockSharedInterruptibly",
"(",
"permit",
",",
"timeou... | Attempts shared acquisition with a max wait time.
@param permit - the permit Integer for this operation. May not be {@code null}.
@param timeout - the time value to wait for acquiring the lock
@param unit - See {@code TimeUnit} for valid values
@return {@code boolean} true on success. | [
"Attempts",
"shared",
"acquisition",
"with",
"a",
"max",
"wait",
"time",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/ModelControllerLock.java#L90-L98 | train |
wildfly/wildfly-core | controller/src/main/java/org/jboss/as/controller/ModelControllerLock.java | ModelControllerLock.lockInterruptibly | void lockInterruptibly(final Integer permit) throws InterruptedException {
if (permit == null) {
throw new IllegalArgumentException();
}
sync.acquireInterruptibly(permit);
} | java | void lockInterruptibly(final Integer permit) throws InterruptedException {
if (permit == null) {
throw new IllegalArgumentException();
}
sync.acquireInterruptibly(permit);
} | [
"void",
"lockInterruptibly",
"(",
"final",
"Integer",
"permit",
")",
"throws",
"InterruptedException",
"{",
"if",
"(",
"permit",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
")",
";",
"}",
"sync",
".",
"acquireInterruptibly",
"(",
"... | Acquire the exclusive lock allowing the acquisition to be interrupted.
@param permit - the permit Integer for this operation. May not be {@code null}.
@throws InterruptedException - if the acquiring thread is interrupted.
@throws IllegalArgumentException if {@code permit} is null. | [
"Acquire",
"the",
"exclusive",
"lock",
"allowing",
"the",
"acquisition",
"to",
"be",
"interrupted",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/ModelControllerLock.java#L106-L111 | train |
wildfly/wildfly-core | controller/src/main/java/org/jboss/as/controller/ModelControllerLock.java | ModelControllerLock.lockSharedInterruptibly | void lockSharedInterruptibly(final Integer permit) throws InterruptedException {
if (permit == null) {
throw new IllegalArgumentException();
}
sync.acquireSharedInterruptibly(permit);
} | java | void lockSharedInterruptibly(final Integer permit) throws InterruptedException {
if (permit == null) {
throw new IllegalArgumentException();
}
sync.acquireSharedInterruptibly(permit);
} | [
"void",
"lockSharedInterruptibly",
"(",
"final",
"Integer",
"permit",
")",
"throws",
"InterruptedException",
"{",
"if",
"(",
"permit",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
")",
";",
"}",
"sync",
".",
"acquireSharedInterruptibly"... | Acquire the shared lock allowing the acquisition to be interrupted.
@param permit - the permit Integer for this operation. May not be {@code null}.
@throws InterruptedException - if the acquiring thread is interrupted.
@throws IllegalArgumentException if {@code permit} is null. | [
"Acquire",
"the",
"shared",
"lock",
"allowing",
"the",
"acquisition",
"to",
"be",
"interrupted",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/ModelControllerLock.java#L119-L124 | train |
wildfly/wildfly-core | controller/src/main/java/org/jboss/as/controller/ModelControllerLock.java | ModelControllerLock.lockInterruptibly | boolean lockInterruptibly(final Integer permit, final long timeout, final TimeUnit unit) throws InterruptedException {
if (permit == null) {
throw new IllegalArgumentException();
}
return sync.tryAcquireNanos(permit, unit.toNanos(timeout));
} | java | boolean lockInterruptibly(final Integer permit, final long timeout, final TimeUnit unit) throws InterruptedException {
if (permit == null) {
throw new IllegalArgumentException();
}
return sync.tryAcquireNanos(permit, unit.toNanos(timeout));
} | [
"boolean",
"lockInterruptibly",
"(",
"final",
"Integer",
"permit",
",",
"final",
"long",
"timeout",
",",
"final",
"TimeUnit",
"unit",
")",
"throws",
"InterruptedException",
"{",
"if",
"(",
"permit",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentExcepti... | Acquire the exclusive lock, with a max wait timeout to acquire.
@param permit - the permit Integer for this operation. May not be {@code null}.
@param timeout - the timeout scalar quantity.
@param unit - see {@code TimeUnit} for quantities.
@return {@code boolean} true on successful acquire.
@throws InterruptedException - if the acquiring thread was interrupted.
@throws IllegalArgumentException if {@code permit} is null. | [
"Acquire",
"the",
"exclusive",
"lock",
"with",
"a",
"max",
"wait",
"timeout",
"to",
"acquire",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/ModelControllerLock.java#L135-L140 | train |
wildfly/wildfly-core | controller/src/main/java/org/jboss/as/controller/ModelControllerLock.java | ModelControllerLock.lockSharedInterruptibly | boolean lockSharedInterruptibly(final Integer permit, final long timeout, final TimeUnit unit) throws InterruptedException {
if (permit == null) {
throw new IllegalArgumentException();
}
return sync.tryAcquireSharedNanos(permit, unit.toNanos(timeout));
} | java | boolean lockSharedInterruptibly(final Integer permit, final long timeout, final TimeUnit unit) throws InterruptedException {
if (permit == null) {
throw new IllegalArgumentException();
}
return sync.tryAcquireSharedNanos(permit, unit.toNanos(timeout));
} | [
"boolean",
"lockSharedInterruptibly",
"(",
"final",
"Integer",
"permit",
",",
"final",
"long",
"timeout",
",",
"final",
"TimeUnit",
"unit",
")",
"throws",
"InterruptedException",
"{",
"if",
"(",
"permit",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentE... | Acquire the shared lock, with a max wait timeout to acquire.
@param permit - the permit Integer for this operation. May not be {@code null}.
@param timeout - the timeout scalar quantity.
@param unit - see {@code TimeUnit} for quantities.
@return {@code boolean} true on successful acquire.
@throws InterruptedException - if the acquiring thread was interrupted.
@throws IllegalArgumentException if {@code permit} is null. | [
"Acquire",
"the",
"shared",
"lock",
"with",
"a",
"max",
"wait",
"timeout",
"to",
"acquire",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/ModelControllerLock.java#L151-L156 | train |
wildfly/wildfly-core | controller/src/main/java/org/jboss/as/controller/CapabilityRegistry.java | CapabilityRegistry.createShadowCopy | CapabilityRegistry createShadowCopy() {
CapabilityRegistry result = new CapabilityRegistry(forServer, this);
readLock.lock();
try {
try {
result.writeLock.lock();
copy(this, result);
} finally {
result.writeLock.unlock();
}
} finally {
readLock.unlock();
}
return result;
} | java | CapabilityRegistry createShadowCopy() {
CapabilityRegistry result = new CapabilityRegistry(forServer, this);
readLock.lock();
try {
try {
result.writeLock.lock();
copy(this, result);
} finally {
result.writeLock.unlock();
}
} finally {
readLock.unlock();
}
return result;
} | [
"CapabilityRegistry",
"createShadowCopy",
"(",
")",
"{",
"CapabilityRegistry",
"result",
"=",
"new",
"CapabilityRegistry",
"(",
"forServer",
",",
"this",
")",
";",
"readLock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"try",
"{",
"result",
".",
"writeLock",
".... | Creates updateable version of capability registry that on publish pushes all changes to main registry
this is used to create context local registry that only on completion commits changes to main registry
@return writable registry | [
"Creates",
"updateable",
"version",
"of",
"capability",
"registry",
"that",
"on",
"publish",
"pushes",
"all",
"changes",
"to",
"main",
"registry",
"this",
"is",
"used",
"to",
"create",
"context",
"local",
"registry",
"that",
"only",
"on",
"completion",
"commits"... | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/CapabilityRegistry.java#L103-L117 | train |
wildfly/wildfly-core | controller/src/main/java/org/jboss/as/controller/CapabilityRegistry.java | CapabilityRegistry.registerRequirement | private void registerRequirement(RuntimeRequirementRegistration requirement) {
assert writeLock.isHeldByCurrentThread();
CapabilityId dependentId = requirement.getDependentId();
if (!capabilities.containsKey(dependentId)) {
throw ControllerLogger.MGMT_OP_LOGGER.unknownCapabilityInContext(dependentId.getName(),
dependentId.getScope().getName());
}
Map<CapabilityId, Map<String, RuntimeRequirementRegistration>> requirementMap =
requirement.isRuntimeOnly() ? runtimeOnlyRequirements : requirements;
Map<String, RuntimeRequirementRegistration> dependents = requirementMap.get(dependentId);
if (dependents == null) {
dependents = new HashMap<>();
requirementMap.put(dependentId, dependents);
}
RuntimeRequirementRegistration existing = dependents.get(requirement.getRequiredName());
if (existing == null) {
dependents.put(requirement.getRequiredName(), requirement);
} else {
existing.addRegistrationPoint(requirement.getOldestRegistrationPoint());
}
modified = true;
} | java | private void registerRequirement(RuntimeRequirementRegistration requirement) {
assert writeLock.isHeldByCurrentThread();
CapabilityId dependentId = requirement.getDependentId();
if (!capabilities.containsKey(dependentId)) {
throw ControllerLogger.MGMT_OP_LOGGER.unknownCapabilityInContext(dependentId.getName(),
dependentId.getScope().getName());
}
Map<CapabilityId, Map<String, RuntimeRequirementRegistration>> requirementMap =
requirement.isRuntimeOnly() ? runtimeOnlyRequirements : requirements;
Map<String, RuntimeRequirementRegistration> dependents = requirementMap.get(dependentId);
if (dependents == null) {
dependents = new HashMap<>();
requirementMap.put(dependentId, dependents);
}
RuntimeRequirementRegistration existing = dependents.get(requirement.getRequiredName());
if (existing == null) {
dependents.put(requirement.getRequiredName(), requirement);
} else {
existing.addRegistrationPoint(requirement.getOldestRegistrationPoint());
}
modified = true;
} | [
"private",
"void",
"registerRequirement",
"(",
"RuntimeRequirementRegistration",
"requirement",
")",
"{",
"assert",
"writeLock",
".",
"isHeldByCurrentThread",
"(",
")",
";",
"CapabilityId",
"dependentId",
"=",
"requirement",
".",
"getDependentId",
"(",
")",
";",
"if",... | This must be called with the write lock held.
@param requirement the requirement | [
"This",
"must",
"be",
"called",
"with",
"the",
"write",
"lock",
"held",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/CapabilityRegistry.java#L208-L230 | train |
wildfly/wildfly-core | controller/src/main/java/org/jboss/as/controller/CapabilityRegistry.java | CapabilityRegistry.removeCapabilityRequirement | @Override
public void removeCapabilityRequirement(RuntimeRequirementRegistration requirementRegistration) {
// We don't know if this got registered as an runtime-only requirement or a hard one
// so clean it from both maps
writeLock.lock();
try {
removeRequirement(requirementRegistration, false);
removeRequirement(requirementRegistration, true);
} finally {
writeLock.unlock();
}
} | java | @Override
public void removeCapabilityRequirement(RuntimeRequirementRegistration requirementRegistration) {
// We don't know if this got registered as an runtime-only requirement or a hard one
// so clean it from both maps
writeLock.lock();
try {
removeRequirement(requirementRegistration, false);
removeRequirement(requirementRegistration, true);
} finally {
writeLock.unlock();
}
} | [
"@",
"Override",
"public",
"void",
"removeCapabilityRequirement",
"(",
"RuntimeRequirementRegistration",
"requirementRegistration",
")",
"{",
"// We don't know if this got registered as an runtime-only requirement or a hard one",
"// so clean it from both maps",
"writeLock",
".",
"lock",... | Remove a previously registered requirement for a capability.
@param requirementRegistration the requirement. Cannot be {@code null}
@see #registerAdditionalCapabilityRequirement(org.jboss.as.controller.capability.registry.RuntimeRequirementRegistration) | [
"Remove",
"a",
"previously",
"registered",
"requirement",
"for",
"a",
"capability",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/CapabilityRegistry.java#L238-L249 | train |
wildfly/wildfly-core | controller/src/main/java/org/jboss/as/controller/CapabilityRegistry.java | CapabilityRegistry.publish | void publish() {
assert publishedFullRegistry != null : "Cannot write directly to main registry";
writeLock.lock();
try {
if (!modified) {
return;
}
publishedFullRegistry.writeLock.lock();
try {
publishedFullRegistry.clear(true);
copy(this, publishedFullRegistry);
pendingRemoveCapabilities.clear();
pendingRemoveRequirements.clear();
modified = false;
} finally {
publishedFullRegistry.writeLock.unlock();
}
} finally {
writeLock.unlock();
}
} | java | void publish() {
assert publishedFullRegistry != null : "Cannot write directly to main registry";
writeLock.lock();
try {
if (!modified) {
return;
}
publishedFullRegistry.writeLock.lock();
try {
publishedFullRegistry.clear(true);
copy(this, publishedFullRegistry);
pendingRemoveCapabilities.clear();
pendingRemoveRequirements.clear();
modified = false;
} finally {
publishedFullRegistry.writeLock.unlock();
}
} finally {
writeLock.unlock();
}
} | [
"void",
"publish",
"(",
")",
"{",
"assert",
"publishedFullRegistry",
"!=",
"null",
":",
"\"Cannot write directly to main registry\"",
";",
"writeLock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"if",
"(",
"!",
"modified",
")",
"{",
"return",
";",
"}",
"publish... | Publish the changes to main registry | [
"Publish",
"the",
"changes",
"to",
"main",
"registry"
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/CapabilityRegistry.java#L739-L760 | train |
wildfly/wildfly-core | controller/src/main/java/org/jboss/as/controller/CapabilityRegistry.java | CapabilityRegistry.rollback | void rollback() {
if (publishedFullRegistry == null) {
return;
}
writeLock.lock();
try {
publishedFullRegistry.readLock.lock();
try {
clear(true);
copy(publishedFullRegistry, this);
modified = false;
} finally {
publishedFullRegistry.readLock.unlock();
}
} finally {
writeLock.unlock();
}
} | java | void rollback() {
if (publishedFullRegistry == null) {
return;
}
writeLock.lock();
try {
publishedFullRegistry.readLock.lock();
try {
clear(true);
copy(publishedFullRegistry, this);
modified = false;
} finally {
publishedFullRegistry.readLock.unlock();
}
} finally {
writeLock.unlock();
}
} | [
"void",
"rollback",
"(",
")",
"{",
"if",
"(",
"publishedFullRegistry",
"==",
"null",
")",
"{",
"return",
";",
"}",
"writeLock",
".",
"lock",
"(",
")",
";",
"try",
"{",
"publishedFullRegistry",
".",
"readLock",
".",
"lock",
"(",
")",
";",
"try",
"{",
... | Discard the changes. | [
"Discard",
"the",
"changes",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/CapabilityRegistry.java#L765-L782 | train |
wildfly/wildfly-core | logging/src/main/java/org/jboss/as/logging/LoggingSubsystemParser.java | LoggingSubsystemParser.addOperationAddress | static void addOperationAddress(final ModelNode operation, final PathAddress base, final String key, final String value) {
operation.get(OP_ADDR).set(base.append(key, value).toModelNode());
} | java | static void addOperationAddress(final ModelNode operation, final PathAddress base, final String key, final String value) {
operation.get(OP_ADDR).set(base.append(key, value).toModelNode());
} | [
"static",
"void",
"addOperationAddress",
"(",
"final",
"ModelNode",
"operation",
",",
"final",
"PathAddress",
"base",
",",
"final",
"String",
"key",
",",
"final",
"String",
"value",
")",
"{",
"operation",
".",
"get",
"(",
"OP_ADDR",
")",
".",
"set",
"(",
"... | Appends the key and value to the address and sets the address on the operation.
@param operation the operation to set the address on
@param base the base address
@param key the key for the new address
@param value the value for the new address | [
"Appends",
"the",
"key",
"and",
"value",
"to",
"the",
"address",
"and",
"sets",
"the",
"address",
"on",
"the",
"operation",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/logging/src/main/java/org/jboss/as/logging/LoggingSubsystemParser.java#L69-L71 | train |
wildfly/wildfly-core | domain-management/src/main/java/org/jboss/as/domain/management/controller/FindNonProgressingOperationHandler.java | FindNonProgressingOperationHandler.findNonProgressingOp | static String findNonProgressingOp(Resource resource, boolean forServer, long timeout) throws OperationFailedException {
Resource.ResourceEntry nonProgressing = null;
for (Resource.ResourceEntry child : resource.getChildren(ACTIVE_OPERATION)) {
ModelNode model = child.getModel();
if (model.get(EXCLUSIVE_RUNNING_TIME).asLong() > timeout) {
nonProgressing = child;
ControllerLogger.MGMT_OP_LOGGER.tracef("non-progressing op: %s", nonProgressing.getModel());
break;
}
}
if (nonProgressing != null && !forServer) {
// WFCORE-263
// See if the op is non-progressing because it's the HC op waiting for commit
// from the DC while other ops (i.e. ops proxied to our servers) associated
// with the same domain-uuid are not completing
ModelNode model = nonProgressing.getModel();
if (model.get(DOMAIN_ROLLOUT).asBoolean()
&& OperationContext.ExecutionStatus.COMPLETING.toString().equals(model.get(EXECUTION_STATUS).asString())
&& model.hasDefined(DOMAIN_UUID)) {
ControllerLogger.MGMT_OP_LOGGER.trace("Potential domain rollout issue");
String domainUUID = model.get(DOMAIN_UUID).asString();
Set<String> relatedIds = null;
List<Resource.ResourceEntry> relatedExecutingOps = null;
for (Resource.ResourceEntry activeOp : resource.getChildren(ACTIVE_OPERATION)) {
if (nonProgressing.getName().equals(activeOp.getName())) {
continue; // ignore self
}
ModelNode opModel = activeOp.getModel();
if (opModel.hasDefined(DOMAIN_UUID) && domainUUID.equals(opModel.get(DOMAIN_UUID).asString())
&& opModel.get(RUNNING_TIME).asLong() > timeout) {
if (relatedIds == null) {
relatedIds = new TreeSet<String>(); // order these as an aid to unit testing
}
relatedIds.add(activeOp.getName());
// If the op is ExecutionStatus.EXECUTING that means it's still EXECUTING on the
// server or a prepare message got lost. It would be COMPLETING if the server
// had sent a prepare message, as that would result in ProxyStepHandler calling completeStep
if (OperationContext.ExecutionStatus.EXECUTING.toString().equals(opModel.get(EXECUTION_STATUS).asString())) {
if (relatedExecutingOps == null) {
relatedExecutingOps = new ArrayList<Resource.ResourceEntry>();
}
relatedExecutingOps.add(activeOp);
ControllerLogger.MGMT_OP_LOGGER.tracef("Related executing: %s", opModel);
} else ControllerLogger.MGMT_OP_LOGGER.tracef("Related non-executing: %s", opModel);
} else ControllerLogger.MGMT_OP_LOGGER.tracef("unrelated: %s", opModel);
}
if (relatedIds != null) {
// There are other ops associated with this domain-uuid that are also not completing
// in the desired time, so we can't treat the one holding the lock as the problem.
if (relatedExecutingOps != null && relatedExecutingOps.size() == 1) {
// There's a single related op that's executing for too long. So we can report that one.
// Note that it's possible that the same problem exists on other hosts as well
// and that this cancellation will not resolve the overall problem. But, we only
// get here on a slave HC and if the user is invoking this on a slave and not the
// master, we'll assume they have a reason for doing that and want us to treat this
// as a problem on this particular host.
nonProgressing = relatedExecutingOps.get(0);
} else {
// Fail and provide a useful failure message.
throw DomainManagementLogger.ROOT_LOGGER.domainRolloutNotProgressing(nonProgressing.getName(),
timeout, domainUUID, relatedIds);
}
}
}
}
return nonProgressing == null ? null : nonProgressing.getName();
} | java | static String findNonProgressingOp(Resource resource, boolean forServer, long timeout) throws OperationFailedException {
Resource.ResourceEntry nonProgressing = null;
for (Resource.ResourceEntry child : resource.getChildren(ACTIVE_OPERATION)) {
ModelNode model = child.getModel();
if (model.get(EXCLUSIVE_RUNNING_TIME).asLong() > timeout) {
nonProgressing = child;
ControllerLogger.MGMT_OP_LOGGER.tracef("non-progressing op: %s", nonProgressing.getModel());
break;
}
}
if (nonProgressing != null && !forServer) {
// WFCORE-263
// See if the op is non-progressing because it's the HC op waiting for commit
// from the DC while other ops (i.e. ops proxied to our servers) associated
// with the same domain-uuid are not completing
ModelNode model = nonProgressing.getModel();
if (model.get(DOMAIN_ROLLOUT).asBoolean()
&& OperationContext.ExecutionStatus.COMPLETING.toString().equals(model.get(EXECUTION_STATUS).asString())
&& model.hasDefined(DOMAIN_UUID)) {
ControllerLogger.MGMT_OP_LOGGER.trace("Potential domain rollout issue");
String domainUUID = model.get(DOMAIN_UUID).asString();
Set<String> relatedIds = null;
List<Resource.ResourceEntry> relatedExecutingOps = null;
for (Resource.ResourceEntry activeOp : resource.getChildren(ACTIVE_OPERATION)) {
if (nonProgressing.getName().equals(activeOp.getName())) {
continue; // ignore self
}
ModelNode opModel = activeOp.getModel();
if (opModel.hasDefined(DOMAIN_UUID) && domainUUID.equals(opModel.get(DOMAIN_UUID).asString())
&& opModel.get(RUNNING_TIME).asLong() > timeout) {
if (relatedIds == null) {
relatedIds = new TreeSet<String>(); // order these as an aid to unit testing
}
relatedIds.add(activeOp.getName());
// If the op is ExecutionStatus.EXECUTING that means it's still EXECUTING on the
// server or a prepare message got lost. It would be COMPLETING if the server
// had sent a prepare message, as that would result in ProxyStepHandler calling completeStep
if (OperationContext.ExecutionStatus.EXECUTING.toString().equals(opModel.get(EXECUTION_STATUS).asString())) {
if (relatedExecutingOps == null) {
relatedExecutingOps = new ArrayList<Resource.ResourceEntry>();
}
relatedExecutingOps.add(activeOp);
ControllerLogger.MGMT_OP_LOGGER.tracef("Related executing: %s", opModel);
} else ControllerLogger.MGMT_OP_LOGGER.tracef("Related non-executing: %s", opModel);
} else ControllerLogger.MGMT_OP_LOGGER.tracef("unrelated: %s", opModel);
}
if (relatedIds != null) {
// There are other ops associated with this domain-uuid that are also not completing
// in the desired time, so we can't treat the one holding the lock as the problem.
if (relatedExecutingOps != null && relatedExecutingOps.size() == 1) {
// There's a single related op that's executing for too long. So we can report that one.
// Note that it's possible that the same problem exists on other hosts as well
// and that this cancellation will not resolve the overall problem. But, we only
// get here on a slave HC and if the user is invoking this on a slave and not the
// master, we'll assume they have a reason for doing that and want us to treat this
// as a problem on this particular host.
nonProgressing = relatedExecutingOps.get(0);
} else {
// Fail and provide a useful failure message.
throw DomainManagementLogger.ROOT_LOGGER.domainRolloutNotProgressing(nonProgressing.getName(),
timeout, domainUUID, relatedIds);
}
}
}
}
return nonProgressing == null ? null : nonProgressing.getName();
} | [
"static",
"String",
"findNonProgressingOp",
"(",
"Resource",
"resource",
",",
"boolean",
"forServer",
",",
"long",
"timeout",
")",
"throws",
"OperationFailedException",
"{",
"Resource",
".",
"ResourceEntry",
"nonProgressing",
"=",
"null",
";",
"for",
"(",
"Resource"... | Separate from other findNonProgressingOp variant to allow unit testing without needing a mock OperationContext | [
"Separate",
"from",
"other",
"findNonProgressingOp",
"variant",
"to",
"allow",
"unit",
"testing",
"without",
"needing",
"a",
"mock",
"OperationContext"
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/domain-management/src/main/java/org/jboss/as/domain/management/controller/FindNonProgressingOperationHandler.java#L103-L174 | train |
wildfly/wildfly-core | deployment-scanner/src/main/java/org/jboss/as/server/deployment/scanner/FileSystemDeploymentService.java | FileSystemDeploymentService.bootTimeScan | void bootTimeScan(final DeploymentOperations deploymentOperations) {
// WFCORE-1579: skip the scan if deployment dir is not available
if (!checkDeploymentDir(this.deploymentDir)) {
DeploymentScannerLogger.ROOT_LOGGER.bootTimeScanFailed(deploymentDir.getAbsolutePath());
return;
}
this.establishDeployedContentList(this.deploymentDir, deploymentOperations);
deployedContentEstablished = true;
if (acquireScanLock()) {
try {
scan(true, deploymentOperations);
} finally {
releaseScanLock();
}
}
} | java | void bootTimeScan(final DeploymentOperations deploymentOperations) {
// WFCORE-1579: skip the scan if deployment dir is not available
if (!checkDeploymentDir(this.deploymentDir)) {
DeploymentScannerLogger.ROOT_LOGGER.bootTimeScanFailed(deploymentDir.getAbsolutePath());
return;
}
this.establishDeployedContentList(this.deploymentDir, deploymentOperations);
deployedContentEstablished = true;
if (acquireScanLock()) {
try {
scan(true, deploymentOperations);
} finally {
releaseScanLock();
}
}
} | [
"void",
"bootTimeScan",
"(",
"final",
"DeploymentOperations",
"deploymentOperations",
")",
"{",
"// WFCORE-1579: skip the scan if deployment dir is not available",
"if",
"(",
"!",
"checkDeploymentDir",
"(",
"this",
".",
"deploymentDir",
")",
")",
"{",
"DeploymentScannerLogger... | Perform a one-off scan during boot to establish deployment tasks to execute during boot | [
"Perform",
"a",
"one",
"-",
"off",
"scan",
"during",
"boot",
"to",
"establish",
"deployment",
"tasks",
"to",
"execute",
"during",
"boot"
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/deployment-scanner/src/main/java/org/jboss/as/server/deployment/scanner/FileSystemDeploymentService.java#L463-L479 | train |
wildfly/wildfly-core | deployment-scanner/src/main/java/org/jboss/as/server/deployment/scanner/FileSystemDeploymentService.java | FileSystemDeploymentService.scan | void scan() {
if (acquireScanLock()) {
boolean scheduleRescan = false;
try {
scheduleRescan = scan(false, deploymentOperations);
} finally {
try {
if (scheduleRescan) {
synchronized (this) {
if (scanEnabled) {
rescanIncompleteTask = scheduledExecutor.schedule(scanRunnable, 200, TimeUnit.MILLISECONDS);
}
}
}
} finally {
releaseScanLock();
}
}
}
} | java | void scan() {
if (acquireScanLock()) {
boolean scheduleRescan = false;
try {
scheduleRescan = scan(false, deploymentOperations);
} finally {
try {
if (scheduleRescan) {
synchronized (this) {
if (scanEnabled) {
rescanIncompleteTask = scheduledExecutor.schedule(scanRunnable, 200, TimeUnit.MILLISECONDS);
}
}
}
} finally {
releaseScanLock();
}
}
}
} | [
"void",
"scan",
"(",
")",
"{",
"if",
"(",
"acquireScanLock",
"(",
")",
")",
"{",
"boolean",
"scheduleRescan",
"=",
"false",
";",
"try",
"{",
"scheduleRescan",
"=",
"scan",
"(",
"false",
",",
"deploymentOperations",
")",
";",
"}",
"finally",
"{",
"try",
... | Perform a normal scan | [
"Perform",
"a",
"normal",
"scan"
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/deployment-scanner/src/main/java/org/jboss/as/server/deployment/scanner/FileSystemDeploymentService.java#L489-L508 | train |
wildfly/wildfly-core | deployment-scanner/src/main/java/org/jboss/as/server/deployment/scanner/FileSystemDeploymentService.java | FileSystemDeploymentService.forcedUndeployScan | void forcedUndeployScan() {
if (acquireScanLock()) {
try {
ROOT_LOGGER.tracef("Performing a post-boot forced undeploy scan for scan directory %s", deploymentDir.getAbsolutePath());
ScanContext scanContext = new ScanContext(deploymentOperations);
// Add remove actions to the plan for anything we count as
// deployed that we didn't find on the scan
for (Map.Entry<String, DeploymentMarker> missing : scanContext.toRemove.entrySet()) {
// remove successful deployment and left will be removed
if (scanContext.registeredDeployments.containsKey(missing.getKey())) {
scanContext.registeredDeployments.remove(missing.getKey());
}
}
Set<String> scannedDeployments = new HashSet<String>(scanContext.registeredDeployments.keySet());
scannedDeployments.removeAll(scanContext.persistentDeployments);
List<ScannerTask> scannerTasks = scanContext.scannerTasks;
for (String toUndeploy : scannedDeployments) {
scannerTasks.add(new UndeployTask(toUndeploy, deploymentDir, scanContext.scanStartTime, true));
}
try {
executeScannerTasks(scannerTasks, deploymentOperations, true);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
ROOT_LOGGER.tracef("Forced undeploy scan complete");
} catch (Exception e) {
ROOT_LOGGER.scanException(e, deploymentDir.getAbsolutePath());
} finally {
releaseScanLock();
}
}
} | java | void forcedUndeployScan() {
if (acquireScanLock()) {
try {
ROOT_LOGGER.tracef("Performing a post-boot forced undeploy scan for scan directory %s", deploymentDir.getAbsolutePath());
ScanContext scanContext = new ScanContext(deploymentOperations);
// Add remove actions to the plan for anything we count as
// deployed that we didn't find on the scan
for (Map.Entry<String, DeploymentMarker> missing : scanContext.toRemove.entrySet()) {
// remove successful deployment and left will be removed
if (scanContext.registeredDeployments.containsKey(missing.getKey())) {
scanContext.registeredDeployments.remove(missing.getKey());
}
}
Set<String> scannedDeployments = new HashSet<String>(scanContext.registeredDeployments.keySet());
scannedDeployments.removeAll(scanContext.persistentDeployments);
List<ScannerTask> scannerTasks = scanContext.scannerTasks;
for (String toUndeploy : scannedDeployments) {
scannerTasks.add(new UndeployTask(toUndeploy, deploymentDir, scanContext.scanStartTime, true));
}
try {
executeScannerTasks(scannerTasks, deploymentOperations, true);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
ROOT_LOGGER.tracef("Forced undeploy scan complete");
} catch (Exception e) {
ROOT_LOGGER.scanException(e, deploymentDir.getAbsolutePath());
} finally {
releaseScanLock();
}
}
} | [
"void",
"forcedUndeployScan",
"(",
")",
"{",
"if",
"(",
"acquireScanLock",
"(",
")",
")",
"{",
"try",
"{",
"ROOT_LOGGER",
".",
"tracef",
"(",
"\"Performing a post-boot forced undeploy scan for scan directory %s\"",
",",
"deploymentDir",
".",
"getAbsolutePath",
"(",
")... | Perform a post-boot scan to remove any deployments added during boot that failed to deploy properly.
This method isn't private solely to allow a unit test in the same package to call it. | [
"Perform",
"a",
"post",
"-",
"boot",
"scan",
"to",
"remove",
"any",
"deployments",
"added",
"during",
"boot",
"that",
"failed",
"to",
"deploy",
"properly",
".",
"This",
"method",
"isn",
"t",
"private",
"solely",
"to",
"allow",
"a",
"unit",
"test",
"in",
... | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/deployment-scanner/src/main/java/org/jboss/as/server/deployment/scanner/FileSystemDeploymentService.java#L514-L549 | train |
wildfly/wildfly-core | deployment-scanner/src/main/java/org/jboss/as/server/deployment/scanner/FileSystemDeploymentService.java | FileSystemDeploymentService.checkDeploymentDir | private boolean checkDeploymentDir(File directory) {
if (!directory.exists()) {
if (deploymentDirAccessible) {
deploymentDirAccessible = false;
ROOT_LOGGER.directoryIsNonexistent(deploymentDir.getAbsolutePath());
}
}
else if (!directory.isDirectory()) {
if (deploymentDirAccessible) {
deploymentDirAccessible = false;
ROOT_LOGGER.isNotADirectory(deploymentDir.getAbsolutePath());
}
}
else if (!directory.canRead()) {
if (deploymentDirAccessible) {
deploymentDirAccessible = false;
ROOT_LOGGER.directoryIsNotReadable(deploymentDir.getAbsolutePath());
}
}
else if (!directory.canWrite()) {
if (deploymentDirAccessible) {
deploymentDirAccessible = false;
ROOT_LOGGER.directoryIsNotWritable(deploymentDir.getAbsolutePath());
}
} else {
deploymentDirAccessible = true;
}
return deploymentDirAccessible;
} | java | private boolean checkDeploymentDir(File directory) {
if (!directory.exists()) {
if (deploymentDirAccessible) {
deploymentDirAccessible = false;
ROOT_LOGGER.directoryIsNonexistent(deploymentDir.getAbsolutePath());
}
}
else if (!directory.isDirectory()) {
if (deploymentDirAccessible) {
deploymentDirAccessible = false;
ROOT_LOGGER.isNotADirectory(deploymentDir.getAbsolutePath());
}
}
else if (!directory.canRead()) {
if (deploymentDirAccessible) {
deploymentDirAccessible = false;
ROOT_LOGGER.directoryIsNotReadable(deploymentDir.getAbsolutePath());
}
}
else if (!directory.canWrite()) {
if (deploymentDirAccessible) {
deploymentDirAccessible = false;
ROOT_LOGGER.directoryIsNotWritable(deploymentDir.getAbsolutePath());
}
} else {
deploymentDirAccessible = true;
}
return deploymentDirAccessible;
} | [
"private",
"boolean",
"checkDeploymentDir",
"(",
"File",
"directory",
")",
"{",
"if",
"(",
"!",
"directory",
".",
"exists",
"(",
")",
")",
"{",
"if",
"(",
"deploymentDirAccessible",
")",
"{",
"deploymentDirAccessible",
"=",
"false",
";",
"ROOT_LOGGER",
".",
... | Checks that given directory if readable & writable and prints a warning if the check fails. Warning is only
printed once and is not repeated until the condition is fixed and broken again.
@param directory deployment directory
@return does given directory exist and is readable and writable? | [
"Checks",
"that",
"given",
"directory",
"if",
"readable",
"&",
"writable",
"and",
"prints",
"a",
"warning",
"if",
"the",
"check",
"fails",
".",
"Warning",
"is",
"only",
"printed",
"once",
"and",
"is",
"not",
"repeated",
"until",
"the",
"condition",
"is",
"... | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/deployment-scanner/src/main/java/org/jboss/as/server/deployment/scanner/FileSystemDeploymentService.java#L808-L837 | train |
wildfly/wildfly-core | domain-management/src/main/java/org/jboss/as/domain/management/security/LdapCacheResourceDefinition.java | LdapCacheResourceDefinition.createOperation | private static ModelNode createOperation(final ModelNode operationToValidate) {
PathAddress pa = PathAddress.pathAddress(operationToValidate.require(OP_ADDR));
PathAddress validationAddress = pa.subAddress(0, pa.size() - 1);
return Util.getEmptyOperation("validate-cache", validationAddress.toModelNode());
} | java | private static ModelNode createOperation(final ModelNode operationToValidate) {
PathAddress pa = PathAddress.pathAddress(operationToValidate.require(OP_ADDR));
PathAddress validationAddress = pa.subAddress(0, pa.size() - 1);
return Util.getEmptyOperation("validate-cache", validationAddress.toModelNode());
} | [
"private",
"static",
"ModelNode",
"createOperation",
"(",
"final",
"ModelNode",
"operationToValidate",
")",
"{",
"PathAddress",
"pa",
"=",
"PathAddress",
".",
"pathAddress",
"(",
"operationToValidate",
".",
"require",
"(",
"OP_ADDR",
")",
")",
";",
"PathAddress",
... | Creates an operations that targets the valiadating handler.
@param operationToValidate the operation that this handler will validate
@return the validation operation | [
"Creates",
"an",
"operations",
"that",
"targets",
"the",
"valiadating",
"handler",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/domain-management/src/main/java/org/jboss/as/domain/management/security/LdapCacheResourceDefinition.java#L214-L219 | train |
wildfly/wildfly-core | controller/src/main/java/org/jboss/as/controller/capability/registry/RequirementRegistration.java | RequirementRegistration.getOldestRegistrationPoint | public synchronized RegistrationPoint getOldestRegistrationPoint() {
return registrationPoints.size() == 0 ? null : registrationPoints.values().iterator().next().get(0);
} | java | public synchronized RegistrationPoint getOldestRegistrationPoint() {
return registrationPoints.size() == 0 ? null : registrationPoints.values().iterator().next().get(0);
} | [
"public",
"synchronized",
"RegistrationPoint",
"getOldestRegistrationPoint",
"(",
")",
"{",
"return",
"registrationPoints",
".",
"size",
"(",
")",
"==",
"0",
"?",
"null",
":",
"registrationPoints",
".",
"values",
"(",
")",
".",
"iterator",
"(",
")",
".",
"next... | Gets the registration point that been associated with the registration for the longest period.
@return the initial registration point, or {@code null} if there are no longer any registration points | [
"Gets",
"the",
"registration",
"point",
"that",
"been",
"associated",
"with",
"the",
"registration",
"for",
"the",
"longest",
"period",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/capability/registry/RequirementRegistration.java#L119-L121 | train |
wildfly/wildfly-core | controller/src/main/java/org/jboss/as/controller/capability/registry/RequirementRegistration.java | RequirementRegistration.getRegistrationPoints | public synchronized Set<RegistrationPoint> getRegistrationPoints() {
Set<RegistrationPoint> result = new HashSet<>();
for (List<RegistrationPoint> registrationPoints : registrationPoints.values()) {
result.addAll(registrationPoints);
}
return Collections.unmodifiableSet(result);
} | java | public synchronized Set<RegistrationPoint> getRegistrationPoints() {
Set<RegistrationPoint> result = new HashSet<>();
for (List<RegistrationPoint> registrationPoints : registrationPoints.values()) {
result.addAll(registrationPoints);
}
return Collections.unmodifiableSet(result);
} | [
"public",
"synchronized",
"Set",
"<",
"RegistrationPoint",
">",
"getRegistrationPoints",
"(",
")",
"{",
"Set",
"<",
"RegistrationPoint",
">",
"result",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"for",
"(",
"List",
"<",
"RegistrationPoint",
">",
"registration... | Get all registration points associated with this registration.
@return all registration points. Will not be {@code null} but may be empty | [
"Get",
"all",
"registration",
"points",
"associated",
"with",
"this",
"registration",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/capability/registry/RequirementRegistration.java#L128-L134 | train |
wildfly/wildfly-core | server/src/main/java/org/jboss/as/server/deployment/DeploymentHandlerUtils.java | DeploymentHandlerUtils.hasValidContentAdditionParameterDefined | public static boolean hasValidContentAdditionParameterDefined(ModelNode operation) {
for (String s : DeploymentAttributes.MANAGED_CONTENT_ATTRIBUTES.keySet()) {
if (operation.hasDefined(s)) {
return true;
}
}
return false;
} | java | public static boolean hasValidContentAdditionParameterDefined(ModelNode operation) {
for (String s : DeploymentAttributes.MANAGED_CONTENT_ATTRIBUTES.keySet()) {
if (operation.hasDefined(s)) {
return true;
}
}
return false;
} | [
"public",
"static",
"boolean",
"hasValidContentAdditionParameterDefined",
"(",
"ModelNode",
"operation",
")",
"{",
"for",
"(",
"String",
"s",
":",
"DeploymentAttributes",
".",
"MANAGED_CONTENT_ATTRIBUTES",
".",
"keySet",
"(",
")",
")",
"{",
"if",
"(",
"operation",
... | Checks to see if a valid deployment parameter has been defined.
@param operation the operation to check.
@return {@code true} of the parameter is valid, otherwise {@code false}. | [
"Checks",
"to",
"see",
"if",
"a",
"valid",
"deployment",
"parameter",
"has",
"been",
"defined",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/server/src/main/java/org/jboss/as/server/deployment/DeploymentHandlerUtils.java#L127-L134 | train |
wildfly/wildfly-core | patching/src/main/java/org/jboss/as/patching/installation/LayersFactory.java | LayersFactory.load | static InstalledIdentity load(final InstalledImage image, final ProductConfig productConfig, final List<File> moduleRoots, final List<File> bundleRoots) throws IOException {
// build the identity information
final String productVersion = productConfig.resolveVersion();
final String productName = productConfig.resolveName();
final Identity identity = new AbstractLazyIdentity() {
@Override
public String getName() {
return productName;
}
@Override
public String getVersion() {
return productVersion;
}
@Override
public InstalledImage getInstalledImage() {
return image;
}
};
final Properties properties = PatchUtils.loadProperties(identity.getDirectoryStructure().getInstallationInfo());
final List<String> allPatches = PatchUtils.readRefs(properties, Constants.ALL_PATCHES);
// Step 1 - gather the installed layers data
final InstalledConfiguration conf = createInstalledConfig(image);
// Step 2 - process the actual module and bundle roots
final ProcessedLayers processedLayers = process(conf, moduleRoots, bundleRoots);
final InstalledConfiguration config = processedLayers.getConf();
// Step 3 - create the actual config objects
// Process layers
final InstalledIdentityImpl installedIdentity = new InstalledIdentityImpl(identity, allPatches, image);
for (final LayerPathConfig layer : processedLayers.getLayers().values()) {
final String name = layer.name;
installedIdentity.putLayer(name, createPatchableTarget(name, layer, config.getLayerMetadataDir(name), image));
}
// Process add-ons
for (final LayerPathConfig addOn : processedLayers.getAddOns().values()) {
final String name = addOn.name;
installedIdentity.putAddOn(name, createPatchableTarget(name, addOn, config.getAddOnMetadataDir(name), image));
}
return installedIdentity;
} | java | static InstalledIdentity load(final InstalledImage image, final ProductConfig productConfig, final List<File> moduleRoots, final List<File> bundleRoots) throws IOException {
// build the identity information
final String productVersion = productConfig.resolveVersion();
final String productName = productConfig.resolveName();
final Identity identity = new AbstractLazyIdentity() {
@Override
public String getName() {
return productName;
}
@Override
public String getVersion() {
return productVersion;
}
@Override
public InstalledImage getInstalledImage() {
return image;
}
};
final Properties properties = PatchUtils.loadProperties(identity.getDirectoryStructure().getInstallationInfo());
final List<String> allPatches = PatchUtils.readRefs(properties, Constants.ALL_PATCHES);
// Step 1 - gather the installed layers data
final InstalledConfiguration conf = createInstalledConfig(image);
// Step 2 - process the actual module and bundle roots
final ProcessedLayers processedLayers = process(conf, moduleRoots, bundleRoots);
final InstalledConfiguration config = processedLayers.getConf();
// Step 3 - create the actual config objects
// Process layers
final InstalledIdentityImpl installedIdentity = new InstalledIdentityImpl(identity, allPatches, image);
for (final LayerPathConfig layer : processedLayers.getLayers().values()) {
final String name = layer.name;
installedIdentity.putLayer(name, createPatchableTarget(name, layer, config.getLayerMetadataDir(name), image));
}
// Process add-ons
for (final LayerPathConfig addOn : processedLayers.getAddOns().values()) {
final String name = addOn.name;
installedIdentity.putAddOn(name, createPatchableTarget(name, addOn, config.getAddOnMetadataDir(name), image));
}
return installedIdentity;
} | [
"static",
"InstalledIdentity",
"load",
"(",
"final",
"InstalledImage",
"image",
",",
"final",
"ProductConfig",
"productConfig",
",",
"final",
"List",
"<",
"File",
">",
"moduleRoots",
",",
"final",
"List",
"<",
"File",
">",
"bundleRoots",
")",
"throws",
"IOExcept... | Load the available layers.
@param image the installed image
@param productConfig the product config to establish the identity
@param moduleRoots the module roots
@param bundleRoots the bundle roots
@return the layers
@throws IOException | [
"Load",
"the",
"available",
"layers",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/patching/src/main/java/org/jboss/as/patching/installation/LayersFactory.java#L58-L102 | train |
wildfly/wildfly-core | patching/src/main/java/org/jboss/as/patching/installation/LayersFactory.java | LayersFactory.process | static ProcessedLayers process(final InstalledConfiguration conf, final List<File> moduleRoots, final List<File> bundleRoots) throws IOException {
final ProcessedLayers layers = new ProcessedLayers(conf);
// Process module roots
final LayerPathSetter moduleSetter = new LayerPathSetter() {
@Override
public boolean setPath(final LayerPathConfig pending, final File root) {
if (pending.modulePath == null) {
pending.modulePath = root;
return true;
}
return false;
}
};
for (final File moduleRoot : moduleRoots) {
processRoot(moduleRoot, layers, moduleSetter);
}
// Process bundle root
final LayerPathSetter bundleSetter = new LayerPathSetter() {
@Override
public boolean setPath(LayerPathConfig pending, File root) {
if (pending.bundlePath == null) {
pending.bundlePath = root;
return true;
}
return false;
}
};
for (final File bundleRoot : bundleRoots) {
processRoot(bundleRoot, layers, bundleSetter);
}
// if (conf.getInstalledLayers().size() != layers.getLayers().size()) {
// throw processingError("processed layers don't match expected %s, but was %s", conf.getInstalledLayers(), layers.getLayers().keySet());
// }
// if (conf.getInstalledAddOns().size() != layers.getAddOns().size()) {
// throw processingError("processed add-ons don't match expected %s, but was %s", conf.getInstalledAddOns(), layers.getAddOns().keySet());
// }
return layers;
} | java | static ProcessedLayers process(final InstalledConfiguration conf, final List<File> moduleRoots, final List<File> bundleRoots) throws IOException {
final ProcessedLayers layers = new ProcessedLayers(conf);
// Process module roots
final LayerPathSetter moduleSetter = new LayerPathSetter() {
@Override
public boolean setPath(final LayerPathConfig pending, final File root) {
if (pending.modulePath == null) {
pending.modulePath = root;
return true;
}
return false;
}
};
for (final File moduleRoot : moduleRoots) {
processRoot(moduleRoot, layers, moduleSetter);
}
// Process bundle root
final LayerPathSetter bundleSetter = new LayerPathSetter() {
@Override
public boolean setPath(LayerPathConfig pending, File root) {
if (pending.bundlePath == null) {
pending.bundlePath = root;
return true;
}
return false;
}
};
for (final File bundleRoot : bundleRoots) {
processRoot(bundleRoot, layers, bundleSetter);
}
// if (conf.getInstalledLayers().size() != layers.getLayers().size()) {
// throw processingError("processed layers don't match expected %s, but was %s", conf.getInstalledLayers(), layers.getLayers().keySet());
// }
// if (conf.getInstalledAddOns().size() != layers.getAddOns().size()) {
// throw processingError("processed add-ons don't match expected %s, but was %s", conf.getInstalledAddOns(), layers.getAddOns().keySet());
// }
return layers;
} | [
"static",
"ProcessedLayers",
"process",
"(",
"final",
"InstalledConfiguration",
"conf",
",",
"final",
"List",
"<",
"File",
">",
"moduleRoots",
",",
"final",
"List",
"<",
"File",
">",
"bundleRoots",
")",
"throws",
"IOException",
"{",
"final",
"ProcessedLayers",
"... | Process the module and bundle roots and cross check with the installed information.
@param conf the installed configuration
@param moduleRoots the module roots
@param bundleRoots the bundle roots
@return the processed layers
@throws IOException | [
"Process",
"the",
"module",
"and",
"bundle",
"roots",
"and",
"cross",
"check",
"with",
"the",
"installed",
"information",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/patching/src/main/java/org/jboss/as/patching/installation/LayersFactory.java#L113-L150 | train |
wildfly/wildfly-core | patching/src/main/java/org/jboss/as/patching/installation/LayersFactory.java | LayersFactory.processRoot | static void processRoot(final File root, final ProcessedLayers layers, final LayerPathSetter setter) throws IOException {
final LayersConfig layersConfig = LayersConfig.getLayersConfig(root);
// Process layers
final File layersDir = new File(root, layersConfig.getLayersPath());
if (!layersDir.exists()) {
if (layersConfig.isConfigured()) {
// Bad config from user
throw PatchLogger.ROOT_LOGGER.installationNoLayersConfigFound(layersDir.getAbsolutePath());
}
// else this isn't a root that has layers and add-ons
} else {
// check for a valid layer configuration
for (final String layer : layersConfig.getLayers()) {
File layerDir = new File(layersDir, layer);
if (!layerDir.exists()) {
if (layersConfig.isConfigured()) {
// Bad config from user
throw PatchLogger.ROOT_LOGGER.installationMissingLayer(layer, layersDir.getAbsolutePath());
}
// else this isn't a standard layers and add-ons structure
return;
}
layers.addLayer(layer, layerDir, setter);
}
}
// Finally process the add-ons
final File addOnsDir = new File(root, layersConfig.getAddOnsPath());
final File[] addOnsList = addOnsDir.listFiles();
if (addOnsList != null) {
for (final File addOn : addOnsList) {
layers.addAddOn(addOn.getName(), addOn, setter);
}
}
} | java | static void processRoot(final File root, final ProcessedLayers layers, final LayerPathSetter setter) throws IOException {
final LayersConfig layersConfig = LayersConfig.getLayersConfig(root);
// Process layers
final File layersDir = new File(root, layersConfig.getLayersPath());
if (!layersDir.exists()) {
if (layersConfig.isConfigured()) {
// Bad config from user
throw PatchLogger.ROOT_LOGGER.installationNoLayersConfigFound(layersDir.getAbsolutePath());
}
// else this isn't a root that has layers and add-ons
} else {
// check for a valid layer configuration
for (final String layer : layersConfig.getLayers()) {
File layerDir = new File(layersDir, layer);
if (!layerDir.exists()) {
if (layersConfig.isConfigured()) {
// Bad config from user
throw PatchLogger.ROOT_LOGGER.installationMissingLayer(layer, layersDir.getAbsolutePath());
}
// else this isn't a standard layers and add-ons structure
return;
}
layers.addLayer(layer, layerDir, setter);
}
}
// Finally process the add-ons
final File addOnsDir = new File(root, layersConfig.getAddOnsPath());
final File[] addOnsList = addOnsDir.listFiles();
if (addOnsList != null) {
for (final File addOn : addOnsList) {
layers.addAddOn(addOn.getName(), addOn, setter);
}
}
} | [
"static",
"void",
"processRoot",
"(",
"final",
"File",
"root",
",",
"final",
"ProcessedLayers",
"layers",
",",
"final",
"LayerPathSetter",
"setter",
")",
"throws",
"IOException",
"{",
"final",
"LayersConfig",
"layersConfig",
"=",
"LayersConfig",
".",
"getLayersConfi... | Process a module or bundle root.
@param root the root
@param layers the processed layers
@param setter the bundle or module path setter
@throws IOException | [
"Process",
"a",
"module",
"or",
"bundle",
"root",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/patching/src/main/java/org/jboss/as/patching/installation/LayersFactory.java#L160-L193 | train |
wildfly/wildfly-core | patching/src/main/java/org/jboss/as/patching/installation/LayersFactory.java | LayersFactory.createPatchableTarget | static AbstractLazyPatchableTarget createPatchableTarget(final String name, final LayerPathConfig layer, final File metadata, final InstalledImage image) throws IOException {
// patchable target
return new AbstractLazyPatchableTarget() {
@Override
public InstalledImage getInstalledImage() {
return image;
}
@Override
public File getModuleRoot() {
return layer.modulePath;
}
@Override
public File getBundleRepositoryRoot() {
return layer.bundlePath;
}
public File getPatchesMetadata() {
return metadata;
}
@Override
public String getName() {
return name;
}
};
} | java | static AbstractLazyPatchableTarget createPatchableTarget(final String name, final LayerPathConfig layer, final File metadata, final InstalledImage image) throws IOException {
// patchable target
return new AbstractLazyPatchableTarget() {
@Override
public InstalledImage getInstalledImage() {
return image;
}
@Override
public File getModuleRoot() {
return layer.modulePath;
}
@Override
public File getBundleRepositoryRoot() {
return layer.bundlePath;
}
public File getPatchesMetadata() {
return metadata;
}
@Override
public String getName() {
return name;
}
};
} | [
"static",
"AbstractLazyPatchableTarget",
"createPatchableTarget",
"(",
"final",
"String",
"name",
",",
"final",
"LayerPathConfig",
"layer",
",",
"final",
"File",
"metadata",
",",
"final",
"InstalledImage",
"image",
")",
"throws",
"IOException",
"{",
"// patchable target... | Create the actual patchable target.
@param name the layer name
@param layer the layer path config
@param metadata the metadata location for this target
@param image the installed image
@return the patchable target
@throws IOException | [
"Create",
"the",
"actual",
"patchable",
"target",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/patching/src/main/java/org/jboss/as/patching/installation/LayersFactory.java#L205-L233 | train |
wildfly/wildfly-core | controller/src/main/java/org/jboss/as/controller/AttributeDefinition.java | AttributeDefinition.getAllowedValues | public List<ModelNode> getAllowedValues() {
if (allowedValues == null) {
return Collections.emptyList();
}
return Arrays.asList(this.allowedValues);
} | java | public List<ModelNode> getAllowedValues() {
if (allowedValues == null) {
return Collections.emptyList();
}
return Arrays.asList(this.allowedValues);
} | [
"public",
"List",
"<",
"ModelNode",
">",
"getAllowedValues",
"(",
")",
"{",
"if",
"(",
"allowedValues",
"==",
"null",
")",
"{",
"return",
"Collections",
".",
"emptyList",
"(",
")",
";",
"}",
"return",
"Arrays",
".",
"asList",
"(",
"this",
".",
"allowedVa... | returns array with all allowed values
@return allowed values | [
"returns",
"array",
"with",
"all",
"allowed",
"values"
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/AttributeDefinition.java#L443-L448 | train |
wildfly/wildfly-core | controller/src/main/java/org/jboss/as/controller/AttributeDefinition.java | AttributeDefinition.addAllowedValuesToDescription | protected void addAllowedValuesToDescription(ModelNode result, ParameterValidator validator) {
if (allowedValues != null) {
for (ModelNode allowedValue : allowedValues) {
result.get(ModelDescriptionConstants.ALLOWED).add(allowedValue);
}
} else if (validator instanceof AllowedValuesValidator) {
AllowedValuesValidator avv = (AllowedValuesValidator) validator;
List<ModelNode> allowed = avv.getAllowedValues();
if (allowed != null) {
for (ModelNode ok : allowed) {
result.get(ModelDescriptionConstants.ALLOWED).add(ok);
}
}
}
} | java | protected void addAllowedValuesToDescription(ModelNode result, ParameterValidator validator) {
if (allowedValues != null) {
for (ModelNode allowedValue : allowedValues) {
result.get(ModelDescriptionConstants.ALLOWED).add(allowedValue);
}
} else if (validator instanceof AllowedValuesValidator) {
AllowedValuesValidator avv = (AllowedValuesValidator) validator;
List<ModelNode> allowed = avv.getAllowedValues();
if (allowed != null) {
for (ModelNode ok : allowed) {
result.get(ModelDescriptionConstants.ALLOWED).add(ok);
}
}
}
} | [
"protected",
"void",
"addAllowedValuesToDescription",
"(",
"ModelNode",
"result",
",",
"ParameterValidator",
"validator",
")",
"{",
"if",
"(",
"allowedValues",
"!=",
"null",
")",
"{",
"for",
"(",
"ModelNode",
"allowedValue",
":",
"allowedValues",
")",
"{",
"result... | Adds the allowed values. Override for attributes who should not use the allowed values.
@param result the node to add the allowed values to
@param validator the validator to get the allowed values from | [
"Adds",
"the",
"allowed",
"values",
".",
"Override",
"for",
"attributes",
"who",
"should",
"not",
"use",
"the",
"allowed",
"values",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/AttributeDefinition.java#L1136-L1150 | train |
wildfly/wildfly-core | cli/src/main/java/org/jboss/as/cli/Util.java | Util.validateRequest | public static ModelNode validateRequest(CommandContext ctx, ModelNode request) throws CommandFormatException {
final Set<String> keys = request.keys();
if (keys.size() == 2) { // no props
return null;
}
ModelNode outcome = (ModelNode) ctx.get(Scope.REQUEST, DESCRIPTION_RESPONSE);
if (outcome == null) {
outcome = retrieveDescription(ctx, request, true);
if (outcome == null) {
return null;
} else {
ctx.set(Scope.REQUEST, DESCRIPTION_RESPONSE, outcome);
}
}
if(!outcome.has(Util.RESULT)) {
throw new CommandFormatException("Failed to perform " + Util.READ_OPERATION_DESCRIPTION + " to validate the request: result is not available.");
}
final String operationName = request.get(Util.OPERATION).asString();
final ModelNode result = outcome.get(Util.RESULT);
final Set<String> definedProps = result.hasDefined(Util.REQUEST_PROPERTIES) ? result.get(Util.REQUEST_PROPERTIES).keys() : Collections.emptySet();
if(definedProps.isEmpty()) {
if(!(keys.size() == 3 && keys.contains(Util.OPERATION_HEADERS))) {
throw new CommandFormatException("Operation '" + operationName + "' does not expect any property.");
}
} else {
int skipped = 0;
for(String prop : keys) {
if(skipped < 2 && (prop.equals(Util.ADDRESS) || prop.equals(Util.OPERATION))) {
++skipped;
continue;
}
if(!definedProps.contains(prop)) {
if(!Util.OPERATION_HEADERS.equals(prop)) {
throw new CommandFormatException("'" + prop + "' is not found among the supported properties: " + definedProps);
}
}
}
}
return outcome;
} | java | public static ModelNode validateRequest(CommandContext ctx, ModelNode request) throws CommandFormatException {
final Set<String> keys = request.keys();
if (keys.size() == 2) { // no props
return null;
}
ModelNode outcome = (ModelNode) ctx.get(Scope.REQUEST, DESCRIPTION_RESPONSE);
if (outcome == null) {
outcome = retrieveDescription(ctx, request, true);
if (outcome == null) {
return null;
} else {
ctx.set(Scope.REQUEST, DESCRIPTION_RESPONSE, outcome);
}
}
if(!outcome.has(Util.RESULT)) {
throw new CommandFormatException("Failed to perform " + Util.READ_OPERATION_DESCRIPTION + " to validate the request: result is not available.");
}
final String operationName = request.get(Util.OPERATION).asString();
final ModelNode result = outcome.get(Util.RESULT);
final Set<String> definedProps = result.hasDefined(Util.REQUEST_PROPERTIES) ? result.get(Util.REQUEST_PROPERTIES).keys() : Collections.emptySet();
if(definedProps.isEmpty()) {
if(!(keys.size() == 3 && keys.contains(Util.OPERATION_HEADERS))) {
throw new CommandFormatException("Operation '" + operationName + "' does not expect any property.");
}
} else {
int skipped = 0;
for(String prop : keys) {
if(skipped < 2 && (prop.equals(Util.ADDRESS) || prop.equals(Util.OPERATION))) {
++skipped;
continue;
}
if(!definedProps.contains(prop)) {
if(!Util.OPERATION_HEADERS.equals(prop)) {
throw new CommandFormatException("'" + prop + "' is not found among the supported properties: " + definedProps);
}
}
}
}
return outcome;
} | [
"public",
"static",
"ModelNode",
"validateRequest",
"(",
"CommandContext",
"ctx",
",",
"ModelNode",
"request",
")",
"throws",
"CommandFormatException",
"{",
"final",
"Set",
"<",
"String",
">",
"keys",
"=",
"request",
".",
"keys",
"(",
")",
";",
"if",
"(",
"k... | return null if the operation has no params to validate | [
"return",
"null",
"if",
"the",
"operation",
"has",
"no",
"params",
"to",
"validate"
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/cli/src/main/java/org/jboss/as/cli/Util.java#L1613-L1655 | train |
wildfly/wildfly-core | cli/src/main/java/org/jboss/as/cli/Util.java | Util.reconnectContext | public static boolean reconnectContext(RedirectException re, CommandContext ctx) {
boolean reconnected = false;
try {
ConnectionInfo info = ctx.getConnectionInfo();
ControllerAddress address = null;
if (info != null) {
address = info.getControllerAddress();
}
if (address != null && isHttpsRedirect(re, address.getProtocol())) {
LOG.debug("Trying to reconnect an http to http upgrade");
try {
ctx.connectController();
reconnected = true;
} catch (Exception ex) {
LOG.warn("Exception reconnecting", ex);
// Proper https redirect but error.
// Ignoring it.
}
}
} catch (URISyntaxException ex) {
LOG.warn("Invalid URI: ", ex);
// OK, invalid redirect.
}
return reconnected;
} | java | public static boolean reconnectContext(RedirectException re, CommandContext ctx) {
boolean reconnected = false;
try {
ConnectionInfo info = ctx.getConnectionInfo();
ControllerAddress address = null;
if (info != null) {
address = info.getControllerAddress();
}
if (address != null && isHttpsRedirect(re, address.getProtocol())) {
LOG.debug("Trying to reconnect an http to http upgrade");
try {
ctx.connectController();
reconnected = true;
} catch (Exception ex) {
LOG.warn("Exception reconnecting", ex);
// Proper https redirect but error.
// Ignoring it.
}
}
} catch (URISyntaxException ex) {
LOG.warn("Invalid URI: ", ex);
// OK, invalid redirect.
}
return reconnected;
} | [
"public",
"static",
"boolean",
"reconnectContext",
"(",
"RedirectException",
"re",
",",
"CommandContext",
"ctx",
")",
"{",
"boolean",
"reconnected",
"=",
"false",
";",
"try",
"{",
"ConnectionInfo",
"info",
"=",
"ctx",
".",
"getConnectionInfo",
"(",
")",
";",
"... | Reconnect the context if the RedirectException is valid. | [
"Reconnect",
"the",
"context",
"if",
"the",
"RedirectException",
"is",
"valid",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/cli/src/main/java/org/jboss/as/cli/Util.java#L1660-L1684 | train |
wildfly/wildfly-core | cli/src/main/java/org/jboss/as/cli/Util.java | Util.compactToString | public static String compactToString(ModelNode node) {
Objects.requireNonNull(node);
final StringWriter stringWriter = new StringWriter();
final PrintWriter writer = new PrintWriter(stringWriter, true);
node.writeString(writer, true);
return stringWriter.toString();
} | java | public static String compactToString(ModelNode node) {
Objects.requireNonNull(node);
final StringWriter stringWriter = new StringWriter();
final PrintWriter writer = new PrintWriter(stringWriter, true);
node.writeString(writer, true);
return stringWriter.toString();
} | [
"public",
"static",
"String",
"compactToString",
"(",
"ModelNode",
"node",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"node",
")",
";",
"final",
"StringWriter",
"stringWriter",
"=",
"new",
"StringWriter",
"(",
")",
";",
"final",
"PrintWriter",
"writer",
... | Build a compact representation of the ModelNode.
@param node The model
@return A single line containing the multi lines ModelNode.toString() content. | [
"Build",
"a",
"compact",
"representation",
"of",
"the",
"ModelNode",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/cli/src/main/java/org/jboss/as/cli/Util.java#L1837-L1843 | train |
wildfly/wildfly-core | host-controller/src/main/java/org/jboss/as/host/controller/discovery/S3Discovery.java | S3Discovery.init | private void init() {
validatePreSignedUrls();
try {
conn = new AWSAuthConnection(access_key, secret_access_key);
// Determine the bucket name if prefix is set or if pre-signed URLs are being used
if (prefix != null && prefix.length() > 0) {
ListAllMyBucketsResponse bucket_list = conn.listAllMyBuckets(null);
List buckets = bucket_list.entries;
if (buckets != null) {
boolean found = false;
for (Object tmp : buckets) {
if (tmp instanceof Bucket) {
Bucket bucket = (Bucket) tmp;
if (bucket.name.startsWith(prefix)) {
location = bucket.name;
found = true;
}
}
}
if (!found) {
location = prefix + "-" + java.util.UUID.randomUUID().toString();
}
}
}
if (usingPreSignedUrls()) {
PreSignedUrlParser parsedPut = new PreSignedUrlParser(pre_signed_put_url);
location = parsedPut.getBucket();
}
if (!conn.checkBucketExists(location)) {
conn.createBucket(location, AWSAuthConnection.LOCATION_DEFAULT, null).connection.getResponseMessage();
}
} catch (Exception e) {
throw HostControllerLogger.ROOT_LOGGER.cannotAccessS3Bucket(location, e.getLocalizedMessage());
}
} | java | private void init() {
validatePreSignedUrls();
try {
conn = new AWSAuthConnection(access_key, secret_access_key);
// Determine the bucket name if prefix is set or if pre-signed URLs are being used
if (prefix != null && prefix.length() > 0) {
ListAllMyBucketsResponse bucket_list = conn.listAllMyBuckets(null);
List buckets = bucket_list.entries;
if (buckets != null) {
boolean found = false;
for (Object tmp : buckets) {
if (tmp instanceof Bucket) {
Bucket bucket = (Bucket) tmp;
if (bucket.name.startsWith(prefix)) {
location = bucket.name;
found = true;
}
}
}
if (!found) {
location = prefix + "-" + java.util.UUID.randomUUID().toString();
}
}
}
if (usingPreSignedUrls()) {
PreSignedUrlParser parsedPut = new PreSignedUrlParser(pre_signed_put_url);
location = parsedPut.getBucket();
}
if (!conn.checkBucketExists(location)) {
conn.createBucket(location, AWSAuthConnection.LOCATION_DEFAULT, null).connection.getResponseMessage();
}
} catch (Exception e) {
throw HostControllerLogger.ROOT_LOGGER.cannotAccessS3Bucket(location, e.getLocalizedMessage());
}
} | [
"private",
"void",
"init",
"(",
")",
"{",
"validatePreSignedUrls",
"(",
")",
";",
"try",
"{",
"conn",
"=",
"new",
"AWSAuthConnection",
"(",
"access_key",
",",
"secret_access_key",
")",
";",
"// Determine the bucket name if prefix is set or if pre-signed URLs are being use... | Do the set-up that's needed to access Amazon S3. | [
"Do",
"the",
"set",
"-",
"up",
"that",
"s",
"needed",
"to",
"access",
"Amazon",
"S3",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/host-controller/src/main/java/org/jboss/as/host/controller/discovery/S3Discovery.java#L210-L245 | train |
wildfly/wildfly-core | host-controller/src/main/java/org/jboss/as/host/controller/discovery/S3Discovery.java | S3Discovery.readFromFile | private List<DomainControllerData> readFromFile(String directoryName) {
List<DomainControllerData> data = new ArrayList<DomainControllerData>();
if (directoryName == null) {
return data;
}
if (conn == null) {
init();
}
try {
if (usingPreSignedUrls()) {
PreSignedUrlParser parsedPut = new PreSignedUrlParser(pre_signed_put_url);
directoryName = parsedPut.getPrefix();
}
String key = S3Util.sanitize(directoryName) + "/" + S3Util.sanitize(DC_FILE_NAME);
GetResponse val = conn.get(location, key, null);
if (val.object != null) {
byte[] buf = val.object.data;
if (buf != null && buf.length > 0) {
try {
data = S3Util.domainControllerDataFromByteBuffer(buf);
} catch (Exception e) {
throw HostControllerLogger.ROOT_LOGGER.failedMarshallingDomainControllerData();
}
}
}
return data;
} catch (IOException e) {
throw HostControllerLogger.ROOT_LOGGER.cannotAccessS3File(e.getLocalizedMessage());
}
} | java | private List<DomainControllerData> readFromFile(String directoryName) {
List<DomainControllerData> data = new ArrayList<DomainControllerData>();
if (directoryName == null) {
return data;
}
if (conn == null) {
init();
}
try {
if (usingPreSignedUrls()) {
PreSignedUrlParser parsedPut = new PreSignedUrlParser(pre_signed_put_url);
directoryName = parsedPut.getPrefix();
}
String key = S3Util.sanitize(directoryName) + "/" + S3Util.sanitize(DC_FILE_NAME);
GetResponse val = conn.get(location, key, null);
if (val.object != null) {
byte[] buf = val.object.data;
if (buf != null && buf.length > 0) {
try {
data = S3Util.domainControllerDataFromByteBuffer(buf);
} catch (Exception e) {
throw HostControllerLogger.ROOT_LOGGER.failedMarshallingDomainControllerData();
}
}
}
return data;
} catch (IOException e) {
throw HostControllerLogger.ROOT_LOGGER.cannotAccessS3File(e.getLocalizedMessage());
}
} | [
"private",
"List",
"<",
"DomainControllerData",
">",
"readFromFile",
"(",
"String",
"directoryName",
")",
"{",
"List",
"<",
"DomainControllerData",
">",
"data",
"=",
"new",
"ArrayList",
"<",
"DomainControllerData",
">",
"(",
")",
";",
"if",
"(",
"directoryName",... | Read the domain controller data from an S3 file.
@param directoryName the name of the directory in the bucket that contains the S3 file
@return the domain controller data | [
"Read",
"the",
"domain",
"controller",
"data",
"from",
"an",
"S3",
"file",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/host-controller/src/main/java/org/jboss/as/host/controller/discovery/S3Discovery.java#L253-L284 | train |
wildfly/wildfly-core | host-controller/src/main/java/org/jboss/as/host/controller/discovery/S3Discovery.java | S3Discovery.writeToFile | private void writeToFile(List<DomainControllerData> data, String domainName) throws IOException {
if(domainName == null || data == null) {
return;
}
if (conn == null) {
init();
}
try {
String key = S3Util.sanitize(domainName) + "/" + S3Util.sanitize(DC_FILE_NAME);
byte[] buf = S3Util.domainControllerDataToByteBuffer(data);
S3Object val = new S3Object(buf, null);
if (usingPreSignedUrls()) {
Map headers = new TreeMap();
headers.put("x-amz-acl", Arrays.asList("public-read"));
conn.put(pre_signed_put_url, val, headers).connection.getResponseMessage();
} else {
Map headers = new TreeMap();
headers.put("Content-Type", Arrays.asList("text/plain"));
conn.put(location, key, val, headers).connection.getResponseMessage();
}
}
catch(Exception e) {
throw HostControllerLogger.ROOT_LOGGER.cannotWriteToS3File(e.getLocalizedMessage());
}
} | java | private void writeToFile(List<DomainControllerData> data, String domainName) throws IOException {
if(domainName == null || data == null) {
return;
}
if (conn == null) {
init();
}
try {
String key = S3Util.sanitize(domainName) + "/" + S3Util.sanitize(DC_FILE_NAME);
byte[] buf = S3Util.domainControllerDataToByteBuffer(data);
S3Object val = new S3Object(buf, null);
if (usingPreSignedUrls()) {
Map headers = new TreeMap();
headers.put("x-amz-acl", Arrays.asList("public-read"));
conn.put(pre_signed_put_url, val, headers).connection.getResponseMessage();
} else {
Map headers = new TreeMap();
headers.put("Content-Type", Arrays.asList("text/plain"));
conn.put(location, key, val, headers).connection.getResponseMessage();
}
}
catch(Exception e) {
throw HostControllerLogger.ROOT_LOGGER.cannotWriteToS3File(e.getLocalizedMessage());
}
} | [
"private",
"void",
"writeToFile",
"(",
"List",
"<",
"DomainControllerData",
">",
"data",
",",
"String",
"domainName",
")",
"throws",
"IOException",
"{",
"if",
"(",
"domainName",
"==",
"null",
"||",
"data",
"==",
"null",
")",
"{",
"return",
";",
"}",
"if",
... | Write the domain controller data to an S3 file.
@param data the domain controller data
@param domainName the name of the directory in the bucket to write the S3 file to
@throws IOException | [
"Write",
"the",
"domain",
"controller",
"data",
"to",
"an",
"S3",
"file",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/host-controller/src/main/java/org/jboss/as/host/controller/discovery/S3Discovery.java#L293-L319 | train |
wildfly/wildfly-core | host-controller/src/main/java/org/jboss/as/host/controller/discovery/S3Discovery.java | S3Discovery.remove | private void remove(String directoryName) {
if ((directoryName == null) || (conn == null))
return;
String key = S3Util.sanitize(directoryName) + "/" + S3Util.sanitize(DC_FILE_NAME);
try {
Map headers = new TreeMap();
headers.put("Content-Type", Arrays.asList("text/plain"));
if (usingPreSignedUrls()) {
conn.delete(pre_signed_delete_url).connection.getResponseMessage();
} else {
conn.delete(location, key, headers).connection.getResponseMessage();
}
}
catch(Exception e) {
ROOT_LOGGER.cannotRemoveS3File(e);
}
} | java | private void remove(String directoryName) {
if ((directoryName == null) || (conn == null))
return;
String key = S3Util.sanitize(directoryName) + "/" + S3Util.sanitize(DC_FILE_NAME);
try {
Map headers = new TreeMap();
headers.put("Content-Type", Arrays.asList("text/plain"));
if (usingPreSignedUrls()) {
conn.delete(pre_signed_delete_url).connection.getResponseMessage();
} else {
conn.delete(location, key, headers).connection.getResponseMessage();
}
}
catch(Exception e) {
ROOT_LOGGER.cannotRemoveS3File(e);
}
} | [
"private",
"void",
"remove",
"(",
"String",
"directoryName",
")",
"{",
"if",
"(",
"(",
"directoryName",
"==",
"null",
")",
"||",
"(",
"conn",
"==",
"null",
")",
")",
"return",
";",
"String",
"key",
"=",
"S3Util",
".",
"sanitize",
"(",
"directoryName",
... | Remove the S3 file that contains the domain controller data.
@param directoryName the name of the directory that contains the S3 file | [
"Remove",
"the",
"S3",
"file",
"that",
"contains",
"the",
"domain",
"controller",
"data",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/host-controller/src/main/java/org/jboss/as/host/controller/discovery/S3Discovery.java#L326-L343 | train |
wildfly/wildfly-core | controller/src/main/java/org/jboss/as/controller/registry/GlobalTransformerRegistry.java | GlobalTransformerRegistry.mergeSubtree | public void mergeSubtree(final OperationTransformerRegistry targetRegistry, final Map<PathAddress, ModelVersion> subTree) {
for(Map.Entry<PathAddress, ModelVersion> entry: subTree.entrySet()) {
mergeSubtree(targetRegistry, entry.getKey(), entry.getValue());
}
} | java | public void mergeSubtree(final OperationTransformerRegistry targetRegistry, final Map<PathAddress, ModelVersion> subTree) {
for(Map.Entry<PathAddress, ModelVersion> entry: subTree.entrySet()) {
mergeSubtree(targetRegistry, entry.getKey(), entry.getValue());
}
} | [
"public",
"void",
"mergeSubtree",
"(",
"final",
"OperationTransformerRegistry",
"targetRegistry",
",",
"final",
"Map",
"<",
"PathAddress",
",",
"ModelVersion",
">",
"subTree",
")",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"PathAddress",
",",
"ModelVersion",
">... | Merge a subtree.
@param targetRegistry the target registry
@param subTree the subtree | [
"Merge",
"a",
"subtree",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/registry/GlobalTransformerRegistry.java#L152-L156 | train |
wildfly/wildfly-core | logging/src/main/java/org/jboss/as/logging/handlers/HandlerOperations.java | HandlerOperations.isDisabledHandler | private static boolean isDisabledHandler(final LogContext logContext, final String handlerName) {
final Map<String, String> disableHandlers = logContext.getAttachment(CommonAttributes.ROOT_LOGGER_NAME, DISABLED_HANDLERS_KEY);
return disableHandlers != null && disableHandlers.containsKey(handlerName);
} | java | private static boolean isDisabledHandler(final LogContext logContext, final String handlerName) {
final Map<String, String> disableHandlers = logContext.getAttachment(CommonAttributes.ROOT_LOGGER_NAME, DISABLED_HANDLERS_KEY);
return disableHandlers != null && disableHandlers.containsKey(handlerName);
} | [
"private",
"static",
"boolean",
"isDisabledHandler",
"(",
"final",
"LogContext",
"logContext",
",",
"final",
"String",
"handlerName",
")",
"{",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"disableHandlers",
"=",
"logContext",
".",
"getAttachment",
"(",
"C... | Checks to see if a handler is disabled
@param handlerName the name of the handler to enable. | [
"Checks",
"to",
"see",
"if",
"a",
"handler",
"is",
"disabled"
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/logging/src/main/java/org/jboss/as/logging/handlers/HandlerOperations.java#L866-L869 | train |
wildfly/wildfly-core | jmx/src/main/java/org/jboss/as/jmx/model/ObjectNameAddressUtil.java | ObjectNameAddressUtil.toPathAddress | static PathAddress toPathAddress(String domain, ImmutableManagementResourceRegistration registry, ObjectName name) {
if (!name.getDomain().equals(domain)) {
return PathAddress.EMPTY_ADDRESS;
}
if (name.equals(ModelControllerMBeanHelper.createRootObjectName(domain))) {
return PathAddress.EMPTY_ADDRESS;
}
final Hashtable<String, String> properties = name.getKeyPropertyList();
return searchPathAddress(PathAddress.EMPTY_ADDRESS, registry, properties);
} | java | static PathAddress toPathAddress(String domain, ImmutableManagementResourceRegistration registry, ObjectName name) {
if (!name.getDomain().equals(domain)) {
return PathAddress.EMPTY_ADDRESS;
}
if (name.equals(ModelControllerMBeanHelper.createRootObjectName(domain))) {
return PathAddress.EMPTY_ADDRESS;
}
final Hashtable<String, String> properties = name.getKeyPropertyList();
return searchPathAddress(PathAddress.EMPTY_ADDRESS, registry, properties);
} | [
"static",
"PathAddress",
"toPathAddress",
"(",
"String",
"domain",
",",
"ImmutableManagementResourceRegistration",
"registry",
",",
"ObjectName",
"name",
")",
"{",
"if",
"(",
"!",
"name",
".",
"getDomain",
"(",
")",
".",
"equals",
"(",
"domain",
")",
")",
"{",... | Straight conversion from an ObjectName to a PathAddress.
There may not necessarily be a Resource at this path address (if that correspond to a pattern) but it must
match a model in the registry.
@param domain the name of the caller's JMX domain
@param registry the root resource for the management model
@param name the ObjectName to convert
@return the PathAddress, or {@code null} if no address matches the object name | [
"Straight",
"conversion",
"from",
"an",
"ObjectName",
"to",
"a",
"PathAddress",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/jmx/src/main/java/org/jboss/as/jmx/model/ObjectNameAddressUtil.java#L238-L247 | train |
wildfly/wildfly-core | io/subsystem/src/main/java/org/wildfly/extension/io/WorkerService.java | WorkerService.stopDone | private void stopDone() {
synchronized (stopLock) {
final StopContext stopContext = this.stopContext;
this.stopContext = null;
if (stopContext != null) {
stopContext.complete();
}
stopLock.notifyAll();
}
} | java | private void stopDone() {
synchronized (stopLock) {
final StopContext stopContext = this.stopContext;
this.stopContext = null;
if (stopContext != null) {
stopContext.complete();
}
stopLock.notifyAll();
}
} | [
"private",
"void",
"stopDone",
"(",
")",
"{",
"synchronized",
"(",
"stopLock",
")",
"{",
"final",
"StopContext",
"stopContext",
"=",
"this",
".",
"stopContext",
";",
"this",
".",
"stopContext",
"=",
"null",
";",
"if",
"(",
"stopContext",
"!=",
"null",
")",... | Callback from the worker when it terminates | [
"Callback",
"from",
"the",
"worker",
"when",
"it",
"terminates"
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/io/subsystem/src/main/java/org/wildfly/extension/io/WorkerService.java#L128-L137 | train |
wildfly/wildfly-core | controller/src/main/java/org/jboss/as/controller/transform/description/DefaultCheckersAndConverter.java | DefaultCheckersAndConverter.getRejectionLogMessageId | public String getRejectionLogMessageId() {
String id = logMessageId;
if (id == null) {
id = getRejectionLogMessage(Collections.<String, ModelNode>emptyMap());
}
logMessageId = id;
return logMessageId;
} | java | public String getRejectionLogMessageId() {
String id = logMessageId;
if (id == null) {
id = getRejectionLogMessage(Collections.<String, ModelNode>emptyMap());
}
logMessageId = id;
return logMessageId;
} | [
"public",
"String",
"getRejectionLogMessageId",
"(",
")",
"{",
"String",
"id",
"=",
"logMessageId",
";",
"if",
"(",
"id",
"==",
"null",
")",
"{",
"id",
"=",
"getRejectionLogMessage",
"(",
"Collections",
".",
"<",
"String",
",",
"ModelNode",
">",
"emptyMap",
... | Returns the log message id used by this checker. This is used to group it so that all attributes failing a type of rejction
end up in the same error message. This default implementation uses the formatted log message with an empty attribute map as the id.
@return the log message id | [
"Returns",
"the",
"log",
"message",
"id",
"used",
"by",
"this",
"checker",
".",
"This",
"is",
"used",
"to",
"group",
"it",
"so",
"that",
"all",
"attributes",
"failing",
"a",
"type",
"of",
"rejction",
"end",
"up",
"in",
"the",
"same",
"error",
"message",
... | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/transform/description/DefaultCheckersAndConverter.java#L94-L101 | train |
wildfly/wildfly-core | host-controller/src/main/java/org/jboss/as/host/controller/ServerInventoryService.java | ServerInventoryService.stop | @Override
public synchronized void stop(final StopContext context) {
final boolean shutdownServers = runningModeControl.getRestartMode() == RestartMode.SERVERS;
if (shutdownServers) {
Runnable task = new Runnable() {
@Override
public void run() {
try {
serverInventory.shutdown(true, -1, true); // TODO graceful shutdown
serverInventory = null;
// client.getValue().setServerInventory(null);
} finally {
serverCallback.getValue().setCallbackHandler(null);
context.complete();
}
}
};
try {
executorService.getValue().execute(task);
} catch (RejectedExecutionException e) {
task.run();
} finally {
context.asynchronous();
}
} else {
// We have to set the shutdown flag in any case
serverInventory.shutdown(false, -1, true);
serverInventory = null;
}
} | java | @Override
public synchronized void stop(final StopContext context) {
final boolean shutdownServers = runningModeControl.getRestartMode() == RestartMode.SERVERS;
if (shutdownServers) {
Runnable task = new Runnable() {
@Override
public void run() {
try {
serverInventory.shutdown(true, -1, true); // TODO graceful shutdown
serverInventory = null;
// client.getValue().setServerInventory(null);
} finally {
serverCallback.getValue().setCallbackHandler(null);
context.complete();
}
}
};
try {
executorService.getValue().execute(task);
} catch (RejectedExecutionException e) {
task.run();
} finally {
context.asynchronous();
}
} else {
// We have to set the shutdown flag in any case
serverInventory.shutdown(false, -1, true);
serverInventory = null;
}
} | [
"@",
"Override",
"public",
"synchronized",
"void",
"stop",
"(",
"final",
"StopContext",
"context",
")",
"{",
"final",
"boolean",
"shutdownServers",
"=",
"runningModeControl",
".",
"getRestartMode",
"(",
")",
"==",
"RestartMode",
".",
"SERVERS",
";",
"if",
"(",
... | Stops all servers.
{@inheritDoc} | [
"Stops",
"all",
"servers",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/host-controller/src/main/java/org/jboss/as/host/controller/ServerInventoryService.java#L134-L163 | train |
wildfly/wildfly-core | host-controller/src/main/java/org/jboss/as/host/controller/ignored/IgnoredDomainResourceRegistry.java | IgnoredDomainResourceRegistry.isResourceExcluded | public boolean isResourceExcluded(final PathAddress address) {
if (!localHostControllerInfo.isMasterDomainController() && address.size() > 0) {
IgnoredDomainResourceRoot root = this.rootResource;
PathElement firstElement = address.getElement(0);
IgnoreDomainResourceTypeResource typeResource = root == null ? null : root.getChildInternal(firstElement.getKey());
if (typeResource != null) {
if (typeResource.hasName(firstElement.getValue())) {
return true;
}
}
}
return false;
} | java | public boolean isResourceExcluded(final PathAddress address) {
if (!localHostControllerInfo.isMasterDomainController() && address.size() > 0) {
IgnoredDomainResourceRoot root = this.rootResource;
PathElement firstElement = address.getElement(0);
IgnoreDomainResourceTypeResource typeResource = root == null ? null : root.getChildInternal(firstElement.getKey());
if (typeResource != null) {
if (typeResource.hasName(firstElement.getValue())) {
return true;
}
}
}
return false;
} | [
"public",
"boolean",
"isResourceExcluded",
"(",
"final",
"PathAddress",
"address",
")",
"{",
"if",
"(",
"!",
"localHostControllerInfo",
".",
"isMasterDomainController",
"(",
")",
"&&",
"address",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"IgnoredDomainResourceR... | Returns whether this host should ignore operations from the master domain controller that target
the given address.
@param address the resource address. Cannot be {@code null}
@return {@code true} if the operation should be ignored; {@code false} otherwise | [
"Returns",
"whether",
"this",
"host",
"should",
"ignore",
"operations",
"from",
"the",
"master",
"domain",
"controller",
"that",
"target",
"the",
"given",
"address",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/host-controller/src/main/java/org/jboss/as/host/controller/ignored/IgnoredDomainResourceRegistry.java#L72-L84 | train |
wildfly/wildfly-core | host-controller/src/main/java/org/jboss/as/host/controller/mgmt/DomainHostExcludeRegistry.java | DomainHostExcludeRegistry.getVersionIgnoreData | VersionExcludeData getVersionIgnoreData(int major, int minor, int micro) {
VersionExcludeData result = registry.get(new VersionKey(major, minor, micro));
if (result == null) {
result = registry.get(new VersionKey(major, minor, null));
}
return result;
} | java | VersionExcludeData getVersionIgnoreData(int major, int minor, int micro) {
VersionExcludeData result = registry.get(new VersionKey(major, minor, micro));
if (result == null) {
result = registry.get(new VersionKey(major, minor, null));
}
return result;
} | [
"VersionExcludeData",
"getVersionIgnoreData",
"(",
"int",
"major",
",",
"int",
"minor",
",",
"int",
"micro",
")",
"{",
"VersionExcludeData",
"result",
"=",
"registry",
".",
"get",
"(",
"new",
"VersionKey",
"(",
"major",
",",
"minor",
",",
"micro",
")",
")",
... | Gets the host-ignore data for a slave host running the given version.
@param major the kernel management API major version
@param minor the kernel management API minor version
@param micro the kernel management API micro version
@return the host-ignore data, or {@code null} if there is no matching registration | [
"Gets",
"the",
"host",
"-",
"ignore",
"data",
"for",
"a",
"slave",
"host",
"running",
"the",
"given",
"version",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/host-controller/src/main/java/org/jboss/as/host/controller/mgmt/DomainHostExcludeRegistry.java#L144-L150 | train |
wildfly/wildfly-core | deployment-repository/src/main/java/org/jboss/as/repository/PathUtil.java | PathUtil.copyRecursively | public static void copyRecursively(final Path source, final Path target, boolean overwrite) throws IOException {
final CopyOption[] options;
if (overwrite) {
options = new CopyOption[]{StandardCopyOption.COPY_ATTRIBUTES, StandardCopyOption.REPLACE_EXISTING};
} else {
options = new CopyOption[]{StandardCopyOption.COPY_ATTRIBUTES};
}
Files.walkFileTree(source, new FileVisitor<Path>() {
@Override
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
Files.copy(dir, target.resolve(source.relativize(dir)), options);
return FileVisitResult.CONTINUE;
}
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
Files.copy(file, target.resolve(source.relativize(file)), options);
return FileVisitResult.CONTINUE;
}
@Override
public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException {
DeploymentRepositoryLogger.ROOT_LOGGER.cannotCopyFile(exc, file);
return FileVisitResult.CONTINUE;
}
@Override
public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
return FileVisitResult.CONTINUE;
}
});
} | java | public static void copyRecursively(final Path source, final Path target, boolean overwrite) throws IOException {
final CopyOption[] options;
if (overwrite) {
options = new CopyOption[]{StandardCopyOption.COPY_ATTRIBUTES, StandardCopyOption.REPLACE_EXISTING};
} else {
options = new CopyOption[]{StandardCopyOption.COPY_ATTRIBUTES};
}
Files.walkFileTree(source, new FileVisitor<Path>() {
@Override
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
Files.copy(dir, target.resolve(source.relativize(dir)), options);
return FileVisitResult.CONTINUE;
}
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
Files.copy(file, target.resolve(source.relativize(file)), options);
return FileVisitResult.CONTINUE;
}
@Override
public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException {
DeploymentRepositoryLogger.ROOT_LOGGER.cannotCopyFile(exc, file);
return FileVisitResult.CONTINUE;
}
@Override
public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
return FileVisitResult.CONTINUE;
}
});
} | [
"public",
"static",
"void",
"copyRecursively",
"(",
"final",
"Path",
"source",
",",
"final",
"Path",
"target",
",",
"boolean",
"overwrite",
")",
"throws",
"IOException",
"{",
"final",
"CopyOption",
"[",
"]",
"options",
";",
"if",
"(",
"overwrite",
")",
"{",
... | Copy a path recursively.
@param source a Path pointing to a file or a directory that must exist
@param target a Path pointing to a directory where the contents will be copied.
@param overwrite overwrite existing files - if set to false fails if the target file already exists.
@throws IOException | [
"Copy",
"a",
"path",
"recursively",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/deployment-repository/src/main/java/org/jboss/as/repository/PathUtil.java#L53-L84 | train |
wildfly/wildfly-core | deployment-repository/src/main/java/org/jboss/as/repository/PathUtil.java | PathUtil.deleteSilentlyRecursively | public static void deleteSilentlyRecursively(final Path path) {
if (path != null) {
try {
deleteRecursively(path);
} catch (IOException ioex) {
DeploymentRepositoryLogger.ROOT_LOGGER.cannotDeleteFile(ioex, path);
}
}
} | java | public static void deleteSilentlyRecursively(final Path path) {
if (path != null) {
try {
deleteRecursively(path);
} catch (IOException ioex) {
DeploymentRepositoryLogger.ROOT_LOGGER.cannotDeleteFile(ioex, path);
}
}
} | [
"public",
"static",
"void",
"deleteSilentlyRecursively",
"(",
"final",
"Path",
"path",
")",
"{",
"if",
"(",
"path",
"!=",
"null",
")",
"{",
"try",
"{",
"deleteRecursively",
"(",
"path",
")",
";",
"}",
"catch",
"(",
"IOException",
"ioex",
")",
"{",
"Deplo... | Delete a path recursively, not throwing Exception if it fails or if the path is null.
@param path a Path pointing to a file or a directory that may not exists anymore. | [
"Delete",
"a",
"path",
"recursively",
"not",
"throwing",
"Exception",
"if",
"it",
"fails",
"or",
"if",
"the",
"path",
"is",
"null",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/deployment-repository/src/main/java/org/jboss/as/repository/PathUtil.java#L90-L98 | train |
wildfly/wildfly-core | deployment-repository/src/main/java/org/jboss/as/repository/PathUtil.java | PathUtil.deleteRecursively | public static void deleteRecursively(final Path path) throws IOException {
DeploymentRepositoryLogger.ROOT_LOGGER.debugf("Deleting %s recursively", path);
if (Files.exists(path)) {
Files.walkFileTree(path, new FileVisitor<Path>() {
@Override
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
return FileVisitResult.CONTINUE;
}
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
Files.delete(file);
return FileVisitResult.CONTINUE;
}
@Override
public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException {
DeploymentRepositoryLogger.ROOT_LOGGER.cannotDeleteFile(exc, path);
throw exc;
}
@Override
public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
Files.delete(dir);
return FileVisitResult.CONTINUE;
}
});
}
} | java | public static void deleteRecursively(final Path path) throws IOException {
DeploymentRepositoryLogger.ROOT_LOGGER.debugf("Deleting %s recursively", path);
if (Files.exists(path)) {
Files.walkFileTree(path, new FileVisitor<Path>() {
@Override
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
return FileVisitResult.CONTINUE;
}
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
Files.delete(file);
return FileVisitResult.CONTINUE;
}
@Override
public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException {
DeploymentRepositoryLogger.ROOT_LOGGER.cannotDeleteFile(exc, path);
throw exc;
}
@Override
public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
Files.delete(dir);
return FileVisitResult.CONTINUE;
}
});
}
} | [
"public",
"static",
"void",
"deleteRecursively",
"(",
"final",
"Path",
"path",
")",
"throws",
"IOException",
"{",
"DeploymentRepositoryLogger",
".",
"ROOT_LOGGER",
".",
"debugf",
"(",
"\"Deleting %s recursively\"",
",",
"path",
")",
";",
"if",
"(",
"Files",
".",
... | Delete a path recursively.
@param path a Path pointing to a file or a directory that may not exists anymore.
@throws IOException | [
"Delete",
"a",
"path",
"recursively",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/deployment-repository/src/main/java/org/jboss/as/repository/PathUtil.java#L105-L133 | train |
wildfly/wildfly-core | deployment-repository/src/main/java/org/jboss/as/repository/PathUtil.java | PathUtil.resolveSecurely | public static final Path resolveSecurely(Path rootPath, String path) {
Path resolvedPath;
if(path == null || path.isEmpty()) {
resolvedPath = rootPath.normalize();
} else {
String relativePath = removeSuperflousSlashes(path);
resolvedPath = rootPath.resolve(relativePath).normalize();
}
if(!resolvedPath.startsWith(rootPath)) {
throw DeploymentRepositoryLogger.ROOT_LOGGER.forbiddenPath(path);
}
return resolvedPath;
} | java | public static final Path resolveSecurely(Path rootPath, String path) {
Path resolvedPath;
if(path == null || path.isEmpty()) {
resolvedPath = rootPath.normalize();
} else {
String relativePath = removeSuperflousSlashes(path);
resolvedPath = rootPath.resolve(relativePath).normalize();
}
if(!resolvedPath.startsWith(rootPath)) {
throw DeploymentRepositoryLogger.ROOT_LOGGER.forbiddenPath(path);
}
return resolvedPath;
} | [
"public",
"static",
"final",
"Path",
"resolveSecurely",
"(",
"Path",
"rootPath",
",",
"String",
"path",
")",
"{",
"Path",
"resolvedPath",
";",
"if",
"(",
"path",
"==",
"null",
"||",
"path",
".",
"isEmpty",
"(",
")",
")",
"{",
"resolvedPath",
"=",
"rootPa... | Resolve a path from the rootPath checking that it doesn't go out of the rootPath.
@param rootPath the starting point for resolution.
@param path the path we want to resolve.
@return the resolved path.
@throws IllegalArgumentException if the resolved path is out of the rootPath or if the resolution failed. | [
"Resolve",
"a",
"path",
"from",
"the",
"rootPath",
"checking",
"that",
"it",
"doesn",
"t",
"go",
"out",
"of",
"the",
"rootPath",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/deployment-repository/src/main/java/org/jboss/as/repository/PathUtil.java#L142-L154 | train |
wildfly/wildfly-core | deployment-repository/src/main/java/org/jboss/as/repository/PathUtil.java | PathUtil.listFiles | public static List<ContentRepositoryElement> listFiles(final Path rootPath, Path tempDir, final ContentFilter filter) throws IOException {
List<ContentRepositoryElement> result = new ArrayList<>();
if (Files.exists(rootPath)) {
if(isArchive(rootPath)) {
return listZipContent(rootPath, filter);
}
Files.walkFileTree(rootPath, new FileVisitor<Path>() {
@Override
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
return FileVisitResult.CONTINUE;
}
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
if (filter.acceptFile(rootPath, file)) {
result.add(ContentRepositoryElement.createFile(formatPath(rootPath.relativize(file)), Files.size(file)));
}
return FileVisitResult.CONTINUE;
}
@Override
public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException {
return FileVisitResult.CONTINUE;
}
@Override
public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
if (filter.acceptDirectory(rootPath, dir)) {
String directoryPath = formatDirectoryPath(rootPath.relativize(dir));
if(! "/".equals(directoryPath)) {
result.add(ContentRepositoryElement.createFolder(directoryPath));
}
}
return FileVisitResult.CONTINUE;
}
private String formatDirectoryPath(Path path) {
return formatPath(path) + '/';
}
private String formatPath(Path path) {
return path.toString().replace(File.separatorChar, '/');
}
});
} else {
Path file = getFile(rootPath);
if(isArchive(file)) {
Path relativePath = file.relativize(rootPath);
Path target = createTempDirectory(tempDir, "unarchive");
unzip(file, target);
return listFiles(target.resolve(relativePath), tempDir, filter);
} else {
throw new FileNotFoundException(rootPath.toString());
}
}
return result;
} | java | public static List<ContentRepositoryElement> listFiles(final Path rootPath, Path tempDir, final ContentFilter filter) throws IOException {
List<ContentRepositoryElement> result = new ArrayList<>();
if (Files.exists(rootPath)) {
if(isArchive(rootPath)) {
return listZipContent(rootPath, filter);
}
Files.walkFileTree(rootPath, new FileVisitor<Path>() {
@Override
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
return FileVisitResult.CONTINUE;
}
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
if (filter.acceptFile(rootPath, file)) {
result.add(ContentRepositoryElement.createFile(formatPath(rootPath.relativize(file)), Files.size(file)));
}
return FileVisitResult.CONTINUE;
}
@Override
public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException {
return FileVisitResult.CONTINUE;
}
@Override
public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
if (filter.acceptDirectory(rootPath, dir)) {
String directoryPath = formatDirectoryPath(rootPath.relativize(dir));
if(! "/".equals(directoryPath)) {
result.add(ContentRepositoryElement.createFolder(directoryPath));
}
}
return FileVisitResult.CONTINUE;
}
private String formatDirectoryPath(Path path) {
return formatPath(path) + '/';
}
private String formatPath(Path path) {
return path.toString().replace(File.separatorChar, '/');
}
});
} else {
Path file = getFile(rootPath);
if(isArchive(file)) {
Path relativePath = file.relativize(rootPath);
Path target = createTempDirectory(tempDir, "unarchive");
unzip(file, target);
return listFiles(target.resolve(relativePath), tempDir, filter);
} else {
throw new FileNotFoundException(rootPath.toString());
}
}
return result;
} | [
"public",
"static",
"List",
"<",
"ContentRepositoryElement",
">",
"listFiles",
"(",
"final",
"Path",
"rootPath",
",",
"Path",
"tempDir",
",",
"final",
"ContentFilter",
"filter",
")",
"throws",
"IOException",
"{",
"List",
"<",
"ContentRepositoryElement",
">",
"resu... | List files in a path according to the specified filter.
@param rootPath the path from which we are listing the files.
@param filter the filter to be applied.
@return the list of files / directory.
@throws IOException | [
"List",
"files",
"in",
"a",
"path",
"according",
"to",
"the",
"specified",
"filter",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/deployment-repository/src/main/java/org/jboss/as/repository/PathUtil.java#L204-L260 | train |
wildfly/wildfly-core | deployment-repository/src/main/java/org/jboss/as/repository/PathUtil.java | PathUtil.createTempDirectory | public static Path createTempDirectory(Path dir, String prefix) throws IOException {
try {
return Files.createTempDirectory(dir, prefix);
} catch (UnsupportedOperationException ex) {
}
return Files.createTempDirectory(dir, prefix);
} | java | public static Path createTempDirectory(Path dir, String prefix) throws IOException {
try {
return Files.createTempDirectory(dir, prefix);
} catch (UnsupportedOperationException ex) {
}
return Files.createTempDirectory(dir, prefix);
} | [
"public",
"static",
"Path",
"createTempDirectory",
"(",
"Path",
"dir",
",",
"String",
"prefix",
")",
"throws",
"IOException",
"{",
"try",
"{",
"return",
"Files",
".",
"createTempDirectory",
"(",
"dir",
",",
"prefix",
")",
";",
"}",
"catch",
"(",
"Unsupported... | Create a temporary directory with the same attributes as its parent directory.
@param dir
the path to directory in which to create the directory
@param prefix
the prefix string to be used in generating the directory's name;
may be {@code null}
@return the path to the newly created directory that did not exist before
this method was invoked
@throws IOException | [
"Create",
"a",
"temporary",
"directory",
"with",
"the",
"same",
"attributes",
"as",
"its",
"parent",
"directory",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/deployment-repository/src/main/java/org/jboss/as/repository/PathUtil.java#L297-L303 | train |
wildfly/wildfly-core | deployment-repository/src/main/java/org/jboss/as/repository/PathUtil.java | PathUtil.unzip | public static void unzip(Path zip, Path target) throws IOException {
try (final ZipFile zipFile = new ZipFile(zip.toFile())){
unzip(zipFile, target);
}
} | java | public static void unzip(Path zip, Path target) throws IOException {
try (final ZipFile zipFile = new ZipFile(zip.toFile())){
unzip(zipFile, target);
}
} | [
"public",
"static",
"void",
"unzip",
"(",
"Path",
"zip",
",",
"Path",
"target",
")",
"throws",
"IOException",
"{",
"try",
"(",
"final",
"ZipFile",
"zipFile",
"=",
"new",
"ZipFile",
"(",
"zip",
".",
"toFile",
"(",
")",
")",
")",
"{",
"unzip",
"(",
"zi... | Unzip a file to a target directory.
@param zip the path to the zip file.
@param target the path to the target directory into which the zip file will be unzipped.
@throws IOException | [
"Unzip",
"a",
"file",
"to",
"a",
"target",
"directory",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/deployment-repository/src/main/java/org/jboss/as/repository/PathUtil.java#L311-L315 | train |
wildfly/wildfly-core | controller/src/main/java/org/jboss/as/controller/services/path/RelativePathService.java | RelativePathService.addService | public static ServiceController<String> addService(final ServiceName name, final String path,
boolean possiblyAbsolute, final String relativeTo, final ServiceTarget serviceTarget) {
if (possiblyAbsolute && isAbsoluteUnixOrWindowsPath(path)) {
return AbsolutePathService.addService(name, path, serviceTarget);
}
RelativePathService service = new RelativePathService(path);
ServiceBuilder<String> builder = serviceTarget.addService(name, service)
.addDependency(pathNameOf(relativeTo), String.class, service.injectedPath);
ServiceController<String> svc = builder.install();
return svc;
} | java | public static ServiceController<String> addService(final ServiceName name, final String path,
boolean possiblyAbsolute, final String relativeTo, final ServiceTarget serviceTarget) {
if (possiblyAbsolute && isAbsoluteUnixOrWindowsPath(path)) {
return AbsolutePathService.addService(name, path, serviceTarget);
}
RelativePathService service = new RelativePathService(path);
ServiceBuilder<String> builder = serviceTarget.addService(name, service)
.addDependency(pathNameOf(relativeTo), String.class, service.injectedPath);
ServiceController<String> svc = builder.install();
return svc;
} | [
"public",
"static",
"ServiceController",
"<",
"String",
">",
"addService",
"(",
"final",
"ServiceName",
"name",
",",
"final",
"String",
"path",
",",
"boolean",
"possiblyAbsolute",
",",
"final",
"String",
"relativeTo",
",",
"final",
"ServiceTarget",
"serviceTarget",
... | Installs a path service.
@param name the name to use for the service
@param path the relative portion of the path
@param possiblyAbsolute {@code true} if {@code path} may be an {@link #isAbsoluteUnixOrWindowsPath(String) absolute path}
and should be {@link AbsolutePathService installed as such} if it is, with any
{@code relativeTo} parameter ignored
@param relativeTo the name of the path that {@code path} may be relative to
@param serviceTarget the {@link ServiceTarget} to use to install the service
@return the ServiceController for the path service | [
"Installs",
"a",
"path",
"service",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/services/path/RelativePathService.java#L72-L84 | train |
wildfly/wildfly-core | patching/src/main/java/org/jboss/as/patching/validation/PatchingGarbageLocator.java | PatchingGarbageLocator.getInactiveHistory | public List<File> getInactiveHistory() throws PatchingException {
if (validHistory == null) {
walk();
}
final File[] inactiveDirs = installedIdentity.getInstalledImage().getPatchesDir().listFiles(new FileFilter() {
@Override
public boolean accept(File pathname) {
return pathname.isDirectory() && !validHistory.contains(pathname.getName());
}
});
return inactiveDirs == null ? Collections.<File>emptyList() : Arrays.asList(inactiveDirs);
} | java | public List<File> getInactiveHistory() throws PatchingException {
if (validHistory == null) {
walk();
}
final File[] inactiveDirs = installedIdentity.getInstalledImage().getPatchesDir().listFiles(new FileFilter() {
@Override
public boolean accept(File pathname) {
return pathname.isDirectory() && !validHistory.contains(pathname.getName());
}
});
return inactiveDirs == null ? Collections.<File>emptyList() : Arrays.asList(inactiveDirs);
} | [
"public",
"List",
"<",
"File",
">",
"getInactiveHistory",
"(",
")",
"throws",
"PatchingException",
"{",
"if",
"(",
"validHistory",
"==",
"null",
")",
"{",
"walk",
"(",
")",
";",
"}",
"final",
"File",
"[",
"]",
"inactiveDirs",
"=",
"installedIdentity",
".",... | Get the inactive history directories.
@return the inactive history | [
"Get",
"the",
"inactive",
"history",
"directories",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/patching/src/main/java/org/jboss/as/patching/validation/PatchingGarbageLocator.java#L149-L160 | train |
wildfly/wildfly-core | patching/src/main/java/org/jboss/as/patching/validation/PatchingGarbageLocator.java | PatchingGarbageLocator.getInactiveOverlays | public List<File> getInactiveOverlays() throws PatchingException {
if (referencedOverlayDirectories == null) {
walk();
}
List<File> inactiveDirs = null;
for (Layer layer : installedIdentity.getLayers()) {
final File overlaysDir = new File(layer.getDirectoryStructure().getModuleRoot(), Constants.OVERLAYS);
final File[] inactiveLayerDirs = overlaysDir.listFiles(new FileFilter() {
@Override
public boolean accept(File pathname) {
return pathname.isDirectory() && !referencedOverlayDirectories.contains(pathname);
}
});
if (inactiveLayerDirs != null && inactiveLayerDirs.length > 0) {
if (inactiveDirs == null) {
inactiveDirs = new ArrayList<File>();
}
inactiveDirs.addAll(Arrays.asList(inactiveLayerDirs));
}
}
return inactiveDirs == null ? Collections.<File>emptyList() : inactiveDirs;
} | java | public List<File> getInactiveOverlays() throws PatchingException {
if (referencedOverlayDirectories == null) {
walk();
}
List<File> inactiveDirs = null;
for (Layer layer : installedIdentity.getLayers()) {
final File overlaysDir = new File(layer.getDirectoryStructure().getModuleRoot(), Constants.OVERLAYS);
final File[] inactiveLayerDirs = overlaysDir.listFiles(new FileFilter() {
@Override
public boolean accept(File pathname) {
return pathname.isDirectory() && !referencedOverlayDirectories.contains(pathname);
}
});
if (inactiveLayerDirs != null && inactiveLayerDirs.length > 0) {
if (inactiveDirs == null) {
inactiveDirs = new ArrayList<File>();
}
inactiveDirs.addAll(Arrays.asList(inactiveLayerDirs));
}
}
return inactiveDirs == null ? Collections.<File>emptyList() : inactiveDirs;
} | [
"public",
"List",
"<",
"File",
">",
"getInactiveOverlays",
"(",
")",
"throws",
"PatchingException",
"{",
"if",
"(",
"referencedOverlayDirectories",
"==",
"null",
")",
"{",
"walk",
"(",
")",
";",
"}",
"List",
"<",
"File",
">",
"inactiveDirs",
"=",
"null",
"... | Get the inactive overlay directories.
@return the inactive overlay directories | [
"Get",
"the",
"inactive",
"overlay",
"directories",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/patching/src/main/java/org/jboss/as/patching/validation/PatchingGarbageLocator.java#L167-L188 | train |
wildfly/wildfly-core | patching/src/main/java/org/jboss/as/patching/validation/PatchingGarbageLocator.java | PatchingGarbageLocator.deleteInactiveContent | public void deleteInactiveContent() throws PatchingException {
List<File> dirs = getInactiveHistory();
if (!dirs.isEmpty()) {
for (File dir : dirs) {
deleteDir(dir, ALL);
}
}
dirs = getInactiveOverlays();
if (!dirs.isEmpty()) {
for (File dir : dirs) {
deleteDir(dir, ALL);
}
}
} | java | public void deleteInactiveContent() throws PatchingException {
List<File> dirs = getInactiveHistory();
if (!dirs.isEmpty()) {
for (File dir : dirs) {
deleteDir(dir, ALL);
}
}
dirs = getInactiveOverlays();
if (!dirs.isEmpty()) {
for (File dir : dirs) {
deleteDir(dir, ALL);
}
}
} | [
"public",
"void",
"deleteInactiveContent",
"(",
")",
"throws",
"PatchingException",
"{",
"List",
"<",
"File",
">",
"dirs",
"=",
"getInactiveHistory",
"(",
")",
";",
"if",
"(",
"!",
"dirs",
".",
"isEmpty",
"(",
")",
")",
"{",
"for",
"(",
"File",
"dir",
... | Delete inactive contents. | [
"Delete",
"inactive",
"contents",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/patching/src/main/java/org/jboss/as/patching/validation/PatchingGarbageLocator.java#L193-L206 | train |
wildfly/wildfly-core | host-controller/src/main/java/org/jboss/as/host/controller/HostControllerBootstrap.java | HostControllerBootstrap.bootstrap | public void bootstrap() throws Exception {
final HostRunningModeControl runningModeControl = environment.getRunningModeControl();
final ControlledProcessState processState = new ControlledProcessState(true);
shutdownHook.setControlledProcessState(processState);
ServiceTarget target = serviceContainer.subTarget();
ControlledProcessStateService controlledProcessStateService = ControlledProcessStateService.addService(target, processState).getValue();
RunningStateJmx.registerMBean(controlledProcessStateService, null, runningModeControl, false);
final HostControllerService hcs = new HostControllerService(environment, runningModeControl, authCode, processState);
target.addService(HostControllerService.HC_SERVICE_NAME, hcs).install();
} | java | public void bootstrap() throws Exception {
final HostRunningModeControl runningModeControl = environment.getRunningModeControl();
final ControlledProcessState processState = new ControlledProcessState(true);
shutdownHook.setControlledProcessState(processState);
ServiceTarget target = serviceContainer.subTarget();
ControlledProcessStateService controlledProcessStateService = ControlledProcessStateService.addService(target, processState).getValue();
RunningStateJmx.registerMBean(controlledProcessStateService, null, runningModeControl, false);
final HostControllerService hcs = new HostControllerService(environment, runningModeControl, authCode, processState);
target.addService(HostControllerService.HC_SERVICE_NAME, hcs).install();
} | [
"public",
"void",
"bootstrap",
"(",
")",
"throws",
"Exception",
"{",
"final",
"HostRunningModeControl",
"runningModeControl",
"=",
"environment",
".",
"getRunningModeControl",
"(",
")",
";",
"final",
"ControlledProcessState",
"processState",
"=",
"new",
"ControlledProce... | Start the host controller services.
@throws Exception | [
"Start",
"the",
"host",
"controller",
"services",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/host-controller/src/main/java/org/jboss/as/host/controller/HostControllerBootstrap.java#L60-L69 | train |
wildfly/wildfly-core | controller/src/main/java/org/jboss/as/controller/PersistentResourceXMLDescription.java | PersistentResourceXMLDescription.persistDecorator | private void persistDecorator(XMLExtendedStreamWriter writer, ModelNode model) throws XMLStreamException {
if (shouldWriteDecoratorAndElements(model)) {
writer.writeStartElement(decoratorElement);
persistChildren(writer, model);
writer.writeEndElement();
}
} | java | private void persistDecorator(XMLExtendedStreamWriter writer, ModelNode model) throws XMLStreamException {
if (shouldWriteDecoratorAndElements(model)) {
writer.writeStartElement(decoratorElement);
persistChildren(writer, model);
writer.writeEndElement();
}
} | [
"private",
"void",
"persistDecorator",
"(",
"XMLExtendedStreamWriter",
"writer",
",",
"ModelNode",
"model",
")",
"throws",
"XMLStreamException",
"{",
"if",
"(",
"shouldWriteDecoratorAndElements",
"(",
"model",
")",
")",
"{",
"writer",
".",
"writeStartElement",
"(",
... | persist decorator and than continue to children without touching the model | [
"persist",
"decorator",
"and",
"than",
"continue",
"to",
"children",
"without",
"touching",
"the",
"model"
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/PersistentResourceXMLDescription.java#L366-L372 | train |
wildfly/wildfly-core | controller/src/main/java/org/jboss/as/controller/PersistentResourceXMLDescription.java | PersistentResourceXMLDescription.decorator | @Deprecated
public static PersistentResourceXMLBuilder decorator(final String elementName) {
return new PersistentResourceXMLBuilder(PathElement.pathElement(elementName), null).setDecoratorGroup(elementName);
} | java | @Deprecated
public static PersistentResourceXMLBuilder decorator(final String elementName) {
return new PersistentResourceXMLBuilder(PathElement.pathElement(elementName), null).setDecoratorGroup(elementName);
} | [
"@",
"Deprecated",
"public",
"static",
"PersistentResourceXMLBuilder",
"decorator",
"(",
"final",
"String",
"elementName",
")",
"{",
"return",
"new",
"PersistentResourceXMLBuilder",
"(",
"PathElement",
".",
"pathElement",
"(",
"elementName",
")",
",",
"null",
")",
"... | Creates builder for passed path element
@param elementName name of xml element that is used as decorator
@return PersistentResourceXMLBuilder
@deprecated decorator element support is currently considered as preview
@since 4.0 | [
"Creates",
"builder",
"for",
"passed",
"path",
"element"
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/PersistentResourceXMLDescription.java#L579-L582 | train |
wildfly/wildfly-core | controller/src/main/java/org/jboss/as/controller/transform/description/AttributeTransformationDescription.java | AttributeTransformationDescription.rejectAttributes | void rejectAttributes(RejectedAttributesLogContext rejectedAttributes, ModelNode attributeValue) {
for (RejectAttributeChecker checker : checks) {
rejectedAttributes.checkAttribute(checker, name, attributeValue);
}
} | java | void rejectAttributes(RejectedAttributesLogContext rejectedAttributes, ModelNode attributeValue) {
for (RejectAttributeChecker checker : checks) {
rejectedAttributes.checkAttribute(checker, name, attributeValue);
}
} | [
"void",
"rejectAttributes",
"(",
"RejectedAttributesLogContext",
"rejectedAttributes",
",",
"ModelNode",
"attributeValue",
")",
"{",
"for",
"(",
"RejectAttributeChecker",
"checker",
":",
"checks",
")",
"{",
"rejectedAttributes",
".",
"checkAttribute",
"(",
"checker",
",... | Checks attributes for rejection
@param rejectedAttributes gathers information about failed attributes
@param attributeValue the attribute value | [
"Checks",
"attributes",
"for",
"rejection"
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/transform/description/AttributeTransformationDescription.java#L90-L94 | train |
wildfly/wildfly-core | controller/src/main/java/org/jboss/as/controller/registry/ConcreteResourceRegistration.java | ConcreteResourceRegistration.getInheritableOperationEntryLocked | private OperationEntry getInheritableOperationEntryLocked(final String operationName) {
final OperationEntry entry = operations == null ? null : operations.get(operationName);
if (entry != null && entry.isInherited()) {
return entry;
}
return null;
} | java | private OperationEntry getInheritableOperationEntryLocked(final String operationName) {
final OperationEntry entry = operations == null ? null : operations.get(operationName);
if (entry != null && entry.isInherited()) {
return entry;
}
return null;
} | [
"private",
"OperationEntry",
"getInheritableOperationEntryLocked",
"(",
"final",
"String",
"operationName",
")",
"{",
"final",
"OperationEntry",
"entry",
"=",
"operations",
"==",
"null",
"?",
"null",
":",
"operations",
".",
"get",
"(",
"operationName",
")",
";",
"... | Only call with the read lock held | [
"Only",
"call",
"with",
"the",
"read",
"lock",
"held"
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/registry/ConcreteResourceRegistration.java#L345-L351 | train |
wildfly/wildfly-core | host-controller/src/main/java/org/jboss/as/host/controller/ignored/IgnoredDomainResourceRoot.java | IgnoredDomainResourceRoot.registerChildInternal | private void registerChildInternal(IgnoreDomainResourceTypeResource child) {
child.setParent(this);
children.put(child.getName(), child);
} | java | private void registerChildInternal(IgnoreDomainResourceTypeResource child) {
child.setParent(this);
children.put(child.getName(), child);
} | [
"private",
"void",
"registerChildInternal",
"(",
"IgnoreDomainResourceTypeResource",
"child",
")",
"{",
"child",
".",
"setParent",
"(",
"this",
")",
";",
"children",
".",
"put",
"(",
"child",
".",
"getName",
"(",
")",
",",
"child",
")",
";",
"}"
] | call with lock on 'children' held | [
"call",
"with",
"lock",
"on",
"children",
"held"
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/host-controller/src/main/java/org/jboss/as/host/controller/ignored/IgnoredDomainResourceRoot.java#L218-L221 | train |
wildfly/wildfly-core | protocol/src/main/java/org/jboss/as/protocol/mgmt/FutureManagementChannel.java | FutureManagementChannel.awaitChannel | protected Channel awaitChannel() throws IOException {
Channel channel = this.channel;
if(channel != null) {
return channel;
}
synchronized (lock) {
for(;;) {
if(state == State.CLOSED) {
throw ProtocolLogger.ROOT_LOGGER.channelClosed();
}
channel = this.channel;
if(channel != null) {
return channel;
}
if(state == State.CLOSING) {
throw ProtocolLogger.ROOT_LOGGER.channelClosed();
}
try {
lock.wait();
} catch (InterruptedException e) {
throw new IOException(e);
}
}
}
} | java | protected Channel awaitChannel() throws IOException {
Channel channel = this.channel;
if(channel != null) {
return channel;
}
synchronized (lock) {
for(;;) {
if(state == State.CLOSED) {
throw ProtocolLogger.ROOT_LOGGER.channelClosed();
}
channel = this.channel;
if(channel != null) {
return channel;
}
if(state == State.CLOSING) {
throw ProtocolLogger.ROOT_LOGGER.channelClosed();
}
try {
lock.wait();
} catch (InterruptedException e) {
throw new IOException(e);
}
}
}
} | [
"protected",
"Channel",
"awaitChannel",
"(",
")",
"throws",
"IOException",
"{",
"Channel",
"channel",
"=",
"this",
".",
"channel",
";",
"if",
"(",
"channel",
"!=",
"null",
")",
"{",
"return",
"channel",
";",
"}",
"synchronized",
"(",
"lock",
")",
"{",
"f... | Get the underlying channel. This may block until the channel is set.
@return the channel
@throws IOException for any error | [
"Get",
"the",
"underlying",
"channel",
".",
"This",
"may",
"block",
"until",
"the",
"channel",
"is",
"set",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/protocol/src/main/java/org/jboss/as/protocol/mgmt/FutureManagementChannel.java#L99-L123 | train |
wildfly/wildfly-core | protocol/src/main/java/org/jboss/as/protocol/mgmt/FutureManagementChannel.java | FutureManagementChannel.prepareClose | protected boolean prepareClose() {
synchronized (lock) {
final State state = this.state;
if (state == State.OPEN) {
this.state = State.CLOSING;
lock.notifyAll();
return true;
}
}
return false;
} | java | protected boolean prepareClose() {
synchronized (lock) {
final State state = this.state;
if (state == State.OPEN) {
this.state = State.CLOSING;
lock.notifyAll();
return true;
}
}
return false;
} | [
"protected",
"boolean",
"prepareClose",
"(",
")",
"{",
"synchronized",
"(",
"lock",
")",
"{",
"final",
"State",
"state",
"=",
"this",
".",
"state",
";",
"if",
"(",
"state",
"==",
"State",
".",
"OPEN",
")",
"{",
"this",
".",
"state",
"=",
"State",
"."... | Signal that we are about to close the channel. This will not have any affect on the underlying channel, however
prevent setting a new channel.
@return whether the closing state was set successfully | [
"Signal",
"that",
"we",
"are",
"about",
"to",
"close",
"the",
"channel",
".",
"This",
"will",
"not",
"have",
"any",
"affect",
"on",
"the",
"underlying",
"channel",
"however",
"prevent",
"setting",
"a",
"new",
"channel",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/protocol/src/main/java/org/jboss/as/protocol/mgmt/FutureManagementChannel.java#L131-L141 | train |
wildfly/wildfly-core | protocol/src/main/java/org/jboss/as/protocol/mgmt/FutureManagementChannel.java | FutureManagementChannel.setChannel | protected boolean setChannel(final Channel newChannel) {
if(newChannel == null) {
return false;
}
synchronized (lock) {
if(state != State.OPEN || channel != null) {
return false;
}
this.channel = newChannel;
this.channel.addCloseHandler(new CloseHandler<Channel>() {
@Override
public void handleClose(final Channel closed, final IOException exception) {
synchronized (lock) {
if(FutureManagementChannel.this.channel == closed) {
FutureManagementChannel.this.channel = null;
}
lock.notifyAll();
}
}
});
lock.notifyAll();
return true;
}
} | java | protected boolean setChannel(final Channel newChannel) {
if(newChannel == null) {
return false;
}
synchronized (lock) {
if(state != State.OPEN || channel != null) {
return false;
}
this.channel = newChannel;
this.channel.addCloseHandler(new CloseHandler<Channel>() {
@Override
public void handleClose(final Channel closed, final IOException exception) {
synchronized (lock) {
if(FutureManagementChannel.this.channel == closed) {
FutureManagementChannel.this.channel = null;
}
lock.notifyAll();
}
}
});
lock.notifyAll();
return true;
}
} | [
"protected",
"boolean",
"setChannel",
"(",
"final",
"Channel",
"newChannel",
")",
"{",
"if",
"(",
"newChannel",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"synchronized",
"(",
"lock",
")",
"{",
"if",
"(",
"state",
"!=",
"State",
".",
"OPEN",
... | Set the channel. This will return whether the channel could be set successfully or not.
@param newChannel the channel
@return whether the operation succeeded or not | [
"Set",
"the",
"channel",
".",
"This",
"will",
"return",
"whether",
"the",
"channel",
"could",
"be",
"set",
"successfully",
"or",
"not",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/protocol/src/main/java/org/jboss/as/protocol/mgmt/FutureManagementChannel.java#L186-L209 | train |
wildfly/wildfly-core | host-controller/src/main/java/org/jboss/as/domain/controller/operations/DomainDeploymentOverlayRedeployLinksHandler.java | DomainDeploymentOverlayRedeployLinksHandler.isRedeployAfterRemoval | private boolean isRedeployAfterRemoval(ModelNode operation) {
return operation.hasDefined(DEPLOYMENT_OVERLAY_LINK_REMOVAL) &&
operation.get(DEPLOYMENT_OVERLAY_LINK_REMOVAL).asBoolean();
} | java | private boolean isRedeployAfterRemoval(ModelNode operation) {
return operation.hasDefined(DEPLOYMENT_OVERLAY_LINK_REMOVAL) &&
operation.get(DEPLOYMENT_OVERLAY_LINK_REMOVAL).asBoolean();
} | [
"private",
"boolean",
"isRedeployAfterRemoval",
"(",
"ModelNode",
"operation",
")",
"{",
"return",
"operation",
".",
"hasDefined",
"(",
"DEPLOYMENT_OVERLAY_LINK_REMOVAL",
")",
"&&",
"operation",
".",
"get",
"(",
"DEPLOYMENT_OVERLAY_LINK_REMOVAL",
")",
".",
"asBoolean",
... | Check if this is a redeployment triggered after the removal of a link.
@param operation the current operation.
@return true if this is a redeploy after the removal of a link.
@see org.jboss.as.server.deploymentoverlay.DeploymentOverlayDeploymentRemoveHandler | [
"Check",
"if",
"this",
"is",
"a",
"redeployment",
"triggered",
"after",
"the",
"removal",
"of",
"a",
"link",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/host-controller/src/main/java/org/jboss/as/domain/controller/operations/DomainDeploymentOverlayRedeployLinksHandler.java#L95-L98 | train |
wildfly/wildfly-core | controller/src/main/java/org/jboss/as/controller/audit/AbstractFileAuditLogHandler.java | AbstractFileAuditLogHandler.createNewFile | protected void createNewFile(final File file) {
try {
file.createNewFile();
setFileNotWorldReadablePermissions(file);
} catch (IOException e){
throw new RuntimeException(e);
}
} | java | protected void createNewFile(final File file) {
try {
file.createNewFile();
setFileNotWorldReadablePermissions(file);
} catch (IOException e){
throw new RuntimeException(e);
}
} | [
"protected",
"void",
"createNewFile",
"(",
"final",
"File",
"file",
")",
"{",
"try",
"{",
"file",
".",
"createNewFile",
"(",
")",
";",
"setFileNotWorldReadablePermissions",
"(",
"file",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"n... | This creates a new audit log file with default permissions.
@param file File to create | [
"This",
"creates",
"a",
"new",
"audit",
"log",
"file",
"with",
"default",
"permissions",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/audit/AbstractFileAuditLogHandler.java#L174-L181 | train |
wildfly/wildfly-core | controller/src/main/java/org/jboss/as/controller/audit/AbstractFileAuditLogHandler.java | AbstractFileAuditLogHandler.setFileNotWorldReadablePermissions | private void setFileNotWorldReadablePermissions(File file) {
file.setReadable(false, false);
file.setWritable(false, false);
file.setExecutable(false, false);
file.setReadable(true, true);
file.setWritable(true, true);
} | java | private void setFileNotWorldReadablePermissions(File file) {
file.setReadable(false, false);
file.setWritable(false, false);
file.setExecutable(false, false);
file.setReadable(true, true);
file.setWritable(true, true);
} | [
"private",
"void",
"setFileNotWorldReadablePermissions",
"(",
"File",
"file",
")",
"{",
"file",
".",
"setReadable",
"(",
"false",
",",
"false",
")",
";",
"file",
".",
"setWritable",
"(",
"false",
",",
"false",
")",
";",
"file",
".",
"setExecutable",
"(",
"... | This procedure sets permissions to the given file to not allow everybody to read it.
Only when underlying OS allows the change.
@param file File to set permissions | [
"This",
"procedure",
"sets",
"permissions",
"to",
"the",
"given",
"file",
"to",
"not",
"allow",
"everybody",
"to",
"read",
"it",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/audit/AbstractFileAuditLogHandler.java#L190-L196 | train |
wildfly/wildfly-core | server/src/main/java/org/jboss/as/server/deployment/integration/Seam2Processor.java | Seam2Processor.getSeamIntResourceRoot | protected synchronized ResourceRoot getSeamIntResourceRoot() throws DeploymentUnitProcessingException {
try {
if (seamIntResourceRoot == null) {
final ModuleLoader moduleLoader = Module.getBootModuleLoader();
Module extModule = moduleLoader.loadModule(EXT_CONTENT_MODULE);
URL url = extModule.getExportedResource(SEAM_INT_JAR);
if (url == null)
throw ServerLogger.ROOT_LOGGER.noSeamIntegrationJarPresent(extModule);
File file = new File(url.toURI());
VirtualFile vf = VFS.getChild(file.toURI());
final Closeable mountHandle = VFS.mountZip(file, vf, TempFileProviderService.provider());
Service<Closeable> mountHandleService = new Service<Closeable>() {
public void start(StartContext startContext) throws StartException {
}
public void stop(StopContext stopContext) {
VFSUtils.safeClose(mountHandle);
}
public Closeable getValue() throws IllegalStateException, IllegalArgumentException {
return mountHandle;
}
};
ServiceBuilder<Closeable> builder = serviceTarget.addService(ServiceName.JBOSS.append(SEAM_INT_JAR),
mountHandleService);
builder.setInitialMode(ServiceController.Mode.ACTIVE).install();
serviceTarget = null; // our cleanup service install work is done
MountHandle dummy = MountHandle.create(null); // actual close is done by the MSC service above
seamIntResourceRoot = new ResourceRoot(vf, dummy);
}
return seamIntResourceRoot;
} catch (Exception e) {
throw new DeploymentUnitProcessingException(e);
}
} | java | protected synchronized ResourceRoot getSeamIntResourceRoot() throws DeploymentUnitProcessingException {
try {
if (seamIntResourceRoot == null) {
final ModuleLoader moduleLoader = Module.getBootModuleLoader();
Module extModule = moduleLoader.loadModule(EXT_CONTENT_MODULE);
URL url = extModule.getExportedResource(SEAM_INT_JAR);
if (url == null)
throw ServerLogger.ROOT_LOGGER.noSeamIntegrationJarPresent(extModule);
File file = new File(url.toURI());
VirtualFile vf = VFS.getChild(file.toURI());
final Closeable mountHandle = VFS.mountZip(file, vf, TempFileProviderService.provider());
Service<Closeable> mountHandleService = new Service<Closeable>() {
public void start(StartContext startContext) throws StartException {
}
public void stop(StopContext stopContext) {
VFSUtils.safeClose(mountHandle);
}
public Closeable getValue() throws IllegalStateException, IllegalArgumentException {
return mountHandle;
}
};
ServiceBuilder<Closeable> builder = serviceTarget.addService(ServiceName.JBOSS.append(SEAM_INT_JAR),
mountHandleService);
builder.setInitialMode(ServiceController.Mode.ACTIVE).install();
serviceTarget = null; // our cleanup service install work is done
MountHandle dummy = MountHandle.create(null); // actual close is done by the MSC service above
seamIntResourceRoot = new ResourceRoot(vf, dummy);
}
return seamIntResourceRoot;
} catch (Exception e) {
throw new DeploymentUnitProcessingException(e);
}
} | [
"protected",
"synchronized",
"ResourceRoot",
"getSeamIntResourceRoot",
"(",
")",
"throws",
"DeploymentUnitProcessingException",
"{",
"try",
"{",
"if",
"(",
"seamIntResourceRoot",
"==",
"null",
")",
"{",
"final",
"ModuleLoader",
"moduleLoader",
"=",
"Module",
".",
"get... | Lookup Seam integration resource loader.
@return the Seam integration resource loader
@throws DeploymentUnitProcessingException for any error | [
"Lookup",
"Seam",
"integration",
"resource",
"loader",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/server/src/main/java/org/jboss/as/server/deployment/integration/Seam2Processor.java#L93-L129 | train |
wildfly/wildfly-core | controller/src/main/java/org/jboss/as/controller/PathAddress.java | PathAddress.pathAddress | public static PathAddress pathAddress(final ModelNode node) {
if (node.isDefined()) {
// final List<Property> props = node.asPropertyList();
// Following bit is crap TODO; uncomment above and delete below
// when bug is fixed
final List<Property> props = new ArrayList<Property>();
String key = null;
for (ModelNode element : node.asList()) {
Property prop = null;
if (element.getType() == ModelType.PROPERTY || element.getType() == ModelType.OBJECT) {
prop = element.asProperty();
} else if (key == null) {
key = element.asString();
} else {
prop = new Property(key, element);
}
if (prop != null) {
props.add(prop);
key = null;
}
}
if (props.size() == 0) {
return EMPTY_ADDRESS;
} else {
final Set<String> seen = new HashSet<String>();
final List<PathElement> values = new ArrayList<PathElement>();
int index = 0;
for (final Property prop : props) {
final String name = prop.getName();
if (seen.add(name)) {
values.add(new PathElement(name, prop.getValue().asString()));
} else {
throw duplicateElement(name);
}
if (index == 1 && name.equals(SERVER) && seen.contains(HOST)) {
seen.clear();
}
index++;
}
return new PathAddress(Collections.unmodifiableList(values));
}
} else {
return EMPTY_ADDRESS;
}
} | java | public static PathAddress pathAddress(final ModelNode node) {
if (node.isDefined()) {
// final List<Property> props = node.asPropertyList();
// Following bit is crap TODO; uncomment above and delete below
// when bug is fixed
final List<Property> props = new ArrayList<Property>();
String key = null;
for (ModelNode element : node.asList()) {
Property prop = null;
if (element.getType() == ModelType.PROPERTY || element.getType() == ModelType.OBJECT) {
prop = element.asProperty();
} else if (key == null) {
key = element.asString();
} else {
prop = new Property(key, element);
}
if (prop != null) {
props.add(prop);
key = null;
}
}
if (props.size() == 0) {
return EMPTY_ADDRESS;
} else {
final Set<String> seen = new HashSet<String>();
final List<PathElement> values = new ArrayList<PathElement>();
int index = 0;
for (final Property prop : props) {
final String name = prop.getName();
if (seen.add(name)) {
values.add(new PathElement(name, prop.getValue().asString()));
} else {
throw duplicateElement(name);
}
if (index == 1 && name.equals(SERVER) && seen.contains(HOST)) {
seen.clear();
}
index++;
}
return new PathAddress(Collections.unmodifiableList(values));
}
} else {
return EMPTY_ADDRESS;
}
} | [
"public",
"static",
"PathAddress",
"pathAddress",
"(",
"final",
"ModelNode",
"node",
")",
"{",
"if",
"(",
"node",
".",
"isDefined",
"(",
")",
")",
"{",
"// final List<Property> props = node.asPropertyList();",
"// Following bit is crap TODO; uncomment above and del... | Creates a PathAddress from the given ModelNode address. The given node is expected to be an address node.
@param node the node (cannot be {@code null})
@return the update identifier | [
"Creates",
"a",
"PathAddress",
"from",
"the",
"given",
"ModelNode",
"address",
".",
"The",
"given",
"node",
"is",
"expected",
"to",
"be",
"an",
"address",
"node",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/PathAddress.java#L64-L110 | train |
wildfly/wildfly-core | controller/src/main/java/org/jboss/as/controller/PathAddress.java | PathAddress.getElement | public PathElement getElement(int index) {
final List<PathElement> list = pathAddressList;
return list.get(index);
} | java | public PathElement getElement(int index) {
final List<PathElement> list = pathAddressList;
return list.get(index);
} | [
"public",
"PathElement",
"getElement",
"(",
"int",
"index",
")",
"{",
"final",
"List",
"<",
"PathElement",
">",
"list",
"=",
"pathAddressList",
";",
"return",
"list",
".",
"get",
"(",
"index",
")",
";",
"}"
] | Gets the element at the given index.
@param index the index
@return the element
@throws IndexOutOfBoundsException if the index is out of range (<tt>index < 0 || index >= size()</tt>) | [
"Gets",
"the",
"element",
"at",
"the",
"given",
"index",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/PathAddress.java#L232-L235 | train |
wildfly/wildfly-core | controller/src/main/java/org/jboss/as/controller/PathAddress.java | PathAddress.getLastElement | public PathElement getLastElement() {
final List<PathElement> list = pathAddressList;
return list.size() == 0 ? null : list.get(list.size() - 1);
} | java | public PathElement getLastElement() {
final List<PathElement> list = pathAddressList;
return list.size() == 0 ? null : list.get(list.size() - 1);
} | [
"public",
"PathElement",
"getLastElement",
"(",
")",
"{",
"final",
"List",
"<",
"PathElement",
">",
"list",
"=",
"pathAddressList",
";",
"return",
"list",
".",
"size",
"(",
")",
"==",
"0",
"?",
"null",
":",
"list",
".",
"get",
"(",
"list",
".",
"size",... | Gets the last element in the address.
@return the element, or {@code null} if {@link #size()} is zero. | [
"Gets",
"the",
"last",
"element",
"in",
"the",
"address",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/PathAddress.java#L242-L245 | train |
wildfly/wildfly-core | controller/src/main/java/org/jboss/as/controller/PathAddress.java | PathAddress.append | public PathAddress append(List<PathElement> additionalElements) {
final ArrayList<PathElement> newList = new ArrayList<PathElement>(pathAddressList.size() + additionalElements.size());
newList.addAll(pathAddressList);
newList.addAll(additionalElements);
return pathAddress(newList);
} | java | public PathAddress append(List<PathElement> additionalElements) {
final ArrayList<PathElement> newList = new ArrayList<PathElement>(pathAddressList.size() + additionalElements.size());
newList.addAll(pathAddressList);
newList.addAll(additionalElements);
return pathAddress(newList);
} | [
"public",
"PathAddress",
"append",
"(",
"List",
"<",
"PathElement",
">",
"additionalElements",
")",
"{",
"final",
"ArrayList",
"<",
"PathElement",
">",
"newList",
"=",
"new",
"ArrayList",
"<",
"PathElement",
">",
"(",
"pathAddressList",
".",
"size",
"(",
")",
... | Create a new path address by appending more elements to the end of this address.
@param additionalElements the elements to append
@return the new path address | [
"Create",
"a",
"new",
"path",
"address",
"by",
"appending",
"more",
"elements",
"to",
"the",
"end",
"of",
"this",
"address",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/PathAddress.java#L275-L280 | train |
wildfly/wildfly-core | controller/src/main/java/org/jboss/as/controller/PathAddress.java | PathAddress.navigate | @Deprecated
public ModelNode navigate(ModelNode model, boolean create) throws NoSuchElementException {
final Iterator<PathElement> i = pathAddressList.iterator();
while (i.hasNext()) {
final PathElement element = i.next();
if (create && !i.hasNext()) {
if (element.isMultiTarget()) {
throw new IllegalStateException();
}
model = model.require(element.getKey()).get(element.getValue());
} else {
model = model.require(element.getKey()).require(element.getValue());
}
}
return model;
} | java | @Deprecated
public ModelNode navigate(ModelNode model, boolean create) throws NoSuchElementException {
final Iterator<PathElement> i = pathAddressList.iterator();
while (i.hasNext()) {
final PathElement element = i.next();
if (create && !i.hasNext()) {
if (element.isMultiTarget()) {
throw new IllegalStateException();
}
model = model.require(element.getKey()).get(element.getValue());
} else {
model = model.require(element.getKey()).require(element.getValue());
}
}
return model;
} | [
"@",
"Deprecated",
"public",
"ModelNode",
"navigate",
"(",
"ModelNode",
"model",
",",
"boolean",
"create",
")",
"throws",
"NoSuchElementException",
"{",
"final",
"Iterator",
"<",
"PathElement",
">",
"i",
"=",
"pathAddressList",
".",
"iterator",
"(",
")",
";",
... | Navigate to this address in the given model node.
@param model the model node
@param create {@code true} to create the last part of the node if it does not exist
@return the submodel
@throws NoSuchElementException if the model contains no such element
@deprecated manipulating a deep DMR node tree via PathAddress is no longer how the management layer works
internally, so this method has become legacy cruft. Management operation handlers
should obtain a {@link org.jboss.as.controller.registry.Resource Resource} from the
{@link org.jboss.as.controller.OperationContext#readResource(PathAddress) OperationContext}
and use the {@code Resource} API to access child resources | [
"Navigate",
"to",
"this",
"address",
"in",
"the",
"given",
"model",
"node",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/PathAddress.java#L324-L339 | train |
wildfly/wildfly-core | controller/src/main/java/org/jboss/as/controller/PathAddress.java | PathAddress.remove | @Deprecated
public ModelNode remove(ModelNode model) throws NoSuchElementException {
final Iterator<PathElement> i = pathAddressList.iterator();
while (i.hasNext()) {
final PathElement element = i.next();
if (i.hasNext()) {
model = model.require(element.getKey()).require(element.getValue());
} else {
final ModelNode parent = model.require(element.getKey());
model = parent.remove(element.getValue()).clone();
}
}
return model;
} | java | @Deprecated
public ModelNode remove(ModelNode model) throws NoSuchElementException {
final Iterator<PathElement> i = pathAddressList.iterator();
while (i.hasNext()) {
final PathElement element = i.next();
if (i.hasNext()) {
model = model.require(element.getKey()).require(element.getValue());
} else {
final ModelNode parent = model.require(element.getKey());
model = parent.remove(element.getValue()).clone();
}
}
return model;
} | [
"@",
"Deprecated",
"public",
"ModelNode",
"remove",
"(",
"ModelNode",
"model",
")",
"throws",
"NoSuchElementException",
"{",
"final",
"Iterator",
"<",
"PathElement",
">",
"i",
"=",
"pathAddressList",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"i",
".",
"h... | Navigate to, and remove, this address in the given model node.
@param model the model node
@return the submodel
@throws NoSuchElementException if the model contains no such element
@deprecated manipulating a deep DMR node tree via PathAddress is no longer how the management layer works
internally, so this method has become legacy cruft. Management operation handlers would
use {@link org.jboss.as.controller.OperationContext#removeResource(PathAddress)} to
remove resources. | [
"Navigate",
"to",
"and",
"remove",
"this",
"address",
"in",
"the",
"given",
"model",
"node",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/PathAddress.java#L353-L366 | train |
wildfly/wildfly-core | controller/src/main/java/org/jboss/as/controller/PathAddress.java | PathAddress.toModelNode | public ModelNode toModelNode() {
final ModelNode node = new ModelNode().setEmptyList();
for (PathElement element : pathAddressList) {
final String value;
if (element.isMultiTarget() && !element.isWildcard()) {
value = '[' + element.getValue() + ']';
} else {
value = element.getValue();
}
node.add(element.getKey(), value);
}
return node;
} | java | public ModelNode toModelNode() {
final ModelNode node = new ModelNode().setEmptyList();
for (PathElement element : pathAddressList) {
final String value;
if (element.isMultiTarget() && !element.isWildcard()) {
value = '[' + element.getValue() + ']';
} else {
value = element.getValue();
}
node.add(element.getKey(), value);
}
return node;
} | [
"public",
"ModelNode",
"toModelNode",
"(",
")",
"{",
"final",
"ModelNode",
"node",
"=",
"new",
"ModelNode",
"(",
")",
".",
"setEmptyList",
"(",
")",
";",
"for",
"(",
"PathElement",
"element",
":",
"pathAddressList",
")",
"{",
"final",
"String",
"value",
";... | Convert this path address to its model node representation.
@return the model node list of properties | [
"Convert",
"this",
"path",
"address",
"to",
"its",
"model",
"node",
"representation",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/PathAddress.java#L373-L385 | train |
wildfly/wildfly-core | controller/src/main/java/org/jboss/as/controller/PathAddress.java | PathAddress.matches | public boolean matches(PathAddress address) {
if (address == null) {
return false;
}
if (equals(address)) {
return true;
}
if (size() != address.size()) {
return false;
}
for (int i = 0; i < size(); i++) {
PathElement pe = getElement(i);
PathElement other = address.getElement(i);
if (!pe.matches(other)) {
// Could be a multiTarget with segments
if (pe.isMultiTarget() && !pe.isWildcard()) {
boolean matched = false;
for (String segment : pe.getSegments()) {
if (segment.equals(other.getValue())) {
matched = true;
break;
}
}
if (!matched) {
return false;
}
} else {
return false;
}
}
}
return true;
} | java | public boolean matches(PathAddress address) {
if (address == null) {
return false;
}
if (equals(address)) {
return true;
}
if (size() != address.size()) {
return false;
}
for (int i = 0; i < size(); i++) {
PathElement pe = getElement(i);
PathElement other = address.getElement(i);
if (!pe.matches(other)) {
// Could be a multiTarget with segments
if (pe.isMultiTarget() && !pe.isWildcard()) {
boolean matched = false;
for (String segment : pe.getSegments()) {
if (segment.equals(other.getValue())) {
matched = true;
break;
}
}
if (!matched) {
return false;
}
} else {
return false;
}
}
}
return true;
} | [
"public",
"boolean",
"matches",
"(",
"PathAddress",
"address",
")",
"{",
"if",
"(",
"address",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"equals",
"(",
"address",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"size",
"... | Check if this path matches the address path.
An address matches this address if its path elements match or are valid
multi targets for this path elements. Addresses that are equal are matching.
@param address The path to check against this path. If null, this method
returns false.
@return true if the provided path matches, false otherwise. | [
"Check",
"if",
"this",
"path",
"matches",
"the",
"address",
"path",
".",
"An",
"address",
"matches",
"this",
"address",
"if",
"its",
"path",
"elements",
"match",
"or",
"are",
"valid",
"multi",
"targets",
"for",
"this",
"path",
"elements",
".",
"Addresses",
... | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/controller/src/main/java/org/jboss/as/controller/PathAddress.java#L476-L508 | train |
wildfly/wildfly-core | server/src/main/java/org/jboss/as/server/deployment/annotation/ResourceRootIndexer.java | ResourceRootIndexer.indexResourceRoot | public static void indexResourceRoot(final ResourceRoot resourceRoot) throws DeploymentUnitProcessingException {
if (resourceRoot.getAttachment(Attachments.ANNOTATION_INDEX) != null) {
return;
}
VirtualFile indexFile = resourceRoot.getRoot().getChild(ModuleIndexBuilder.INDEX_LOCATION);
if (indexFile.exists()) {
try {
IndexReader reader = new IndexReader(indexFile.openStream());
resourceRoot.putAttachment(Attachments.ANNOTATION_INDEX, reader.read());
ServerLogger.DEPLOYMENT_LOGGER.tracef("Found and read index at: %s", indexFile);
return;
} catch (Exception e) {
ServerLogger.DEPLOYMENT_LOGGER.cannotLoadAnnotationIndex(indexFile.getPathName());
}
}
// if this flag is present and set to false then do not index the resource
Boolean shouldIndexResource = resourceRoot.getAttachment(Attachments.INDEX_RESOURCE_ROOT);
if (shouldIndexResource != null && !shouldIndexResource) {
return;
}
final List<String> indexIgnorePathList = resourceRoot.getAttachment(Attachments.INDEX_IGNORE_PATHS);
final Set<String> indexIgnorePaths;
if (indexIgnorePathList != null && !indexIgnorePathList.isEmpty()) {
indexIgnorePaths = new HashSet<String>(indexIgnorePathList);
} else {
indexIgnorePaths = null;
}
final VirtualFile virtualFile = resourceRoot.getRoot();
final Indexer indexer = new Indexer();
try {
final VisitorAttributes visitorAttributes = new VisitorAttributes();
visitorAttributes.setLeavesOnly(true);
visitorAttributes.setRecurseFilter(new VirtualFileFilter() {
public boolean accepts(VirtualFile file) {
return indexIgnorePaths == null || !indexIgnorePaths.contains(file.getPathNameRelativeTo(virtualFile));
}
});
final List<VirtualFile> classChildren = virtualFile.getChildren(new SuffixMatchFilter(".class", visitorAttributes));
for (VirtualFile classFile : classChildren) {
InputStream inputStream = null;
try {
inputStream = classFile.openStream();
indexer.index(inputStream);
} catch (Exception e) {
ServerLogger.DEPLOYMENT_LOGGER.cannotIndexClass(classFile.getPathNameRelativeTo(virtualFile), virtualFile.getPathName(), e);
} finally {
VFSUtils.safeClose(inputStream);
}
}
final Index index = indexer.complete();
resourceRoot.putAttachment(Attachments.ANNOTATION_INDEX, index);
ServerLogger.DEPLOYMENT_LOGGER.tracef("Generated index for archive %s", virtualFile);
} catch (Throwable t) {
throw ServerLogger.ROOT_LOGGER.deploymentIndexingFailed(t);
}
} | java | public static void indexResourceRoot(final ResourceRoot resourceRoot) throws DeploymentUnitProcessingException {
if (resourceRoot.getAttachment(Attachments.ANNOTATION_INDEX) != null) {
return;
}
VirtualFile indexFile = resourceRoot.getRoot().getChild(ModuleIndexBuilder.INDEX_LOCATION);
if (indexFile.exists()) {
try {
IndexReader reader = new IndexReader(indexFile.openStream());
resourceRoot.putAttachment(Attachments.ANNOTATION_INDEX, reader.read());
ServerLogger.DEPLOYMENT_LOGGER.tracef("Found and read index at: %s", indexFile);
return;
} catch (Exception e) {
ServerLogger.DEPLOYMENT_LOGGER.cannotLoadAnnotationIndex(indexFile.getPathName());
}
}
// if this flag is present and set to false then do not index the resource
Boolean shouldIndexResource = resourceRoot.getAttachment(Attachments.INDEX_RESOURCE_ROOT);
if (shouldIndexResource != null && !shouldIndexResource) {
return;
}
final List<String> indexIgnorePathList = resourceRoot.getAttachment(Attachments.INDEX_IGNORE_PATHS);
final Set<String> indexIgnorePaths;
if (indexIgnorePathList != null && !indexIgnorePathList.isEmpty()) {
indexIgnorePaths = new HashSet<String>(indexIgnorePathList);
} else {
indexIgnorePaths = null;
}
final VirtualFile virtualFile = resourceRoot.getRoot();
final Indexer indexer = new Indexer();
try {
final VisitorAttributes visitorAttributes = new VisitorAttributes();
visitorAttributes.setLeavesOnly(true);
visitorAttributes.setRecurseFilter(new VirtualFileFilter() {
public boolean accepts(VirtualFile file) {
return indexIgnorePaths == null || !indexIgnorePaths.contains(file.getPathNameRelativeTo(virtualFile));
}
});
final List<VirtualFile> classChildren = virtualFile.getChildren(new SuffixMatchFilter(".class", visitorAttributes));
for (VirtualFile classFile : classChildren) {
InputStream inputStream = null;
try {
inputStream = classFile.openStream();
indexer.index(inputStream);
} catch (Exception e) {
ServerLogger.DEPLOYMENT_LOGGER.cannotIndexClass(classFile.getPathNameRelativeTo(virtualFile), virtualFile.getPathName(), e);
} finally {
VFSUtils.safeClose(inputStream);
}
}
final Index index = indexer.complete();
resourceRoot.putAttachment(Attachments.ANNOTATION_INDEX, index);
ServerLogger.DEPLOYMENT_LOGGER.tracef("Generated index for archive %s", virtualFile);
} catch (Throwable t) {
throw ServerLogger.ROOT_LOGGER.deploymentIndexingFailed(t);
}
} | [
"public",
"static",
"void",
"indexResourceRoot",
"(",
"final",
"ResourceRoot",
"resourceRoot",
")",
"throws",
"DeploymentUnitProcessingException",
"{",
"if",
"(",
"resourceRoot",
".",
"getAttachment",
"(",
"Attachments",
".",
"ANNOTATION_INDEX",
")",
"!=",
"null",
")"... | Creates and attaches the annotation index to a resource root, if it has not already been attached | [
"Creates",
"and",
"attaches",
"the",
"annotation",
"index",
"to",
"a",
"resource",
"root",
"if",
"it",
"has",
"not",
"already",
"been",
"attached"
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/server/src/main/java/org/jboss/as/server/deployment/annotation/ResourceRootIndexer.java#L52-L112 | train |
wildfly/wildfly-core | patching/src/main/java/org/jboss/as/patching/validation/PatchHistoryValidations.java | PatchHistoryValidations.validateRollbackState | public static void validateRollbackState(final String patchID, final InstalledIdentity identity) throws PatchingException {
final Set<String> validHistory = processRollbackState(patchID, identity);
if (patchID != null && !validHistory.contains(patchID)) {
throw PatchLogger.ROOT_LOGGER.patchNotFoundInHistory(patchID);
}
} | java | public static void validateRollbackState(final String patchID, final InstalledIdentity identity) throws PatchingException {
final Set<String> validHistory = processRollbackState(patchID, identity);
if (patchID != null && !validHistory.contains(patchID)) {
throw PatchLogger.ROOT_LOGGER.patchNotFoundInHistory(patchID);
}
} | [
"public",
"static",
"void",
"validateRollbackState",
"(",
"final",
"String",
"patchID",
",",
"final",
"InstalledIdentity",
"identity",
")",
"throws",
"PatchingException",
"{",
"final",
"Set",
"<",
"String",
">",
"validHistory",
"=",
"processRollbackState",
"(",
"pat... | Validate the consistency of patches to the point we rollback.
@param patchID the patch id which gets rolled back
@param identity the installed identity
@throws PatchingException | [
"Validate",
"the",
"consistency",
"of",
"patches",
"to",
"the",
"point",
"we",
"rollback",
"."
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/patching/src/main/java/org/jboss/as/patching/validation/PatchHistoryValidations.java#L54-L59 | train |
wildfly/wildfly-core | server/src/main/java/org/jboss/as/server/deployment/JPADeploymentMarker.java | JPADeploymentMarker.mark | public static void mark(DeploymentUnit unit) {
unit = DeploymentUtils.getTopDeploymentUnit(unit);
unit.putAttachment(MARKER, Boolean.TRUE);
} | java | public static void mark(DeploymentUnit unit) {
unit = DeploymentUtils.getTopDeploymentUnit(unit);
unit.putAttachment(MARKER, Boolean.TRUE);
} | [
"public",
"static",
"void",
"mark",
"(",
"DeploymentUnit",
"unit",
")",
"{",
"unit",
"=",
"DeploymentUtils",
".",
"getTopDeploymentUnit",
"(",
"unit",
")",
";",
"unit",
".",
"putAttachment",
"(",
"MARKER",
",",
"Boolean",
".",
"TRUE",
")",
";",
"}"
] | Mark the top level deployment as being a JPA deployment. If the deployment is not a top level deployment the parent is
marked instead | [
"Mark",
"the",
"top",
"level",
"deployment",
"as",
"being",
"a",
"JPA",
"deployment",
".",
"If",
"the",
"deployment",
"is",
"not",
"a",
"top",
"level",
"deployment",
"the",
"parent",
"is",
"marked",
"instead"
] | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/server/src/main/java/org/jboss/as/server/deployment/JPADeploymentMarker.java#L39-L42 | train |
wildfly/wildfly-core | deployment-repository/src/main/java/org/jboss/as/repository/ContentRepositoryImpl.java | ContentRepositoryImpl.cleanObsoleteContent | @Override
public Map<String, Set<String>> cleanObsoleteContent() {
if(!readWrite) {
return Collections.emptyMap();
}
Map<String, Set<String>> cleanedContents = new HashMap<>(2);
cleanedContents.put(MARKED_CONTENT, new HashSet<>());
cleanedContents.put(DELETED_CONTENT, new HashSet<>());
synchronized (contentHashReferences) {
for (ContentReference fsContent : listLocalContents()) {
if (!readWrite) {
return Collections.emptyMap();
}
if (!contentHashReferences.containsKey(fsContent.getHexHash())) { //We have no reference to this content
if (markAsObsolete(fsContent)) {
cleanedContents.get(DELETED_CONTENT).add(fsContent.getContentIdentifier());
} else {
cleanedContents.get(MARKED_CONTENT).add(fsContent.getContentIdentifier());
}
} else {
obsoleteContents.remove(fsContent.getHexHash()); //Remove existing references from obsoleteContents
}
}
}
return cleanedContents;
} | java | @Override
public Map<String, Set<String>> cleanObsoleteContent() {
if(!readWrite) {
return Collections.emptyMap();
}
Map<String, Set<String>> cleanedContents = new HashMap<>(2);
cleanedContents.put(MARKED_CONTENT, new HashSet<>());
cleanedContents.put(DELETED_CONTENT, new HashSet<>());
synchronized (contentHashReferences) {
for (ContentReference fsContent : listLocalContents()) {
if (!readWrite) {
return Collections.emptyMap();
}
if (!contentHashReferences.containsKey(fsContent.getHexHash())) { //We have no reference to this content
if (markAsObsolete(fsContent)) {
cleanedContents.get(DELETED_CONTENT).add(fsContent.getContentIdentifier());
} else {
cleanedContents.get(MARKED_CONTENT).add(fsContent.getContentIdentifier());
}
} else {
obsoleteContents.remove(fsContent.getHexHash()); //Remove existing references from obsoleteContents
}
}
}
return cleanedContents;
} | [
"@",
"Override",
"public",
"Map",
"<",
"String",
",",
"Set",
"<",
"String",
">",
">",
"cleanObsoleteContent",
"(",
")",
"{",
"if",
"(",
"!",
"readWrite",
")",
"{",
"return",
"Collections",
".",
"emptyMap",
"(",
")",
";",
"}",
"Map",
"<",
"String",
",... | Clean obsolete contents from the content repository. It will first mark contents as obsolete then after some time
if these contents are still obsolete they will be removed.
@return a map containing the list of marked contents and the list of deleted contents. | [
"Clean",
"obsolete",
"contents",
"from",
"the",
"content",
"repository",
".",
"It",
"will",
"first",
"mark",
"contents",
"as",
"obsolete",
"then",
"after",
"some",
"time",
"if",
"these",
"contents",
"are",
"still",
"obsolete",
"they",
"will",
"be",
"removed",
... | cfaf0479dcbb2d320a44c5374b93b944ec39fade | https://github.com/wildfly/wildfly-core/blob/cfaf0479dcbb2d320a44c5374b93b944ec39fade/deployment-repository/src/main/java/org/jboss/as/repository/ContentRepositoryImpl.java#L338-L363 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.