_id stringlengths 2 7 | title stringlengths 3 140 | partition stringclasses 3 values | text stringlengths 73 34.1k | language stringclasses 1 value | meta_information dict |
|---|---|---|---|---|---|
q2500 | InstalledIdentity.load | train | public static InstalledIdentity load(final File jbossHome, final ProductConfig productConfig, final File... repoRoots) throws IOException {
final InstalledImage installedImage = installedImage(jbossHome);
return load(installedImage, productConfig, Arrays.<File>asList(repoRoots), Collections.<File>emptyList());
} | java | {
"resource": ""
} |
q2501 | InstalledIdentity.load | train | public static InstalledIdentity load(final InstalledImage installedImage, final ProductConfig productConfig, List<File> moduleRoots, final List<File> bundleRoots) throws IOException {
return LayersFactory.load(installedImage, productConfig, moduleRoots, bundleRoots);
} | java | {
"resource": ""
} |
q2502 | ProtocolConnectionManager.shutdown | train | public void shutdown() {
final Connection connection;
synchronized (this) {
if(shutdown) return;
shutdown = true;
connection = this.connection;
if(connectTask != null) {
connectTask.shutdown();
}
}
if (connection != null) {
connection.closeAsync();
}
} | java | {
"resource": ""
} |
q2503 | ProtocolConnectionManager.onConnectionClose | train | private void onConnectionClose(final Connection closed) {
synchronized (this) {
if(connection == closed) {
connection = null;
if(shutdown) {
connectTask = DISCONNECTED;
return;
}
final ConnectTask previous = connectTask;
connectTask = previous.connectionClosed();
}
}
} | java | {
"resource": ""
} |
q2504 | ProtocolConnectionManager.create | train | public static ProtocolConnectionManager create(final Connection connection, final ConnectionOpenHandler openHandler) {
return create(new EstablishedConnection(connection, openHandler));
} | java | {
"resource": ""
} |
q2505 | Pipe.await | train | public void await() {
boolean intr = false;
final Object lock = this.lock;
try {
synchronized (lock) {
while (! readClosed) {
try {
lock.wait();
} catch (InterruptedException e) {
intr = true;
}
}
}
} finally {
if (intr) {
Thread.currentThread().interrupt();
}
}
} | java | {
"resource": ""
} |
q2506 | ExtensionRegistry.removeExtension | train | public void removeExtension(Resource rootResource, String moduleName, ManagementResourceRegistration rootRegistration) throws IllegalStateException {
final ManagementResourceRegistration profileReg;
if (rootRegistration.getPathAddress().size() == 0) {
//domain or server extension
// Can't use processType.isServer() to determine where to look for profile reg because a lot of test infrastructure
// doesn't add the profile mrr even in HC-based tests
ManagementResourceRegistration reg = rootRegistration.getSubModel(PathAddress.pathAddress(PathElement.pathElement(PROFILE)));
if (reg == null) {
reg = rootRegistration;
}
profileReg = reg;
} else {
//host model extension
profileReg = rootRegistration;
}
ManagementResourceRegistration deploymentsReg = processType.isServer() ? rootRegistration.getSubModel(PathAddress.pathAddress(PathElement.pathElement(DEPLOYMENT))) : null;
ExtensionInfo extension = extensions.remove(moduleName);
if (extension != null) {
//noinspection SynchronizationOnLocalVariableOrMethodParameter
synchronized (extension) {
Set<String> subsystemNames = extension.subsystems.keySet();
final boolean dcExtension = processType.isHostController() ?
rootRegistration.getPathAddress().size() == 0 : false;
for (String subsystem : subsystemNames) {
if (hasSubsystemsRegistered(rootResource, subsystem, dcExtension)) {
// Restore the data
extensions.put(moduleName, extension);
throw ControllerLogger.ROOT_LOGGER.removingExtensionWithRegisteredSubsystem(moduleName, subsystem);
}
}
for (Map.Entry<String, SubsystemInformation> entry : extension.subsystems.entrySet()) {
String subsystem = entry.getKey();
profileReg.unregisterSubModel(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, subsystem));
if (deploymentsReg != null) {
deploymentsReg.unregisterSubModel(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, subsystem));
deploymentsReg.unregisterSubModel(PathElement.pathElement(ModelDescriptionConstants.SUBDEPLOYMENT, subsystem));
}
if (extension.xmlMapper != null) {
SubsystemInformationImpl subsystemInformation = SubsystemInformationImpl.class.cast(entry.getValue());
for (String namespace : subsystemInformation.getXMLNamespaces()) {
extension.xmlMapper.unregisterRootElement(new QName(namespace, SUBSYSTEM));
}
}
}
}
}
} | java | {
"resource": ""
} |
q2507 | AbstractServerGroupRolloutTask.recordPreparedOperation | train | protected void recordPreparedOperation(final ServerIdentity identity, final TransactionalProtocolClient.PreparedOperation<ServerTaskExecutor.ServerOperation> prepared) {
final ModelNode preparedResult = prepared.getPreparedResult();
// Hmm do the server results need to get translated as well as the host one?
// final ModelNode transformedResult = prepared.getOperation().transformResult(preparedResult);
updatePolicy.recordServerResult(identity, preparedResult);
executor.recordPreparedOperation(prepared);
} | java | {
"resource": ""
} |
q2508 | Jvm.resolveJavaCommand | train | private static String resolveJavaCommand(final Path javaHome) {
final String exe;
if (javaHome == null) {
exe = "java";
} else {
exe = javaHome.resolve("bin").resolve("java").toString();
}
if (exe.contains(" ")) {
return "\"" + exe + "\"";
}
return exe;
} | java | {
"resource": ""
} |
q2509 | MiscContentItem.getRelativePath | train | public String getRelativePath() {
final StringBuilder builder = new StringBuilder();
for(final String p : path) {
builder.append(p).append("/");
}
builder.append(getName());
return builder.toString();
} | java | {
"resource": ""
} |
q2510 | ScriptAction.runScript | train | protected void runScript(File script) {
if (!script.exists()) {
JOptionPane.showMessageDialog(cliGuiCtx.getMainPanel(), script.getAbsolutePath() + " does not exist.",
"Unable to run script.", JOptionPane.ERROR_MESSAGE);
return;
}
int choice = JOptionPane.showConfirmDialog(cliGuiCtx.getMainPanel(), "Run CLI script " + script.getName() + "?",
"Confirm run script", JOptionPane.YES_NO_OPTION);
if (choice != JOptionPane.YES_OPTION) return;
menu.addScript(script);
cliGuiCtx.getTabs().setSelectedIndex(1); // set to Output tab to view the output
output.post("\n");
SwingWorker scriptRunner = new ScriptRunner(script);
scriptRunner.execute();
} | java | {
"resource": ""
} |
q2511 | ScriptAction.getCommandLines | train | private List<String> getCommandLines(File file) {
List<String> lines = new ArrayList<>();
try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
String line = reader.readLine();
while (line != null) {
lines.add(line);
line = reader.readLine();
}
} catch (Throwable e) {
throw new IllegalStateException("Failed to process file " + file.getAbsolutePath(), e);
}
return lines;
} | java | {
"resource": ""
} |
q2512 | TargetAttribute.getFlags | train | public Set<AttributeAccess.Flag> getFlags() {
if (attributeAccess == null) {
return Collections.emptySet();
}
return attributeAccess.getFlags();
} | java | {
"resource": ""
} |
q2513 | AuthenticationValidatingHandler.createOperation | train | static ModelNode createOperation(final ModelNode operationToValidate) {
PathAddress pa = PathAddress.pathAddress(operationToValidate.require(ModelDescriptionConstants.OP_ADDR));
PathAddress realmPA = null;
for (int i = pa.size() - 1; i > 0; i--) {
PathElement pe = pa.getElement(i);
if (SECURITY_REALM.equals(pe.getKey())) {
realmPA = pa.subAddress(0, i + 1);
break;
}
}
assert realmPA != null : "operationToValidate did not have an address that included a " + SECURITY_REALM;
return Util.getEmptyOperation("validate-authentication", realmPA.toModelNode());
} | java | {
"resource": ""
} |
q2514 | RemotingServices.channelServiceName | train | public static ServiceName channelServiceName(final ServiceName endpointName, final String channelName) {
return endpointName.append("channel").append(channelName);
} | java | {
"resource": ""
} |
q2515 | ManagementChannelHandler.getRemoteAddress | train | public InetAddress getRemoteAddress() {
final Channel channel;
try {
channel = strategy.getChannel();
} catch (IOException e) {
return null;
}
final Connection connection = channel.getConnection();
final InetSocketAddress peerAddress = connection.getPeerAddress(InetSocketAddress.class);
return peerAddress == null ? null : peerAddress.getAddress();
} | java | {
"resource": ""
} |
q2516 | ManagementChannelHandler.addHandlerFactory | train | public void addHandlerFactory(ManagementRequestHandlerFactory factory) {
for (;;) {
final ManagementRequestHandlerFactory[] snapshot = updater.get(this);
final int length = snapshot.length;
final ManagementRequestHandlerFactory[] newVal = new ManagementRequestHandlerFactory[length + 1];
System.arraycopy(snapshot, 0, newVal, 0, length);
newVal[length] = factory;
if (updater.compareAndSet(this, snapshot, newVal)) {
return;
}
}
} | java | {
"resource": ""
} |
q2517 | ManagementChannelHandler.removeHandlerFactory | train | public boolean removeHandlerFactory(ManagementRequestHandlerFactory instance) {
for(;;) {
final ManagementRequestHandlerFactory[] snapshot = updater.get(this);
final int length = snapshot.length;
int index = -1;
for(int i = 0; i < length; i++) {
if(snapshot[i] == instance) {
index = i;
break;
}
}
if(index == -1) {
return false;
}
final ManagementRequestHandlerFactory[] newVal = new ManagementRequestHandlerFactory[length - 1];
System.arraycopy(snapshot, 0, newVal, 0, index);
System.arraycopy(snapshot, index + 1, newVal, index, length - index - 1);
if (updater.compareAndSet(this, snapshot, newVal)) {
return true;
}
}
} | java | {
"resource": ""
} |
q2518 | FilenameTabCompleter.translatePath | train | public String translatePath(String path) {
String translated;
// special character: ~ maps to the user's home directory
if (path.startsWith("~" + File.separator)) {
translated = System.getProperty("user.home") + path.substring(1);
} else if (path.startsWith("~")) {
String userName = path.substring(1);
translated = new File(new File(System.getProperty("user.home")).getParent(),
userName).getAbsolutePath();
// Keep the path separator in translated or add one if no user home specified
translated = userName.isEmpty() || path.endsWith(File.separator) ? translated + File.separator : translated;
} else if (!new File(path).isAbsolute()) {
translated = ctx.getCurrentDir().getAbsolutePath() + File.separator + path;
} else {
translated = path;
}
return translated;
} | java | {
"resource": ""
} |
q2519 | FilenameTabCompleter.clearPath | train | private static String clearPath(String path) {
try {
ExpressionBaseState state = new ExpressionBaseState("EXPR", true, false);
if (Util.isWindows()) {
// to not require escaping FS name separator
state.setDefaultHandler(WordCharacterHandler.IGNORE_LB_ESCAPE_OFF);
} else {
state.setDefaultHandler(WordCharacterHandler.IGNORE_LB_ESCAPE_ON);
}
// Remove escaping characters
path = ArgumentWithValue.resolveValue(path, state);
} catch (CommandFormatException ex) {
// XXX OK, continue translation
}
// Remove quote to retrieve candidates.
if (path.startsWith("\"")) {
path = path.substring(1);
}
// Could be an escaped " character. We don't take into account this corner case.
// concider it the end of the quoted part.
if (path.endsWith("\"")) {
path = path.substring(0, path.length() - 1);
}
return path;
} | java | {
"resource": ""
} |
q2520 | RequestController.resume | train | @Override
public synchronized void resume() {
this.paused = false;
ServerActivityCallback listener = listenerUpdater.get(this);
if (listener != null) {
listenerUpdater.compareAndSet(this, listener, null);
}
while (!taskQueue.isEmpty() && (activeRequestCount < maxRequestCount || maxRequestCount < 0)) {
runQueuedTask(false);
}
} | java | {
"resource": ""
} |
q2521 | RequestController.pauseDeployment | train | public synchronized void pauseDeployment(final String deployment, ServerActivityCallback listener) {
final List<ControlPoint> eps = new ArrayList<ControlPoint>();
for (ControlPoint ep : entryPoints.values()) {
if (ep.getDeployment().equals(deployment)) {
if(!ep.isPaused()) {
eps.add(ep);
}
}
}
CountingRequestCountCallback realListener = new CountingRequestCountCallback(eps.size(), listener);
for (ControlPoint ep : eps) {
ep.pause(realListener);
}
} | java | {
"resource": ""
} |
q2522 | RequestController.resumeDeployment | train | public synchronized void resumeDeployment(final String deployment) {
for (ControlPoint ep : entryPoints.values()) {
if (ep.getDeployment().equals(deployment)) {
ep.resume();
}
}
} | java | {
"resource": ""
} |
q2523 | RequestController.resumeControlPoint | train | public synchronized void resumeControlPoint(final String entryPoint) {
for (ControlPoint ep : entryPoints.values()) {
if (ep.getEntryPoint().equals(entryPoint)) {
ep.resume();
}
}
} | java | {
"resource": ""
} |
q2524 | RequestController.getControlPoint | train | public synchronized ControlPoint getControlPoint(final String deploymentName, final String entryPointName) {
ControlPointIdentifier id = new ControlPointIdentifier(deploymentName, entryPointName);
ControlPoint ep = entryPoints.get(id);
if (ep == null) {
ep = new ControlPoint(this, deploymentName, entryPointName, trackIndividualControlPoints);
entryPoints.put(id, ep);
}
ep.increaseReferenceCount();
return ep;
} | java | {
"resource": ""
} |
q2525 | RequestController.removeControlPoint | train | public synchronized void removeControlPoint(ControlPoint controlPoint) {
if (controlPoint.decreaseReferenceCount() == 0) {
ControlPointIdentifier id = new ControlPointIdentifier(controlPoint.getDeployment(), controlPoint.getEntryPoint());
entryPoints.remove(id);
}
} | java | {
"resource": ""
} |
q2526 | RequestController.runQueuedTask | train | private boolean runQueuedTask(boolean hasPermit) {
if (!hasPermit && beginRequest(paused) == RunResult.REJECTED) {
return false;
}
QueuedTask task = null;
if (!paused) {
task = taskQueue.poll();
} else {
//the container is suspended, but we still need to run any force queued tasks
task = findForcedTask();
}
if (task != null) {
if(!task.runRequest()) {
decrementRequestCount();
}
return true;
} else {
decrementRequestCount();
return false;
}
} | java | {
"resource": ""
} |
q2527 | DefaultOperationCandidatesProvider.getProperty | train | static Property getProperty(String propName, ModelNode attrs) {
String[] arr = propName.split("\\.");
ModelNode attrDescr = attrs;
for (String item : arr) {
// Remove list part.
if (item.endsWith("]")) {
int i = item.indexOf("[");
if (i < 0) {
return null;
}
item = item.substring(0, i);
}
ModelNode descr = attrDescr.get(item);
if (!descr.isDefined()) {
if (attrDescr.has(Util.VALUE_TYPE)) {
ModelNode vt = attrDescr.get(Util.VALUE_TYPE);
if (vt.has(item)) {
attrDescr = vt.get(item);
continue;
}
}
return null;
}
attrDescr = descr;
}
return new Property(propName, attrDescr);
} | java | {
"resource": ""
} |
q2528 | LoggingConfigDeploymentProcessor.configure | train | private LoggingConfigurationService configure(final ResourceRoot root, final VirtualFile configFile, final ClassLoader classLoader, final LogContext logContext) throws DeploymentUnitProcessingException {
InputStream configStream = null;
try {
LoggingLogger.ROOT_LOGGER.debugf("Found logging configuration file: %s", configFile);
// Get the filname and open the stream
final String fileName = configFile.getName();
configStream = configFile.openStream();
// Check the type of the configuration file
if (isLog4jConfiguration(fileName)) {
final ClassLoader current = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
final LogContext old = logContextSelector.getAndSet(CONTEXT_LOCK, logContext);
try {
WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(classLoader);
if (LOG4J_XML.equals(fileName) || JBOSS_LOG4J_XML.equals(fileName)) {
new DOMConfigurator().doConfigure(configStream, org.apache.log4j.JBossLogManagerFacade.getLoggerRepository(logContext));
} else {
final Properties properties = new Properties();
properties.load(new InputStreamReader(configStream, ENCODING));
new org.apache.log4j.PropertyConfigurator().doConfigure(properties, org.apache.log4j.JBossLogManagerFacade.getLoggerRepository(logContext));
}
} finally {
logContextSelector.getAndSet(CONTEXT_LOCK, old);
WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(current);
}
return new LoggingConfigurationService(null, resolveRelativePath(root, configFile));
} else {
// Create a properties file
final Properties properties = new Properties();
properties.load(new InputStreamReader(configStream, ENCODING));
// Attempt to see if this is a J.U.L. configuration file
if (isJulConfiguration(properties)) {
LoggingLogger.ROOT_LOGGER.julConfigurationFileFound(configFile.getName());
} else {
// Load non-log4j types
final PropertyConfigurator propertyConfigurator = new PropertyConfigurator(logContext);
propertyConfigurator.configure(properties);
return new LoggingConfigurationService(propertyConfigurator.getLogContextConfiguration(), resolveRelativePath(root, configFile));
}
}
} catch (Exception e) {
throw LoggingLogger.ROOT_LOGGER.failedToConfigureLogging(e, configFile.getName());
} finally {
safeClose(configStream);
}
return null;
} | java | {
"resource": ""
} |
q2529 | OperationValidator.validateOperations | train | public void validateOperations(final List<ModelNode> operations) {
if (operations == null) {
return;
}
for (ModelNode operation : operations) {
try {
validateOperation(operation);
} catch (RuntimeException e) {
if (exitOnError) {
throw e;
} else {
System.out.println("---- Operation validation error:");
System.out.println(e.getMessage());
}
}
}
} | java | {
"resource": ""
} |
q2530 | OperationValidator.validateOperation | train | public void validateOperation(final ModelNode operation) {
if (operation == null) {
return;
}
final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR));
final String name = operation.get(OP).asString();
OperationEntry entry = root.getOperationEntry(address, name);
if (entry == null) {
throwOrWarnAboutDescriptorProblem(ControllerLogger.ROOT_LOGGER.noOperationEntry(name, address));
}
//noinspection ConstantConditions
if (entry.getType() == EntryType.PRIVATE || entry.getFlags().contains(OperationEntry.Flag.HIDDEN)) {
return;
}
if (entry.getOperationHandler() == null) {
throwOrWarnAboutDescriptorProblem(ControllerLogger.ROOT_LOGGER.noOperationHandler(name, address));
}
final DescriptionProvider provider = getDescriptionProvider(operation);
final ModelNode description = provider.getModelDescription(null);
final Map<String, ModelNode> describedProperties = getDescribedRequestProperties(operation, description);
final Map<String, ModelNode> actualParams = getActualRequestProperties(operation);
checkActualOperationParamsAreDescribed(operation, describedProperties, actualParams);
checkAllRequiredPropertiesArePresent(description, operation, describedProperties, actualParams);
checkParameterTypes(description, operation, describedProperties, actualParams);
//TODO check ranges
} | java | {
"resource": ""
} |
q2531 | OperationValidator.throwOrWarnAboutDescriptorProblem | train | private void throwOrWarnAboutDescriptorProblem(String message) {
if (validateDescriptions) {
throw new IllegalArgumentException(message);
}
ControllerLogger.ROOT_LOGGER.warn(message);
} | java | {
"resource": ""
} |
q2532 | RuntimeCapability.buildDynamicCapabilityName | train | public static String buildDynamicCapabilityName(String baseName, String dynamicNameElement) {
return buildDynamicCapabilityName(baseName, new String[]{dynamicNameElement});
} | java | {
"resource": ""
} |
q2533 | RuntimeCapability.buildDynamicCapabilityName | train | public static String buildDynamicCapabilityName(String baseName, String ... dynamicNameElement) {
assert baseName != null;
assert dynamicNameElement != null;
assert dynamicNameElement.length > 0;
StringBuilder sb = new StringBuilder(baseName);
for (String part:dynamicNameElement){
sb.append(".").append(part);
}
return sb.toString();
} | java | {
"resource": ""
} |
q2534 | OperationBuilder.addInputStream | train | public OperationBuilder addInputStream(final InputStream in) {
Assert.checkNotNullParam("in", in);
if (inputStreams == null) {
inputStreams = new ArrayList<InputStream>();
}
inputStreams.add(in);
return this;
} | java | {
"resource": ""
} |
q2535 | InstallationManagerImpl.getInstalledIdentity | train | @Override
public InstalledIdentity getInstalledIdentity(String productName, String productVersion) throws PatchingException {
final String defaultIdentityName = defaultIdentity.getIdentity().getName();
if(productName == null) {
productName = defaultIdentityName;
}
final File productConf = new File(installedImage.getInstallationMetadata(), productName + Constants.DOT_CONF);
final String recordedProductVersion;
if(!productConf.exists()) {
recordedProductVersion = null;
} else {
final Properties props = loadProductConf(productConf);
recordedProductVersion = props.getProperty(Constants.CURRENT_VERSION);
}
if(defaultIdentityName.equals(productName)) {
if(recordedProductVersion != null && !recordedProductVersion.equals(defaultIdentity.getIdentity().getVersion())) {
// this means the patching history indicates that the current version is different from the one specified in the server's version module,
// which could happen in case:
// - the last applied CP didn't include the new version module or
// - the version module version included in the last CP didn't match the version specified in the CP's metadata, or
// - the version module was updated from a one-off, or
// - the patching history was edited somehow
// In any case, here I decided to rely on the patching history.
defaultIdentity = loadIdentity(productName, recordedProductVersion);
}
if(productVersion != null && !defaultIdentity.getIdentity().getVersion().equals(productVersion)) {
throw new PatchingException(PatchLogger.ROOT_LOGGER.productVersionDidNotMatchInstalled(
productName, productVersion, defaultIdentity.getIdentity().getVersion()));
}
return defaultIdentity;
}
if(recordedProductVersion != null && !Constants.UNKNOWN.equals(recordedProductVersion)) {
if(productVersion != null) {
if (!productVersion.equals(recordedProductVersion)) {
throw new PatchingException(PatchLogger.ROOT_LOGGER.productVersionDidNotMatchInstalled(productName, productVersion, recordedProductVersion));
}
} else {
productVersion = recordedProductVersion;
}
}
return loadIdentity(productName, productVersion);
} | java | {
"resource": ""
} |
q2536 | InstallationManagerImpl.getInstalledIdentities | train | @Override
public List<InstalledIdentity> getInstalledIdentities() throws PatchingException {
List<InstalledIdentity> installedIdentities;
final File metadataDir = installedImage.getInstallationMetadata();
if(!metadataDir.exists()) {
installedIdentities = Collections.singletonList(defaultIdentity);
} else {
final String defaultConf = defaultIdentity.getIdentity().getName() + Constants.DOT_CONF;
final File[] identityConfs = metadataDir.listFiles(new FileFilter() {
@Override
public boolean accept(File pathname) {
return pathname.isFile() &&
pathname.getName().endsWith(Constants.DOT_CONF) &&
!pathname.getName().equals(defaultConf);
}
});
if(identityConfs == null || identityConfs.length == 0) {
installedIdentities = Collections.singletonList(defaultIdentity);
} else {
installedIdentities = new ArrayList<InstalledIdentity>(identityConfs.length + 1);
installedIdentities.add(defaultIdentity);
for(File conf : identityConfs) {
final Properties props = loadProductConf(conf);
String productName = conf.getName();
productName = productName.substring(0, productName.length() - Constants.DOT_CONF.length());
final String productVersion = props.getProperty(Constants.CURRENT_VERSION);
InstalledIdentity identity;
try {
identity = LayersFactory.load(installedImage, new ProductConfig(productName, productVersion, null), moduleRoots, bundleRoots);
} catch (IOException e) {
throw new PatchingException(PatchLogger.ROOT_LOGGER.failedToLoadInfo(productName), e);
}
installedIdentities.add(identity);
}
}
}
return installedIdentities;
} | java | {
"resource": ""
} |
q2537 | StandaloneCommandBuilder.setDebug | train | public StandaloneCommandBuilder setDebug(final boolean suspend, final int port) {
debugArg = String.format(DEBUG_FORMAT, (suspend ? "y" : "n"), port);
return this;
} | java | {
"resource": ""
} |
q2538 | StandaloneCommandBuilder.addSecurityProperty | train | public StandaloneCommandBuilder addSecurityProperty(final String key, final String value) {
securityProperties.put(key, value);
return this;
} | java | {
"resource": ""
} |
q2539 | AbstractAttributeDefinitionBuilder.addAccessConstraint | train | @SuppressWarnings("deprecation")
public BUILDER addAccessConstraint(final AccessConstraintDefinition accessConstraint) {
if (accessConstraints == null) {
accessConstraints = new AccessConstraintDefinition[] {accessConstraint};
} else {
accessConstraints = Arrays.copyOf(accessConstraints, accessConstraints.length + 1);
accessConstraints[accessConstraints.length - 1] = accessConstraint;
}
return (BUILDER) this;
} | java | {
"resource": ""
} |
q2540 | AbstractAttributeDefinitionBuilder.setAttributeGroup | train | public BUILDER setAttributeGroup(String attributeGroup) {
assert attributeGroup == null || attributeGroup.length() > 0;
//noinspection deprecation
this.attributeGroup = attributeGroup;
return (BUILDER) this;
} | java | {
"resource": ""
} |
q2541 | AbstractAttributeDefinitionBuilder.setAllowedValues | train | @SuppressWarnings("deprecation")
public BUILDER setAllowedValues(String ... allowedValues) {
assert allowedValues!= null;
this.allowedValues = new ModelNode[allowedValues.length];
for (int i = 0; i < allowedValues.length; i++) {
this.allowedValues[i] = new ModelNode(allowedValues[i]);
}
return (BUILDER) this;
} | java | {
"resource": ""
} |
q2542 | LoggingProfileContextSelector.getOrCreate | train | protected LogContext getOrCreate(final String loggingProfile) {
LogContext result = profileContexts.get(loggingProfile);
if (result == null) {
result = LogContext.create();
final LogContext current = profileContexts.putIfAbsent(loggingProfile, result);
if (current != null) {
result = current;
}
}
return result;
} | java | {
"resource": ""
} |
q2543 | DomainControllerData.writeTo | train | public void writeTo(DataOutput outstream) throws Exception {
S3Util.writeString(host, outstream);
outstream.writeInt(port);
S3Util.writeString(protocol, outstream);
} | java | {
"resource": ""
} |
q2544 | DomainControllerData.readFrom | train | public void readFrom(DataInput instream) throws Exception {
host = S3Util.readString(instream);
port = instream.readInt();
protocol = S3Util.readString(instream);
} | java | {
"resource": ""
} |
q2545 | OperationRequestCompleter.complete | train | protected int complete(CommandContext ctx, ParsedCommandLine parsedCmd, OperationCandidatesProvider candidatesProvider, final String buffer, int cursor, List<String> candidates) {
if(parsedCmd.isRequestComplete()) {
return -1;
}
// Headers completion
if(parsedCmd.endsOnHeaderListStart() || parsedCmd.hasHeaders()) {
return completeHeaders(ctx, parsedCmd, candidatesProvider, buffer, cursor, candidates);
}
// Completed.
if(parsedCmd.endsOnPropertyListEnd()) {
return buffer.length();
}
// Complete properties
if (parsedCmd.hasProperties() || parsedCmd.endsOnPropertyListStart()
|| parsedCmd.endsOnNotOperator()) {
return completeProperties(ctx, parsedCmd, candidatesProvider, buffer, candidates);
}
// Complete Operation name
if (parsedCmd.hasOperationName() || parsedCmd.endsOnAddressOperationNameSeparator()) {
return completeOperationName(ctx, parsedCmd, candidatesProvider, buffer, candidates);
}
// Finally Complete address
return completeAddress(ctx, parsedCmd, candidatesProvider, buffer, candidates);
} | java | {
"resource": ""
} |
q2546 | CompositeIndexProcessor.handleClassPathItems | train | private Collection<? extends ResourceRoot> handleClassPathItems(final DeploymentUnit deploymentUnit) {
final Set<ResourceRoot> additionalRoots = new HashSet<ResourceRoot>();
final ArrayDeque<ResourceRoot> toProcess = new ArrayDeque<ResourceRoot>();
final List<ResourceRoot> resourceRoots = DeploymentUtils.allResourceRoots(deploymentUnit);
toProcess.addAll(resourceRoots);
final Set<ResourceRoot> processed = new HashSet<ResourceRoot>(resourceRoots);
while (!toProcess.isEmpty()) {
final ResourceRoot root = toProcess.pop();
final List<ResourceRoot> classPathRoots = root.getAttachmentList(Attachments.CLASS_PATH_RESOURCE_ROOTS);
for(ResourceRoot cpRoot : classPathRoots) {
if(!processed.contains(cpRoot)) {
additionalRoots.add(cpRoot);
toProcess.add(cpRoot);
processed.add(cpRoot);
}
}
}
return additionalRoots;
} | java | {
"resource": ""
} |
q2547 | ObjectListAttributeDefinition.resolveValue | train | @Override
public ModelNode resolveValue(ExpressionResolver resolver, ModelNode value) throws OperationFailedException {
// Pass non-LIST values through the superclass so it can reject weird values and, in the odd chance
// that's how this object is set up, turn undefined into a default list value.
ModelNode superResult = value.getType() == ModelType.LIST ? value : super.resolveValue(resolver, value);
// If it's not a LIST (almost certainly UNDEFINED), then nothing more we can do
if (superResult.getType() != ModelType.LIST) {
return superResult;
}
// Resolve each element.
// Don't mess with the original value
ModelNode clone = superResult == value ? value.clone() : superResult;
ModelNode result = new ModelNode();
result.setEmptyList();
for (ModelNode element : clone.asList()) {
result.add(valueType.resolveValue(resolver, element));
}
// Validate the entire list
getValidator().validateParameter(getName(), result);
return result;
} | java | {
"resource": ""
} |
q2548 | LoggingExtension.getResourceDescriptionResolver | train | public static ResourceDescriptionResolver getResourceDescriptionResolver(final String... keyPrefix) {
StringBuilder prefix = new StringBuilder(SUBSYSTEM_NAME);
for (String kp : keyPrefix) {
prefix.append('.').append(kp);
}
return new StandardResourceDescriptionResolver(prefix.toString(), RESOURCE_NAME, LoggingExtension.class.getClassLoader(), true, false) {
@Override
public String getOperationParameterDescription(final String operationName, final String paramName, final Locale locale, final ResourceBundle bundle) {
if (DELEGATE_DESC_OPTS.contains(operationName)) {
return getResourceAttributeDescription(paramName, locale, bundle);
}
return super.getOperationParameterDescription(operationName, paramName, locale, bundle);
}
@Override
public String getOperationParameterValueTypeDescription(final String operationName, final String paramName, final Locale locale,
final ResourceBundle bundle, final String... suffixes) {
if (DELEGATE_DESC_OPTS.contains(operationName)) {
return getResourceAttributeDescription(paramName, locale, bundle);
}
return super.getOperationParameterValueTypeDescription(operationName, paramName, locale, bundle, suffixes);
}
@Override
public String getOperationParameterDeprecatedDescription(final String operationName, final String paramName, final Locale locale, final ResourceBundle bundle) {
if (DELEGATE_DESC_OPTS.contains(operationName)) {
return getResourceAttributeDeprecatedDescription(paramName, locale, bundle);
}
return super.getOperationParameterDeprecatedDescription(operationName, paramName, locale, bundle);
}
};
} | java | {
"resource": ""
} |
q2549 | RemotingSubsystem10Parser.parseWorkerThreadPool | train | void parseWorkerThreadPool(final XMLExtendedStreamReader reader, final ModelNode subsystemAdd) throws XMLStreamException {
final int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
requireNoNamespaceAttribute(reader, i);
final String value = reader.getAttributeValue(i);
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
switch (attribute) {
case WORKER_READ_THREADS:
if (subsystemAdd.hasDefined(CommonAttributes.WORKER_READ_THREADS)) {
throw duplicateAttribute(reader, CommonAttributes.WORKER_READ_THREADS);
}
RemotingSubsystemRootResource.WORKER_READ_THREADS.parseAndSetParameter(value, subsystemAdd, reader);
break;
case WORKER_TASK_CORE_THREADS:
if (subsystemAdd.hasDefined(CommonAttributes.WORKER_TASK_CORE_THREADS)) {
throw duplicateAttribute(reader, CommonAttributes.WORKER_TASK_CORE_THREADS);
}
RemotingSubsystemRootResource.WORKER_TASK_CORE_THREADS.parseAndSetParameter(value, subsystemAdd, reader);
break;
case WORKER_TASK_KEEPALIVE:
if (subsystemAdd.hasDefined(CommonAttributes.WORKER_TASK_KEEPALIVE)) {
throw duplicateAttribute(reader, CommonAttributes.WORKER_TASK_KEEPALIVE);
}
RemotingSubsystemRootResource.WORKER_TASK_KEEPALIVE.parseAndSetParameter(value, subsystemAdd, reader);
break;
case WORKER_TASK_LIMIT:
if (subsystemAdd.hasDefined(CommonAttributes.WORKER_TASK_LIMIT)) {
throw duplicateAttribute(reader, CommonAttributes.WORKER_TASK_LIMIT);
}
RemotingSubsystemRootResource.WORKER_TASK_LIMIT.parseAndSetParameter(value, subsystemAdd, reader);
break;
case WORKER_TASK_MAX_THREADS:
if (subsystemAdd.hasDefined(CommonAttributes.WORKER_TASK_MAX_THREADS)) {
throw duplicateAttribute(reader, CommonAttributes.WORKER_TASK_MAX_THREADS);
}
RemotingSubsystemRootResource.WORKER_TASK_MAX_THREADS.parseAndSetParameter(value, subsystemAdd, reader);
break;
case WORKER_WRITE_THREADS:
if (subsystemAdd.hasDefined(CommonAttributes.WORKER_WRITE_THREADS)) {
throw duplicateAttribute(reader, CommonAttributes.WORKER_WRITE_THREADS);
}
RemotingSubsystemRootResource.WORKER_WRITE_THREADS.parseAndSetParameter(value, subsystemAdd, reader);
break;
default:
throw unexpectedAttribute(reader, i);
}
}
requireNoContent(reader);
} | java | {
"resource": ""
} |
q2550 | ServerRequireRestartTask.createOperation | train | private static ModelNode createOperation(ServerIdentity identity) {
// The server address
final ModelNode address = new ModelNode();
address.add(ModelDescriptionConstants.HOST, identity.getHostName());
address.add(ModelDescriptionConstants.RUNNING_SERVER, identity.getServerName());
//
final ModelNode operation = OPERATION.clone();
operation.get(ModelDescriptionConstants.OP_ADDR).set(address);
return operation;
} | java | {
"resource": ""
} |
q2551 | PropertyFileFinder.buildDirPath | train | private File buildDirPath(final String serverConfigUserDirPropertyName, final String suppliedConfigDir,
final String serverConfigDirPropertyName, final String serverBaseDirPropertyName, final String defaultBaseDir) {
String propertyDir = System.getProperty(serverConfigUserDirPropertyName);
if (propertyDir != null) {
return new File(propertyDir);
}
if (suppliedConfigDir != null) {
return new File(suppliedConfigDir);
}
propertyDir = System.getProperty(serverConfigDirPropertyName);
if (propertyDir != null) {
return new File(propertyDir);
}
propertyDir = System.getProperty(serverBaseDirPropertyName);
if (propertyDir != null) {
return new File(propertyDir);
}
return new File(new File(stateValues.getOptions().getJBossHome(), defaultBaseDir), "configuration");
} | java | {
"resource": ""
} |
q2552 | PropertyFileFinder.validatePermissions | train | private void validatePermissions(final File dirPath, final File file) {
// Check execute and read permissions for parent dirPath
if( !dirPath.canExecute() || !dirPath.canRead() ) {
validFilePermissions = false;
filePermissionsProblemPath = dirPath.getAbsolutePath();
return;
}
// Check read and write permissions for properties file
if( !file.canRead() || !file.canWrite() ) {
validFilePermissions = false;
filePermissionsProblemPath = dirPath.getAbsolutePath();
}
} | java | {
"resource": ""
} |
q2553 | AbstractCommandBuilder.normalizePath | train | protected Path normalizePath(final Path parent, final String path) {
return parent.resolve(path).toAbsolutePath().normalize();
} | java | {
"resource": ""
} |
q2554 | ContainerStateMonitor.awaitStabilityUninterruptibly | train | void awaitStabilityUninterruptibly(long timeout, TimeUnit timeUnit) throws TimeoutException {
boolean interrupted = false;
try {
long toWait = timeUnit.toMillis(timeout);
long msTimeout = System.currentTimeMillis() + toWait;
while (true) {
if (interrupted) {
toWait = msTimeout - System.currentTimeMillis();
}
try {
if (toWait <= 0 || !monitor.awaitStability(toWait, TimeUnit.MILLISECONDS, failed, problems)) {
throw new TimeoutException();
}
break;
} catch (InterruptedException e) {
interrupted = true;
}
}
} finally {
if (interrupted) {
Thread.currentThread().interrupt();
}
}
} | java | {
"resource": ""
} |
q2555 | ServerService.addService | train | public static void addService(final ServiceTarget serviceTarget, final Bootstrap.Configuration configuration,
final ControlledProcessState processState, final BootstrapListener bootstrapListener,
final RunningModeControl runningModeControl, final AbstractVaultReader vaultReader, final ManagedAuditLogger auditLogger,
final DelegatingConfigurableAuthorizer authorizer, final ManagementSecurityIdentitySupplier securityIdentitySupplier,
final SuspendController suspendController) {
// Install Executor services
final ThreadGroup threadGroup = new ThreadGroup("ServerService ThreadGroup");
final String namePattern = "ServerService Thread Pool -- %t";
final ThreadFactory threadFactory = doPrivileged(new PrivilegedAction<ThreadFactory>() {
public ThreadFactory run() {
return new JBossThreadFactory(threadGroup, Boolean.FALSE, null, namePattern, null, null);
}
});
// TODO determine why QueuelessThreadPoolService makes boot take > 35 secs
// final QueuelessThreadPoolService serverExecutorService = new QueuelessThreadPoolService(Integer.MAX_VALUE, false, new TimeSpec(TimeUnit.SECONDS, 5));
// serverExecutorService.getThreadFactoryInjector().inject(threadFactory);
final boolean forDomain = ProcessType.DOMAIN_SERVER == getProcessType(configuration.getServerEnvironment());
final ServerExecutorService serverExecutorService = new ServerExecutorService(threadFactory, forDomain);
serviceTarget.addService(MANAGEMENT_EXECUTOR, serverExecutorService)
.addAliases(Services.JBOSS_SERVER_EXECUTOR, ManagementRemotingServices.SHUTDOWN_EXECUTOR_NAME) // Use this executor for mgmt shutdown for now
.install();
final ServerScheduledExecutorService serverScheduledExecutorService = new ServerScheduledExecutorService(threadFactory);
serviceTarget.addService(JBOSS_SERVER_SCHEDULED_EXECUTOR, serverScheduledExecutorService)
.addAliases(JBOSS_SERVER_SCHEDULED_EXECUTOR)
.addDependency(MANAGEMENT_EXECUTOR, ExecutorService.class, serverScheduledExecutorService.executorInjector)
.install();
final CapabilityRegistry capabilityRegistry = configuration.getCapabilityRegistry();
ServerService service = new ServerService(configuration, processState, null, bootstrapListener, new ServerDelegatingResourceDefinition(),
runningModeControl, vaultReader, auditLogger, authorizer, securityIdentitySupplier, capabilityRegistry, suspendController);
ExternalManagementRequestExecutor.install(serviceTarget, threadGroup, EXECUTOR_CAPABILITY.getCapabilityServiceName(), service.getStabilityMonitor());
ServiceBuilder<?> serviceBuilder = serviceTarget.addService(Services.JBOSS_SERVER_CONTROLLER, service);
serviceBuilder.addDependency(DeploymentMountProvider.SERVICE_NAME,DeploymentMountProvider.class, service.injectedDeploymentRepository);
serviceBuilder.addDependency(ContentRepository.SERVICE_NAME, ContentRepository.class, service.injectedContentRepository);
serviceBuilder.addDependency(Services.JBOSS_SERVICE_MODULE_LOADER, ServiceModuleLoader.class, service.injectedModuleLoader);
serviceBuilder.addDependency(Services.JBOSS_EXTERNAL_MODULE_SERVICE, ExternalModuleService.class,
service.injectedExternalModuleService);
serviceBuilder.addDependency(PATH_MANAGER_CAPABILITY.getCapabilityServiceName(), PathManager.class, service.injectedPathManagerService);
if (configuration.getServerEnvironment().isAllowModelControllerExecutor()) {
serviceBuilder.addDependency(MANAGEMENT_EXECUTOR, ExecutorService.class, service.getExecutorServiceInjector());
}
if (configuration.getServerEnvironment().getLaunchType() == ServerEnvironment.LaunchType.DOMAIN) {
serviceBuilder.addDependency(HostControllerConnectionService.SERVICE_NAME, ControllerInstabilityListener.class,
service.getContainerInstabilityInjector());
}
serviceBuilder.install();
} | java | {
"resource": ""
} |
q2556 | PatchOperationTarget.createLocal | train | public static final PatchOperationTarget createLocal(final File jbossHome, List<File> moduleRoots, List<File> bundlesRoots) throws IOException {
final PatchTool tool = PatchTool.Factory.createLocalTool(jbossHome, moduleRoots, bundlesRoots);
return new LocalPatchOperationTarget(tool);
} | java | {
"resource": ""
} |
q2557 | PatchOperationTarget.createStandalone | train | public static final PatchOperationTarget createStandalone(final ModelControllerClient controllerClient) {
final PathAddress address = PathAddress.EMPTY_ADDRESS.append(CORE_SERVICES);
return new RemotePatchOperationTarget(address, controllerClient);
} | java | {
"resource": ""
} |
q2558 | PatchOperationTarget.createHost | train | public static final PatchOperationTarget createHost(final String hostName, final ModelControllerClient client) {
final PathElement host = PathElement.pathElement(HOST, hostName);
final PathAddress address = PathAddress.EMPTY_ADDRESS.append(host, CORE_SERVICES);
return new RemotePatchOperationTarget(address, client);
} | java | {
"resource": ""
} |
q2559 | OperationTransformerRegistry.resolveResourceTransformer | train | public ResourceTransformerEntry resolveResourceTransformer(final PathAddress address, final PlaceholderResolver placeholderResolver) {
return resolveResourceTransformer(address.iterator(), null, placeholderResolver);
} | java | {
"resource": ""
} |
q2560 | OperationTransformerRegistry.resolveOperationTransformer | train | public OperationTransformerEntry resolveOperationTransformer(final PathAddress address, final String operationName, PlaceholderResolver placeholderResolver) {
final Iterator<PathElement> iterator = address.iterator();
final OperationTransformerEntry entry = resolveOperationTransformer(iterator, operationName, placeholderResolver);
if(entry != null) {
return entry;
}
// Default is forward unchanged
return FORWARD;
} | java | {
"resource": ""
} |
q2561 | OperationTransformerRegistry.mergeSubsystem | train | public void mergeSubsystem(final GlobalTransformerRegistry registry, String subsystemName, ModelVersion version) {
final PathElement element = PathElement.pathElement(SUBSYSTEM, subsystemName);
registry.mergeSubtree(this, PathAddress.EMPTY_ADDRESS.append(element), version);
} | java | {
"resource": ""
} |
q2562 | OperationTransformerRegistry.getPathTransformations | train | public List<PathAddressTransformer> getPathTransformations(final PathAddress address, PlaceholderResolver placeholderResolver) {
final List<PathAddressTransformer> list = new ArrayList<PathAddressTransformer>();
final Iterator<PathElement> iterator = address.iterator();
resolvePathTransformers(iterator, list, placeholderResolver);
if(iterator.hasNext()) {
while(iterator.hasNext()) {
iterator.next();
list.add(PathAddressTransformer.DEFAULT);
}
}
return list;
} | java | {
"resource": ""
} |
q2563 | ModificationBuilderTarget.addContentModification | train | public T addContentModification(final ContentModification modification) {
if (itemFilter.accepts(modification.getItem())) {
internalAddModification(modification);
}
return returnThis();
} | java | {
"resource": ""
} |
q2564 | ModificationBuilderTarget.addBundle | train | public T addBundle(final String moduleName, final String slot, final byte[] newHash) {
final ContentItem item = createBundleItem(moduleName, slot, newHash);
addContentModification(createContentModification(item, ModificationType.ADD, NO_CONTENT));
return returnThis();
} | java | {
"resource": ""
} |
q2565 | ModificationBuilderTarget.modifyBundle | train | public T modifyBundle(final String moduleName, final String slot, final byte[] existingHash, final byte[] newHash) {
final ContentItem item = createBundleItem(moduleName, slot, newHash);
addContentModification(createContentModification(item, ModificationType.MODIFY, existingHash));
return returnThis();
} | java | {
"resource": ""
} |
q2566 | ModificationBuilderTarget.removeBundle | train | public T removeBundle(final String moduleName, final String slot, final byte[] existingHash) {
final ContentItem item = createBundleItem(moduleName, slot, NO_CONTENT);
addContentModification(createContentModification(item, ModificationType.REMOVE, existingHash));
return returnThis();
} | java | {
"resource": ""
} |
q2567 | ModificationBuilderTarget.addFile | train | public T addFile(final String name, final List<String> path, final byte[] newHash, final boolean isDirectory) {
return addFile(name, path, newHash, isDirectory, null);
} | java | {
"resource": ""
} |
q2568 | ModificationBuilderTarget.modifyFile | train | public T modifyFile(final String name, final List<String> path, final byte[] existingHash, final byte[] newHash, final boolean isDirectory) {
return modifyFile(name, path, existingHash, newHash, isDirectory, null);
} | java | {
"resource": ""
} |
q2569 | ModificationBuilderTarget.removeFile | train | public T removeFile(final String name, final List<String> path, final byte[] existingHash, final boolean isDirectory) {
return removeFile(name, path, existingHash, isDirectory, null);
} | java | {
"resource": ""
} |
q2570 | ModificationBuilderTarget.addModule | train | public T addModule(final String moduleName, final String slot, final byte[] newHash) {
final ContentItem item = createModuleItem(moduleName, slot, newHash);
addContentModification(createContentModification(item, ModificationType.ADD, NO_CONTENT));
return returnThis();
} | java | {
"resource": ""
} |
q2571 | ModificationBuilderTarget.modifyModule | train | public T modifyModule(final String moduleName, final String slot, final byte[] existingHash, final byte[] newHash) {
final ContentItem item = createModuleItem(moduleName, slot, newHash);
addContentModification(createContentModification(item, ModificationType.MODIFY, existingHash));
return returnThis();
} | java | {
"resource": ""
} |
q2572 | ModificationBuilderTarget.removeModule | train | public T removeModule(final String moduleName, final String slot, final byte[] existingHash) {
final ContentItem item = createModuleItem(moduleName, slot, NO_CONTENT);
addContentModification(createContentModification(item, ModificationType.REMOVE, existingHash));
return returnThis();
} | java | {
"resource": ""
} |
q2573 | LoggerOperations.getLogManagerLoggerName | train | private static String getLogManagerLoggerName(final String name) {
return (name.equals(RESOURCE_NAME) ? CommonAttributes.ROOT_LOGGER_NAME : name);
} | java | {
"resource": ""
} |
q2574 | ParseUtils.unexpectedEndElement | train | public static XMLStreamException unexpectedEndElement(final XMLExtendedStreamReader reader) {
return ControllerLogger.ROOT_LOGGER.unexpectedEndElement(reader.getName(), reader.getLocation());
} | java | {
"resource": ""
} |
q2575 | ParseUtils.missingRequiredElement | train | public static XMLStreamException missingRequiredElement(final XMLExtendedStreamReader reader, final Set<?> required) {
final StringBuilder b = new StringBuilder();
Iterator<?> iterator = required.iterator();
while (iterator.hasNext()) {
final Object o = iterator.next();
b.append(o.toString());
if (iterator.hasNext()) {
b.append(", ");
}
}
final XMLStreamException ex = ControllerLogger.ROOT_LOGGER.missingRequiredElements(b, reader.getLocation());
Set<String> set = new HashSet<>();
for (Object o : required) {
String toString = o.toString();
set.add(toString);
}
return new XMLStreamValidationException(ex.getMessage(),
ValidationError.from(ex, ErrorType.REQUIRED_ELEMENTS_MISSING)
.element(reader.getName())
.alternatives(set),
ex);
} | java | {
"resource": ""
} |
q2576 | ParseUtils.requireNamespace | train | public static void requireNamespace(final XMLExtendedStreamReader reader, final Namespace requiredNs) throws XMLStreamException {
Namespace actualNs = Namespace.forUri(reader.getNamespaceURI());
if (actualNs != requiredNs) {
throw unexpectedElement(reader);
}
} | java | {
"resource": ""
} |
q2577 | ParseUtils.readBooleanAttributeElement | train | public static boolean readBooleanAttributeElement(final XMLExtendedStreamReader reader, final String attributeName)
throws XMLStreamException {
requireSingleAttribute(reader, attributeName);
final boolean value = Boolean.parseBoolean(reader.getAttributeValue(0));
requireNoContent(reader);
return value;
} | java | {
"resource": ""
} |
q2578 | ParseUtils.readListAttributeElement | train | @SuppressWarnings({"unchecked", "WeakerAccess"})
public static <T> List<T> readListAttributeElement(final XMLExtendedStreamReader reader, final String attributeName,
final Class<T> type) throws XMLStreamException {
requireSingleAttribute(reader, attributeName);
// todo: fix this when this method signature is corrected
final List<T> value = (List<T>) reader.getListAttributeValue(0, type);
requireNoContent(reader);
return value;
} | java | {
"resource": ""
} |
q2579 | ParseUtils.readArrayAttributeElement | train | @SuppressWarnings({ "unchecked" })
public static <T> T[] readArrayAttributeElement(final XMLExtendedStreamReader reader, final String attributeName,
final Class<T> type) throws XMLStreamException {
final List<T> list = readListAttributeElement(reader, attributeName, type);
return list.toArray((T[]) Array.newInstance(type, list.size()));
} | java | {
"resource": ""
} |
q2580 | ObjectTypeAttributeDefinition.resolveValue | train | @Override
public ModelNode resolveValue(ExpressionResolver resolver, ModelNode value) throws OperationFailedException {
// Pass non-OBJECT values through the superclass so it can reject weird values and, in the odd chance
// that's how this object is set up, turn undefined into a default list value.
ModelNode superResult = value.getType() == ModelType.OBJECT ? value : super.resolveValue(resolver, value);
// If it's not an OBJECT (almost certainly UNDEFINED), then nothing more we can do
if (superResult.getType() != ModelType.OBJECT) {
return superResult;
}
// Resolve each field.
// Don't mess with the original value
ModelNode clone = superResult == value ? value.clone() : superResult;
ModelNode result = new ModelNode();
for (AttributeDefinition field : valueTypes) {
String fieldName = field.getName();
if (clone.has(fieldName)) {
result.get(fieldName).set(field.resolveValue(resolver, clone.get(fieldName)));
} else {
// Input doesn't have a child for this field.
// Don't create one in the output unless the AD produces a default value.
// TBH this doesn't make a ton of sense, since any object should have
// all of its fields, just some may be undefined. But doing it this
// way may avoid breaking some code that is incorrectly checking node.has("xxx")
// instead of node.hasDefined("xxx")
ModelNode val = field.resolveValue(resolver, new ModelNode());
if (val.isDefined()) {
result.get(fieldName).set(val);
}
}
}
// Validate the entire object
getValidator().validateParameter(getName(), result);
return result;
} | java | {
"resource": ""
} |
q2581 | ResponseAttachmentInputStreamSupport.handleDomainOperationResponseStreams | train | public static void handleDomainOperationResponseStreams(final OperationContext context,
final ModelNode responseNode,
final List<OperationResponse.StreamEntry> streams) {
if (responseNode.hasDefined(RESPONSE_HEADERS)) {
ModelNode responseHeaders = responseNode.get(RESPONSE_HEADERS);
// Strip out any stream header as the header created by this process is what counts
responseHeaders.remove(ATTACHED_STREAMS);
if (responseHeaders.asInt() == 0) {
responseNode.remove(RESPONSE_HEADERS);
}
}
for (OperationResponse.StreamEntry streamEntry : streams) {
context.attachResultStream(streamEntry.getUUID(), streamEntry.getMimeType(), streamEntry.getStream());
}
} | java | {
"resource": ""
} |
q2582 | ResponseAttachmentInputStreamSupport.shutdown | train | public final synchronized void shutdown() { // synchronize on 'this' to avoid races with registerStreams
stopped = true;
// If the cleanup task is running tell it to stop looping, and then remove it from the scheduled executor
if (cleanupTaskFuture != null) {
cleanupTaskFuture.cancel(false);
}
// Close remaining streams
for (Map.Entry<InputStreamKey, TimedStreamEntry> entry : streamMap.entrySet()) {
InputStreamKey key = entry.getKey();
TimedStreamEntry timedStreamEntry = entry.getValue();
//noinspection SynchronizationOnLocalVariableOrMethodParameter
synchronized (timedStreamEntry) { // ensure there's no race with a request that got a ref before we removed it
closeStreamEntry(timedStreamEntry, key.requestId, key.index);
}
}
} | java | {
"resource": ""
} |
q2583 | ResponseAttachmentInputStreamSupport.gc | train | void gc() {
if (stopped) {
return;
}
long expirationTime = System.currentTimeMillis() - timeout;
for (Iterator<Map.Entry<InputStreamKey, TimedStreamEntry>> iter = streamMap.entrySet().iterator(); iter.hasNext();) {
if (stopped) {
return;
}
Map.Entry<InputStreamKey, TimedStreamEntry> entry = iter.next();
TimedStreamEntry timedStreamEntry = entry.getValue();
if (timedStreamEntry.timestamp.get() <= expirationTime) {
iter.remove();
InputStreamKey key = entry.getKey();
//noinspection SynchronizationOnLocalVariableOrMethodParameter
synchronized (timedStreamEntry) { // ensure there's no race with a request that got a ref before we removed it
closeStreamEntry(timedStreamEntry, key.requestId, key.index);
}
}
}
} | java | {
"resource": ""
} |
q2584 | SecurityManagerSubsystemAdd.retrievePermissionSet | train | private List<PermissionFactory> retrievePermissionSet(final OperationContext context, final ModelNode node) throws OperationFailedException {
final List<PermissionFactory> permissions = new ArrayList<>();
if (node != null && node.isDefined()) {
for (ModelNode permissionNode : node.asList()) {
String permissionClass = CLASS.resolveModelAttribute(context, permissionNode).asString();
String permissionName = null;
if (permissionNode.hasDefined(PERMISSION_NAME))
permissionName = NAME.resolveModelAttribute(context, permissionNode).asString();
String permissionActions = null;
if (permissionNode.hasDefined(PERMISSION_ACTIONS))
permissionActions = ACTIONS.resolveModelAttribute(context, permissionNode).asString();
String moduleName = null;
if(permissionNode.hasDefined(PERMISSION_MODULE)) {
moduleName = MODULE.resolveModelAttribute(context, permissionNode).asString();
}
ClassLoader cl = WildFlySecurityManager.getClassLoaderPrivileged(this.getClass());
if(moduleName != null) {
try {
cl = Module.getBootModuleLoader().loadModule(ModuleIdentifier.fromString(moduleName)).getClassLoader();
} catch (ModuleLoadException e) {
throw new OperationFailedException(e);
}
}
permissions.add(new LoadedPermissionFactory(cl,
permissionClass, permissionName, permissionActions));
}
}
return permissions;
} | java | {
"resource": ""
} |
q2585 | DeploymentScannerService.addService | train | public static ServiceController<DeploymentScanner> addService(final OperationContext context, final PathAddress resourceAddress, final String relativeTo, final String path,
final int scanInterval, TimeUnit unit, final boolean autoDeployZip,
final boolean autoDeployExploded, final boolean autoDeployXml, final boolean scanEnabled, final long deploymentTimeout, boolean rollbackOnRuntimeFailure,
final FileSystemDeploymentService bootTimeService, final ScheduledExecutorService scheduledExecutorService) {
final DeploymentScannerService service = new DeploymentScannerService(resourceAddress, relativeTo, path, scanInterval, unit, autoDeployZip,
autoDeployExploded, autoDeployXml, scanEnabled, deploymentTimeout, rollbackOnRuntimeFailure, bootTimeService);
final ServiceName serviceName = getServiceName(resourceAddress.getLastElement().getValue());
service.scheduledExecutorValue.inject(scheduledExecutorService);
final ServiceBuilder<DeploymentScanner> sb = context.getServiceTarget().addService(serviceName, service);
sb.addDependency(context.getCapabilityServiceName(PATH_MANAGER_CAPABILITY, PathManager.class), PathManager.class, service.pathManagerValue);
sb.addDependency(context.getCapabilityServiceName("org.wildfly.management.notification-handler-registry", null),
NotificationHandlerRegistry.class, service.notificationRegistryValue);
sb.addDependency(context.getCapabilityServiceName("org.wildfly.management.model-controller-client-factory", null),
ModelControllerClientFactory.class, service.clientFactoryValue);
sb.requires(org.jboss.as.server.deployment.Services.JBOSS_DEPLOYMENT_CHAINS);
sb.addDependency(ControlledProcessStateService.SERVICE_NAME, ControlledProcessStateService.class, service.controlledProcessStateServiceValue);
return sb.install();
} | java | {
"resource": ""
} |
q2586 | ManagementModel.findNode | train | public ManagementModelNode findNode(String address) {
ManagementModelNode root = (ManagementModelNode)tree.getModel().getRoot();
Enumeration<javax.swing.tree.TreeNode> allNodes = root.depthFirstEnumeration();
while (allNodes.hasMoreElements()) {
ManagementModelNode node = (ManagementModelNode)allNodes.nextElement();
if (node.addressPath().equals(address)) return node;
}
return null;
} | java | {
"resource": ""
} |
q2587 | ManagementModel.getSelectedNode | train | public ManagementModelNode getSelectedNode() {
if (tree.getSelectionPath() == null) return null;
return (ManagementModelNode)tree.getSelectionPath().getLastPathComponent();
} | java | {
"resource": ""
} |
q2588 | ProtocolConnectionUtils.connectSync | train | public static Connection connectSync(final ProtocolConnectionConfiguration configuration) throws IOException {
long timeoutMillis = configuration.getConnectionTimeout();
CallbackHandler handler = configuration.getCallbackHandler();
final CallbackHandler actualHandler;
ProtocolTimeoutHandler timeoutHandler = configuration.getTimeoutHandler();
// Note: If a client supplies a ProtocolTimeoutHandler it is taking on full responsibility for timeout management.
if (timeoutHandler == null) {
GeneralTimeoutHandler defaultTimeoutHandler = new GeneralTimeoutHandler();
// No point wrapping our AnonymousCallbackHandler.
actualHandler = handler != null ? new WrapperCallbackHandler(defaultTimeoutHandler, handler) : null;
timeoutHandler = defaultTimeoutHandler;
} else {
actualHandler = handler;
}
final IoFuture<Connection> future = connect(actualHandler, configuration);
IoFuture.Status status = timeoutHandler.await(future, timeoutMillis);
if (status == IoFuture.Status.DONE) {
return future.get();
}
if (status == IoFuture.Status.FAILED) {
throw ProtocolLogger.ROOT_LOGGER.failedToConnect(configuration.getUri(), future.getException());
}
throw ProtocolLogger.ROOT_LOGGER.couldNotConnect(configuration.getUri());
} | java | {
"resource": ""
} |
q2589 | CLITerminalConnection.openBlockingInterruptable | train | public void openBlockingInterruptable()
throws InterruptedException {
// We need to thread this call in order to interrupt it (when Ctrl-C occurs).
connectionThread = new Thread(() -> {
// This thread can't be interrupted from another thread.
// Will stay alive until System.exit is called.
Thread thr = new Thread(() -> super.openBlocking(),
"CLI Terminal Connection (uninterruptable)");
thr.start();
try {
thr.join();
} catch (InterruptedException ex) {
// XXX OK, interrupted, just leaving.
}
}, "CLI Terminal Connection (interruptable)");
connectionThread.start();
connectionThread.join();
} | java | {
"resource": ""
} |
q2590 | ManagementProtocolHeader.validateSignature | train | protected static void validateSignature(final DataInput input) throws IOException {
final byte[] signatureBytes = new byte[4];
input.readFully(signatureBytes);
if (!Arrays.equals(ManagementProtocol.SIGNATURE, signatureBytes)) {
throw ProtocolLogger.ROOT_LOGGER.invalidSignature(Arrays.toString(signatureBytes));
}
} | java | {
"resource": ""
} |
q2591 | ManagementProtocolHeader.parse | train | public static ManagementProtocolHeader parse(DataInput input) throws IOException {
validateSignature(input);
expectHeader(input, ManagementProtocol.VERSION_FIELD);
int version = input.readInt();
expectHeader(input, ManagementProtocol.TYPE);
byte type = input.readByte();
switch (type) {
case ManagementProtocol.TYPE_REQUEST:
return new ManagementRequestHeader(version, input);
case ManagementProtocol.TYPE_RESPONSE:
return new ManagementResponseHeader(version, input);
case ManagementProtocol.TYPE_BYE_BYE:
return new ManagementByeByeHeader(version);
case ManagementProtocol.TYPE_PING:
return new ManagementPingHeader(version);
case ManagementProtocol.TYPE_PONG:
return new ManagementPongHeader(version);
default:
throw ProtocolLogger.ROOT_LOGGER.invalidType("0x" + Integer.toHexString(type));
}
} | java | {
"resource": ""
} |
q2592 | SimplePasswordStrengthChecker.checkConsecutiveAlpha | train | protected void checkConsecutiveAlpha() {
Pattern symbolsPatter = Pattern.compile(REGEX_ALPHA_UC + "+");
Matcher matcher = symbolsPatter.matcher(this.password);
int met = 0;
while (matcher.find()) {
int start = matcher.start();
int end = matcher.end();
if (start == end) {
continue;
}
int diff = end - start;
if (diff >= 3) {
met += diff;
}
}
this.result.negative(met * CONSECUTIVE_ALPHA_WEIGHT);
// alpha lower case
symbolsPatter = Pattern.compile(REGEX_ALPHA_LC + "+");
matcher = symbolsPatter.matcher(this.password);
met = 0;
while (matcher.find()) {
int start = matcher.start();
int end = matcher.end();
if (start == end) {
continue;
}
int diff = end - start;
if (diff >= 3) {
met += diff;
}
}
this.result.negative(met * CONSECUTIVE_ALPHA_WEIGHT);
} | java | {
"resource": ""
} |
q2593 | ManagedServerOperationsFactory.createBootUpdates | train | public static ModelNode createBootUpdates(final String serverName, final ModelNode domainModel, final ModelNode hostModel,
final DomainController domainController, final ExpressionResolver expressionResolver) {
final ManagedServerOperationsFactory factory = new ManagedServerOperationsFactory(serverName, domainModel,
hostModel, domainController, expressionResolver);
return factory.getBootUpdates();
} | java | {
"resource": ""
} |
q2594 | HostServerGroupTracker.getMappableDomainEffect | train | private synchronized HostServerGroupEffect getMappableDomainEffect(PathAddress address, String key,
Map<String, Set<String>> map, Resource root) {
if (requiresMapping) {
map(root);
requiresMapping = false;
}
Set<String> mapped = map.get(key);
return mapped != null ? HostServerGroupEffect.forDomain(address, mapped)
: HostServerGroupEffect.forUnassignedDomain(address);
} | java | {
"resource": ""
} |
q2595 | HostServerGroupTracker.getHostEffect | train | private synchronized HostServerGroupEffect getHostEffect(PathAddress address, String host, Resource root) {
if (requiresMapping) {
map(root);
requiresMapping = false;
}
Set<String> mapped = hostsToGroups.get(host);
if (mapped == null) {
// Unassigned host. Treat like an unassigned profile or socket-binding-group;
// i.e. available to all server group scoped roles.
// Except -- WFLY-2085 -- the master HC is not open to all s-g-s-rs
Resource hostResource = root.getChild(PathElement.pathElement(HOST, host));
if (hostResource != null) {
ModelNode dcModel = hostResource.getModel().get(DOMAIN_CONTROLLER);
if (!dcModel.hasDefined(REMOTE)) {
mapped = Collections.emptySet(); // prevents returning HostServerGroupEffect.forUnassignedHost(address, host)
}
}
}
return mapped == null ? HostServerGroupEffect.forUnassignedHost(address, host)
: HostServerGroupEffect.forMappedHost(address, mapped, host);
} | java | {
"resource": ""
} |
q2596 | HostServerGroupTracker.map | train | private void map(Resource root) {
for (Resource.ResourceEntry serverGroup : root.getChildren(SERVER_GROUP)) {
String serverGroupName = serverGroup.getName();
ModelNode serverGroupModel = serverGroup.getModel();
String profile = serverGroupModel.require(PROFILE).asString();
store(serverGroupName, profile, profilesToGroups);
String socketBindingGroup = serverGroupModel.require(SOCKET_BINDING_GROUP).asString();
store(serverGroupName, socketBindingGroup, socketsToGroups);
for (Resource.ResourceEntry deployment : serverGroup.getChildren(DEPLOYMENT)) {
store(serverGroupName, deployment.getName(), deploymentsToGroups);
}
for (Resource.ResourceEntry overlay : serverGroup.getChildren(DEPLOYMENT_OVERLAY)) {
store(serverGroupName, overlay.getName(), overlaysToGroups);
}
}
for (Resource.ResourceEntry host : root.getChildren(HOST)) {
String hostName = host.getPathElement().getValue();
for (Resource.ResourceEntry serverConfig : host.getChildren(SERVER_CONFIG)) {
ModelNode serverConfigModel = serverConfig.getModel();
String serverGroupName = serverConfigModel.require(GROUP).asString();
store(serverGroupName, hostName, hostsToGroups);
}
}
} | java | {
"resource": ""
} |
q2597 | LegacyResourceDefinition.registerAttributes | train | @Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
for (AttributeAccess attr : attributes.values()) {
resourceRegistration.registerReadOnlyAttribute(attr.getAttributeDefinition(), null);
}
} | java | {
"resource": ""
} |
q2598 | LegacyResourceDefinition.registerChildren | train | @Override
public void registerChildren(ManagementResourceRegistration resourceRegistration) {
// Register wildcard children last to prevent duplicate registration errors when override definitions exist
for (ResourceDefinition rd : singletonChildren) {
resourceRegistration.registerSubModel(rd);
}
for (ResourceDefinition rd : wildcardChildren) {
resourceRegistration.registerSubModel(rd);
}
} | java | {
"resource": ""
} |
q2599 | ManagementRemotingServices.installDomainConnectorServices | train | public static void installDomainConnectorServices(final OperationContext context,
final ServiceTarget serviceTarget,
final ServiceName endpointName,
final ServiceName networkInterfaceBinding,
final int port,
final OptionMap options,
final ServiceName securityRealm,
final ServiceName saslAuthenticationFactory,
final ServiceName sslContext) {
String sbmCap = "org.wildfly.management.socket-binding-manager";
ServiceName sbmName = context.hasOptionalCapability(sbmCap, NATIVE_MANAGEMENT_RUNTIME_CAPABILITY.getName(), null)
? context.getCapabilityServiceName(sbmCap, SocketBindingManager.class) : null;
installConnectorServicesForNetworkInterfaceBinding(serviceTarget, endpointName, MANAGEMENT_CONNECTOR,
networkInterfaceBinding, port, options, securityRealm, saslAuthenticationFactory, sslContext, sbmName);
} | java | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.