code
stringlengths
73
34.1k
label
stringclasses
1 value
private Set<String> checkModel(final ModelNode model, TransformationContext context) throws OperationFailedException { final Set<String> attributes = new HashSet<String>(); AttributeTransformationRequirementChecker checker; for (final String attribute : attributeNames) { if (model.ha...
java
public void setValue(String propName, Object value) { for (RequestProp prop : props) { if (prop.getName().equals(propName)) { JComponent valComp = prop.getValueComponent(); if (valComp instanceof JTextComponent) { ((JTextComponent)valComp).setText(...
java
static void doDifference( Map<String, String> left, Map<String, String> right, Map<String, String> onlyOnLeft, Map<String, String> onlyOnRight, Map<String, String> updated ) { onlyOnRight.clear(); onlyOnRight.putAll(right); for (Map...
java
public void close() throws IOException { final ManagedBinding binding = this.socketBindingManager.getNamedRegistry().getManagedBinding(this.name); if (binding == null) { return; } binding.close(); }
java
public static boolean requiresReload(final Set<Flag> flags) { return flags.contains(Flag.RESTART_ALL_SERVICES) || flags.contains(Flag.RESTART_RESOURCE_SERVICES); }
java
@Override protected void updateState(final String name, final InstallationModificationImpl modification, final InstallationModificationImpl.InstallationState state) { final PatchableTarget.TargetInfo identityInfo = modification.getModifiedState(); this.identity = new Identity() { @Overri...
java
public static Set<String> listAllLinks(OperationContext context, String overlay) { Set<String> serverGoupNames = listServerGroupsReferencingOverlay(context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS), overlay); Set<String> links = new HashSet<>(); for (String serverGoupName : serverGoupNames...
java
public static Set<String> listLinks(OperationContext context, PathAddress overlayAddress) { Resource overlayResource = context.readResourceFromRoot(overlayAddress); if (overlayResource.hasChildren(DEPLOYMENT)) { return overlayResource.getChildrenNames(DEPLOYMENT); } return Co...
java
public static void redeployDeployments(OperationContext context, PathAddress deploymentsRootAddress, Set<String> deploymentNames) throws OperationFailedException { for (String deploymentName : deploymentNames) { PathAddress address = deploymentsRootAddress.append(DEPLOYMENT, deploymentName); ...
java
public static void redeployLinksAndTransformOperation(OperationContext context, ModelNode removeOperation, PathAddress deploymentsRootAddress, Set<String> runtimeNames) throws OperationFailedException { Set<String> deploymentNames = listDeployments(context.readResourceFromRoot(deploymentsRootAddress), runtimeNa...
java
public static Set<String> listDeployments(Resource deploymentRootResource, Set<String> runtimeNames) { Set<Pattern> set = new HashSet<>(); for (String wildcardExpr : runtimeNames) { Pattern pattern = DeploymentOverlayIndex.getPattern(wildcardExpr); set.add(pattern); ...
java
public void execute(CommandHandler handler, int timeout, TimeUnit unit) throws CommandLineException, InterruptedException, ExecutionException, TimeoutException { ExecutableBuilder builder = new ExecutableBuilder() { CommandContext c = newTimeoutCommand...
java
void execute(ExecutableBuilder builder, int timeout, TimeUnit unit) throws CommandLineException, InterruptedException, ExecutionException, TimeoutException { Future<Void> task = executorService.submit(() -> { builder.build().execute(); retu...
java
public String getOriginalValue(ParsedCommandLine parsedLine, boolean required) throws CommandFormatException { String value = null; if(parsedLine.hasProperties()) { if(index >= 0) { List<String> others = parsedLine.getOtherProperties(); if(others.size() > inde...
java
public static void logBeforeExit(ExitLogger logger) { try { if (logged.compareAndSet(false, true)) { logger.logExit(); } } catch (Throwable ignored){ // ignored } }
java
private String getName(CommandContext ctx, boolean failInBatch) throws CommandLineException { final ParsedCommandLine args = ctx.getParsedCommandLine(); final String name = this.name.getValue(args, true); if (name == null) { throw new CommandFormatException(this.name + " is missing v...
java
public static ServiceName moduleSpecServiceName(ModuleIdentifier identifier) { if (!isDynamicModule(identifier)) { throw ServerLogger.ROOT_LOGGER.missingModulePrefix(identifier, MODULE_PREFIX); } return MODULE_SPEC_SERVICE_PREFIX.append(identifier.getName()).append(identifier.getSlot...
java
public static ServiceName moduleResolvedServiceName(ModuleIdentifier identifier) { if (!isDynamicModule(identifier)) { throw ServerLogger.ROOT_LOGGER.missingModulePrefix(identifier, MODULE_PREFIX); } return MODULE_RESOLVED_SERVICE_PREFIX.append(identifier.getName()).append(identifier...
java
public static ServiceName moduleServiceName(ModuleIdentifier identifier) { if (!identifier.getName().startsWith(MODULE_PREFIX)) { throw ServerLogger.ROOT_LOGGER.missingModulePrefix(identifier, MODULE_PREFIX); } return MODULE_SERVICE_PREFIX.append(identifier.getName()).append(identifi...
java
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); final ServicesAttachment servicesAttachment = deploymentUnit.getAttachment(Attachments.SERVICES); if (servicesAttachment == n...
java
synchronized void openConnection(final ModelController controller, final ActiveOperation.CompletedCallback<ModelNode> callback) throws Exception { boolean ok = false; final Connection connection = connectionManager.connect(); try { channelHandler.executeRequest(new ServerRegisterRequ...
java
synchronized void asyncReconnect(final URI reconnectUri, String authKey, final ReconnectCallback callback) { if (getState() != State.OPEN) { return; } // Update the configuration with the new credentials final ProtocolConnectionConfiguration config = ProtocolConnectionConfigu...
java
synchronized boolean doReConnect() throws IOException { // In case we are still connected, test the connection and see if we can reuse it if(connectionManager.isConnected()) { try { final Future<Long> result = channelHandler.executeRequest(ManagementPingRequest.INSTANCE, nul...
java
synchronized void started() { try { if(isConnected()) { channelHandler.executeRequest(new ServerStartedRequest(), null).getResult().await(); } } catch (Exception e) { ServerLogger.AS_ROOT_LOGGER.debugf(e, "failed to send started notification"); ...
java
public int executeTask(final TransactionalProtocolClient.TransactionalOperationListener<ServerOperation> listener, final ServerUpdateTask task) { try { return execute(listener, task.getServerIdentity(), task.getOperation()); } catch (OperationFailedException e) { // Handle failur...
java
protected boolean executeOperation(final TransactionalProtocolClient.TransactionalOperationListener<ServerOperation> listener, TransactionalProtocolClient client, final ServerIdentity identity, final ModelNode operation, final OperationResultTransformer transformer) { if(client == null) { return fal...
java
void recordPreparedOperation(final TransactionalProtocolClient.PreparedOperation<ServerTaskExecutor.ServerOperation> preparedOperation) { recordPreparedTask(new ServerTaskExecutor.ServerPreparedResponse(preparedOperation)); }
java
void recordOperationPrepareTimeout(final BlockingQueueOperationListener.FailedOperation<ServerOperation> failedOperation) { recordPreparedTask(new ServerTaskExecutor.ServerPreparedResponse(failedOperation)); // Swap out the submitted task so we don't wait for the final result. Use a future the returns ...
java
public static ServiceController<InstallationManager> installService(ServiceTarget serviceTarget) { final InstallationManagerService service = new InstallationManagerService(); return serviceTarget.addService(InstallationManagerService.NAME, service) .addDependency(JBOSS_PRODUCT_CONFIG_SE...
java
public Method getMethod(Method method) { return getMethod(method.getReturnType(), method.getName(), method.getParameterTypes()); }
java
public Collection<Method> getAllMethods(String name) { final Map<ParamList, Map<Class<?>, Method>> nameMap = methods.get(name); if (nameMap == null) { return Collections.emptySet(); } final Collection<Method> methods = new ArrayList<Method>(); for (Map<Class<?>, Metho...
java
public Collection<Method> getAllMethods(String name, int paramCount) { final Map<ParamList, Map<Class<?>, Method>> nameMap = methods.get(name); if (nameMap == null) { return Collections.emptySet(); } final Collection<Method> methods = new ArrayList<Method>(); for (Map...
java
public static ServiceActivator create(final ModelNode endpointConfig, final URI managementURI, final String serverName, final String serverProcessName, final String authKey, final boolean managementSubsystemEndpoint, final Supplier<SSLContext> sslContextSupplier) { ret...
java
public InetSocketAddress getMulticastSocketAddress() { if (multicastAddress == null) { throw MESSAGES.noMulticastBinding(name); } return new InetSocketAddress(multicastAddress, multicastPort); }
java
public ServerSocket createServerSocket() throws IOException { final ServerSocket socket = getServerSocketFactory().createServerSocket(name); socket.bind(getSocketAddress()); return socket; }
java
public static void registerDeploymentResource(final DeploymentResourceSupport deploymentResourceSupport, final LoggingConfigurationService service) { final PathElement base = PathElement.pathElement("configuration", service.getConfiguration()); deploymentResourceSupport.getDeploymentSubModel(LoggingExte...
java
public static String constructUrl(final HttpServerExchange exchange, final String path) { final HeaderMap headers = exchange.getRequestHeaders(); String host = headers.getFirst(HOST); String protocol = exchange.getConnection().getSslSessionInfo() != null ? "https" : "http"; return proto...
java
public boolean matches(Property property) { return property.getName().equals(key) && (value == WILDCARD_VALUE || property.getValue().asString().equals(value)); }
java
public boolean matches(PathElement pe) { return pe.key.equals(key) && (isWildcard() || pe.value.equals(value)); }
java
public void setAppender(final Appender appender) { if (this.appender != null) { close(); } checkAccess(this); if (applyLayout && appender != null) { final Formatter formatter = getFormatter(); appender.setLayout(formatter == null ? null : new Formatter...
java
private ModelNode createOSNode() throws OperationFailedException { String osName = getProperty("os.name"); final ModelNode os = new ModelNode(); if (osName != null && osName.toLowerCase().contains("linux")) { try { os.set(GnuLinuxDistribution.discover()); ...
java
private ModelNode createJVMNode() throws OperationFailedException { ModelNode jvm = new ModelNode().setEmptyObject(); jvm.get(NAME).set(getProperty("java.vm.name")); jvm.get(JAVA_VERSION).set(getProperty("java.vm.specification.version")); jvm.get(JVM_VERSION).set(getProperty("java.versio...
java
private ModelNode createCPUNode() throws OperationFailedException { ModelNode cpu = new ModelNode().setEmptyObject(); cpu.get(ARCH).set(getProperty("os.arch")); cpu.get(AVAILABLE_PROCESSORS).set(ProcessorInfo.availableProcessors()); return cpu; }
java
private String getProperty(String name) { return System.getSecurityManager() == null ? System.getProperty(name) : doPrivileged(new ReadPropertyAction(name)); }
java
public void explore() { if (isLeaf) return; if (isGeneric) return; removeAllChildren(); try { String addressPath = addressPath(); ModelNode resourceDesc = executor.doCommand(addressPath + ":read-resource-description"); resourceDesc = resourceDesc.get(...
java
public String addressPath() { if (isLeaf) { ManagementModelNode parent = (ManagementModelNode)getParent(); return parent.addressPath(); } StringBuilder builder = new StringBuilder(); for (Object pathElement : getUserObjectPath()) { UserObject userObj ...
java
private static boolean mayBeIPv6Address(String input) { if (input == null) { return false; } boolean result = false; int colonsCounter = 0; int length = input.length(); for (int i = 0; i < length; i++) { char c = input.charAt(i); if (c...
java
public static void initializeDomainRegistry(final TransformerRegistry registry) { //The chains for transforming will be as follows //For JBoss EAP: 8.0.0 -> 5.0.0 -> 4.0.0 -> 1.8.0 -> 1.7.0 -> 1.6.0 -> 1.5.0 registerRootTransformers(registry); registerChainedManagementTransformers(regi...
java
static boolean killProcess(final String processName, int id) { int pid; try { pid = processUtils.resolveProcessId(processName, id); if(pid > 0) { try { Runtime.getRuntime().exec(processUtils.getKillCommand(pid)); return true...
java
public Launcher addEnvironmentVariable(final String key, final String value) { env.put(key, value); return this; }
java
private void buildTransformers_3_0(ResourceTransformationDescriptionBuilder builder) { /* ====== Resource root address: ["subsystem" => "remoting"] - Current version: 4.0.0; legacy version: 3.0.0 ======= --- Problems for relative address to root ["configuration" => "endpoint"]: Different...
java
private void buildTransformers_4_0(ResourceTransformationDescriptionBuilder builder) { // We need to do custom transformation of the attribute in the root resource // related to endpoint configs, as these were moved to the root from a previous child resource EndPointWriteTransformer endPointWri...
java
ServerStatus getState() { final InternalState requiredState = this.requiredState; final InternalState state = internalState; if(requiredState == InternalState.FAILED) { return ServerStatus.FAILED; } switch (state) { case STOPPED: return Ser...
java
synchronized boolean reload(int permit, boolean suspend) { return internalSetState(new ReloadTask(permit, suspend), InternalState.SERVER_STARTED, InternalState.RELOADING); }
java
synchronized void start(final ManagedServerBootCmdFactory factory) { final InternalState required = this.requiredState; // Ignore if the server is already started if(required == InternalState.SERVER_STARTED) { return; } // In case the server failed to start, try to st...
java
synchronized void stop(Integer timeout) { final InternalState required = this.requiredState; if(required != InternalState.STOPPED) { this.requiredState = InternalState.STOPPED; ROOT_LOGGER.stoppingServer(serverName); // Only send the stop operation if the server is st...
java
synchronized void reconnectServerProcess(final ManagedServerBootCmdFactory factory) { if(this.requiredState != InternalState.SERVER_STARTED) { this.bootConfiguration = factory; this.requiredState = InternalState.SERVER_STARTED; ROOT_LOGGER.reconnectingServer(serverName); ...
java
synchronized void removeServerProcess() { this.requiredState = InternalState.STOPPED; internalSetState(new ProcessRemoveTask(), InternalState.STOPPED, InternalState.PROCESS_REMOVING); }
java
synchronized void setServerProcessStopping() { this.requiredState = InternalState.STOPPED; internalSetState(null, InternalState.STOPPED, InternalState.PROCESS_STOPPING); }
java
boolean awaitState(final InternalState expected) { synchronized (this) { final InternalState initialRequired = this.requiredState; for(;;) { final InternalState required = this.requiredState; // Stop in case the server failed to reach the state ...
java
boolean processUnstable() { boolean change = !unstable; if (change) { // Only once until the process is removed. A process is unstable until removed. unstable = true; HostControllerLogger.ROOT_LOGGER.managedServerUnstable(serverName); } return change; }
java
boolean callbackUnregistered(final TransactionalProtocolClient old, final boolean shuttingDown) { // Disconnect the remote connection. // WFCORE-196 Do this out of the sync block to avoid deadlocks where in-flight requests can't // be informed that the channel has closed protocolClient.d...
java
synchronized void processFinished() { final InternalState required = this.requiredState; final InternalState state = this.internalState; // If the server was not stopped if(required == InternalState.STOPPED && state == InternalState.PROCESS_STOPPING) { finishTransition(Intern...
java
synchronized void transitionFailed(final InternalState state) { final InternalState current = this.internalState; if(state == current) { // Revert transition and mark as failed switch (current) { case PROCESS_ADDING: this.internalState = Intern...
java
private synchronized void finishTransition(final InternalState current, final InternalState next) { internalSetState(getTransitionTask(next), current, next); transition(); }
java
@Override public void registerCapabilities(ManagementResourceRegistration resourceRegistration) { if (capabilities!=null) { for (RuntimeCapability c : capabilities) { resourceRegistration.registerCapability(c); } } if (incorporatingCapabilities != null...
java
@Deprecated @SuppressWarnings("deprecation") protected void registerAddOperation(final ManagementResourceRegistration registration, final OperationStepHandler handler, OperationEntry.Flag... flags) { if (handler instanceof DescriptionProvider) { registration.registerOperationHandler(getOpera...
java
private static void handlePing(final Channel channel, final ManagementProtocolHeader header) throws IOException { final ManagementProtocolHeader response = new ManagementPongHeader(header.getVersion()); final MessageOutputStream output = channel.writeMessage(); try { writeHeader(resp...
java
public static String resolveOrOriginal(String input) { try { return resolve(input, true); } catch (UnresolvedExpressionException e) { return input; } }
java
private OperationResponse executeForResult(final OperationExecutionContext executionContext) throws IOException { try { return execute(executionContext).get(); } catch(Exception e) { throw new IOException(e); } }
java
public static LayersConfig getLayersConfig(final File repoRoot) throws IOException { final File layersList = new File(repoRoot, LAYERS_CONF); if (!layersList.exists()) { return new LayersConfig(); } final Properties properties = PatchUtils.loadProperties(layersList); ...
java
private boolean parseRemoteDomainControllerAttributes_1_5(final XMLExtendedStreamReader reader, final ModelNode address, final List<ModelNode> list, boolean allowDiscoveryOptions) throws XMLStreamException { final ModelNode update = new ModelNode();...
java
public static RemoteProxyController create(final TransactionalProtocolClient client, final PathAddress pathAddress, final ProxyOperationAddressTranslator addressTranslator, final ModelVersion targetKernelVersion) { ret...
java
@Deprecated public static RemoteProxyController create(final ManagementChannelHandler channelAssociation, final PathAddress pathAddress, final ProxyOperationAddressTranslator addressTranslator) { final TransactionalProtocolClient client = TransactionalProtocolHandlers.createClient(channelAssociation); ...
java
public ModelNode translateOperationForProxy(final ModelNode op) { return translateOperationForProxy(op, PathAddress.pathAddress(op.get(OP_ADDR))); }
java
private void flush(final boolean propagate) throws IOException { final int avail = baseNCodec.available(context); if (avail > 0) { final byte[] buf = new byte[avail]; final int c = baseNCodec.readResults(buf, 0, avail, context); if (c > 0) { out.write(...
java
@Override public void close() throws IOException { // Notify encoder of EOF (-1). if (doEncode) { baseNCodec.encode(singleByte, 0, EOF, context); } else { baseNCodec.decode(singleByte, 0, EOF, context); } flush(); out.close(); }
java
private ModelNode resolveExpressionsRecursively(final ModelNode node) throws OperationFailedException { if (!node.isDefined()) { return node; } ModelType type = node.getType(); ModelNode resolved; if (type == ModelType.EXPRESSION) { resolved = resolveExpr...
java
private ModelNode resolveExpressionStringRecursively(final String expressionString, final boolean ignoreDMRResolutionFailure, final boolean initial) throws OperationFailedException { ParseAndResolveResult resolved = parseAndResolve(expressionString, ignor...
java
private String resolveExpressionString(final String unresolvedString) throws OperationFailedException { // parseAndResolve should only be providing expressions with no leading or trailing chars assert unresolvedString.startsWith("${") && unresolvedString.endsWith("}"); // Default result is no ...
java
private static XMLStreamException unexpectedElement(final XMLStreamReader reader) { return SecurityManagerLogger.ROOT_LOGGER.unexpectedElement(reader.getName(), reader.getLocation()); }
java
private static XMLStreamException unexpectedAttribute(final XMLStreamReader reader, final int index) { return SecurityManagerLogger.ROOT_LOGGER.unexpectedAttribute(reader.getAttributeName(index), reader.getLocation()); }
java
public static byte[] storeContentAndTransformOperation(OperationContext context, ModelNode operation, ContentRepository contentRepository) throws IOException, OperationFailedException { if (!operation.hasDefined(CONTENT)) { throw createFailureException(DomainControllerLogger.ROOT_LOGGER.invalidConte...
java
public static byte[] explodeContentAndTransformOperation(OperationContext context, ModelNode operation, ContentRepository contentRepository) throws OperationFailedException, ExplodedContentException { final Resource deploymentResource = context.readResource(PathAddress.EMPTY_ADDRESS); ModelNode contentI...
java
public static byte[] addContentToExplodedAndTransformOperation(OperationContext context, ModelNode operation, ContentRepository contentRepository) throws OperationFailedException, ExplodedContentException { final Resource deploymentResource = context.readResource(PathAddress.EMPTY_ADDRESS); ModelNode co...
java
public static byte[] removeContentFromExplodedAndTransformOperation(OperationContext context, ModelNode operation, ContentRepository contentRepository) throws OperationFailedException, ExplodedContentException { final Resource deploymentResource = context.readResource(PathAddress.EMPTY_ADDRESS); ModelNo...
java
public static byte[] synchronizeSlaveHostController(ModelNode operation, final PathAddress address, HostFileRepository fileRepository, ContentRepository contentRepository, boolean backup, byte[] oldHash) { ModelNode operationContentItem = operation.get(DeploymentAttributes.CONTENT_RESOURCE_ALL.getName()).get(0)...
java
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); for (ResourceRoot resourceRoot : DeploymentUtils.allResourceRoots(deploymentUnit)) { ResourceRootIndexer.indexResourceRoo...
java
public static File newFile(File baseDir, String... segments) { File f = baseDir; for (String segment : segments) { f = new File(f, segment); } return f; }
java
public PasswordCheckResult check(boolean isAdminitrative, String userName, String password) { // TODO: allow custom restrictions? List<PasswordRestriction> passwordValuesRestrictions = getPasswordRestrictions(); final PasswordStrengthCheckResult strengthResult = this.passwordStrengthChecker.chec...
java
public String getCmdLineArg() { StringBuilder builder = new StringBuilder(" --server-groups="); boolean foundSelected = false; for (JCheckBox serverGroup : serverGroups) { if (serverGroup.isSelected()) { foundSelected = true; builder.append(serverGrou...
java
public static boolean isCompleteZip(File file) throws IOException, NonScannableZipException { FileChannel channel = null; try { channel = new FileInputStream(file).getChannel(); long size = channel.size(); if (size < ENDLEN) { // Obvious case return ...
java
private static boolean scanForEndSig(File file, FileChannel channel) throws IOException, NonScannableZipException { // TODO Consider just reading in MAX_REVERSE_SCAN bytes -- increased peak memory cost but less complex ByteBuffer bb = getByteBuffer(CHUNK_SIZE); long start = channel.size(); ...
java
static void sendFailedResponse(final ManagementRequestContext<RegistrationContext> context, final byte errorCode, final String message) throws IOException { final ManagementResponseHeader header = ManagementResponseHeader.create(context.getRequestHeader()); final FlushableDataOutput output = context.wri...
java
public static boolean isOperationDefined(final ModelNode operation) { for (final AttributeDefinition def : ROOT_ATTRIBUTES) { if (operation.hasDefined(def.getName())) { return true; } } return false; }
java
@Deprecated private static ListAttributeDefinition wrapAsList(final AttributeDefinition def) { final ListAttributeDefinition list = new ListAttributeDefinition(new SimpleListAttributeDefinition.Builder(def.getName(), def) .setElementValidator(def.getValidator())) { @Override ...
java
private static int resolveDomainTimeoutAdder() { String propValue = WildFlySecurityManager.getPropertyPrivileged(DOMAIN_TEST_SYSTEM_PROPERTY, DEFAULT_DOMAIN_TIMEOUT_STRING); if (sysPropDomainValue == null || !sysPropDomainValue.equals(propValue)) { // First call or the system property change...
java
public TransformersSubRegistration getDomainRegistration(final ModelVersionRange range) { final PathAddress address = PathAddress.EMPTY_ADDRESS; return new TransformersSubRegistrationImpl(range, domain, address); }
java
public TransformersSubRegistration getHostRegistration(final ModelVersionRange range) { final PathAddress address = PathAddress.EMPTY_ADDRESS.append(HOST); return new TransformersSubRegistrationImpl(range, domain, address); }
java
public TransformersSubRegistration getServerRegistration(final ModelVersionRange range) { final PathAddress address = PathAddress.EMPTY_ADDRESS.append(HOST, SERVER); return new TransformersSubRegistrationImpl(range, domain, address); }
java